Spaces:
Running
Running
File size: 673 Bytes
35716ec 3aa7f71 35716ec 3aa7f71 35716ec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
var switch_theme_toggler = document.getElementById("theme-toggler");
switch_theme_toggler.addEventListener("change", toggleTheme);
function setTheme(themeName) {
localStorage.setItem("theme", themeName);
document.documentElement.className = themeName;
}
function toggleTheme() {
var currentTheme = localStorage.getItem("theme");
var newTheme = currentTheme === "theme-dark" ? "theme-light" : "theme-dark";
setTheme(newTheme);
switch_theme_toggler.checked = newTheme === "theme-dark";
}
(function () {
var currentTheme = localStorage.getItem("theme") || "theme-dark";
setTheme(currentTheme);
switch_theme_toggler.checked = currentTheme === "theme-dark";
})();
|