2025-06-18 18:38:20 +03:00
|
|
|
const basePath = "/assets/css";
|
2026-04-04 16:50:30 +03:00
|
|
|
const themeToggles = document.querySelectorAll(".theme-toggle");
|
2025-10-14 19:40:29 +03:00
|
|
|
const themeStylesheet = document.getElementById("themed");
|
2025-06-18 18:38:20 +03:00
|
|
|
|
|
|
|
|
const themes = [
|
2026-04-04 16:50:30 +03:00
|
|
|
{ name: "system", file: "default/system.css" },
|
2026-04-07 20:14:23 +03:00
|
|
|
{ name: "citrus", file: "citrus/citrus.css" },
|
2025-06-18 18:38:20 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let currentTheme = localStorage.getItem("theme") || themes[0].name;
|
|
|
|
|
setTheme(currentTheme);
|
|
|
|
|
|
|
|
|
|
function setTheme(themeName) {
|
2026-04-04 16:50:30 +03:00
|
|
|
const theme = themes.find(t => t.name === themeName);
|
|
|
|
|
if (theme && themeStylesheet) {
|
|
|
|
|
themeStylesheet.href = `${basePath}/${theme.file}`;
|
|
|
|
|
}
|
2025-06-18 18:38:20 +03:00
|
|
|
}
|
|
|
|
|
|
2026-04-04 16:50:30 +03:00
|
|
|
themeToggles.forEach(btn =>
|
|
|
|
|
btn.addEventListener("click", () => {
|
|
|
|
|
currentTheme = themes[(themes.findIndex(t => t.name === currentTheme) + 1) % themes.length].name;
|
|
|
|
|
setTheme(currentTheme);
|
|
|
|
|
localStorage.setItem("theme", currentTheme);
|
|
|
|
|
})
|
|
|
|
|
);
|