/
hamster75
/
Life
Обзор
Документация
Войти
/
hamster75
/
Life
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
6
CI/CD
Аналитика
Безопасность
master
js/settings.js
55 строк
2 KB
Dmitry Smirnov
my collection wip
28 май 2026, 17:34
28 май 2026, 17:34
fd4c915
Код
Авторство
О чём код?
const STORAGE_KEY = 'gol_settings'; export const DEFAULTS = { textScale: 1.0, // 0.80 – 1.30 paletteTileW: 80, // 60 – 140 px libCardMin: 110, // 80 – 180 px soupTileMin: 128, // 80 – 200 px questToast: true, }; export function loadSettings() { try { const stored = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}'); return { ...DEFAULTS, ...stored }; } catch { return { ...DEFAULTS }; } } export function saveSettings(s) { localStorage.setItem(STORAGE_KEY, JSON.stringify(s)); } export function applySettings(s) { const t = s.textScale; const r = document.documentElement; r.style.setProperty('--fs-xs', `${Math.round(10 * t)}px`); r.style.setProperty('--fs-sm', `${Math.round(11 * t)}px`); r.style.setProperty('--fs-base', `${Math.round(12 * t)}px`); r.style.setProperty('--fs-md', `${Math.round(13 * t)}px`); r.style.setProperty('--fs-lg', `${Math.round(14 * t)}px`); r.style.setProperty('--fs-title', `${Math.round(15 * t)}px`); r.style.setProperty('--fs-xl', `${Math.round(16 * t)}px`); r.style.setProperty('--fs-icon', `${Math.round(18 * t)}px`); r.style.setProperty('--fs-2xl', `${Math.round(20 * t)}px`); r.style.setProperty('--fs-3xl', `${Math.round(22 * t)}px`); r.style.setProperty('--palette-tile-w', `${s.paletteTileW}px`); r.style.setProperty('--lib-card-min', `${s.libCardMin}px`); r.style.setProperty('--soup-tile-min', `${s.soupTileMin}px`); } export function resetSettings() { localStorage.removeItem(STORAGE_KEY); return { ...DEFAULTS }; } export function resetUIState() { ['life_theme', 'gol-float-palette', 'gol-academy-modal', 'gol-lib-modal', 'gol-nav-panel'] .forEach(k => localStorage.removeItem(k)); } export function clearUserData() { ['gol-palette-v1', 'life_finds', 'life_quests'] .forEach(k => localStorage.removeItem(k)); }