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

Z Kolejopedia
Przejdź do nawigacji Przejdź do wyszukiwania
Utworzono nową stronę "Umieszczony tutaj kod JavaScript zostanie załadowany przez każdego użytkownika, podczas każdego ładowania strony.: mw.loader.using(['mediawiki.util'], function () { $(function () { // Data początkowa: start Kolejopedii const startDate = new Date("2025-07-02"); const endDate = new Date("2025-07-31"); const today = new Date(); const msPerDay = 24 * 60 * 60 * 1000; const daysSinceStart = Math.floor((toda…"
 
Nie podano opisu zmian
 
(Nie pokazano 16 pośrednich wersji utworzonych przez tego samego użytkownika)
Linia 3: Linia 3:
mw.loader.using(['mediawiki.util'], function () {
mw.loader.using(['mediawiki.util'], function () {
     $(function () {
     $(function () {
        // Data początkowa: start Kolejopedii
         const startDate = new Date("2025-07-01");
         const startDate = new Date("2025-07-02");
         const endDate = new Date("2026-02-1");
         const endDate = new Date("2025-07-31");
         const today = new Date();
         const today = new Date();


Linia 19: Linia 18:
         });
         });


        // Tworzymy pasek info
         const infoBox = document.createElement("div");
         const infoBox = document.createElement("div");
         infoBox.style.background = "#f2f2f2";
         infoBox.style.backgroundColor = "var(--background-color-base)";
         infoBox.style.borderBottom = "2px solid #999";
         infoBox.style.border = "2px solid var(--border-color-base)";
        infoBox.style.margin = "10px 0";
         infoBox.style.padding = "8px";
         infoBox.style.padding = "8px";
         infoBox.style.fontSize = "14px";
         infoBox.style.fontSize = "14px";
Linia 28: Linia 27:
         infoBox.style.textAlign = "center";
         infoBox.style.textAlign = "center";
         infoBox.style.fontFamily = "Verdana, sans-serif";
         infoBox.style.fontFamily = "Verdana, sans-serif";
        infoBox.style.color = "var(--color-base)";


         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 = `
            <!-- <p style="color: red;">PROSIMY NIE SPAMOWAĆ!! To jest KOLEJOPEDIA nie SPAMOPEDIA!!!!</p> -->
            &nbsp; 📅 <b>${formatDate}</b> &nbsp; | &nbsp; ⌛ Kolejopedia działa już <b>${daysSinceStart}</b> dni  
            &nbsp; | &nbsp; 🏅 Do końca akcji „Dobry Artykuł Zima 2025”: <b>${daysToEnd}</b> dni
        `;


        // Wstawiamy przed główną zawartością
         const content = document.getElementById("bodyContent");
         const content = document.getElementById("content");
         if (content) content.insertBefore(infoBox, content.firstChild);
         if (content) content.parentNode.insertBefore(infoBox, content);
     });
     });
});
});

Aktualna wersja na dzień 08:01, 2 sty 2026

/* 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("2026-02-1");
        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.backgroundColor = "var(--background-color-base)";
        infoBox.style.border = "2px solid var(--border-color-base)";
        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.style.color = "var(--color-base)";

        infoBox.innerHTML = `
            <!-- <p style="color: red;">PROSIMY NIE SPAMOWAĆ!! To jest KOLEJOPEDIA nie SPAMOPEDIA!!!!</p> -->
            &nbsp; 📅 <b>${formatDate}</b> &nbsp; | &nbsp; ⌛ Kolejopedia działa już <b>${daysSinceStart}</b> dni 
            &nbsp; | &nbsp; 🏅 Do końca akcji „Dobry Artykuł Zima 2025”: <b>${daysToEnd}</b> dni
        `;

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