MediaWiki:Common.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição Etiqueta: Reversão manual |
Sem resumo de edição |
||
| Linha 1: | Linha 1: | ||
/* | /* ===== CARREGAMENTO ===== */ | ||
document.addEventListener("DOMContentLoaded", function () { | |||
/* Remover link das imagens */ | |||
document.querySelectorAll('a.image').forEach(function(el) { | |||
el.removeAttribute('href'); | |||
}); | |||
/* Carregar tema salvo */ | |||
const saved = localStorage.getItem("theme"); | |||
if (saved === "dark") { | |||
document.body.classList.add("dark-mode"); | |||
} else { | |||
document.body.classList.add("light-mode"); | |||
} | |||
/* Criar botão flutuante */ | |||
const btn = document.createElement("button"); | |||
btn.innerHTML = "🌙"; | |||
btn.id = "theme-toggle-btn"; | |||
btn.onclick = function () { | |||
toggleTheme(); | |||
// trocar ícone | |||
if (document.body.classList.contains("dark-mode")) { | |||
btn.innerHTML = "🌙"; | |||
} else { | |||
btn.innerHTML = "☀️"; | |||
} | |||
}; | |||
document.body.appendChild(btn); | |||
}); | }); | ||
/* ===== TROCA DE TEMA ===== */ | |||
function toggleTheme() { | |||
const body = document.body; | |||
if (body.classList.contains("dark-mode")) { | |||
body.classList.remove("dark-mode"); | |||
body.classList.add("light-mode"); | |||
localStorage.setItem("theme", "light"); | |||
} else { | |||
body.classList.remove("light-mode"); | |||
body.classList.add("dark-mode"); | |||
localStorage.setItem("theme", "dark"); | |||
} | |||
} | |||
Edição das 16h38min de 2 de maio de 2026
/* ===== CARREGAMENTO ===== */
document.addEventListener("DOMContentLoaded", function () {
/* Remover link das imagens */
document.querySelectorAll('a.image').forEach(function(el) {
el.removeAttribute('href');
});
/* Carregar tema salvo */
const saved = localStorage.getItem("theme");
if (saved === "dark") {
document.body.classList.add("dark-mode");
} else {
document.body.classList.add("light-mode");
}
/* Criar botão flutuante */
const btn = document.createElement("button");
btn.innerHTML = "🌙";
btn.id = "theme-toggle-btn";
btn.onclick = function () {
toggleTheme();
// trocar ícone
if (document.body.classList.contains("dark-mode")) {
btn.innerHTML = "🌙";
} else {
btn.innerHTML = "☀️";
}
};
document.body.appendChild(btn);
});
/* ===== TROCA DE TEMA ===== */
function toggleTheme() {
const body = document.body;
if (body.classList.contains("dark-mode")) {
body.classList.remove("dark-mode");
body.classList.add("light-mode");
localStorage.setItem("theme", "light");
} else {
body.classList.remove("light-mode");
body.classList.add("dark-mode");
localStorage.setItem("theme", "dark");
}
}