مدیاویکی:Common.js: تفاوت میان نسخهها
بدون خلاصۀ ویرایش |
(افزودن دکمهٔ شب/روز به هدر) |
||
| خط ۱۰: | خط ۱۰: | ||
document.body.appendChild(ribbon); | document.body.appendChild(ribbon); | ||
}); | }); | ||
/* ===== Wikijoo night-mode toggle (2026-05-31) ===== */ | |||
(function () { | |||
function apply(t) { | |||
document.documentElement.classList.toggle('wj-night', t === 'dark'); | |||
var b = document.getElementById('wj-theme-btn'); | |||
if (b) { b.textContent = (t === 'dark' ? '☀️' : '🌙'); b.title = (t === 'dark' ? 'حالت روز' : 'حالت شب'); } | |||
} | |||
var saved = 'light'; | |||
try { saved = localStorage.getItem('wj-theme') || 'light'; } catch (e) {} | |||
apply(saved); | |||
function addBtn() { | |||
if (document.getElementById('wj-theme-btn')) return; | |||
var host = document.querySelector('.vector-header-end') || document.querySelector('#p-personal') || document.querySelector('.vector-user-links'); | |||
if (!host) return; | |||
var btn = document.createElement('button'); | |||
btn.id = 'wj-theme-btn'; | |||
btn.type = 'button'; | |||
btn.className = 'wj-theme-btn'; | |||
btn.setAttribute('aria-label', 'تغییر حالت شب و روز'); | |||
host.insertBefore(btn, host.firstChild); | |||
btn.addEventListener('click', function () { | |||
var cur = document.documentElement.classList.contains('wj-night') ? 'dark' : 'light'; | |||
var next = cur === 'dark' ? 'light' : 'dark'; | |||
try { localStorage.setItem('wj-theme', next); } catch (e) {} | |||
apply(next); | |||
}); | |||
apply(document.documentElement.classList.contains('wj-night') ? 'dark' : 'light'); | |||
} | |||
if (document.readyState !== 'loading') addBtn(); | |||
else document.addEventListener('DOMContentLoaded', addBtn); | |||
})(); | |||
نسخهٔ ۳۱ مهٔ ۲۰۲۶، ساعت ۱۲:۱۰
#تغییرمسیر[[اسعد_رزم_آرا،_خلیل_(ملایر_۱۳۰۰ـ_تهران_۱۳۸۲ش)|اسعد_رزم_آرا،_خلیل_(ملایر_۱۳۰۰ـ_تهران_۱۳۸۲ش)]]
$( '.CategoryTreeToggle' ).click();
mw.loader.using('mediawiki.util', function () {
var ribbon = document.createElement("div");
ribbon.className = "ribbon";
document.body.appendChild(ribbon);
});
/* ===== Wikijoo night-mode toggle (2026-05-31) ===== */
(function () {
function apply(t) {
document.documentElement.classList.toggle('wj-night', t === 'dark');
var b = document.getElementById('wj-theme-btn');
if (b) { b.textContent = (t === 'dark' ? '☀️' : '🌙'); b.title = (t === 'dark' ? 'حالت روز' : 'حالت شب'); }
}
var saved = 'light';
try { saved = localStorage.getItem('wj-theme') || 'light'; } catch (e) {}
apply(saved);
function addBtn() {
if (document.getElementById('wj-theme-btn')) return;
var host = document.querySelector('.vector-header-end') || document.querySelector('#p-personal') || document.querySelector('.vector-user-links');
if (!host) return;
var btn = document.createElement('button');
btn.id = 'wj-theme-btn';
btn.type = 'button';
btn.className = 'wj-theme-btn';
btn.setAttribute('aria-label', 'تغییر حالت شب و روز');
host.insertBefore(btn, host.firstChild);
btn.addEventListener('click', function () {
var cur = document.documentElement.classList.contains('wj-night') ? 'dark' : 'light';
var next = cur === 'dark' ? 'light' : 'dark';
try { localStorage.setItem('wj-theme', next); } catch (e) {}
apply(next);
});
apply(document.documentElement.classList.contains('wj-night') ? 'dark' : 'light');
}
if (document.readyState !== 'loading') addBtn();
else document.addEventListener('DOMContentLoaded', addBtn);
})();