MediaWiki:Gadget-theme.js: различия между версиями

м Полностью удалено содержимое страницы
Метка: очистка
мНет описания правки
Метка: отменено
Строка 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);
    }
})();