Update static/webui/script.js

This commit is contained in:
Animan8000 2025-05-21 05:44:48 -07:00
parent 9cc88f4e11
commit e87740e238

View File

@ -1,5 +1,6 @@
let loginOrRegisterPending = false; let loginOrRegisterPending = false;
window.registerSubmit = false; window.registerSubmit = false;
document.documentElement.setAttribute("data-bs-theme", localStorage.getItem("theme") || "dark");
function doLogin() { function doLogin() {
if (loginOrRegisterPending) { if (loginOrRegisterPending) {
@ -155,6 +156,7 @@ function setActiveLanguage(lang) {
script.src = "/translations/" + webui_lang + ".js"; script.src = "/translations/" + webui_lang + ".js";
script.onload = function () { script.onload = function () {
updateLocElements(); updateLocElements();
setTheme(localStorage.getItem("theme") ?? "dark");
resolve(window.dict); resolve(window.dict);
}; };
document.documentElement.appendChild(script); 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 = [ const webUiModularWeapons = [
"/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon", "/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon",
"/Lotus/Weapons/Ostron/Melee/LotusModularWeapon", "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon",