MediaWiki:Common.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição |
||
| Linha 1: | Linha 1: | ||
document.addEventListener("DOMContentLoaded", function () { | document.addEventListener("DOMContentLoaded", function () { | ||
/* Remover link das imagens */ | /* Remover link das imagens */ | ||
document.querySelectorAll('a.image').forEach | document.querySelectorAll('a.image').forEach(el => el.removeAttribute('href')); | ||
const saved = localStorage.getItem("theme"); | const saved = localStorage.getItem("theme"); | ||
document.body.classList.add(saved === "light" ? "light-mode" : "dark-mode"); | |||
/* Criar botão */ | |||
const btn = document.createElement("button"); | |||
btn.id = "theme-toggle-btn"; | |||
document.body.classList. | |||
function updateIcon() { | |||
btn.innerHTML = document.body.classList.contains("dark-mode") ? "🌙" : "☀️"; | |||
} | } | ||
updateIcon(); | |||
btn.onclick = function () { | btn.onclick = function () { | ||
document.body.classList.toggle("dark-mode"); | |||
document.body.classList.toggle("light-mode"); | |||
const current = document.body.classList.contains("dark-mode") ? "dark" : "light"; | |||
localStorage.setItem("theme", current); | |||
updateIcon(); | |||
}; | }; | ||
document.body.appendChild(btn); | document.body.appendChild(btn); | ||
}); | }); | ||
Edição das 16h43min de 2 de maio de 2026
document.addEventListener("DOMContentLoaded", function () {
/* Remover link das imagens */
document.querySelectorAll('a.image').forEach(el => el.removeAttribute('href'));
const saved = localStorage.getItem("theme");
document.body.classList.add(saved === "light" ? "light-mode" : "dark-mode");
/* Criar botão */
const btn = document.createElement("button");
btn.id = "theme-toggle-btn";
function updateIcon() {
btn.innerHTML = document.body.classList.contains("dark-mode") ? "🌙" : "☀️";
}
updateIcon();
btn.onclick = function () {
document.body.classList.toggle("dark-mode");
document.body.classList.toggle("light-mode");
const current = document.body.classList.contains("dark-mode") ? "dark" : "light";
localStorage.setItem("theme", current);
updateIcon();
};
document.body.appendChild(btn);
});