freegpt-webui / client /js /theme-toggler.js
monra's picture
Modifies the position & style of the switch site theme button
3aa7f71
raw
history blame
673 Bytes
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";
})();