Un pot de crédits global (BASIC 100 / PRO 1 000 / BUSINESS 4 000) remplace les seaux par fonction côté débit. Packs one-shot S/M/L, admin sans seaux legacy, usage multi-features, hints de coût, anti-flash thème et hydratation admin. Inclut aussi le pipeline slides renforcé et la page publique polishée.
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
(function () {
|
|
try {
|
|
var root = document.documentElement;
|
|
var fallback = root.getAttribute('data-server-theme') || 'light';
|
|
var defaultAccent = root.getAttribute('data-server-accent') || '#A47148';
|
|
var stored = localStorage.getItem('theme-preference');
|
|
var raw = stored || fallback;
|
|
if (raw === 'slate') raw = 'light';
|
|
var allowed = {
|
|
light: 1,
|
|
dark: 1,
|
|
auto: 1,
|
|
sepia: 1,
|
|
midnight: 1,
|
|
rose: 1,
|
|
green: 1,
|
|
lavender: 1,
|
|
sand: 1,
|
|
ocean: 1,
|
|
sunset: 1,
|
|
blue: 1,
|
|
};
|
|
var theme = allowed[raw] ? raw : 'light';
|
|
|
|
// Synchroniser le cookie pour les prochains rendus serveur (anti-flash)
|
|
try {
|
|
document.cookie =
|
|
'memento-theme=' +
|
|
encodeURIComponent(theme) +
|
|
'; path=/; max-age=31536000; SameSite=Lax';
|
|
if (!stored) localStorage.setItem('theme-preference', theme);
|
|
} catch (e) {
|
|
/* ignore */
|
|
}
|
|
|
|
// Ne jamais retirer .dark avant de le remettre
|
|
var wantsDark = false;
|
|
if (theme === 'auto') {
|
|
wantsDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
} else if (theme === 'dark' || theme === 'midnight') {
|
|
wantsDark = true;
|
|
}
|
|
|
|
if (wantsDark) {
|
|
root.classList.add('dark');
|
|
} else {
|
|
root.classList.remove('dark');
|
|
}
|
|
|
|
if (theme === 'auto' || theme === 'dark' || theme === 'light') {
|
|
root.removeAttribute('data-theme');
|
|
} else {
|
|
root.setAttribute('data-theme', theme);
|
|
}
|
|
|
|
root.setAttribute('data-applied-theme', theme);
|
|
|
|
var accentStored = localStorage.getItem('accent-color');
|
|
var effectiveAccent = accentStored || defaultAccent;
|
|
root.style.setProperty('--color-brand-accent', effectiveAccent);
|
|
} catch (e) {
|
|
console.error('Theme script error', e);
|
|
}
|
|
})();
|