1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 01:05:55 +00:00

add hotkey (a N) to toggle night.css

This commit is contained in:
Andrew Dolgov
2018-12-09 21:17:50 +03:00
parent a5813bb766
commit 1c8593c1fa
13 changed files with 62 additions and 23 deletions

View File

@@ -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);
},