From e87740e2385a8e0179d150f04fb11b58313e1331 Mon Sep 17 00:00:00 2001 From: Animan8000 Date: Wed, 21 May 2025 05:44:48 -0700 Subject: [PATCH] Update static/webui/script.js --- static/webui/script.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/static/webui/script.js b/static/webui/script.js index d8d30a41..348d1944 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1,5 +1,6 @@ let loginOrRegisterPending = false; window.registerSubmit = false; +document.documentElement.setAttribute("data-bs-theme", localStorage.getItem("theme") || "dark"); function doLogin() { if (loginOrRegisterPending) { @@ -155,6 +156,7 @@ function setActiveLanguage(lang) { script.src = "/translations/" + webui_lang + ".js"; script.onload = function () { updateLocElements(); + setTheme(localStorage.getItem("theme") ?? "dark"); resolve(window.dict); }; document.documentElement.appendChild(script); @@ -172,6 +174,15 @@ function setLanguage(lang) { } } +function setTheme(theme) { + localStorage.setItem("theme", theme); + document.documentElement.setAttribute("data-bs-theme", theme); + const themeName = document.querySelector(`[data-theme="${theme}"]`)?.textContent; + document.getElementById("active-theme-name").textContent = themeName; + document.querySelectorAll("[data-theme].active").forEach(el => el.classList.remove("active")); + document.querySelector(`[data-theme="${theme}"]`)?.classList.add("active"); +} + const webUiModularWeapons = [ "/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon", "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon",