MediaWiki:Common.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* JavaScript placed here will be applied to all skins */
$(document).ready(function () {
// ============================================================
// Global code — runs on ALL pages
// ============================================================
// Remove noindex meta tag if present
$('meta[name="robots"][content="noindex"]').remove();
// Set custom favicon
var link = document.createElement('link');
link.rel = 'icon';
link.type = 'image/x-icon';
link.href = '/resources/assets/fav-icon.ico';
document.head.appendChild(link);
// ============================================================
// Page-specific code (Main Page + Header only)
// ============================================================
const allowedPages = [
'Main_Page',
'ViewersVault:MainPageHeader',
'ViewersVault:Statistics'
];
const currentPage = mw.config.get('wgPageName');
if (allowedPages.includes(currentPage)) {
// ================================
// Live clock functionality
// ================================
function pad(n) {
return n < 10 ? '0' + n : n;
}
function updateTime() {
const now = new Date();
const hours = pad(now.getHours());
const minutes = pad(now.getMinutes());
const seconds = pad(now.getSeconds());
const clockElement = document.getElementById('live-clock');
if (clockElement) {
clockElement.textContent = `${hours}:${minutes}.${seconds}`;
}
}
function updateDate() {
const now = new Date();
const weekday = now.toLocaleString('en-GB', { weekday: 'short' });
const day = now.getDate();
const month = now.toLocaleString('en-GB', { month: 'short' });
const dateElement = document.getElementById('live-date');
if (dateElement) {
dateElement.textContent = `${weekday} ${day} ${month}`;
}
}
function formatNumberWithCommas(number) {
if (isNaN(number) || number === null || number === undefined) {
return '0';
}
return Number(number).toLocaleString();
}
// Start clock/date
updateTime();
setInterval(updateTime, 1000);
updateDate();
// function fetchSiteStatistics() {
// const apiUrl = 'https://viewersvault.com/api.php?action=query&meta=siteinfo&siprop=statistics&format=json';
// $.getJSON(apiUrl, function (data) {
// const stats = data.query.statistics;
// const pages = formatNumberWithCommas(stats.pages);
// const articles = formatNumberWithCommas(stats.articles);
// const edits = formatNumberWithCommas(stats.edits);
// const images = formatNumberWithCommas(stats.images);
// const users = formatNumberWithCommas(stats.users);
// const activeUsers = formatNumberWithCommas(stats.activeusers);
// const admins = formatNumberWithCommas(stats.admins);
// const jobs = formatNumberWithCommas(stats.jobs);
// const statsHtml = `
// <h2>Site Statistics</h2>
// <ul>
// <li><strong>Pages:</strong> ${pages}</li>
// <li><strong>Articles:</strong> ${articles}</li>
// <li><strong>Edits:</strong> ${edits}</li>
// <li><strong>Images:</strong> ${images}</li>
// <li><strong>Users:</strong> ${users}</li>
// <li><strong>Active Users:</strong> ${activeUsers}</li>
// <li><strong>Admins:</strong> ${admins}</li>
// <li><strong>(System) Jobs:</strong> ${jobs}</li>
// </ul>
// `;
// $('#job-list').html(statsHtml);
// }).fail(function () {
// $('#job-list').html('<p>Error fetching site statistics.</p>');
// console.error('API request failed');
// });
// }
// // Fetch stats
// fetchSiteStatistics();
// const prideMessages = [
// '🏳️🌈 Happy Pride Month! 🏳️🌈',
// '❤️ Love is Love 🧡',
// '🏳️⚧️ Trans Rights are Human Rights 🏳️⚧️',
// '🌈 Celebrate Diversity 🌈',
// '🦄 Everyone is Welcome Here 🦄',
// '👨❤️💋👨 Celebrating the LGBTQIA+ Community 👩❤️💋👩',
// '🌈 Pride, Equality & Inclusion 🏳️🌈',
// '💜 Be Proud of Who You Are ✨'
// ];
// let prideIndex = 0;
// setInterval(() => {
// const banner = $('#pride-banner');
// if (banner.length) {
// banner.fadeOut(500, function () {
// prideIndex = (prideIndex + 1) % prideMessages.length;
// banner.text(prideMessages[prideIndex]);
// banner.fadeIn(500);
// });
// }
// }, 3000);
}
// ============================================================
// Teletext functionality — runs globally
// ============================================================
// 🔵 Teletext title flashing
const title = document.querySelector(".teletext-title");
if (title) {
setInterval(() => {
title.style.color = (title.style.color === "blue") ? "yellow" : "blue";
}, 1000);
}
// Teletext page animations
const pageSpan = document.getElementById('teletext-100');
const pageNumSpan = document.querySelector('.teletext-pagenum');
if (pageSpan && pageNumSpan) {
// ... your existing teletext animation logic ...
}
// ============================================================
// Technical difficulties banner
// ============================================================
var endTime = new Date(Date.UTC(2025, 8, 9, 13, 0, 0));
var now = new Date();
if (now < endTime) {
var $banner = $('<div>', {
id: 'site-error-banner',
text: '⚠️ We are currently experiencing technical difficulties. Some features may not work as expected.',
});
$banner.css({
'background-color': '#ffcccc',
'color': '#990000',
'padding': '10px',
'text-align': 'center',
'font-weight': 'bold',
'border-bottom': '2px solid #990000',
'font-size': '14px',
'z-index': '9999'
});
$('#mw-content-text').prepend($banner);
}
// ============================================================
// Greeting banner rotator (original greetings commented out)
// ============================================================
/*
var greetings = [
'🎅 HAPPY ST. NICHOLAS DAY! • Sinterklaasdag 🎅 (6 Dec)',
'🌳 HAPPY BODHI DAY! • सुप्रभात बोधि दिवस • බෝධි පෝය 🌳 (8 Dec)',
'🕎 HAPPY HANUKKAH! • חֲנוּכָּה שַׂמֵחַ • פייערלעךין חנוכה 🕎 (14–22 Dec)',
'❄️ HAPPY WINTER SOLSTICE! • Blessed Yule ❄️ (21 Dec)',
'🎄 MERRY CHRISTMAS! • Feliz Navidad • Joyeux Noël 🎄 (25 Dec)',
'🎁 HAPPY BOXING DAY! • HAPPY ST. STEPHEN\'S DAY! ⛪ (26 Dec)',
'🟩 HAPPY KWANZAA! • Heri za Kwanzaa 🟥 (26 Dec – 1 Jan)',
'🎉 HAPPY NEW YEAR\'S EVE! 🎉 (31 Dec)',
'🕛 HAPPY NEW YEAR! • Feliz Año Nuevo • Bonne Année 🥂 (1 Jan)',
'⭐ HAPPY EPIPHANY! • Θεοφάνεια (Theophaneia) ⭐ (6 Jan)',
'✝️ HAPPY ORTHODOX CHRISTMAS! ✝️ (7 Jan)',
'🎊 HAPPY ORTHODOX NEW YEAR! 🎊 (14 Jan)'
];
var index = 0;
function cycleGreetings() {
var greetingEl = document.getElementById('greeting');
if (!greetingEl) return;
greetingEl.innerHTML = greetings[index];
index = (index + 1) % greetings.length;
}
setInterval(cycleGreetings, 3000);
*/
});