diff options
author | Andrew Dolgov <[email protected]> | 2018-12-09 21:17:50 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-12-09 21:17:50 +0300 |
commit | 1c8593c1fa68cd5287c975bb8ef96efce4edbbab (patch) | |
tree | 19deb4ac6fbbfe70f13611323c40bc0da65acb23 /js/AppBase.js | |
parent | a5813bb76699978fcaf7909796b1fbd953a4975b (diff) |
add hotkey (a N) to toggle night.css
Diffstat (limited to 'js/AppBase.js')
-rw-r--r-- | js/AppBase.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/js/AppBase.js b/js/AppBase.js index b5df4a800..4552eea11 100644 --- a/js/AppBase.js +++ b/js/AppBase.js @@ -51,8 +51,9 @@ define(["dojo/_base/declare"], function (declare) { if (dijit.byId("loading_bar")) dijit.byId("loading_bar").update({progress: loading_progress}); - if (loading_progress >= 90) - Element.hide("overlay"); + if (loading_progress >= 90) { + $("overlay").hide(); + } }, keyeventToAction: function(event) { @@ -351,6 +352,29 @@ define(["dojo/_base/declare"], function (declare) { this.initSecondStage(); }, + toggleNightMode: function() { + const link = $("theme_css"); + + if (link) { + + let user_theme = ""; + let user_css = ""; + + if (link.getAttribute("href").indexOf("themes/night.css") == -1) { + user_css = "themes/night.css?" + Date.now(); + user_theme = "night.css"; + } else { + user_theme = "default.php"; + user_css = "css/default.css?" + Date.now(); + } + + fetch(user_css).then(() => { + link.setAttribute("href", user_css); + xhrPost("backend.php", {op: "rpc", method: "setpref", key: "USER_CSS_THEME", value: user_theme}); + }); + + } + }, explainError: function(code) { return this.displayDlg(__("Error explained"), "explainError", code); }, |