aboutsummaryrefslogtreecommitdiff
path: root/static/js/themes.js
diff options
context:
space:
mode:
authorKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-08-16 16:35:19 -0300
committerKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-08-16 16:35:19 -0300
commitc455494cd617d66bc28a30afb1fbd4377e0ecb01 (patch)
treea7e9608c0fc713467987d074947e2d1e8feb0c40 /static/js/themes.js
parent1d8e5651dedf56470d10b94a0022942a91cde6cd (diff)
extremely basic themes support
Diffstat (limited to 'static/js/themes.js')
-rw-r--r--static/js/themes.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/static/js/themes.js b/static/js/themes.js
new file mode 100644
index 0000000..70a1b7f
--- /dev/null
+++ b/static/js/themes.js
@@ -0,0 +1,24 @@
+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() {
+ setTheme(getCookie("theme") || "default");
+}