MediaWiki:Common.js: Difference between revisions

From FHX Wiki
No edit summary
(Replaced content with "alert("JS is working!");")
Tag: Replaced
Line 1: Line 1:
function countdownToChristmas() {
    const targetDate = new Date(new Date().getFullYear(), 11, 25); // Dec 25 of current year
    const now = new Date();
   
    // If Christmas already passed this year, use next year's Christmas
    if (now > targetDate) {
        targetDate.setFullYear(targetDate.getFullYear() + 1);
    }
    function updateCountdown() {
        const now = new Date();
        const diff = targetDate - now;
        if (diff <= 0) {
            document.getElementById('xmas-timer').innerText = "🎄 Merry Christmas!";
            return;
        }
        const days = Math.floor(diff / (1000 * 60 * 60 * 24));
        const hours = Math.floor((diff / (1000 * 60 * 60)) % 24);
        const minutes = Math.floor((diff / (1000 * 60)) % 60);
        const seconds = Math.floor((diff / 1000) % 60);
        document.getElementById('xmas-timer').innerText =
            `🎅 Countdown to Christmas: ${days}d ${hours}h ${minutes}m ${seconds}s`;
    }
    updateCountdown(); // initial call
    setInterval(updateCountdown, 1000);
}
$(document).ready(countdownToChristmas);
alert("JS is working!");
alert("JS is working!");

Revision as of 16:45, 28 July 2025

alert("JS is working!");