MediaWiki:Vector.js: различия между версиями
Aylong (обсуждение | вклад) Нет описания правки Метка: ручная отмена |
Aylong (обсуждение | вклад) Нет описания правки Метка: отменено |
||
| Строка 1: | Строка 1: | ||
$(document).ready(function() { | |||
function loadCSS(url) { | |||
var link = document.createElement('link'); | |||
link.rel = 'stylesheet'; | |||
link.type = 'text/css'; | |||
link.href = url; | |||
document.head.appendChild(link); | |||
} | |||
function loadJS(url, callback) { | |||
var script = document.createElement('script'); | |||
script.type = 'text/javascript'; | |||
if (script.readyState) { | |||
script.onreadystatechange = function() { | |||
if (script.readyState == 'loaded' || script.readyState == 'complete') { | |||
script.onreadystatechange = null; | |||
callback(); | |||
} | |||
}; | |||
} else { | |||
script.onload = function() { | |||
callback(); | |||
}; | |||
} | |||
script.src = url; | |||
document.head.appendChild(script); | |||
} | |||
loadCSS('/wiki/common.css'); | |||
loadJS('/wiki/common.js', function() { | |||
}); | |||
$(window).on('load', function() { | |||
}); | |||
}); | |||
$(document).ready(function() { | $(document).ready(function() { | ||
var button = document.createElement("button"); | var button = document.createElement("button"); | ||
Версия от 17:52, 4 мая 2024
$(document).ready(function() {
function loadCSS(url) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url;
document.head.appendChild(link);
}
function loadJS(url, callback) {
var script = document.createElement('script');
script.type = 'text/javascript';
if (script.readyState) {
script.onreadystatechange = function() {
if (script.readyState == 'loaded' || script.readyState == 'complete') {
script.onreadystatechange = null;
callback();
}
};
} else {
script.onload = function() {
callback();
};
}
script.src = url;
document.head.appendChild(script);
}
loadCSS('/wiki/common.css');
loadJS('/wiki/common.js', function() {
});
$(window).on('load', function() {
});
});
$(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() {
var isLightTheme = document.documentElement.classList.toggle('light');
localStorage.setItem("isLightTheme", isLightTheme);
}