/
VictoriaKoltsova
/
AI_2026_Module2_Project2
Обзор
Документация
Войти
/
VictoriaKoltsova
/
AI_2026_Module2_Project2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
js/theme.js
24 строки
1 KB
moskoltsova2009-ai
Build UK Quest game platform
09 авг 2026, 23:28
09 авг 2026, 23:28
54234c0
Код
Авторство
О чём код?
(() => { const { loadProgress, updateProgress } = window.UKQuestStorage; function applyTheme(theme) { const selected = theme === "light" ? "light" : "dark"; document.documentElement.dataset.theme = selected; document.querySelectorAll("[data-theme-toggle]").forEach((button) => { button.textContent = selected === "light" ? "DARK THEME" : "LIGHT THEME"; button.setAttribute("aria-label", `Switch to ${selected === "light" ? "dark" : "light"} theme`); button.setAttribute("aria-pressed", selected === "light" ? "true" : "false"); }); } function toggleTheme() { const nextTheme = loadProgress().theme === "light" ? "dark" : "light"; updateProgress((progress) => { progress.theme = nextTheme; }); applyTheme(nextTheme); } applyTheme(loadProgress().theme); document.querySelectorAll("[data-theme-toggle]").forEach((button) => button.addEventListener("click", toggleTheme)); window.addEventListener("ukquest:progress", (event) => applyTheme(event.detail.theme)); window.UKQuestTheme = { applyTheme, toggleTheme }; })();