MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus The Alchenomicon Wiki
Gk (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Gk (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
// Theme Toggle | |||
(function() { | |||
if (localStorage.getItem('theme') === 'dark') { | |||
document.body.classList.add('dark'); | |||
} | |||
mw.hook('wikipage.content').add(function() { | |||
var btn = document.createElement('button'); | |||
btn.id = 'theme-toggle'; | |||
btn.textContent = document.body.classList.contains('dark') ? '☀️' : '🌙'; | |||
btn.style.cssText = 'position:fixed; bottom:20px; right:20px; z-index:9999; background:#2a1f14; color:#e8dfc8; border:1px solid #5a4530; padding:8px 12px; cursor:pointer; border-radius:4px; font-size:1.2em;'; | |||
btn.addEventListener('click', function() { | |||
document.body.classList.toggle('dark'); | |||
var isDark = document.body.classList.contains('dark'); | |||
localStorage.setItem('theme', isDark ? 'dark' : 'light'); | |||
btn.textContent = isDark ? '☀️' : '🌙'; | |||
}); | |||
document.body.appendChild(btn); | |||
}); | |||
})(); | |||
mw.hook('wikipage.content').add(function() { | mw.hook('wikipage.content').add(function() { | ||
document.querySelectorAll('.mw-category a').forEach(function(a) { | document.querySelectorAll('.mw-category a').forEach(function(a) { | ||
Version vom 25. Mai 2026, 14:40 Uhr
// Theme Toggle
(function() {
if (localStorage.getItem('theme') === 'dark') {
document.body.classList.add('dark');
}
mw.hook('wikipage.content').add(function() {
var btn = document.createElement('button');
btn.id = 'theme-toggle';
btn.textContent = document.body.classList.contains('dark') ? '☀️' : '🌙';
btn.style.cssText = 'position:fixed; bottom:20px; right:20px; z-index:9999; background:#2a1f14; color:#e8dfc8; border:1px solid #5a4530; padding:8px 12px; cursor:pointer; border-radius:4px; font-size:1.2em;';
btn.addEventListener('click', function() {
document.body.classList.toggle('dark');
var isDark = document.body.classList.contains('dark');
localStorage.setItem('theme', isDark ? 'dark' : 'light');
btn.textContent = isDark ? '☀️' : '🌙';
});
document.body.appendChild(btn);
});
})();
mw.hook('wikipage.content').add(function() {
document.querySelectorAll('.mw-category a').forEach(function(a) {
var text = a.textContent;
var colon = text.indexOf(':');
if (colon !== -1) {
a.textContent = text.substring(colon + 1);
}
});
});