summaryrefslogtreecommitdiffstats
path: root/assets/js/settings.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--assets/js/settings.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/assets/js/settings.js b/assets/js/settings.js
index fda9ea5..0410aeb 100644
--- a/assets/js/settings.js
+++ b/assets/js/settings.js
@@ -8,12 +8,22 @@ async function setLanguage(langCode) {
}
document.addEventListener("DOMContentLoaded", async () => {
- $(".settings-language-selector").click(function () {
- let languageToSet = $(this).attr("data-language");
+
+ $("#select-language").on("change", () => {
+ let languageToSet = $(this).find(":selected").data("language");
setLanguage(languageToSet);
});
+ localforage.getItem("chosenLang").then((value) => {
+ let selectedLanguage = value ?? "sl";
+ $(`#option-${selectedLanguage}`).attr("selected", true);
+ }).catch(() => {});
+
// Setup side menu
const menus = document.querySelectorAll(".side-menu");
M.Sidenav.init(menus, { edge: "right", draggable: true });
+
+ // Setup language select dropdown
+ var elems = document.querySelectorAll('select');
+ M.FormSelect.init(elems, {});
});