From 1c8593c1fa68cd5287c975bb8ef96efce4edbbab Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 9 Dec 2018 21:17:50 +0300 Subject: add hotkey (a N) to toggle night.css --- js/AppBase.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'js/AppBase.js') 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); }, -- cgit v1.2.3