MediaWiki:Common.js: различия между версиями
Перейти к навигации
Перейти к поиску
Xdarkes (обсуждение | вклад) |
Xdarkes (обсуждение | вклад) |
||
| Строка 1: | Строка 1: | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Версия 17:29, 12 августа 2026
mw.loader.using(['mediawiki.util', 'mediawiki.storage']).done(function () {
var storageKey = 'ligapedia-dark-mode';
var isDark = mw.storage.get(storageKey) === '1';
function setTheme(dark) {
if (dark) {
document.documentElement.classList.add('dark-mode');
mw.storage.set(storageKey, '1');
} else {
document.documentElement.classList.remove('dark-mode');
mw.storage.set(storageKey, '0');
}
isDark = dark;
}
if (isDark) {
document.documentElement.classList.add('dark-mode');
}
var link = mw.util.addPortletLink(
'p-personal',
'#',
'Тёмная тема',
'pt-dark-mode-toggle',
'Переключить тему'
);
if (link) {
$(link).on('click', function (e) {
e.preventDefault();
setTheme(!isDark);
$(this).text(isDark ? 'Светлая тема' : 'Тёмная тема');
});
$(link).text(isDark ? 'Светлая тема' : 'Тёмная тема');
}
});