MediaWiki:Common.js: Różnice pomiędzy wersjami

Z Kolejopedia
Przejdź do nawigacji Przejdź do wyszukiwania
Nie podano opisu zmian
Nie podano opisu zmian
Linia 4: Linia 4:
     $(function () {
     $(function () {
         const startDate = new Date("2025-07-01");
         const startDate = new Date("2025-07-01");
         const endDate = new Date("2025-07-31");
         /* const endDate = new Date("2025-07-31"); */
         const today = new Date();
         const today = new Date();


Linia 28: Linia 28:
         infoBox.style.fontFamily = "Verdana, sans-serif";
         infoBox.style.fontFamily = "Verdana, sans-serif";


         infoBox.innerHTML = `📅 <b>${formatDate}</b> &nbsp; | &nbsp; ⌛ Kolejopedia działa już <b>${daysSinceStart}</b> dni &nbsp; | &nbsp; 🏅 Do końca akcji „Dobry Artykuł”: <b>${daysToEnd}</b> dni`;
         infoBox.innerHTML = `📅 <b>${formatDate}</b> &nbsp; | &nbsp; ⌛ Kolejopedia działa już <b>${daysSinceStart}</b> dni &nbsp; | &nbsp; 🏅 Koniec akcji „Dobry Artykuł”`;


         const content = document.getElementById("bodyContent");
         const content = document.getElementById("bodyContent");

Wersja z 08:48, 1 sie 2025

/* Umieszczony tutaj kod JavaScript zostanie załadowany przez każdego użytkownika, podczas każdego ładowania strony. */

mw.loader.using(['mediawiki.util'], function () {
    $(function () {
        const startDate = new Date("2025-07-01");
        /* const endDate = new Date("2025-07-31"); */
        const today = new Date();

        const msPerDay = 24 * 60 * 60 * 1000;
        const daysSinceStart = Math.floor((today - startDate) / msPerDay) + 1;
        const daysToEnd = Math.max(0, Math.ceil((endDate - today) / msPerDay));

        const formatDate = today.toLocaleDateString("pl-PL", {
            weekday: "long",
            year: "numeric",
            month: "long",
            day: "numeric"
        });

        const infoBox = document.createElement("div");
        infoBox.style.background = "#f2f2f2";
        infoBox.style.border = "2px solid #aaa";
        infoBox.style.margin = "10px 0";
        infoBox.style.padding = "8px";
        infoBox.style.fontSize = "14px";
        infoBox.style.fontWeight = "bold";
        infoBox.style.textAlign = "center";
        infoBox.style.fontFamily = "Verdana, sans-serif";

        infoBox.innerHTML = `📅 <b>${formatDate}</b> &nbsp; | &nbsp; ⌛ Kolejopedia działa już <b>${daysSinceStart}</b> dni &nbsp; | &nbsp; 🏅 Koniec akcji „Dobry Artykuł”`;

        const content = document.getElementById("bodyContent");
        if (content) content.insertBefore(infoBox, content.firstChild);
    });
});