MediaWiki:Gadget-theme.js: различия между версиями
Материал из Space Station 14 Вики
Pok (обсуждение | вклад) м Полностью удалено содержимое страницы Метка: очистка |
Pok (обсуждение | вклад) мНет описания правки Метка: отменено |
||
| Строка 1: | Строка 1: | ||
;(function(){ | |||
const COOKIE_NAME = 'ss14_wikiTheme'; | |||
function getCookie(name) { | |||
const value = `; ${document.cookie}`; | |||
const parts = value.split(`; ${name}=`); | |||
if (parts.length === 2) return parts.pop().split(';').shift(); | |||
} | |||
function loadTheme() { | |||
return getCookie(COOKIE_NAME) || 'normal'; | |||
} | |||
function applyTheme(theme) { | |||
document.body.classList.remove('wgl-theme-normal', 'wgl-theme-light', 'wgl-theme-dark'); | |||
document.body.classList.add(`wgl-theme-${theme}`); | |||
} | |||
const theme = loadTheme(); | |||
document.documentElement.classList.add(`wgl-theme-${theme}`); | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', function() { | |||
applyTheme(theme); | |||
}); | |||
} else { | |||
applyTheme(theme); | |||
} | |||
})(); | |||
Версия от 16:59, 8 мая 2025
;(function(){
const COOKIE_NAME = 'ss14_wikiTheme';
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
function loadTheme() {
return getCookie(COOKIE_NAME) || 'normal';
}
function applyTheme(theme) {
document.body.classList.remove('wgl-theme-normal', 'wgl-theme-light', 'wgl-theme-dark');
document.body.classList.add(`wgl-theme-${theme}`);
}
const theme = loadTheme();
document.documentElement.classList.add(`wgl-theme-${theme}`);
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function() {
applyTheme(theme);
});
} else {
applyTheme(theme);
}
})();