diff options
author | FChannel <> | 2022-06-19 12:47:32 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 16:03:29 -0700 |
commit | b02f813e519dc890f2eb4827ff52cff3ff90c828 (patch) | |
tree | d020fbdefda52542aab3f4250bf93533e9f38504 /static/js/themes.js | |
parent | cd99df8d6781c3f0a191d119ea0ddf8c4a16089f (diff) |
v0.1.0
Diffstat (limited to 'static/js/themes.js')
-rw-r--r-- | static/js/themes.js | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/static/js/themes.js b/static/js/themes.js deleted file mode 100644 index ccdd277..0000000 --- a/static/js/themes.js +++ /dev/null @@ -1,40 +0,0 @@ -function setCookie(key, value, age) { - document.cookie = key + "=" + encodeURIComponent(value) + ";sameSite=strict;max-age=" + (60 * 60 * 24 * age) + ";path=/"; -} - -function getCookie(key) { - if (document.cookie.length != 0) { - return document.cookie.split('; ').find(row => row.startsWith(key)).split('=')[1]; - } - return ""; -} - -function setTheme(name) { - for (let i = 0, tags = document.getElementsByTagName("link"); i < tags.length; i++) { - if (tags[i].type === "text/css" && tags[i].title) { - tags[i].disabled = !(tags[i].title === name); - } - } - - setCookie("theme", name, 3650); -} - -function applyTheme() { - // HACK: disable all of the themes first. this for some reason makes things work. - for (let i = 0, tags = document.getElementsByTagName("link"); i < tags.length; i++) { - if (tags[i].type === "text/css" && tags[i].title) { - tags[i].disabled = true; - } - } - let theme = getCookie("theme") || "default"; - setTheme(theme); - - // reflect this in the switcher - let switcher = document.getElementById("themeSwitcher"); - for(var i = 0; i < switcher.options.length; i++) { - if (switcher.options[i].value === theme) { - switcher.selectedIndex = i; - break; - } - } -} |