aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/templates/-base.html.tmpl32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/templates/-base.html.tmpl b/src/templates/-base.html.tmpl
index 46b81eb..42ec216 100644
--- a/src/templates/-base.html.tmpl
+++ b/src/templates/-base.html.tmpl
@@ -13,23 +13,25 @@
const $ = q => document.querySelector(q);
const $$ = q => document.querySelectorAll(q);
- const validate = theme =>
- ["light", "dark"].includes(theme) ? theme : "light";
- const toggle = theme =>
- theme == "light" ? "dark" : "light";
+ (() => {
+ const validate = theme =>
+ ["light", "dark"].includes(theme) ? theme : "light";
+ const toggle = theme =>
+ theme == "light" ? "dark" : "light";
- const setTheme = theme => {
- localStorage.setItem("theme", theme);
- $("html").setAttribute("data-theme", theme);
- $(`#nav-icon-theme-${theme}`).style.display = "";
- $(`#nav-icon-theme-${toggle(theme)}`).style.display = "none";
- };
+ const setTheme = theme => {
+ localStorage.setItem("theme", theme);
+ $("html").setAttribute("data-theme", theme);
+ $(`#nav-icon-theme-${theme}`).style.display = "";
+ $(`#nav-icon-theme-${toggle(theme)}`).style.display = "none";
+ };
- document.addEventListener("DOMContentLoaded", _ => {
- $("#theme-button").onclick = () =>
- setTheme(toggle(validate(localStorage.getItem("theme"))));
- setTheme(validate(localStorage.getItem("theme")));
- });
+ document.addEventListener("DOMContentLoaded", _ => {
+ $("#theme-button").onclick = () =>
+ setTheme(toggle(validate(localStorage.getItem("theme"))));
+ setTheme(validate(localStorage.getItem("theme")));
+ });
+ })();
</script>
{{ includeIfExists "header" . }}
</head>