From 82ab89b7509f81066eea40d00dc7d7addf90be77 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 29 Apr 2024 17:55:06 +0200 Subject: fixed app/js/settings.js to for custom `'s for their value only worked on the `forcedlang` setting, now it just works overall, this wasn't an issue before, as we had no need for it. More importantly `forcedlang` is special in that it dynamically loads the list of languages available, so it was and still is handled separately, to support that behavior. --- src/app/js/settings.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'src/app/js/settings.js') diff --git a/src/app/js/settings.js b/src/app/js/settings.js index 2d68c13..9eb6c76 100644 --- a/src/app/js/settings.js +++ b/src/app/js/settings.js @@ -1,6 +1,7 @@ var settings_fuse; var Settings = { + default: {settings}, toggle: (state) => { Settings.load(); options.scrollTo(0, 0); @@ -42,11 +43,25 @@ var Settings = { let categories = document.querySelectorAll("#options details"); for (let i = 0; i < categories.length; i++) { categories[i].setAttribute("open", true); + + // hide categories that aren't for the current platform + let for_platform = categories[i].getAttribute("platform"); + if (for_platform && process.platform != for_platform) { + categories[i].style.display = "none"; + categories[i].setAttribute("perma-hidden", true); + } } let options = document.querySelectorAll(".option"); for (let i = 0; i < options.length; i++) { + // hide options that aren't for the current platform + let for_platform = options[i].getAttribute("platform"); + if (for_platform && process.platform != for_platform) { + options[i].style.display = "none"; + options[i].setAttribute("perma-hidden", true); + } + let optName = options[i].getAttribute("name"); if (optName == "forcedlang") { let div = options[i].querySelector("select"); @@ -75,6 +90,25 @@ var Settings = { } if (settings[optName] != undefined) { + // check if setting has a `` to the settings value + select_el.value = settings[optName]; + } else { // use the default value + select_el.value = Settings.default[optName]; + } + + continue; + } + switch(typeof settings[optName]) { case "string": options[i].querySelector(".actions input").value = settings[optName]; @@ -92,7 +126,6 @@ var Settings = { switchDiv.classList.remove("on"); } break - } } } -- cgit v1.2.3