From 8eb340c3ca9f30e48d8019f16d3b2a4385881192 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 1 Aug 2025 17:20:05 +0300 Subject: make default light/dark themes configurable, add support for main application and login form --- js/App.js | 4 +++- js/utility.js | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/App.js b/js/App.js index 5c4be5ea0..1ac3a43f0 100644 --- a/js/App.js +++ b/js/App.js @@ -173,7 +173,7 @@ const App = { if (link) { if (navigator.onLine) { - const css_override = is_night ? "themes/night.css" : "themes/light.css"; + const css_override = is_night ? App.getInitParam("default_dark_theme") : App.getInitParam("default_light_theme"); link.setAttribute("href", css_override + "?" + Date.now()); } else if (retry < 5) { console.log("nightModeChanged: we're offline, will attempt to retry..."); @@ -704,6 +704,8 @@ const App = { window.onerror = this.Error.onWindowError; this.setInitParam("csrf_token", __csrf_token); + this.setInitParam("default_light_theme", __default_light_theme); + this.setInitParam("default_dark_theme", __default_dark_theme); this.setupNightModeDetection(() => { parser.parse(); diff --git a/js/utility.js b/js/utility.js index 43ad5644e..070e9e2d1 100644 --- a/js/utility.js +++ b/js/utility.js @@ -7,8 +7,11 @@ window.addEventListener("load", function() { apply_night_mode: function (is_night, link) { console.log("night mode changed to", is_night); + const light_theme = typeof __default_light_theme != 'undefined' ? __default_light_theme : 'themes/light.css'; + const dark_theme = typeof __default_dark_theme != 'undefined' ? __default_dark_theme : 'themes/dark.css'; + if (link) { - const css_override = is_night ? "themes/night.css" : "themes/light.css"; + const css_override = is_night ? dark_theme : light_theme; link.setAttribute("href", css_override + "?" + Date.now()); } -- cgit v1.2.3-54-g00ecf