Gebruiker:Rots61/Gadget-LogTheCounter.js: verschil tussen versies

Uit Wikikids
Naar navigatie springen Naar zoeken springen
(artikel)
Regel 1: Regel 1:
 
/* jshint sub:true maxerr:100000 */
 
/* jshint sub:true maxerr:100000 */
// Gadget gemaakt door [[User:Rots61]]
+
// [[User:MakiBoy/Gadget-LogCounter.js]] gemaakt door [[User:MakiBoy]]
// Documentatie op [[WikiKids:Opschonen]]
 
  
var opschoonversion = '1.2.1';
+
var version = '2.9';
var text;
 
var api = new mw.Api();
 
var alreadydone;
 
  
function showProject(text) {
+
function parseNumber(number) {
     // text = array
+
     return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
    document.getElementsByTagName("h1")[0].textContent = "Speciaal:Opschonen";
 
    document.title = "Opschonen - WikiKids";
 
    tempgetal = 1;
 
    tempnumber = 1;
 
    var tabelstuk1 = '<th style="line-height:99%;vertical-align:bottom;padding:.4em .4em .2em;background-position:50% .4em !important;min-width:0.875em;max-width:0.875em;width:0.875em;overflow:hidden;"><div style="vertical-rl=-webkit-writing-mode: vertical-rl; -o-writing-mode: vertical-rl; -ms-writing-mode: tb-rl;writing-mode: tb-rl; writing-mode: vertical-rl; layout-flow: vertical-ideographic;transform:rotate(180deg);display:inline-block;padding-left:1px;text-align:left;">Gecontroleerd</div></th>';
 
    var tabelstuk2 = '<th style="line-height:99%;vertical-align:bottom;padding:.4em .4em .2em;background-position:50% .4em !important;min-width:0.875em;max-width:0.875em;width:0.875em;overflow:hidden;"><div style="vertical-rl=-webkit-writing-mode: vertical-rl; -o-writing-mode: vertical-rl; -ms-writing-mode: tb-rl;writing-mode: tb-rl; writing-mode: vertical-rl; layout-flow: vertical-ideographic;transform:rotate(180deg);display:inline-block;padding-left:1px;text-align:left;">Niet aangepast</div></th>';
 
    var tabelstuk3 = '<th style="line-height:99%;vertical-align:bottom;padding:.4em .4em .2em;background-position:50% .4em !important;min-width:0.875em;max-width:0.875em;width:0.875em;overflow:hidden;"><div style="vertical-rl=-webkit-writing-mode: vertical-rl; -o-writing-mode: vertical-rl; -ms-writing-mode: tb-rl;writing-mode: tb-rl; writing-mode: vertical-rl; layout-flow: vertical-ideographic;transform:rotate(180deg);display:inline-block;padding-left:1px;text-align:left;">Niet bekeken</div></th>';
 
    tabel = "Deze artikels kun je controleren. Je hoeft niet alle onderstaande artikels te controleren. Dat mag natuurlijk wel. Opmerking is niet nodig, het mag wel. "
 
        + '<br>Opslaan duurt een paar seconden, wacht totdat je ziet dat de wijziging is doorgevoerd. Als je meer specifiek wil controleren klik dan <a href="https://wikikids.nl/Speciaal:Opschonen?action=help">hier</a>.'
 
        + '<br>Het doel is om alle pagina\'s op WikiKids te controleren. Als je 10 artikels per dag controleerd, dan help je goed mee!'
 
        + '<br><input type="text" id="addarticle" name="addarticle"> <button onclick="addArticleToList()">Voeg toe</button>'
 
        + '<table class="wikitable"> <tbody> <tr> <th width="300"><div style="float: left; text-align: left">Pagina</div><div style="float: right; text-align: right">Gebruiker</div></th>' + tabelstuk1 + tabelstuk2 + tabelstuk3 + '<th width="1">Opmerking<br><span style="color:gray;">van de andere gebruiker</span></th> <th>Thema</th> </tr>';
 
    showAantal = mw.util.getParamValue('aantal');
 
    showAll = mw.util.getParamValue('allepaginas');
 
    showSkipDone = mw.util.getParamValue('notdone');
 
    //Zorg ervoor dat je al gecontroleerde pagina's niet ziet
 
    showSkipThema = mw.util.getParamValue('notthema');
 
    //Zorg ervoor dat je al bekeken pagina's niet ziet
 
    showDone = mw.util.getParamValue('done');
 
    //Zorg ervoor dat je alle gecontroleerde pagina's ziet
 
    showThema = mw.util.getParamValue('thema');
 
    //Zorg ervoor dat je alle pagina's ziet met een thema
 
    showUser = mw.util.getParamValue('user');
 
    //Zorg ervoor dat je alle pagina's ziet waar deze gebruiker bij staat.
 
    showStartwith = mw.util.getParamValue('Startwith');
 
    showTo = mw.util.getParamValue('to');
 
    showFrom = mw.util.getParamValue('from');
 
    showFirstAuthor = mw.util.getParamValue('firstauthor');
 
    if (showFirstAuthor) {
 
    showAantal = '0';
 
    }
 
    if (showAantal === 'max') {
 
        showAantal = text.length - 1;
 
        showMax = true;
 
        showAll = true;
 
    } else if (showAantal) {
 
        showAantal = parseInt(showAantal) + 1;
 
    } else if (showAll) {
 
        showAantal = text.length - 1;
 
    }
 
    if ((showThema || showDone) || (showSkipThema || (showSkipDone || (showTo || (showFrom || (showUser || (showStartwith || showAantal))))))) {
 
    } else {
 
        showAantal = 51;
 
        showSkipDone = true;
 
    }
 
    lengtetext = text.length;
 
    while (tempnumber !== showAantal) {
 
        Artikeln[tempgetal] = getURLParamNumber(text);
 
        if (Artikeln[tempgetal] === 'exit') {
 
            tempnumber = -1;
 
            showAantal = -1;
 
        } else {
 
            Artikelr[tempgetal] = text[Artikeln[tempgetal]]["N"];
 
            if (text[Artikeln[tempgetal]]["D"]) {
 
                gedaan[tempgetal] = " disabled";
 
                text[Artikeln[tempgetal]]["T"] = "&nbsp;";
 
                linkextra[tempgetal] = "Done";
 
                Knop1x[tempgetal] = "";
 
                Knop2x[tempgetal] = "";
 
                Knop3x[tempgetal] = '<td colspan="3" style="color:green; font-weight: bold; text-align: center;">Gedaan</td>';
 
            } else {
 
                gedaan[tempgetal] = "";
 
                linkextra[tempgetal] = "Niet";
 
                Knop1x[tempgetal] = '<td><input type="radio" id="Radio1.' + tempgetal + '" name="Knop' + tempgetal + '" onclick="Change1(' + tempgetal + ');"></td>';
 
                Knop2x[tempgetal] = '<td><input type="radio" id="Radio2.' + tempgetal + '" name="Knop' + tempgetal + '" onclick="Change2(' + tempgetal + ');"></td>';
 
                Knop3x[tempgetal] = '<td><input type="radio" id="Radio3.' + tempgetal + '" name="Knop' + tempgetal + '" onclick="Change3(' + tempgetal + ');"></td>';
 
 
 
            }
 
            if (text[Artikeln[tempgetal]]["U"]) {
 
                vorigeuser[tempgetal] = ' <div style="float: right; font-weight: bold; text-align: right">' + text[Artikeln[tempgetal]]["U"] + '</div>';
 
            } else {
 
                vorigeuser[tempgetal] = "";
 
            }
 
            if (text[Artikeln[tempgetal]]["O"]) {
 
                Opmerking[tempgetal] = text[Artikeln[tempgetal]]["O"];
 
            } else {
 
                Opmerking[tempgetal] = '<input type="text" id=Opmerking' + tempgetal + ' name=Opmerking' + tempgetal + ' size=70">';
 
            }
 
            if (text[Artikeln[tempgetal]]["T"]) {
 
                Thema[tempgetal] = '<center>' + text[Artikeln[tempgetal]]["T"] + '</center>';
 
            } else {
 
                Thema[tempgetal] = '<input type="text" id=Thema' + tempgetal + ' name=Thema' + tempgetal + ' size=10">';
 
            }
 
            console.log(Artikeln[tempgetal] + ": " + Artikelr[tempgetal]);
 
            Artikellink[tempgetal] = '<a href="https://wikikids.nl/' + Artikelr[tempgetal] + '?projectopschonen=x&checked=' + linkextra[tempgetal] + '" target="_blank">' + Artikelr[tempgetal] + '</a>' + vorigeuser[tempgetal];
 
            tabel += '<tr> <td>' + Artikellink[tempgetal] + '</td>' + Knop1x[tempgetal] + Knop2x[tempgetal] + Knop3x[tempgetal] + '<td>' + Opmerking[tempgetal] + '</td> <td>' + Thema[tempgetal] + '</td> </tr>';
 
            tempgetal += 1;
 
            if (showMax) {
 
                tempnumber = allNummer;
 
            } else {
 
                tempnumber = tempgetal;
 
            }
 
        }
 
    }
 
    // text = array
 
    eindetabel += '</tbody></table> <button onclick="startIT()">Opslaan</button>';
 
    document.getElementById('bodyContent').innerHTML = tabel + eindetabel;
 
    if (showFirstAuthor) {
 
    getallNewPagesFirstAuthor(showFirstAuthor).done(function (textyz) {
 
  for (var i = 0; i < textyz.length; i++) {
 
addArticleToList(textyz[i]);
 
          }
 
          mw.notify("Welkom!", { 'tag': 'addpagetolistopschonen', 'autoHideSeconds': 30 });
 
        });
 
    } else {
 
    mw.notify("Welkom!");
 
    }
 
 
}
 
}
  
function getallNewPagesFirstAuthor( showFirstAuthor, apiContinue ) {  
+
function showProjectLogCounter(pages) {
     return api.get( {
+
     document.getElementsByTagName("h1")[0].textContent = "Speciaal:LogCounter";
        action: "query",
+
    document.title = "LogCounter - WikiKids";
        list: "usercontribs",
 
        ucprop: "title",
 
        uclimit: "500",
 
        ucshow: "new",
 
        ucnamespace: "0",
 
        ucuser: showFirstAuthor,
 
        uccontinue: apiContinue ? apiContinue.uccontinue : undefined
 
    } ).then( function (data) {
 
        if ( data.continue ) {
 
            return getallNewPagesFirstAuthor( showFirstAuthor, data.continue )
 
                .then( function ( temparrayfirstauthor ) {
 
                console.log(temparrayfirstauthor);
 
                for (var i = 0; i < data.query.usercontribs.length; i++) {
 
        temparrayfirstauthor.push(data.query.usercontribs[i]['title']);
 
        console.log(data.query.usercontribs[i]['title']);
 
        }
 
                    return temparrayfirstauthor;
 
                } );
 
        } else {
 
        for (var i = 0; i < data.query.usercontribs.length; i++) {
 
        temparrayfirstauthor.push(data.query.usercontribs[i]['title']);
 
        console.log(data.query.usercontribs[i]['title']);
 
        }
 
        console.log(temparrayfirstauthor);
 
        return temparrayfirstauthor;
 
        }
 
    } );
 
}
 
  
function getURLParamNumber(text, nummer) {
+
     var searchBar = '<div><input type="text" id="lc-searchbar"> <button onclick="searchTitle();">Zoek</button></div>'
     willekeuriggetal = 0;
+
        + '<button onclick="reloadPagesLogCounter();">Laad alles opnieuw in</button>';
    while (willekeuriggetal === 0) {
+
    var logCounterInfo = '<div id="logCounterInfo">Deze pagina laat zien hoeveel paginabezoeken er zijn geweest op een specifieke pagina. De rij "Views" bevat alle views. De rij "Categorie" laat alleen maar zien hoeveel views er vanuit een categorie komen.</div>';
        willekeuriggetal = getRandomNumber(text.length);
 
        if (willekeuriggetal === text.length) {
 
            return 'exit';
 
        } else {
 
            if (showUser) {
 
                if (text[willekeuriggetal]["U"] === showUser) {
 
                } else {
 
                    willekeuriggetal = 0;
 
                }
 
            }
 
            if (showThema) {
 
                if (text[willekeuriggetal]["T"]) {
 
                } else {
 
                    willekeuriggetal = 0;
 
                }
 
            } else if (showSkipThema) {
 
                if (text[willekeuriggetal]["T"]) {
 
                    willekeuriggetal = 0;
 
                }
 
            }
 
            if (showDone) {
 
                if (text[willekeuriggetal]["D"]) {
 
                } else {
 
                    willekeuriggetal = 0;
 
                }
 
            } else if (showSkipDone) {
 
                if (text[willekeuriggetal]["D"]) {
 
                    willekeuriggetal = 0;
 
                }
 
            }
 
            if (showStartwith) {
 
                var re = new RegExp('^' + showStartwith, "g");
 
                if (text[willekeuriggetal]["N"] !== text[willekeuriggetal]["N"].replace(re, "newstring")) {
 
                } else {
 
                    willekeuriggetal = 0;
 
                }
 
            }
 
            if (showFrom) {
 
                if (text[willekeuriggetal]["N"]) {
 
  
                }
+
     var table = document.createElement('table');
                if (showTo) {
+
     table.classList.add('wikitable');
                    if (text[willekeuriggetal]["N"]) {
+
                    }
+
var arrayHoofdpagina = ["1", "20012023"]; //voeg versies toe die de hoofdpagina gebruiken
                }
+
var arrayCategorie = ["1"]; //voeg versies toe die de categorieën gebruiken
            }
+
     var tableHead = document.createElement('thead');
        }
+
     var tableHeadRow = document.createElement('tr');
     }
+
     var tableHeadTitles;
    return willekeuriggetal;
+
     if (arrayHoofdpagina.includes(requestDate)) {
}
+
    tableHeadTitles = ['Paginatitel', 'Laatste bezoek', 'Views', 'Hoofdpagina'];
 
 
function disableaddfunction() {
 
console.log('disabled');
 
}
 
 
 
function Change1(getal) {
 
disableaddfunction();
 
    if (!document.getElementById('Thema' + getal).disabled) {
 
        Thematemp[getal] = document.getElementById('Thema' + getal).value;
 
    }
 
    document.getElementById('Thema' + getal).disabled = true;
 
     document.getElementById('Opmerking' + getal).disabled = false;
 
    document.getElementById('Thema' + getal).value = "";
 
    Opmerkingtempx = document.getElementById('Opmerking' + getal).value;
 
    document.getElementById('Opmerking' + getal).value = Opmerkingtemp[getal] ? Opmerkingtemp[getal] : Opmerkingtempx ? Opmerkingtempx : "";
 
 
 
}
 
 
 
function Change2(getal) {
 
disableaddfunction();
 
    Thematempx = document.getElementById('Thema' + getal).value;
 
    Opmerkingtempx = document.getElementById('Opmerking' + getal).value;
 
    document.getElementById('Thema' + getal).disabled = false;
 
    document.getElementById('Opmerking' + getal).disabled = false;
 
    document.getElementById('Thema' + getal).value = Thematemp[getal] ? Thematemp[getal] : Thematempx ? Thematempx : "";
 
    document.getElementById('Opmerking' + getal).value = Opmerkingtemp[getal] ? Opmerkingtemp[getal] : Opmerkingtempx ? Opmerkingtempx : "";
 
}
 
 
 
function Change3(getal) {
 
    if (!document.getElementById('Thema' + getal).disabled) {
 
        Thematemp[getal] = document.getElementById('Thema' + getal).value;
 
     }
 
    if (!document.getElementById('Opmerking' + getal).disabled) {
 
        Opmerkingtemp[getal] = document.getElementById('Opmerking' + getal).value;
 
     }
 
    document.getElementById('Thema' + getal).disabled = true;
 
    document.getElementById('Opmerking' + getal).disabled = true;
 
    document.getElementById('Thema' + getal).value = "";
 
    document.getElementById('Opmerking' + getal).value = "";
 
}
 
 
 
function fromPageaddPage() {
 
     var text;
 
    var artikel;
 
    var checkconfirm;
 
    var checkopmerking;
 
    getJSONText().done(function (text) {
 
        fromPageCheckOnList(text);
 
    });
 
}
 
 
 
function fromPageCheckOnList(text) {
 
     if (!Array.isArray(text)) {
 
        text = JSON.parse(text);
 
    }
 
    if (!text[1]["N"]) {
 
        text = JSON.parse(text);
 
    }
 
    addarticle = mw.config.get('wgPageName').replace(/ /g, '_');
 
    var Nummer;
 
    for (var i = 0, iLen = text.length; i < iLen; i++) {
 
        if (text[i].N == addarticle) Nummer = i;
 
    }
 
    if (!Nummer) {
 
        api.get({
 
            action: "query",
 
            titles: addarticle,
 
            redirects: true,
 
        }).then(function (ret) {
 
            if (ret.query.redirects) {
 
                alreadydone = true;
 
                mw.notify("Pagina is een redirect.");
 
            } else {
 
                $.each(ret.query.pages, function () {
 
                    if (this.missing !== "") {
 
                        if (this.ns === 0) {
 
                            Nummer = text.length;
 
                            text[text.length] = { "N": addarticle, "D": "D", "U": mw.config.get('wgUserName') };
 
                        } else {
 
                            alreadydone = true;
 
                            mw.notify("Pagina staat niet in de hoofdnaamruimte.");
 
                        }
 
                    } else {
 
                        alreadydone = true;
 
                        mw.notify("Pagina bestaat niet. ");
 
                    }
 
                }, function (error) {
 
                });
 
            }
 
        });
 
    } else if (text[Nummer]["D"] === "D") {
 
        mw.notify("Dit aritkel is al gecontroleerd door " + text[Nummer]["U"]);
 
        alreadydone = true;
 
 
     } else {
 
     } else {
        text[Nummer]["D"] = "D";
+
    tableHeadTitles = ['Paginatitel', 'Laatste bezoek', 'Views', 'Categorie'];
        text[Nummer]["U"] = mw.config.get('wgUserName');
 
 
     }
 
     }
     fromPageSave(text);
+
     var tableBody = document.createElement('tbody');
}
 
  
function fromPageSave(text) {
+
     var currentPage = 1;
     if (alreadydone) {
+
     var rowsPerPage = mw.util.getParamValue('rows') ? parseInt(mw.util.getParamValue('rows')) : 25;
    } else if (!Nummer) {
+
    var totalPages = Math.ceil(pages.length / rowsPerPage);
        setTimeout(fromPageSave, 250);
 
     } else {
 
        checkopmerking = prompt("Mogelijke opmerking over het artikel: ");
 
        if (checkopmerking === null) {
 
        } else if (checkopmerking === '') {
 
            editpagenow(text);
 
        } else {
 
            text[Nummer]["O"] = checkopmerking;
 
            editpagenow(text);
 
        }
 
    }
 
}
 
  
function addArticleToList(artikel) {
+
    function showPage(pageNumber) {
    if (!text[1]["N"]) {
+
        currentPage = pageNumber;
         text = JSON.parse(text);
+
        tableBody.innerHTML = '';
    }
+
        var start = (currentPage - 1) * rowsPerPage;
    addarticle = undefined;
+
        var end = start + rowsPerPage;
    if (artikel) {
+
         var paginatedItems = pages.slice(start, end);
        addarticle = artikel;
+
        paginatedItems.forEach(function (page) {
    } else {
+
            var row = document.createElement('tr');
        addarticle = document.getElementById('addarticle').value.replace(/ /g, '_');
+
            var totalVisitors, mainPageVisited, pageTitle, pageLink, date;
    }
+
            if (historyLogCounter) {
    for (var i = 0, iLen = text.length; i < iLen; i++) {
+
            totalVisitors = page.nV + page.mPV;
        if (text[i].N == addarticle) Nummer = i;
+
            mainPageVisited = page.mPV ? parseNumber(page.mPV) : "";
    }
+
            pageTitle = page.t.replace(/_/g, ' ');
    if (!Nummer) {
+
            pageLink = page.t;
        api.get({
+
            if (pageLink.includes("S:Z\\")) {
            action: "query",
+
            pageLink = pageLink.replace(/S:Z\\/g, 'Speciaal:Zoeken/');
            titles: addarticle,
+
            pageTitle = pageTitle.replace(/S:Z\\/g, 'Zoekopdracht: ');
            redirects: true,
+
            }
        }).then(function (ret) {
+
            date = new Date(page.uA);
            if (ret.query.redirects) {
 
                mw.notify("Pagina is een redirect, kan niet gecontroleerd worden.", { 'tag': 'addpagetolistopschonen'});
 
 
             } else {
 
             } else {
                $.each(ret.query.pages, function () {
+
            totalVisitors = page.normalVisitors + page.mainPageVisitors;
                    if (this.missing !== "") {
+
            mainPageVisited = page.mainPageVisitors ? parseNumber(page.mainPageVisitors) : "";
                        if (this.ns === 0) {
+
            pageTitle = page.title.replace(/_/g, ' ');
                            Nummer = text.length;
+
            pageLink = page.title;
                            text[text.length] = { "N": addarticle };
+
            if (pageLink.includes("S:Z")) {
                        } else {
+
            pageLink = pageLink.replace(/S:Z\\/g, 'Speciaal:Zoeken/');
                            mw.notify("Pagina staat niet in de hoofdnaamruimte.", { tag: 'addpagetolistopschonen' });
+
            pageTitle = page.title;
                        }
+
            }
                    } else {
+
            date = new Date(page.updatedAt);
                        mw.notify("Pagina bestaat niet. ", { tag: 'addpagetolistopschonen' });
 
                    }
 
                }, function (error) {
 
                });
 
 
             }
 
             }
        });
+
             function addZero(number) {
    }
+
                 return number < 10 ? "0" + number : number;
    if (Nummer) {
 
        tempgetal = 1;
 
        var gewenstelengte = Artikelr.length;
 
        if (gewenstelengte === 0) {
 
            gewenstelengte = 1;
 
             tempgetal = 1;
 
        }
 
        /*
 
        while (tempgetal !== gewenstelengte) {
 
            if (document.getElementById('Radio1.' + tempgetal)) {
 
                 Waardes['Radio1'][tempgetal] = document.getElementById('Radio1.' + tempgetal).checked;
 
                Waardes['Radio2'][tempgetal] = document.getElementById('Radio2.' + tempgetal).checked;
 
                Waardes['Radio3'][tempgetal] = document.getElementById('Radio3.' + tempgetal).checked;
 
                Waardes['Opmerking'][tempgetal] = document.getElementById('Opmerking' + tempgetal).value;
 
                Waardes['Thema'][tempgetal] = document.getElementById('Thema' + tempgetal).value;
 
                Waardes['Themadis'][tempgetal] = document.getElementById('Thema' + tempgetal).disabled;
 
                Waardes['Opmerkingdis'][tempgetal] = document.getElementById('Opmerking' + tempgetal).disabled;
 
 
             }
 
             }
            tempgetal += 1;
 
        }
 
        */
 
        tempgetal = Artikelr.length;
 
        Artikeln[tempgetal] = Nummer;
 
        Artikelr[tempgetal] = text[Artikeln[tempgetal]]["N"];
 
        if (text[Artikeln[tempgetal]]["D"]) {
 
            gedaan[tempgetal] = " disabled";
 
            text[Artikeln[tempgetal]]["T"] = "&nbsp;";
 
            linkextra[tempgetal] = "Done";
 
            Knop1x[tempgetal] = "";
 
            Knop2x[tempgetal] = "";
 
            Knop3x[tempgetal] = '<td colspan="3" style="color:green; font-weight: bold;">Gedaan</td>';
 
        } else {
 
            gedaan[tempgetal] = "";
 
            linkextra[tempgetal] = "Niet";
 
            Knop1x[tempgetal] = '<td><input type="radio" id="Radio1.' + tempgetal + '" name="Knop' + tempgetal + '" onclick="Change1(' + tempgetal + ');"></td>';
 
            Knop2x[tempgetal] = '<td><input type="radio" id="Radio2.' + tempgetal + '" name="Knop' + tempgetal + '" onclick="Change2(' + tempgetal + ');"></td>';
 
            Knop3x[tempgetal] = '<td><input type="radio" id="Radio3.' + tempgetal + '" name="Knop' + tempgetal + '" onclick="Change3(' + tempgetal + ');"></td>';
 
        }
 
        if (text[Artikeln[tempgetal]]["U"]) {
 
            vorigeuser[tempgetal] = ' <div style="float: right; font-weight: bold; text-align: right">' + text[Artikeln[tempgetal]]["U"] + '</div>';
 
        } else {
 
            vorigeuser[tempgetal] = "";
 
        }
 
        if (text[Artikeln[tempgetal]]["O"]) {
 
            Opmerking[tempgetal] = text[Artikeln[tempgetal]]["O"];
 
        } else {
 
            Opmerking[tempgetal] = '<input type="text" id=Opmerking' + tempgetal + ' name=Opmerking' + tempgetal + ' size=70">';
 
        }
 
        if (text[Artikeln[tempgetal]]["T"]) {
 
            Thema[tempgetal] = '<center>' + text[Artikeln[tempgetal]]["T"] + '</center>';
 
        } else {
 
            Thema[tempgetal] = '<input type="text" id=Thema' + tempgetal + ' name=Thema' + tempgetal + ' size=10">';
 
        }
 
        console.log(Artikeln[tempgetal] + ": " + Artikelr[tempgetal]);
 
        Artikellink[tempgetal] = '<a href="https://wikikids.nl/' + Artikelr[tempgetal] + '?projectopschonen=x&checked=' + linkextra[tempgetal] + '" target="_blank">' + Artikelr[tempgetal] + '</a>' + vorigeuser[tempgetal];
 
        tabel += '<tr> <td>' + Artikellink[tempgetal] + '</td>' + Knop1x[tempgetal] + Knop2x[tempgetal] + Knop3x[tempgetal] + '<td>' + Opmerking[tempgetal] + '</td> <td>' + Thema[tempgetal] + '</td> </tr>';
 
        mw.notify("Artikel toegevoegd op deze pagina.", { 'tag': 'addpagetolistopschonen'});
 
        document.getElementById('bodyContent').innerHTML = tabel + eindetabel;
 
        tempgetal = 1;
 
        /*
 
        while (tempgetal !== gewenstelengte) {
 
            document.getElementById('Radio1.' + tempgetal).checked = Waardes['Radio1'][tempgetal];
 
            document.getElementById('Radio2.' + tempgetal).checked = Waardes['Radio2'][tempgetal];
 
            document.getElementById('Radio3.' + tempgetal).checked = Waardes['Radio3'][tempgetal];
 
            document.getElementById('Opmerking' + tempgetal).value = Waardes['Opmerking'][tempgetal];
 
            document.getElementById('Thema' + tempgetal).value = Waardes['Thema'][tempgetal];
 
            document.getElementById('Opmerking' + tempgetal).disabled = Waardes['Opmerkingdis'][tempgetal];
 
            document.getElementById('Thema' + tempgetal).disabled = Waardes['Themadis'][tempgetal];
 
            tempgetal += 1;
 
        }
 
        */
 
        Nummer = undefined;
 
    }
 
    Nummer = undefined;
 
}
 
  
function editpagenow(textx) {
+
            var dateString = addZero(date.getDate()) + "-" + addZero((date.getMonth() + 1)) + "-" + date.getFullYear();
    while (textx) {
+
 
        text = textx;
+
             row.innerHTML = `<td><a href="/${pageLink}">${pageTitle}</a></td>
        textx = false;
+
                <td>${dateString}</td>
    }
+
                <td>${parseNumber(totalVisitors)}</td><td><span style="color:green; font-weight: bold;">${parseNumber(mainPageVisited)}</span></td>`;
    if (Array.isArray(text)) {
+
            tableBody.appendChild(row);
        text = JSON.stringify(text);
 
    }
 
    api.get({
 
        action: 'query',
 
        prop: 'info',
 
        intoken: 'edit',
 
        titles: 'kaslv', //Pagina moet niet bestaan.  
 
    }).done(
 
        function (data) {
 
            edit_token = data.query.pages['-1'].edittoken;
 
        }).done(function (data) {
 
            api.post({
 
                'action': 'edit',
 
                'title': "Gebruiker:Rots61/Test.json",
 
                'text': text,
 
                'summary': "Pagina's als gecontroleerd gemarkeerd. [[WikiKids:Opschonen|(bewerking gedaan met 'Opschonen')]]",
 
                'tags': 'Opschonen',
 
                'bot': true,
 
                'token': edit_token,
 
             }).done(
 
                function (data) {
 
                    if (data.edit.result == "Success") {
 
                        mw.notify("Opgeslagen!", { autoHide: false });
 
                    } else {
 
                        mw.notify("Mislukt, meldt dit bij mij", { autoHide: false });
 
                    }
 
                    console.log(data.edit);
 
                    document.getElementById('bodyContent').innerHTML = "Opslaan gelukt. Herlaad de pagina om hem opnieuw te gebruiken. ";
 
                });
 
 
         });
 
         });
}
 
 
function startIT() {
 
    if (!Array.isArray(text)) {
 
        text = JSON.parse(text);
 
    }
 
    tempgetal = 1;
 
    highArtikelr = Artikelr.length;
 
    while (tempgetal !== highArtikelr) {
 
        if (text[Artikeln[tempgetal]]["D"]) {
 
        } else {
 
            getKnop3 = document.getElementById("Radio3." + tempgetal);
 
            if (getKnop3 && getKnop3.checked) {
 
            } else {
 
                var getonderwerp = document.getElementById("Thema" + tempgetal);
 
                if (getonderwerp && getonderwerp.value) {
 
                    getonderwerp = getonderwerp.value;
 
                } else {
 
                    getonderwerp = "";
 
                }
 
                var getopmerking = document.getElementById("Opmerking" + tempgetal);
 
                if (getopmerking && getopmerking.value) {
 
                    getopmerking = getopmerking.value;
 
                } else {
 
                    getopmerking = "";
 
                }
 
                getKnop1 = document.getElementById("Radio1." + tempgetal);
 
                getKnop2 = document.getElementById("Radio2." + tempgetal);
 
                if (getKnop1 && getKnop1.checked) {
 
                    if (getopmerking) {
 
                        text[Artikeln[tempgetal]]["U"] = mw.config.get('wgUserName');
 
                        text[Artikeln[tempgetal]]["O"] = getopmerking;
 
                        text[Artikeln[tempgetal]]["D"] = "D";
 
                    } else {
 
                        text[Artikeln[tempgetal]]["D"] = "D";
 
                        text[Artikeln[tempgetal]]["U"] = mw.config.get('wgUserName');
 
                    }
 
                } else if ((getKnop2 && getKnop2.checked) || getopmerking || getonderwerp) {
 
                    text[Artikeln[tempgetal]]["U"] = mw.config.get('wgUserName');
 
                    text[Artikeln[tempgetal]]["O"] = getopmerking;
 
                    text[Artikeln[tempgetal]]["T"] = getonderwerp;
 
                }
 
            }
 
        }
 
        tempgetal += 1;
 
 
     }
 
     }
    editpagenow(text);
 
}
 
  
function getJSONText() {
+
     showPage(1);
     return api.get({
 
        action: "query",
 
        prop: "revisions",
 
        titles: "Gebruiker:Rots61/Test.json",
 
        rvlimit: "1",
 
        rvprop: "content",
 
        rvslots: "main",
 
    }).then(function (data) {
 
        temp = data.query.pages;
 
        temp = temp[148926];
 
        temp = temp.revisions;
 
        temp = temp[0];
 
        text = temp.slots.main;
 
        text = text["*"];
 
        return JSON.parse(text);
 
    });
 
}
 
  
function getRandomNumber(lengtetext) {
+
     var pagination = document.createElement('div');
     if (showAll) {
+
     pagination.classList.add('pagination');
        allNummer += 1;
 
        return allNummer;
 
     }
 
    return Math.floor(Math.random() * lengtetext);
 
}
 
  
function startHints() {
+
     var prevButton = document.createElement('button');
     htmltext = document.getElementById('mw-content-text').innerHTML;
+
     prevButton.textContent = 'Vorige';
     paginalink = 'https://wikikids.nl/Wikikids:Wikiproject/Opschonen#';
+
     prevButton.style = 'margin-right: 10px;';
     document.getElementById('mw-content-text').innerHTML = '<div id="gadget-ophalen">Hints ophalen</div>'
+
    prevButton.addEventListener('click', function () {
        + '<div id="gadget-hint-http" style="color:red; display:none;">Er is een link die begint met http. (<a href="' + paginalink + 'HTTP_links">Wat moet ik doen?</a>)</div>'
+
         if (currentPage > 1) {
        + '<div id="gadget-hint-vreemdelink" style="color:red; display:none;">Er klopt iets niet met een link. (<a href="' + paginalink + 'Link_klopt_niet">Wat moet ik doen?</a>)</div>'
+
             showPage(currentPage - 1);
        + '<div id="gadget-hint-dp" style="color:red; display:none;">Er staat een link naar een doorverwijspagina op dit artikel. (<a href="' + paginalink + 'Doorverwijspagina">Wat moet ik doen?</a>)</div>'
+
             //Manier waarop je kunt zien op welke pagina je bent
        + '<span id="gadget-hint-geenlinks" style="color:red; display:none;">Er verwijzen geen andere artikels naar dit artikel. <span id="gadget-hint-welportaal" style="color:green; display:none;">(Wel een portaal) </span>(<a href="' + paginalink + 'Geen_links">Wat moet ik doen?</a>)</span>'
+
             document.getElementById('pageCounter').textContent = `Pagina ${currentPage} van ${totalPages}`;
        + '<div id="gadget-hint-grootbeg" style="color:red; display:none;">Dit artikel is wel groot voor een beginnetje. (<a href="' + paginalink + 'Groot_beginnetje">Wat moet ik doen?</a>)</div>'
 
        + '<div id="gadget-hint-geencat" style="color:red; font-weight:bold; display:none;">Er staat geen categorie op dit artikel. (<a href="' + paginalink + 'Geen_categorie">Wat moet ik doen?</a>)</div>'
 
        + '<div id="gadget-hint-weiniglinks" style="color:red; display:none;">Er staan te weinig links op dit artikel. (<a href="' + paginalink + 'Te_weinig_links_op_pagina">Wat moet ik doen?</a>)</div>'
 
        + '<div id="gadget-hint-woordenschat" style="display:none;">Ter informatie: Woordenschatartikel</div>'
 
        + '<div id="gadget-hint-extlink" style="display:none;">Er staan externe links op deze pagina. (<a href="' + paginalink + 'Externe_links">Wat moet ik doen?</a>)</div>'
 
        + '<div id="gadget-hint-gebruiker" style="color:green; font-weight:bold; display:none;">Artikel is geschreven door Hanssain. (<a href="' + paginalink + 'Artikel_gemaakt_door_gebruiker">Wat moet ik doen?</a>)</div>'
 
        + '<div id="gadget-hint-gecontroleerd" style="color:green; font-weight:bold; display:none;">Artikel is al gecontroleerd. (<a href="' + paginalink + 'Artikel_al_gecontroleerd">Wat moet ik doen?</a>)</div>'
 
        + '<hr id="gadget-ophalenlijn>'
 
        + document.getElementById('mw-content-text').innerHTML;
 
    getFirstAuteur();
 
    getCategories();
 
    getTextLength();
 
    getBeg();
 
    getLinksOut();
 
    checkIfChecked();
 
    getWoordenschat();
 
    getExterneLinks();
 
    setTimeout(removeloading, 1500);
 
}
 
 
 
function removeloading() {
 
    if (!woordenschat) {
 
    getLinksIn();
 
         if (articlesize > 2000) {
 
             if (beg) {
 
                document.getElementById('gadget-hint-grootbeg').style.display = "";
 
             }
 
             if (linksopartikel < 5) {
 
                document.getElementById('gadget-hint-weiniglinks').style.display = "";
 
            }
 
        } else if (linksopartikel < 2) {
 
            document.getElementById('gadget-hint-weiniglinks').style.display = "";
 
        }
 
    }
 
    api.get({
 
        action: "query",
 
        prop: "linkshere",
 
        titles: articletitle,
 
        lhnamespace: "100",
 
        lhlimit: "50",
 
        lhshow: "!redirect",
 
    }).then(function (data) {
 
        temp = data.query.pages[articleId];
 
        if (typeof temp.linkshere === 'undefined') {
 
        } else {
 
            document.getElementById('gadget-hint-welportaal').style.display = "";
 
            document.getElementById('gadget-hint-geenlinks').style.color = "";
 
 
         }
 
         }
 
     });
 
     });
     document.getElementById("gadget-ophalen").innerHTML = "";
+
     pagination.appendChild(prevButton);
}
 
  
function getTextLength() {
+
     var pageCounter = document.createElement('span');
     return api.get({
+
     pageCounter.id = "pageCounter";
        action: "query",
+
    pageCounter.textContent = `Pagina ${currentPage} van ${totalPages}`;
        prop: "revisions",
+
     pagination.appendChild(pageCounter);
        titles: articletitle,
 
        rvlimit: "1",
 
        rvprop: "content|size",
 
        rvslots: "main",
 
     }).then(function (data) {
 
        temp = data.query.pages;
 
        temp = temp[articleId].revisions["0"].size;
 
        articlesize = temp;
 
        return temp;
 
     });
 
}
 
  
function getCategories() {
+
    var nextButton = document.createElement('button');
     return api.get({
+
     nextButton.textContent = 'Volgende';
        action: "query",
+
    nextButton.style = 'margin-left: 10px;';
        prop: "categories",
+
     nextButton.addEventListener('click', function () {
        titles: articletitle,
+
         if (currentPage < totalPages) {
        clshow: "!hidden",
+
            showPage(currentPage + 1);
     }).then(function (data) {
+
            //Manier waarop je kunt zien op welke pagina je bent
        temp = data.query.pages[articleId].categories;
+
             document.getElementById('pageCounter').textContent = `Pagina ${currentPage} van ${totalPages}`;
         if (!temp) {
 
             document.getElementById("gadget-hint-geencat").style.display = "";
 
 
         }
 
         }
 
     });
 
     });
}
+
    pagination.appendChild(nextButton);
  
function getFirstAuteur() {
+
     tableHeadTitles.forEach(function (title) {
     return api.get({
+
         var tableHeadCell = document.createElement('th');
        action: "query",
+
         tableHeadCell.textContent = title;
        prop: "revisions",
+
        tableHeadRow.appendChild(tableHeadCell);
        titles: articletitle,
 
        rvlimit: "1",
 
        rvprop: "user",
 
        rvdir: "newer",
 
        rvslots: "main",
 
    }).then(function (data) {
 
         temp = data.query.pages[articleId].revisions[0].user;
 
         if (temp === "Hanssain") {
 
            document.getElementById("gadget-hint-gebruiker").style.display = "";
 
        }
 
 
     });
 
     });
}
+
    tableHead.appendChild(tableHeadRow);
 +
    table.appendChild(tableHead);
 +
    table.appendChild(tableBody);
  
function getWoordenschat() {
+
    var totalVisitors = pages.reduce(function (total, page) {
    return api.get({
+
    if (historyLogCounter) {
        action: "query",
+
    return total + page.nV + page.mPV;
        prop: "categories",
+
    } else {
        clcategories: "Category:Woordenschat",
+
    return total + page.normalVisitors + page.mainPageVisitors;
        titles: articletitle,
+
    }
    }).then(function (data) {
+
     }, 0);
        temp = data.query.pages;
 
        temp = temp[articleId];
 
        if (typeof temp.categories !== 'undefined') {
 
            woordenschat = true;
 
            document.getElementById('gadget-hint-woordenschat').style.display = "";
 
        }
 
     });
 
}
 
  
function getBeg() {
+
    var totalElement = document.createElement('div');
     return api.get({
+
     totalElement.style = 'margin-top: 20px; display: flex; flex-direction: column;';
        action: "query",
 
        prop: "categories",
 
        clcategories: "Category:WikiKids:Beginnetje",
 
        titles: articletitle,
 
    }).then(function (data) {
 
        temp = data.query.pages;
 
        temp = temp[articleId];
 
        if (typeof temp.categories !== 'undefined') {
 
            beg = true;
 
        }
 
    });
 
}
 
  
function getLinksOut() {
+
     var totalVisitorsElement = document.createElement('span');
     return api.get({
+
    totalVisitorsElement.textContent = `Totaal aantal bezoeken: ${parseNumber(totalVisitors)}`;
        action: "query",
+
     totalElement.appendChild(totalVisitorsElement);
        prop: "links",
 
        titles: articletitle,
 
        pllimit: "5000",
 
    }).then(function (data) {
 
        temp = data.query.pages;
 
        temp = temp[articleId];
 
        if (typeof temp.links !== 'undefined') {
 
            linksopartikel = temp.links.length;
 
            getDP();
 
        } else {
 
            linksopartikel = 0;
 
        }
 
     });
 
}
 
  
function getLinksIn() {
+
     var totalPagesElement = document.createElement('span');
     api.get({
+
    totalPagesElement.textContent = `Totaal aantal pagina's: ${parseNumber(pages.length)}`;
        action: "query",
+
     totalElement.appendChild(totalPagesElement);
        prop: "linkshere",
 
        titles: articletitle,
 
        lhnamespace: "0",
 
        lhlimit: "50",
 
        lhshow: "!redirect",
 
    }).then(function (data) {
 
        temp = data.query.pages[articleId];
 
        if (typeof temp.linkshere === 'undefined') {
 
            document.getElementById("gadget-hint-geenlinks").style.display = "";
 
        }
 
     });
 
}
 
  
function checkIfChecked() {
+
     //document.getElementById('bodyContent').innerHTML = '';
     valuechecked = mw.util.getParamValue('checked');
+
     document.getElementById('bodyContent').innerHTML = searchBar + logCounterInfo;
     if (valuechecked === "Done") {
+
     document.getElementById('bodyContent').appendChild(table);
        document.getElementById("gadget-hint-gecontroleerd").style.display = "";
+
    document.getElementById('bodyContent').appendChild(pagination);
     } else {
+
    document.getElementById('bodyContent').appendChild(totalElement);
        getJSONText().done(function (text) {
 
            for (var i = 0, iLen = text.length; i < iLen; i++) {
 
                if (text[i].N == articletitle) checkChecked = text[i]["D"];
 
            }
 
            if (checkChecked === "D") {
 
                document.getElementById("gadget-hint-gecontroleerd").style.display = "";
 
            }
 
        });
 
    }
 
 
}
 
}
  
function getDP() {
+
function getCategoriesLogCounter() { //toon alleen pagina's in een specifieke categorie
    api.get({
+
        action: "query",
 
        generator: "links",
 
        prop: "categories",
 
        titles: articletitle,
 
        gpllimit: "5000",
 
        cllimit: "5000",
 
        clcategories: "Categorie:Wikikids:Doorverwijspagina",
 
    }).then(function (data) {
 
        temp = data.query.pages;
 
        for (const property in temp) {
 
            if (temp[property].categories) {
 
                document.getElementById("gadget-hint-dp").style.display = "";
 
            }
 
        }
 
    });
 
 
}
 
}
  
function getExterneLinks() {
+
function getPagesLogCounter() {
     api.get({
+
     var pages = [];
        action: "query",
+
    var request = new XMLHttpRequest();
        prop: "extlinks|categories",
+
    request.open('GET', urlLogCounter, false);
        titles: articletitle,
+
    request.send(null);
        ellimit: "5000",
+
    if (request.status === 200) {
    }).then(function (data) {
+
        pages = JSON.parse(request.responseText);
        temp = data.query.pages;
+
    }
        temp = temp[articleId].extlinks;
+
    // Sorteer de pagina's op het aantal bezoekers (hoog naar laag) (page.normalVisitors + page.mainPageVisitors)
        if (typeof temp === 'undefined') {
+
    pages.sort(function (a, b) {
        } else {
+
    if (historyLogCounter) {
            var tempgetal = 0;
+
    return b.nV + b.mPV - a.nV - a.mPV;
            while (typeof temp[tempgetal] !== 'undefined') {
+
    } else {
                if (temp[tempgetal]["*"].startsWith("http:")) {
+
    return b.normalVisitors + b.mainPageVisitors - a.normalVisitors - a.mainPageVisitors;
                    document.getElementById("gadget-hint-http").style.display = "";
+
    }
                } else if (temp[tempgetal]["*"].startsWith("https:")) {
 
                    if (beg === true) {
 
                        if (temp[tempgetal]["*"] == "https://schooltv.nl/zoekresultaten/?q=" + articletitle) {
 
                        } else if (temp[tempgetal]["*"] == "https://www.youtube.com/results?search_query=" + articletitle) {
 
                        } else if (temp[tempgetal]["*"] == "https://commons.wikimedia.org/w/index.php?title=Special:Search&search=" + articletitle + "&ns0=1&ns6=1&ns12=1&ns14=1&ns100=1&ns106=1") {
 
                        } else if (temp[tempgetal]["*"] == "https://commons.wikimedia.org/w/index.php?search=" + articletitle + "&title=Special:MediaSearch&go=Go&type=image") {
 
                        } else if (temp[tempgetal]["*"] == "https://www.google.nl/search?q=" + articletitle) {
 
                        } else if (temp[tempgetal]["*"] == "https://nl.wikipedia.org/wiki/" + articletitle) {
 
                        } else if (temp[tempgetal]["*"] == "https://wikikids.nl/Wikikids:Beeldbank") {
 
                        } else {
 
                            document.getElementById("gadget-hint-extlink").style.display = "";
 
                        }
 
                    } else {
 
                        document.getElementById("gadget-hint-extlink").style.display = "";
 
                    }
 
                } else {
 
                    document.getElementById("gadget-hint-vreemdelink").style.display = "";
 
                }
 
                tempgetal += 1;
 
            }
 
        }
 
 
     });
 
     });
 +
    return pages;
 
}
 
}
  
function changeInstellingen() {
+
function reloadPagesLogCounter() {
     var instelling = document.getElementById("instellingen").style.display;
+
     var allPages = getPagesLogCounter();
     if (instelling === 'none') {
+
     showProjectLogCounter(allPages);
        document.getElementById("instellingen").style.display = "";
 
        document.getElementById("maxoption").disabled = false;
 
    } else {
 
        document.getElementById("instellingen").style.display = 'none';
 
        document.getElementById("maxoption").disabled = true;
 
        document.getElementById("user").value = "";
 
        document.getElementById("startwith").value = "";
 
    }
 
}
 
 
 
function hulpInfo() {
 
    document.getElementsByTagName("h1")[0].textContent = "Speciaal:Opschonen";
 
    document.title = "Help - Opschonen - WikiKids";
 
    infotext = '<input type="checkbox" id="allepaginas" onclick="changeInstellingen();">Krijg willekeurige pagina\'s. <br>'
 
        + '<div id="instellingen">'
 
        + 'Gebruiker: <input type="text" id="user"><br>'
 
        + 'Geschreven door: <input type="text" id="firstauthor"><br>'
 
        + 'Alleen artikels die starten met: <input type="text" id="startwith"><br></div>'
 
        + 'Gecontroleerd: <select name="done" id="done">'
 
        + '<option value="notdone">Niet</option>'
 
        + '<option value="xdone" selected>Maakt niet uit</option>'
 
        + '<option value="done">Wel</option>'
 
        + '</select><br>'
 
        + 'Thema: <select name="thema" id="thema">'
 
        + '<option value="notthema">Geen</option>'
 
        + '<option value="xthema" selected>Maakt niet uit</option>'
 
        + '<option value="thema">Wel</option>'
 
        + '</select><br>'
 
        + 'Aantal: <select name="aantal" id="aantal">'
 
        + '<option value="100">100</option>'
 
        + '<option value="50" selected>50</option>'
 
        + '<option value="10">10</option>'
 
        + '<option value="0">0</option>'
 
        + '<option value="max" id="maxoption">Max</option>'
 
        + '</select><br>'
 
        + '<br><button onclick="getsettings()">Bekijk pagina\'s</button>'
 
        + 'Vragen hierover? Laat het me weten';
 
    document.getElementById('bodyContent').innerHTML = infotext;
 
}
 
 
 
function getsettings() {
 
    var allepaginasl = document.getElementById('allepaginas').checked;
 
    var startwithl = document.getElementById('startwith').value;
 
    var themal = document.getElementById('thema').value;
 
    var userl = document.getElementById('user').value;
 
    var aantall = document.getElementById('aantal').value;
 
    var donel = document.getElementById('done').value;
 
    var firstauthorl = document.getElementById('firstauthor').value;
 
    var url = 'https://wikikids.nl/Speciaal:Opschonen?';
 
    if (allepaginasl) {
 
    } else {
 
        url += 'allepaginas=x&';
 
    }
 
    if (themal === "thema") {
 
        url += 'thema=x&';
 
    } else if (themal === "notthema") {
 
        url += 'notthema=x&';
 
    }
 
    if (donel === "done") {
 
        url += 'done=x&';
 
    } else if (donel === "notdone") {
 
        url += 'notdone=x&';
 
    }
 
    if (userl) {
 
        url += 'user=' + userl + '&';
 
    }
 
    if (firstauthorl)  {
 
        url += 'firstauthor=' + firstauthorl + '&';
 
    }
 
    url += 'aantal=' + aantall;
 
    window.location.href = url;
 
}
 
 
 
if (mw.config.get('wgNamespaceNumber') === -1 && mw.config.get('wgTitle') === "Opschonen") {
 
    document.getElementById("footer-places").innerHTML += '<li id="footer-places-gadget-opschonen">Script gemaakt door <a href="/User:Rots61" title="Gebruiker:Rots61">Rots61</a>, versie: ' + opschoonversion + '</li>';
 
    if (document.URL === "https://wikikids.nl/Speciaal:Opschonen?action=help") {
 
        var infotext;
 
        hulpInfo();
 
    } else {
 
        showAantal = parseInt(mw.util.getParamValue('aantal'));
 
        showUser = mw.util.getParamValue('user');
 
        showStartwith = mw.util.getParamValue('Startwith');
 
        var tussenvoegsel;
 
        document.getElementById('bodyContent').innerHTML = "Laden... krijg je niets te zien? Maak hier dan een melding van bij mij met deze url:" + document.URL;
 
        var edit_token;
 
        var tempgetal;
 
        var temp;
 
        var Artikelr = [];
 
        var Artikeln = [];
 
        var Artikellink = [];
 
        var getUser;
 
        var Thematemp = [];
 
        var Opmerkingtemp = [];
 
        var Thematempx;
 
        var Opmerkingtempx;
 
        var Knop1x = [];
 
        var Knop2x = [];
 
        var Knop3x = [];
 
        var Opmerking = [];
 
        var Thema = [];
 
        var tabel;
 
        var eindetabel;
 
        var highArtikelr;
 
        var showAantal;
 
        var gedaan = [];
 
        var vorigeuser = [];
 
        var linkextra = [];
 
        var getKnop3;
 
        var getKnop2;
 
        var getKnop1;
 
        var randomNumber;
 
        var showAll;
 
        var showSkipDone;
 
        var showSkipSkipped;
 
        var showDone;
 
        var showThema;
 
        var addarticle;
 
        var paginalink;
 
        var checkChecked;
 
        var allNummer = 1;
 
        var showFrom;
 
        var showTo;
 
        var showSkipThema;
 
        var lengtetext;
 
        var showMax;
 
      var temparrayfirstauthor = [];
 
        var Waardes = { "Radio1": [], "Radio2": [], "Radio3": [], "Opmerking": [], "Thema": [], "Opmerkingdis": [], "Themadis": [] };
 
        //varvar
 
        getJSONText().done(function (text) {
 
            showProject(text);
 
        });
 
    }
 
 
}
 
}
  
var showHints = mw.util.getParamValue('projectopschonen');
+
var allPages;
if (showHints) {
+
if (mw.config.get('wgNamespaceNumber') === -1 && mw.config.get('wgTitle') === "LogTheCounter") {
    document.getElementById("footer-places").innerHTML += '<li id="footer-places-gadget-opschonen">Hints zijn gemaakt door <a href="/User:Rots61" title="Gebruiker:Rots61">Rots61</a>, versie: ' + opschoonversion + '</li>';
+
     var allPages = getPagesLogCounter();
    //varvar
+
     showProjectLogCounter(allPages);
    var articletitle = mw.config.get('wgPageName');
+
for (const x of allpages) {
    var articleId = mw.config.get('wgArticleId');
+
deleteit('mPV', 'mainPageVisitors', x);
    var beg = false;
+
deleteit('nV','normalVisitors', x);
    var dp = false;
+
deleteit('t','title', x);
    var link = 0;
+
deleteit('uA','updatedAt', x);
    var link2 = "";
+
}
    var temp;
+
console.log(allpages);  
     var temp2;
 
    var linkhttp = 0;
 
     var redirects = "";
 
    var Hints = "";
 
    var htmltext;
 
    var Nummer;
 
    var CheckChecked;
 
    var articlesize;
 
    var linksopartikel;
 
    var valuechecked;
 
    var woordenschat = false;
 
    startHints();
 
 
}
 
}
  
if ((mw.config.get('wgNamespaceNumber') === 0) && (mw.config.get('wgArticleId') > 1)) {
+
function deleteit(new_key, old_key, x){
    document.getElementById("mw-panel").innerHTML += `<nav id="p-op" style="background-color: #1D9CB9" class="vector-menu vector-menu-portal portal"
+
Object.defineProperty(allpages[x], new_key,
    aria-labelledby="p-op-label" role="navigation">
+
         Object.getOwnPropertyDescriptor(allpages[x], old_key));
    <h3 id="p-op-label">
+
     delete allpages[x][old_key];
         <span>Opschonen</span>
 
    </h3>
 
    <div class="body vector-menu-content" style="border-bottom: 1px solid #1D9CB9">
 
        <ul class="vector-menu-content-list">
 
            <li>
 
                <a href="https://wikikids.nl/Speciaal:Opschonen">Speciaal:Opschonen</a>
 
            </li>
 
            <li>
 
            <a href="https://wikikids.nl/${mw.config.get('wgPageName')}?projectopschonen=x">Opschoon hints</a>
 
            </li>
 
            <li>
 
                <button onclick="fromPageaddPage()">Gecontroleerd</button>
 
            </li>
 
        </ul>
 
     </div>
 
</nav>`;
 
 
}
 
}

Versie van 31 jan 2023 21:16

/* jshint sub:true maxerr:100000 */
// [[User:MakiBoy/Gadget-LogCounter.js]] gemaakt door [[User:MakiBoy]]

var version = '2.9';

function parseNumber(number) {
    return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}

function showProjectLogCounter(pages) {
    document.getElementsByTagName("h1")[0].textContent = "Speciaal:LogCounter";
    document.title = "LogCounter - WikiKids";

    var searchBar = '<div><input type="text" id="lc-searchbar"> <button onclick="searchTitle();">Zoek</button></div>'
        + '<button onclick="reloadPagesLogCounter();">Laad alles opnieuw in</button>';
    var logCounterInfo = '<div id="logCounterInfo">Deze pagina laat zien hoeveel paginabezoeken er zijn geweest op een specifieke pagina. De rij "Views" bevat alle views. De rij "Categorie" laat alleen maar zien hoeveel views er vanuit een categorie komen.</div>';

    var table = document.createElement('table');
    table.classList.add('wikitable');
	
	var arrayHoofdpagina = ["1", "20012023"]; //voeg versies toe die de hoofdpagina gebruiken
	var arrayCategorie = ["1"]; //voeg versies toe die de categorieën gebruiken
    var tableHead = document.createElement('thead');
    var tableHeadRow = document.createElement('tr');
    var tableHeadTitles;
    if (arrayHoofdpagina.includes(requestDate)) {
    	tableHeadTitles = ['Paginatitel', 'Laatste bezoek', 'Views', 'Hoofdpagina'];
    } else {
    	tableHeadTitles = ['Paginatitel', 'Laatste bezoek', 'Views', 'Categorie'];
    }
    var tableBody = document.createElement('tbody');

    var currentPage = 1;
    var rowsPerPage = mw.util.getParamValue('rows') ? parseInt(mw.util.getParamValue('rows')) : 25;
    var totalPages = Math.ceil(pages.length / rowsPerPage);

    function showPage(pageNumber) {
        currentPage = pageNumber;
        tableBody.innerHTML = '';
        var start = (currentPage - 1) * rowsPerPage;
        var end = start + rowsPerPage;
        var paginatedItems = pages.slice(start, end);
        paginatedItems.forEach(function (page) {
            var row = document.createElement('tr');
            var totalVisitors, mainPageVisited, pageTitle, pageLink, date;
            if (historyLogCounter) {
	            totalVisitors = page.nV + page.mPV;
	            mainPageVisited = page.mPV ? parseNumber(page.mPV) : "";
	            pageTitle = page.t.replace(/_/g, ' ');
	            pageLink = page.t;
	            if (pageLink.includes("S:Z\\")) {
	            	pageLink = pageLink.replace(/S:Z\\/g, 'Speciaal:Zoeken/');
	            	pageTitle = pageTitle.replace(/S:Z\\/g, 'Zoekopdracht: ');
	            }
	            date = new Date(page.uA);
            } else {
	            totalVisitors = page.normalVisitors + page.mainPageVisitors;
	            mainPageVisited = page.mainPageVisitors ? parseNumber(page.mainPageVisitors) : "";
	            pageTitle = page.title.replace(/_/g, ' ');
	            pageLink = page.title;
	            if (pageLink.includes("S:Z")) {
	            	pageLink = pageLink.replace(/S:Z\\/g, 'Speciaal:Zoeken/');
	            	pageTitle = page.title;
	            }
	            date = new Date(page.updatedAt);
            }
            function addZero(number) {
                return number < 10 ? "0" + number : number;
            }

            var dateString = addZero(date.getDate()) + "-" + addZero((date.getMonth() + 1)) + "-" + date.getFullYear();

            row.innerHTML = `<td><a href="/${pageLink}">${pageTitle}</a></td>
                <td>${dateString}</td>
                <td>${parseNumber(totalVisitors)}</td><td><span style="color:green; font-weight: bold;">${parseNumber(mainPageVisited)}</span></td>`;
            tableBody.appendChild(row);
        });
    }

    showPage(1);

    var pagination = document.createElement('div');
    pagination.classList.add('pagination');

    var prevButton = document.createElement('button');
    prevButton.textContent = 'Vorige';
    prevButton.style = 'margin-right: 10px;';
    prevButton.addEventListener('click', function () {
        if (currentPage > 1) {
            showPage(currentPage - 1);
            //Manier waarop je kunt zien op welke pagina je bent
            document.getElementById('pageCounter').textContent = `Pagina ${currentPage} van ${totalPages}`;
        }
    });
    pagination.appendChild(prevButton);

    var pageCounter = document.createElement('span');
    pageCounter.id = "pageCounter";
    pageCounter.textContent = `Pagina ${currentPage} van ${totalPages}`;
    pagination.appendChild(pageCounter);

    var nextButton = document.createElement('button');
    nextButton.textContent = 'Volgende';
    nextButton.style = 'margin-left: 10px;';
    nextButton.addEventListener('click', function () {
        if (currentPage < totalPages) {
            showPage(currentPage + 1);
            //Manier waarop je kunt zien op welke pagina je bent
            document.getElementById('pageCounter').textContent = `Pagina ${currentPage} van ${totalPages}`;
        }
    });
    pagination.appendChild(nextButton);

    tableHeadTitles.forEach(function (title) {
        var tableHeadCell = document.createElement('th');
        tableHeadCell.textContent = title;
        tableHeadRow.appendChild(tableHeadCell);
    });
    tableHead.appendChild(tableHeadRow);
    table.appendChild(tableHead);
    table.appendChild(tableBody);

    var totalVisitors = pages.reduce(function (total, page) {
    	if (historyLogCounter) {
    		return total + page.nV + page.mPV;
    	} else {
    		return total + page.normalVisitors + page.mainPageVisitors;
    	}
    }, 0);

    var totalElement = document.createElement('div');
    totalElement.style = 'margin-top: 20px; display: flex; flex-direction: column;';

    var totalVisitorsElement = document.createElement('span');
    totalVisitorsElement.textContent = `Totaal aantal bezoeken: ${parseNumber(totalVisitors)}`;
    totalElement.appendChild(totalVisitorsElement);

    var totalPagesElement = document.createElement('span');
    totalPagesElement.textContent = `Totaal aantal pagina's: ${parseNumber(pages.length)}`;
    totalElement.appendChild(totalPagesElement);

    //document.getElementById('bodyContent').innerHTML = '';
    document.getElementById('bodyContent').innerHTML = searchBar + logCounterInfo;
    document.getElementById('bodyContent').appendChild(table);
    document.getElementById('bodyContent').appendChild(pagination);
    document.getElementById('bodyContent').appendChild(totalElement);
}

function getCategoriesLogCounter() { //toon alleen pagina's in een specifieke categorie
	
}

function getPagesLogCounter() {
    var pages = [];
    var request = new XMLHttpRequest();
    request.open('GET', urlLogCounter, false);
    request.send(null);
    if (request.status === 200) {
        pages = JSON.parse(request.responseText);
    }
    // Sorteer de pagina's op het aantal bezoekers (hoog naar laag) (page.normalVisitors + page.mainPageVisitors)
    pages.sort(function (a, b) {
    	if (historyLogCounter) {
    		return b.nV + b.mPV - a.nV - a.mPV;
    	} else {
    		return b.normalVisitors + b.mainPageVisitors - a.normalVisitors - a.mainPageVisitors;
    	}
    });
    return pages;
}

function reloadPagesLogCounter() {
    var allPages = getPagesLogCounter();
    showProjectLogCounter(allPages);
}

var allPages;
if (mw.config.get('wgNamespaceNumber') === -1 && mw.config.get('wgTitle') === "LogTheCounter") {
    var allPages = getPagesLogCounter();
    showProjectLogCounter(allPages);
	for (const x of allpages) {
		deleteit('mPV', 'mainPageVisitors', x);
		deleteit('nV','normalVisitors', x);
		deleteit('t','title', x);
		deleteit('uA','updatedAt', x);
	}
	console.log(allpages); 
}

function deleteit(new_key, old_key, x){
	Object.defineProperty(allpages[x], new_key,
        Object.getOwnPropertyDescriptor(allpages[x], old_key));
    delete allpages[x][old_key];
}
Afkomstig van Wikikids , de interactieve Nederlandstalige Internet-encyclopedie voor en door kinderen. "https://wikikids.nl/index.php?title=Gebruiker:Rots61/Gadget-LogTheCounter.js&oldid=764228"