summaryrefslogtreecommitdiffstats
path: root/assets/js/settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/settings.js')
-rw-r--r--assets/js/settings.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/assets/js/settings.js b/assets/js/settings.js
index 0410aeb..411a38e 100644
--- a/assets/js/settings.js
+++ b/assets/js/settings.js
@@ -7,6 +7,13 @@ async function setLanguage(langCode) {
});
}
+async function setTheme(targetTheme) {
+ localforage.setItem("targetTheme", targetTheme).then((value) => {
+ console.log("Theme set: " + value);
+ UIAlert(D("themeSet"), "setTheme(): themeSet");
+ });
+}
+
document.addEventListener("DOMContentLoaded", async () => {
$("#select-language").on("change", () => {
@@ -14,11 +21,21 @@ document.addEventListener("DOMContentLoaded", async () => {
setLanguage(languageToSet);
});
+ $("#select-theme").on("change", () => {
+ let themeToSet = $(this).find(":selected").data("theme");
+ setTheme(themeToSet);
+ });
+
localforage.getItem("chosenLang").then((value) => {
let selectedLanguage = value ?? "sl";
$(`#option-${selectedLanguage}`).attr("selected", true);
}).catch(() => {});
+ localforage.getItem("theme").then((value) => {
+ let selectedTheme = value ?? "sl";
+ $(`#option-${selectedTheme}`).attr("selected", true);
+ }).catch(() => {});
+
// Setup side menu
const menus = document.querySelectorAll(".side-menu");
M.Sidenav.init(menus, { edge: "right", draggable: true });