MediaWiki:Vector.js: различия между версиями
Aylong (обсуждение | вклад) Нет описания правки Метки: ручная отмена отменено |
Aylong (обсуждение | вклад) Нет описания правки Метка: отменено |
||
| Строка 19: | Строка 19: | ||
function toggleTheme() { | function toggleTheme() { | ||
const root = document.documentElement; | |||
const currentTheme = root.getAttribute('data-theme'); | |||
const newTheme = currentTheme === 'light' ? 'dark' : 'light'; | |||
root.setAttribute('data-theme', newTheme); | |||
} | } | ||
Версия от 16:57, 4 мая 2024
$(document).ready(function() {
var button = document.createElement("button");
button.innerHTML = "Сменить тему";
button.className = "theme-button";
button.onclick = toggleTheme;
var container = document.getElementById("p-personal");
if (container) {
container.parentNode.insertBefore(button, container);
}
var isLightTheme = localStorage.getItem("isLightTheme");
if (isLightTheme === "true") {
document.documentElement.classList.add('light');
} else {
document.documentElement.classList.remove('light');
}
});
function toggleTheme() {
const root = document.documentElement;
const currentTheme = root.getAttribute('data-theme');
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
root.setAttribute('data-theme', newTheme);
}