branded header, nav, footer for OTB
https://outsidethebox.top
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
841 B
31 lines
841 B
(function () { |
|
function applyTheme(theme) { |
|
document.documentElement.setAttribute("data-theme", theme); |
|
|
|
if (theme === "dark") { |
|
document.body.classList.add("otb-dark"); |
|
} else { |
|
document.body.classList.remove("otb-dark"); |
|
} |
|
|
|
const toggle = document.getElementById("otbThemeToggle"); |
|
if (toggle) toggle.checked = theme === "light"; |
|
} |
|
|
|
function savedTheme() { |
|
return localStorage.getItem("otb_theme") || "dark"; |
|
} |
|
|
|
window.addEventListener("DOMContentLoaded", function () { |
|
applyTheme(savedTheme()); |
|
|
|
const toggle = document.getElementById("otbThemeToggle"); |
|
if (!toggle) return; |
|
|
|
toggle.addEventListener("change", function () { |
|
const theme = toggle.checked ? "light" : "dark"; |
|
localStorage.setItem("otb_theme", theme); |
|
applyTheme(theme); |
|
}); |
|
}); |
|
})();
|
|
|