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

Z Kolejopedia
Przejdź do nawigacji Przejdź do wyszukiwania
Nie podano opisu zmian
Nie podano opisu zmian
 
(Nie pokazano 8 pośrednich wersji utworzonych przez tego samego użytkownika)
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-10-01");
         const endDate = new Date("2026-02-1");
         const today = new Date();
         const today = new Date();


Linia 19: Linia 19:


         const infoBox = document.createElement("div");
         const infoBox = document.createElement("div");
         infoBox.style.background = "#f2f2f2";
         infoBox.style.backgroundColor = "var(--background-color-base)";
         infoBox.style.border = "2px solid #aaa";
         infoBox.style.border = "2px solid var(--border-color-base)";
         infoBox.style.margin = "10px 0";
         infoBox.style.margin = "10px 0";
         infoBox.style.padding = "8px";
         infoBox.style.padding = "8px";
Linia 27: 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 = ` | <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 początku akcji „Dobry Artykuł Jesień 2025”: <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
        `;


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

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);
    });
});