static/js/themetoggle.js (view raw)
1function setTheme(mode) {
2 localStorage.setItem("theme-storage", mode);
3 if (mode === "dark") {
4 document.getElementById("darkModeStyle").disabled=false;
5 document.getElementById("dark-mode-toggle").innerHTML = "<i data-feather=\"sun\"></i>";
6 feather.replace()
7 } else if (mode === "light") {
8 document.getElementById("darkModeStyle").disabled=true;
9 document.getElementById("dark-mode-toggle").innerHTML = "<i data-feather=\"moon\"></i>";
10 feather.replace()
11 }
12}
13
14function toggleTheme() {
15 if (localStorage.getItem("theme-storage") === "light") {
16 setTheme("dark");
17 } else if (localStorage.getItem("theme-storage") === "dark") {
18 setTheme("light");
19 }
20}
21
22var savedTheme = localStorage.getItem("theme-storage") || "light";
23setTheme(savedTheme);