MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Freifunk Köln, Bonn und Umgebung
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
const DATE_CONFIG = [
const DATE_CONFIG = [
{
    {
week: 1, // 1st week
        week: 1, // 1st week
day: 4, // Thursday
        day: 4, // Thursday
text: 'in der <a rel="nofollow" class="external text" href="https://www.openstreetmap.org/way/123890490">Alten VHS, Wilhelmstraße 34</a>, <b>20:00</b> Uhr'
        text: 'in der <a rel="nofollow" class="external text" href="https://www.openstreetmap.org/way/123890490">Alten VHS, Wilhelmstraße 34</a>, <b>20:00</b> Uhr'
}, {
    }, {
week: 2, //2nd week
        week: 2, //2nd week
day: 4, // Thursday
        day: 4, // Thursday
text: 'im <a rel="nofollow" class="external text" href="https://koeln.ccc.de">C4</a> in Köln, <a rel="nofollow" class="external text" href="http://www.koeln.ccc.de/c4/faq/index.xml#anreise">Helios Str. 6a</a>, <b>20:00</b> Uhr'
        text: 'im <a rel="nofollow" class="external text" href="https://koeln.ccc.de">C4</a> in Köln, <a rel="nofollow" class="external text" href="http://www.koeln.ccc.de/c4/faq/index.xml#anreise">Helios Str. 6a</a>, <b>20:00</b> Uhr'
}, {
    }, {
week: 3, // 3rd week
        week: 3, // 3rd week
day: 4, // Thursday
        day: 4, // Thursday
text: 'in der <a rel="nofollow" class="external text" href="https://www.openstreetmap.org/way/123890490">Alten VHS, Wilhelmstraße 34</a>, <b>20:00</b> Uhr'
        text: 'in der <a rel="nofollow" class="external text" href="https://www.openstreetmap.org/way/123890490">Alten VHS, Wilhelmstraße 34</a>, <b>20:00</b> Uhr'
}
    }
];
];


function upcomingDates(){
const upcomingDates = function(){
let ret = "";
    let ret = "";
let today = new Date();
    let today = new Date();


for (let counter = 0;counter < 3; counter++){
    for (let counter = 0;counter < 3; counter++){
let text = null;
        let text = null;
while (!(text = getDateText(today, bonnText, koelnText))) { // Count
        while (!(text = getDateText(today, bonnText, koelnText))) { // Count
today.setDate(today.getDate() + 1);
            today.setDate(today.getDate() + 1);
}
        }
today.setDate(today.getDate() + 1);
        today.setDate(today.getDate() + 1);
ret += text;
        ret += text;
}
    }
return ret;
    return ret;
}
};


function getDateText(d, bonnText, koelnText) {
const getDateText = function (d, bonnText, koelnText) {
const dayOfMonth = d.getDate();
    const dayOfMonth = d.getDate();
const month = d.getMonth() +1;
    const month = d.getMonth() +1;
const year = d.getFullYear();
    const year = d.getFullYear();


for(let index = 0; index < DATE_CONFIG.length; index++){
    for(let index = 0; index < DATE_CONFIG.length; index++){
const conf = DATE_CONFIG[index];
        const conf = DATE_CONFIG[index];
if (d.getDay() == conf.day && dayOfMonth <= 7 * conf.week){
        if (d.getDay() == conf.day && dayOfMonth <= 7 * conf.week){
const dateStr = (dayOfMonth < 9) ? "0" + dayOfMonth : "" + dayOfMonth;
            const dateStr = (dayOfMonth < 9) ? "0" + dayOfMonth : "" + dayOfMonth;
return '<li>' + dateStr + '.' + month + '.' + year + " " + conf.text + '</li>';
            return '<li>' + dateStr + '.' + month + '.' + year + " " + conf.text + '</li>';
}
        }
}
    }
return null;
    return null;
}
};

Version vom 22. Oktober 2019, 09:44 Uhr

const DATE_CONFIG = [
    {
        week: 1, // 1st week
        day: 4, // Thursday
        text: 'in der <a rel="nofollow" class="external text" href="https://www.openstreetmap.org/way/123890490">Alten VHS, Wilhelmstraße 34</a>, <b>20:00</b> Uhr'
    }, {
        week: 2, //2nd week
        day: 4, // Thursday
        text: 'im <a rel="nofollow" class="external text" href="https://koeln.ccc.de">C4</a> in Köln, <a rel="nofollow" class="external text" href="http://www.koeln.ccc.de/c4/faq/index.xml#anreise">Helios Str. 6a</a>, <b>20:00</b> Uhr'
    }, {
        week: 3, // 3rd week
        day: 4, // Thursday
        text: 'in der <a rel="nofollow" class="external text" href="https://www.openstreetmap.org/way/123890490">Alten VHS, Wilhelmstraße 34</a>, <b>20:00</b> Uhr'
    }
];

const upcomingDates = function(){
    let ret = "";
    let today = new Date();

    for (let counter = 0;counter < 3; counter++){
        let text = null;
        while (!(text = getDateText(today, bonnText, koelnText))) { // Count
            today.setDate(today.getDate() + 1);
        }
        today.setDate(today.getDate() + 1);
        ret += text;
    }
    return ret;
};

const getDateText = function (d, bonnText, koelnText) {
    const dayOfMonth = d.getDate();
    const month = d.getMonth() +1;
    const year = d.getFullYear();

    for(let index = 0; index < DATE_CONFIG.length; index++){
        const conf = DATE_CONFIG[index];
        if (d.getDay() == conf.day && dayOfMonth <= 7 * conf.week){
            const dateStr = (dayOfMonth < 9) ? "0" + dayOfMonth : "" + dayOfMonth;
            return '<li>' + dateStr + '.' + month + '.' + year + " " + conf.text + '</li>';
        }
    }
     return null;
};