From 8e8a1ece2e95e3817739b0ded93eac5214ba49b6 Mon Sep 17 00:00:00 2001 From: rstular Date: Wed, 20 May 2020 20:47:22 +0200 Subject: New themes --- dist/js/settings.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'dist/js/settings.js') diff --git a/dist/js/settings.js b/dist/js/settings.js index 1dd3bfc..0854042 100644 --- a/dist/js/settings.js +++ b/dist/js/settings.js @@ -21,8 +21,53 @@ async function setErrorReporting(targetE) { }); } +function shuffleArray(array) { + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } +} + +function setUIAdditionalOptions(state) { + var SENSITIVE_THEMES = { + "left": "Left / leva", + "right": "Right / desna" + }; + if (state === true) { + var theme_keys = Object.keys(SENSITIVE_THEMES); + shuffleArray(theme_keys); + theme_keys.forEach((item) => { + var option_element = $(``); + $("#select-theme").append(option_element); + }); + } else { + Object.keys(SENSITIVE_THEMES).forEach((item) => { + $("#option-" + item).remove(); + }); + } +} + +async function setAdditionalOptions(state) { + localforage.setItem("triggerWarningAccepted", state).then((value) => { + console.log("TriggerWarning set: " + value); + UIAlert(D("triggerWarningSet"), "setAdditionalOptions(): triggerWarningSet"); + setUIAdditionalOptions(value); + }); +} + document.addEventListener("DOMContentLoaded", async () => { + // Setup checkbox handler + $("#triggered-checkbox").change(function() { + if (this.checked) { + setAdditionalOptions(true); + } else { + setAdditionalOptions(false); + } + }); + $("#select-language").on("change", function() { setLanguage($(this).find(":selected").val()); }); -- cgit v1.2.3 From 9a8fc181865154f0fc72a30a9554c72bb28c3ce3 Mon Sep 17 00:00:00 2001 From: rstular Date: Wed, 20 May 2020 20:54:10 +0200 Subject: Bug fix --- dist/js/settings.js | 1 + 1 file changed, 1 insertion(+) (limited to 'dist/js/settings.js') diff --git a/dist/js/settings.js b/dist/js/settings.js index 0854042..f9e3c79 100644 --- a/dist/js/settings.js +++ b/dist/js/settings.js @@ -47,6 +47,7 @@ function setUIAdditionalOptions(state) { $("#option-" + item).remove(); }); } + $("#select-theme").formSelect(); } async function setAdditionalOptions(state) { -- cgit v1.2.3