/
slsh
/
agent_register
Обзор
Документация
Войти
/
slsh
/
agent_register
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/static/theme.js
26 строк
965 B
Igor Tveritin
initial
14 июл 2026, 11:23
14 июл 2026, 11:23
69e8254
Код
Авторство
О чём код?
const themeButton = document.querySelector(".theme-toggle"); const themeStorageKey = "agent-register-theme"; const rootElement = document.documentElement; if (themeButton) { applyTheme(rootElement.dataset.theme === "dark" ? "dark" : "light"); themeButton.addEventListener("click", () => { const nextTheme = rootElement.dataset.theme === "dark" ? "light" : "dark"; applyTheme(nextTheme); try { localStorage.setItem(themeStorageKey, nextTheme); } catch { return; } }); } function applyTheme(theme) { const isDark = theme === "dark"; rootElement.dataset.theme = isDark ? "dark" : "light"; themeButton.setAttribute("aria-pressed", String(isDark)); themeButton.setAttribute("title", isDark ? "Включить светлую тему" : "Включить темную тему"); themeButton.setAttribute("aria-label", isDark ? "Включить светлую тему" : "Включить темную тему"); }