Gebruiker:Rots61/JS-WikiStats.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(4 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 15: | Regel 15: | ||
function containsAnyWS(str, substrings) { | function containsAnyWS(str, substrings) { | ||
− | for ( | + | for (let i = 0; i != substrings.length; i++) { |
var substring = substrings[i]; | var substring = substrings[i]; | ||
if (str.indexOf(substring) != - 1) { | if (str.indexOf(substring) != - 1) { | ||
Regel 51: | Regel 51: | ||
// Variabele die informatie geeft over de LogCounter. | // Variabele die informatie geeft over de LogCounter. | ||
− | var logCounterInfo = '<div id="logCounterInfo">Deze pagina laat zien hoeveel paginabezoeken er zijn geweest op een specifieke pagina. De rij "Views" bevat <b>alle</b> views. De rij daarachter laat alleen maar zien hoeveel views komen vanuit iets specifieks, bijvoorbeeld vanuit een categorie of van een mobiele telefoon. <a href="/Speciaal:Statistieken_WikiKids?action=tabel">Klik hier voor statistieken van vorige weken.</a> De statistieken zijn voor het laatst gereset op: <span id="WikiStats-starttijd"> ' + infoHistoryWS['Endtime'] + '</span> (in UTC)</div>'; | + | var logCounterInfo = '<div id="logCounterInfo">Deze pagina laat zien hoeveel paginabezoeken er zijn geweest op een specifieke pagina. De rij "Views" bevat <b>alle</b> views. De rij daarachter laat alleen maar zien hoeveel views komen vanuit iets specifieks, bijvoorbeeld vanuit een categorie of van een mobiele telefoon. <a href="/Speciaal:Statistieken_WikiKids?action=tabel">Klik hier voor statistieken van vorige weken.</a> De statistieken zijn voor het laatst gereset op: <span id="WikiStats-starttijd"> ' + infoHistoryWS['Endtime'] + '</span> (in UTC).</div>'; |
// Controleert of het een speciale week is, als dat het geval is, dan wordt de informatie uitgebreid. | // Controleert of het een speciale week is, als dat het geval is, dan wordt de informatie uitgebreid. | ||
if (parameterWS['specialeweek']) { | if (parameterWS['specialeweek']) { | ||
Regel 107: | Regel 107: | ||
var totalVisitors, mainPageVisited, pageTitle, pageLink, date, tempDate, filterShow, percentMainPage, percentStyle, pageStyle; | var totalVisitors, mainPageVisited, pageTitle, pageLink, date, tempDate, filterShow, percentMainPage, percentStyle, pageStyle; | ||
if (infoHistoryWS.Doublerequest) { | if (infoHistoryWS.Doublerequest) { | ||
− | totalVisitors = page.nV ? page.nV : | + | totalVisitors = page.nV ? page.nV : page.mPV; |
} else { | } else { | ||
// Controleert of een gedeelte van de informatie leeg is gelaten. Dit is enkel voor normale versies | // Controleert of een gedeelte van de informatie leeg is gelaten. Dit is enkel voor normale versies | ||
Regel 152: | Regel 152: | ||
totalVisitors = '-'; | totalVisitors = '-'; | ||
percentMainPage = '-'; | percentMainPage = '-'; | ||
+ | percentFromTotal100 = '-'; | ||
} else if (pageLink.startsWith('X:')) { | } else if (pageLink.startsWith('X:')) { | ||
pageLink = ''; | pageLink = ''; | ||
pageStyle = 'style="color:black;"'; | pageStyle = 'style="color:black;"'; | ||
+ | percentMainPage = '-'; | ||
+ | percentFromTotal100 = '-'; | ||
} | } | ||
row.innerHTML = `<td ${pageStyle}><a href="/${pageLink}">${pageTitle}</a></td> | row.innerHTML = `<td ${pageStyle}><a href="/${pageLink}">${pageTitle}</a></td> | ||
Regel 243: | Regel 246: | ||
var moreInfoElement = document.createElement('span'); | var moreInfoElement = document.createElement('span'); | ||
if (!infoHistoryWS.Live) { | if (!infoHistoryWS.Live) { | ||
− | + | let firstDateString = ''; | |
− | + | if (infoHistoryWS.Starttime) { | |
− | + | let xStarttime = new Date(infoHistoryWS.Starttime); | |
− | + | firstDateString = addZeroWS(xStarttime.getDate()) + "-" + addZeroWS((xStarttime.getMonth() + 1)) + "-" + xStarttime.getFullYear() + " " + addZeroWS(xStarttime.getHours()) + ":" + addZeroWS(xStarttime.getMinutes()); | |
+ | } | ||
+ | const xEndtime = new Date(infoHistoryWS.Endtime); | ||
+ | let lastDateString = addZeroWS(xEndtime.getDate()) + "-" + addZeroWS((xEndtime.getMonth() + 1)) + "-" + xEndtime.getFullYear() + " " + addZeroWS(xEndtime.getHours()) + ":" + addZeroWS(xEndtime.getMinutes()); | ||
moreInfoElement.textContent = `${firstDateString} tot ${lastDateString}`; | moreInfoElement.textContent = `${firstDateString} tot ${lastDateString}`; | ||
} else { | } else { | ||
Regel 270: | Regel 276: | ||
if (!historyWS) { | if (!historyWS) { | ||
if (parameterWS['specialdata']) { | if (parameterWS['specialdata']) { | ||
− | for ( | + | for (let x = 0; x < pages.length; x++) { |
if (!(pages[x].title.includes('Zoeken:') || pages[x].title.startsWith('X:'))) { | if (!(pages[x].title.includes('Zoeken:') || pages[x].title.startsWith('X:'))) { | ||
pages.splice(x, 1); | pages.splice(x, 1); | ||
Regel 279: | Regel 285: | ||
} | } | ||
} else { | } else { | ||
− | for ( | + | for (let x = 0; x < pages.length; x++) { |
if (pages[x].title.includes('Zoeken:') || pages[x].title.startsWith('X:')) { | if (pages[x].title.includes('Zoeken:') || pages[x].title.startsWith('X:')) { | ||
pages.splice(x, 1); | pages.splice(x, 1); | ||
Regel 290: | Regel 296: | ||
} else { | } else { | ||
if (parameterWS['specialdata']) { | if (parameterWS['specialdata']) { | ||
− | for ( | + | for (let x = 0; x < pages.length; x++) { |
if (!(pages[x].t.includes('Zoeken:') || pages[x].t.startsWith('X:'))) { | if (!(pages[x].t.includes('Zoeken:') || pages[x].t.startsWith('X:'))) { | ||
pages.splice(x, 1); | pages.splice(x, 1); | ||
Regel 297: | Regel 303: | ||
} | } | ||
} else { | } else { | ||
− | for ( | + | for (let x = 0; x < pages.length; x++) { |
if (pages[x].t.includes('Zoeken:') || pages[x].t.startsWith('X:')) { | if (pages[x].t.includes('Zoeken:') || pages[x].t.startsWith('X:')) { | ||
pages.splice(x, 1); | pages.splice(x, 1); | ||
Regel 317: | Regel 323: | ||
} | } | ||
//Filter percentmax, percentmin, aantalmax, aantalmin, only | //Filter percentmax, percentmin, aantalmax, aantalmin, only | ||
− | for ( | + | for (let y=0; y < pages.length; y++) { |
pages[y].mPV = pages[y].mPV ? pages[y].mPV : 0; | pages[y].mPV = pages[y].mPV ? pages[y].mPV : 0; | ||
pages[y].nV = pages[y].nV ? pages[y].nV : 0; | pages[y].nV = pages[y].nV ? pages[y].nV : 0; | ||
Regel 397: | Regel 403: | ||
} | } | ||
var searchResult = []; | var searchResult = []; | ||
− | for ( | + | for (let i = 0; i < allPagesWS.length; i++) { |
if (parameterWS['regex']) { | if (parameterWS['regex']) { | ||
regex = new RegExp(searchQuery, "i"); | regex = new RegExp(searchQuery, "i"); | ||
Regel 411: | Regel 417: | ||
setTimeout(function () { | setTimeout(function () { | ||
if (!searchResult.length) { | if (!searchResult.length) { | ||
− | + | const printToScreen = '<br>Er is geen pagina die <a href="https://wikikids.nl/Speciaal:Zoeken/' + searchQuery + '">' + searchQuery + '</a> bevat, en die in deze periode views heeft ontvangen.' | |
+ 'Kijk voor meer <a href="https://wikikids.nl/WikiKids:Statistieken">informatie op deze pagina</a>.'; | + 'Kijk voor meer <a href="https://wikikids.nl/WikiKids:Statistieken">informatie op deze pagina</a>.'; | ||
document.getElementById('bodyContent').innerHTML = terugnaarWS + searchBarWS + printToScreen; | document.getElementById('bodyContent').innerHTML = terugnaarWS + searchBarWS + printToScreen; | ||
} else { | } else { | ||
− | |||
showProjectWS(searchResult, searchQuery); | showProjectWS(searchResult, searchQuery); | ||
} | } | ||
Regel 436: | Regel 441: | ||
searchQuery = parameterWS['exactzoeken']; | searchQuery = parameterWS['exactzoeken']; | ||
} | } | ||
− | + | let searchResult = []; | |
− | for ( | + | for (let i = 0; i < allPagesWS.length; i++) { |
if (allPagesWS[i]['t'].toLowerCase() === searchQuery.toLowerCase()) { | if (allPagesWS[i]['t'].toLowerCase() === searchQuery.toLowerCase()) { | ||
searchResult.push(allPagesWS[i]); | searchResult.push(allPagesWS[i]); | ||
Regel 444: | Regel 449: | ||
setTimeout(function () { | setTimeout(function () { | ||
if (!searchResult.length) { | if (!searchResult.length) { | ||
− | + | let printToScreen = '<br>De pagina <a href="https://wikikids.nl/' + searchQuery + '">' + searchQuery + '</a> heeft geen views ontvangen, voldoet niet aan het ingestelde filter of bestaat niet. '; | |
document.getElementById('bodyContent').innerHTML = terugnaarWS + searchBarWS + printToScreen; | document.getElementById('bodyContent').innerHTML = terugnaarWS + searchBarWS + printToScreen; | ||
} else { | } else { | ||
Regel 509: | Regel 514: | ||
urlPath += 'exactzoeken=' + parameterWS['exactzoeken'] + '&'; | urlPath += 'exactzoeken=' + parameterWS['exactzoeken'] + '&'; | ||
} | } | ||
− | if (parameterWS[' | + | if (parameterWS['seconddata']) { |
− | urlPath += ' | + | urlPath += 'seconddata=' + parameterWS['seconddata'] + '&'; |
} | } | ||
if (parameterWS['specialeweek']) { | if (parameterWS['specialeweek']) { | ||
Regel 581: | Regel 586: | ||
// Download functies | // Download functies | ||
function downloadWS(tss) { | function downloadWS(tss) { | ||
− | + | let downloadResult = 'Paginatitel' + tss + 'Views' + tss + 'Speciale statistiek \n'; | |
− | for ( | + | for (let x = 0; x < allPagesWS.length; x++){ |
if (!allPagesWS[x].mPV) { | if (!allPagesWS[x].mPV) { | ||
downloadResult += allPagesWS[x].t.replace(/,/g, '.') + tss + (allPagesWS[x].nV) + tss + '0' + tss + '\n'; | downloadResult += allPagesWS[x].t.replace(/,/g, '.') + tss + (allPagesWS[x].nV) + tss + '0' + tss + '\n'; | ||
Regel 701: | Regel 706: | ||
} | } | ||
} | } | ||
+ | |||
+ | function clearSecondStatsWS() { | ||
+ | var settings = { | ||
+ | "url": "https://wikikids.wikirots61.workers.dev/pages/delete", | ||
+ | "method": "POST", | ||
+ | "timeout": 0, | ||
+ | "headers": { | ||
+ | "Host": "wikikids.wikirots61.workers.dev/", | ||
+ | "Content-Type": "application/json" | ||
+ | }, | ||
+ | "data": JSON.stringify({ | ||
+ | "message": 'gek' | ||
+ | }), | ||
+ | }; | ||
+ | $.ajax(settings).done(function (response) { | ||
+ | mw.notify("Reseten statistieken gelukt", { autoHide: false }); | ||
+ | window.onbeforeunload = null; | ||
+ | }).catch(function (error) { | ||
+ | if (error.responseText || JSON.parse(error.responseText).succes) { | ||
+ | mw.notify("Reseten statistieken2 gelukt", { autoHide: false }); | ||
+ | window.onbeforeunload = null; | ||
+ | } else { | ||
+ | mw.notify('Resetten mislukt, stuur Rots61 aub direct een berichtje.', {autoHide: false}); | ||
+ | } | ||
+ | }); | ||
+ | } | ||
+ | |||
function renamekeyWS(new_key, old_key, x){ | function renamekeyWS(new_key, old_key, x){ | ||
Regel 723: | Regel 755: | ||
parameterWS['exactzoeken'] = mw.util.getParamValue('exactzoeken'); | parameterWS['exactzoeken'] = mw.util.getParamValue('exactzoeken'); | ||
parameterWS['specialeweek'] = mw.util.getParamValue('specialeweek'); | parameterWS['specialeweek'] = mw.util.getParamValue('specialeweek'); | ||
− | parameterWS[' | + | parameterWS['seconddata'] = mw.util.getParamValue('seconddata'); |
parameterWS['specialdata'] = mw.util.getParamValue('specialdata'); | parameterWS['specialdata'] = mw.util.getParamValue('specialdata'); | ||
Regel 796: | Regel 828: | ||
} | } | ||
historyWS = true; | historyWS = true; | ||
− | } else if (parameterWS[' | + | } else if (parameterWS['seconddata']) { |
− | urlWS = 'https://wikikids. | + | if (parameterWS['seconddata'].startsWith('http')) { |
+ | urlWS = parameterWS['seconddata']; | ||
+ | } else { | ||
+ | urlWS = 'https://wikikids.wikirots61.workers.dev/pages'; | ||
+ | } | ||
historyWS = false; | historyWS = false; | ||
} else { | } else { | ||
Regel 835: | Regel 871: | ||
// deze variabele regelt wat er bovenin de tabel te zien is als speciale statistiek. Ook regelt hij dingen zoals de dubbele requests. Zodat het goed geregeld kan worden. | // deze variabele regelt wat er bovenin de tabel te zien is als speciale statistiek. Ook regelt hij dingen zoals de dubbele requests. Zodat het goed geregeld kan worden. | ||
var infoHistoryWS = {"Types":"Mobiel", Live:true}; | var infoHistoryWS = {"Types":"Mobiel", Live:true}; | ||
− | var waarschuwingenWS = ['waar ', 'woont', 'in de ', 'geschiedenis van', 'belangrijk', 'beroemd', 'welk', 'wanneer', 'waarom', 'hoe', 'belangerijk', ' de ', ' het ', 'weetjes', 'Waar ', 'Woont', 'In de ', 'Geschiedenis ', 'Belangrijk', 'Beroemd', 'Welk', 'Wanneer', 'Waarom', 'Hoe', 'Belangerijk', 'De ', 'Het ', 'Weetjes', 'over ', 'Over ', 'Wat is een ', 'wat is een ', 'hoofstad', 'Bekend', 'Bijzonder', 'Bizonder', 'Hoofd stad', 'Wat ', 'Beste ', 'weetje']; | + | var waarschuwingenWS = ['wie', 'leuk', 'zoek', 'is een', 'ooit', 'waar ', 'woont', 'in de ', 'geschiedenis van', 'belangrijk', 'beroemd', 'welk', 'wanneer', 'waarom', 'hoe', 'belangerijk', ' de ', ' het ', 'weetjes', 'Waar ', 'Woont', 'In de ', 'Geschiedenis ', 'Belangrijk', 'Beroemd', 'Welk', 'Wanneer', 'Waarom', 'Hoe', 'Belangerijk', 'De ', 'Het ', 'Weetjes', 'over ', 'Over ', 'Wat is een ', 'wat is een ', 'hoofstad', 'Bekend', 'Bijzonder', 'Bizonder', 'Hoofd stad', 'Wat ', 'Beste ', 'weetje']; |
var verwijderenWS = []; | var verwijderenWS = []; | ||
mw.loader.using('mediawiki.util', function() { | mw.loader.using('mediawiki.util', function() { |
Huidige versie van 12 feb 2025 om 12:51
/* jshint sub:true maxerr:100000 */
// [[User:Rots61/JS-WikiStats.js]];
// eerste versie gemaakt door [[User:MakiBoy]] ( https://wikikids.nl/index.php?title=Gebruiker:MakiBoy/Gadget-LogCounter.js&oldid=759863 )
// onderhouden door [[User:Rots61]]
// Wordt gebruikt om de views op de juiste manier te formaten
function parseNumberWS(number) {
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.');
}
// Wordt gebruikt om een nul toe te voegen bij de datum
function addZeroWS(number) {
return number < 10 ? "0" + number : number;
}
function containsAnyWS(str, substrings) {
for (let i = 0; i != substrings.length; i++) {
var substring = substrings[i];
if (str.indexOf(substring) != - 1) {
return substring;
}
}
return null;
}
/*
laat de speciale pagina uiteindelijk zien
pages = array met alle pagina's die getoont moeten worden
zoekwoord = de waarde die zichtbaar moet zijn in de zoekbalk
*/
function showProjectWS (pages, zoekwoord) {
// Dit zorgt ervoor dat de kleur wordt weergegeven of de kleurcode.
//console.log(pages);
// Past de titel van de speciale pagina aan
document.getElementsByTagName("h1")[0].textContent = "Speciaal:" + mw.config.get('wgTitle');
document.title = "Statistieken WikiKids";
var request45 = new XMLHttpRequest();
request45.open('GET', 'https://wikikids.nl/api.php?action=query&list=allpages&apminsize=100000&apnamespace=4&apprefix=Statistieken/Logs&aplimit=500&format=json', false);
request45.send(null);
if (request45.status === 200) {
allHistoryPages = JSON.parse(request45.responseText);
}
//laatsteHistory = allHistoryPages.query.allpages[allHistoryPages.query.allpages.length-2]['title'].slice(-8);
//infoHistoryWS = getInfoPageWS('https://wikikids.nl/Wikikids:Statistieken/Logs/' + laatsteHistory + '/info?action=raw', 2);
searchBarWS = '<div><input type="text" id="lc-searchbar" value=' + zoekwoord +'> <button onclick="searchContainsButtonWS();"><img src="https://upload.wikimedia.org/wikipedia/commons/9/9a/OOjs_UI_indicator_search-ltr.svg" title="Bevat (zoeken)" height="25"></button> <button onclick="searchExactButtonWS();"><img src="https://upload.wikimedia.org/wikipedia/commons/8/86/OOjs_UI_icon_articleSearch-ltr.svg" title="Exact (zoeken)" height="25"></button> </div>'
+ '<div><img src="https://upload.wikimedia.org/wikipedia/commons/8/8b/OOjs_UI_icon_download.svg" title="height="25"> <button onclick="downloadWS(\';\');"><b>;</b></button> <button onclick="downloadWS(\',\');"><b>,</b></button></button>';
// Variabele die informatie geeft over de LogCounter.
var logCounterInfo = '<div id="logCounterInfo">Deze pagina laat zien hoeveel paginabezoeken er zijn geweest op een specifieke pagina. De rij "Views" bevat <b>alle</b> views. De rij daarachter laat alleen maar zien hoeveel views komen vanuit iets specifieks, bijvoorbeeld vanuit een categorie of van een mobiele telefoon. <a href="/Speciaal:Statistieken_WikiKids?action=tabel">Klik hier voor statistieken van vorige weken.</a> De statistieken zijn voor het laatst gereset op: <span id="WikiStats-starttijd"> ' + infoHistoryWS['Endtime'] + '</span> (in UTC).</div>';
// Controleert of het een speciale week is, als dat het geval is, dan wordt de informatie uitgebreid.
if (parameterWS['specialeweek']) {
logCounterInfo += '<span style="color:red;">Let op! De week die je nu bekijkt, is een speciale week. In deze week is gekeken naar de bezoeker op een andere manier dan de standaard manier (per pagina). De gegevens die hier staan zijn dus niet eenvoudig te begrijpen. </span><br>';
}
// Het maken van een tabel
var table = document.createElement('table');
table.classList.add('wikitable');
var tableHead = document.createElement('thead');
var tableHeadRow = document.createElement('tr');
var tableBody = document.createElement('tbody');
var tableHeadTitles;
// Geeft de titels van de tabel weer.
tableHeadTitles = ['Titel', 'Views', infoHistoryWS.Types, '%', '%'];
/*
Variabelen:
currentPage = de huidige pagina, deze informatie komt uit de parameters die megegeven zijn door de gebruiker
rowsPerPage = aantal rijen, krijgt de informatie uit de parameters die meegegeven zijn
totalPages = totaal aantal pagina's, gebaseerd op het aantal rijen.
*/
var currentPage = parseInt(parameterWS['pagenr']);
var rowsPerPage = parseInt(parameterWS['rows']);
var totalPages = Math.ceil(pages.length / rowsPerPage);
var totalVisitorsAll, totalSpecialVisitorsAll;
if (infoHistoryWS.Doublerequest) {
totalVisitorsAll = pages.reduce(function (total, page) {
return total + page.nV;
}, 0);
} else {
totalVisitorsAll = pages.reduce(function (total, page) {
if (!page.nV) {
return total + page.mPV;
} else if (!page.mPV) {
return total + page.nV;
} else {
return total + page.nV + page.mPV;
}
}, 0);
}
totalSpecialVisitorsAll = pages.reduce(function (total, page) {
return total + page.mPV;
}, 0);
// Functie die een specifieke pagina laat zien, op basis van de parameter 'pageNumber'
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');
// Definieert variabelen die later nodig zijn
var totalVisitors, mainPageVisited, pageTitle, pageLink, date, tempDate, filterShow, percentMainPage, percentStyle, pageStyle;
if (infoHistoryWS.Doublerequest) {
totalVisitors = page.nV ? page.nV : page.mPV;
} else {
// Controleert of een gedeelte van de informatie leeg is gelaten. Dit is enkel voor normale versies
if (!page.nV) {
totalVisitors = page.mPV;
} else if (!page.mPV) {
totalVisitors = page.nV;
} else {
totalVisitors = page.nV + page.mPV;
}
}
mainPageVisited = page.mPV ? page.mPV : "";
pageTitle = page.t.replace(/_/g, ' ');
pageLink = page.t;
if (parameterWS['specialeweek']) {
if (pageLink.includes('Tijd')) {
tempDate = new Date((parseInt(pageTitle.replace(/Tijd.?:/g,"")) + 28026240) * 60 * 1000);
pageTitle = pageTitle.replace(/Tijd/g,"T").replace(/:.*/g, ":");
}
}
date = new Date(page.uA);
filterShow = page.filterShow ? page.filterShow : "";
percentMainPage = Math.round((100/totalVisitors)*mainPageVisited*100)/100;
percentFromTotal100 = Math.round(totalVisitors/totalVisitorsAll*100*10000)/10000;
percentStyle = '';
if (filterShow) {
percentStyle = 'style="background: ' + filterShow + '"';
}
if (pageLink.includes('Zoeken:')) {
pageLink = 'Speciaal:Zoeken?search=' + pageTitle.replace(/Zoeken.?:/g,"");
/*
if (containsAnyWS(pageTitle.toLowerCase(), verwijderenWS)) {
temp5 = pageTitle.replace(containsAnyWS(pageTitle.toLowerCase(), verwijderenWS) , "");
pageTitle = pageTitle + '</a> - <a href="https://wikikids.nl/Speciaal:Zoeken/' + temp5.replace(/Zoeken.?:/g,"")+ '">' + temp5;
pageStyle = 'style="background: #FFAAAA;"';
} */
pageTitle = pageTitle.charAt(7).toUpperCase() + pageTitle.slice(8).toLowerCase();
if (parameterWS['specialdata'] !== 'wit') {
if (waarschuwingenWS.some(function(v) { return pageTitle.indexOf(v) >= 0; })) {
pageStyle = 'style="background: orange;"';
}
}
pageTitle = 'Zoek:' + pageTitle;
totalVisitors = '-';
percentMainPage = '-';
percentFromTotal100 = '-';
} else if (pageLink.startsWith('X:')) {
pageLink = '';
pageStyle = 'style="color:black;"';
percentMainPage = '-';
percentFromTotal100 = '-';
}
row.innerHTML = `<td ${pageStyle}><a href="/${pageLink}">${pageTitle}</a></td>
<td>${parseNumberWS(totalVisitors)}</td><td>${parseNumberWS(mainPageVisited)}</td>
<td ${percentStyle}> ${percentMainPage}</td>
<td> ${percentFromTotal100}</td>`;
tableBody.appendChild(row);
});
}
showPage(currentPage);
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) {
parameterWS['pagenr'] = currentPage - 1;
showPage(currentPage - 1);
changeURLWS();
// Manier waarop je kunt zien op welke pagina je bent
document.getElementById('pageCounter').innerHTML = `Pagina <input id="logcounternumberpage" type="number" size="5" value=${currentPage}> van ${totalPages}`;
}
});
pagination.appendChild(prevButton);
var pageCounter = document.createElement('span');
pageCounter.id = "pageCounter";
pageCounter.innerHTML = `Pagina <input id="logcounternumberpage" type="number" size="5" value=${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) {
parameterWS['pagenr'] = currentPage + 1;
showPage(currentPage + 1);
changeURLWS();
// Manier waarop je kunt zien op welke pagina je bent
document.getElementById('pageCounter').innerHTML = `Pagina <input id="logcounternumberpage" type="number" size="5" value=${currentPage}> van ${totalPages}`;
}
});
var gotoButton = document.createElement('button');
gotoButton.textContent = 'Gaan';
gotoButton.style = 'margin-left: 10px;';
gotoButton.addEventListener('click', function () {
if (document.getElementById('logcounternumberpage').value > totalPages || document.getElementById('logcounternumberpage').value < 1) {
} else {
parameterWS['pagenr'] = parseInt(document.getElementById('logcounternumberpage').value);
showPage(parseInt(document.getElementById('logcounternumberpage').value));
changeURLWS();
document.getElementById('pageCounter').innerHTML = `Pagina <input id="logcounternumberpage" type="number" size="5" value=${currentPage}> van ${totalPages}`;
}
});
pagination.appendChild(gotoButton);
pagination.appendChild(nextButton);
tableHeadTitles.forEach(function (title) {
var tableHeadCell = document.createElement('th');
tableHeadCell.textContent = title;
//if (title === 'Laatste bezoek') {tableHeadCell.classList.add('datumstringWS')}
tableHeadRow.appendChild(tableHeadCell);
});
tableHead.appendChild(tableHeadRow);
table.appendChild(tableHead);
table.appendChild(tableBody);
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: ${parseNumberWS(totalVisitorsAll)}`;
totalElement.appendChild(totalVisitorsElement);
var totalSpecialVisitorsElement = document.createElement('span');
totalSpecialVisitorsElement.textContent = `Totaal aantal 'speciale' bezoeken: ${parseNumberWS(totalSpecialVisitorsAll)} (${Math.round((100/totalVisitorsAll)*totalSpecialVisitorsAll*100)/100}%)`;
totalElement.appendChild(totalSpecialVisitorsElement);
var totalPagesElement = document.createElement('span');
totalPagesElement.textContent = `Totaal aantal pagina's: ${parseNumberWS(pages.length)}`;
totalElement.appendChild(totalPagesElement);
var moreInfoElement = document.createElement('span');
if (!infoHistoryWS.Live) {
let firstDateString = '';
if (infoHistoryWS.Starttime) {
let xStarttime = new Date(infoHistoryWS.Starttime);
firstDateString = addZeroWS(xStarttime.getDate()) + "-" + addZeroWS((xStarttime.getMonth() + 1)) + "-" + xStarttime.getFullYear() + " " + addZeroWS(xStarttime.getHours()) + ":" + addZeroWS(xStarttime.getMinutes());
}
const xEndtime = new Date(infoHistoryWS.Endtime);
let lastDateString = addZeroWS(xEndtime.getDate()) + "-" + addZeroWS((xEndtime.getMonth() + 1)) + "-" + xEndtime.getFullYear() + " " + addZeroWS(xEndtime.getHours()) + ":" + addZeroWS(xEndtime.getMinutes());
moreInfoElement.textContent = `${firstDateString} tot ${lastDateString}`;
} else {
moreInfoElement.textContent = 'Live';
}
totalElement.appendChild(moreInfoElement);
document.getElementById('bodyContent').innerHTML = terugnaarWS + searchBarWS + logCounterInfo;
document.getElementById('bodyContent').appendChild(table);
document.getElementById('bodyContent').appendChild(pagination);
document.getElementById('bodyContent').appendChild(totalElement);
}
function getPagesWS() {
var request = new XMLHttpRequest();
request.open('GET', urlWS, false);
request.send(null);
if (request.status === 200) {
pages = JSON.parse(request.responseText);
}
// hernoemen alle keys zodat het later makkelijker gaat
if (!historyWS) {
if (parameterWS['specialdata']) {
for (let x = 0; x < pages.length; x++) {
if (!(pages[x].title.includes('Zoeken:') || pages[x].title.startsWith('X:'))) {
pages.splice(x, 1);
x--;
} else {
renamekeyWS('t','title', x);
}
}
} else {
for (let x = 0; x < pages.length; x++) {
if (pages[x].title.includes('Zoeken:') || pages[x].title.startsWith('X:')) {
pages.splice(x, 1);
x--;
} else {
renamekeyWS('t','title', x);
}
}
}
} else {
if (parameterWS['specialdata']) {
for (let x = 0; x < pages.length; x++) {
if (!(pages[x].t.includes('Zoeken:') || pages[x].t.startsWith('X:'))) {
pages.splice(x, 1);
x--;
}
}
} else {
for (let x = 0; x < pages.length; x++) {
if (pages[x].t.includes('Zoeken:') || pages[x].t.startsWith('X:')) {
pages.splice(x, 1);
x--;
}
}
}
}
fullPagesWS = pages;
// Sorteer de pagina's op het aantal bezoekers (hoog naar laag) (page.normalVisitors + page.mainPageVisitors)
if (infoHistoryWS.Doublerequest) {
pages.sort(function (a, b) {
return b.nV + b.nV - a.nV - a.nV;
});
} else {
pages.sort(function (a, b) {
return b.nV + b.mPV - a.nV - a.mPV;
});
}
//Filter percentmax, percentmin, aantalmax, aantalmin, only
for (let y=0; y < pages.length; y++) {
pages[y].mPV = pages[y].mPV ? pages[y].mPV : 0;
pages[y].nV = pages[y].nV ? pages[y].nV : 0;
if (infoHistoryWS.Doublerequest) {
aantalviewspagina = pages[y].nV;
procent = (100/pages[y].nV)*pages[y].mPV;
if (procent === Infinity) {
procent = 100;
}
} else {
aantalviewspagina = pages[y].nV + pages[y].mPV;
procent = (100/(aantalviewspagina))*pages[y].mPV; // 50
}
if (procent < parameterWS['only'][0] || procent > parameterWS['only'][1]) { // dat wat buiten deze categorie ([x, y]) wordt verwijderd.
pages.splice(y, 1);
y = y-1;
} else if (aantalviewspagina < parameterWS['only'][2] || aantalviewspagina > parameterWS['only'][3]) { // bovenstaande
pages.splice(y, 1);
y = y-1;
} else if (parameterWS['kleur1'] || parameterWS['kleur2'] || parameterWS['kleur3'] || parameterWS['kleur4']) {
if (parameterWS['kleur1']) {
if (procent >= parameterWS['kleur1'][0]) {
if (procent <= parameterWS['kleur1'][1]) {
haakjenodig = /[G-Za-z]/.test(parameterWS['kleur1'][2]) ? '' : '#';
pages[y].filterShow = haakjenodig + parameterWS['kleur1'][2];
}
}
}
if (parameterWS['kleur2']) {
if (procent >= parameterWS['kleur2'][0]) {
if (procent <= parameterWS['kleur2'][1]) {
haakjenodig = /[G-Za-z]/.test(parameterWS['kleur2'][2]) ? '' : '#';
pages[y].filterShow = haakjenodig + parameterWS['kleur2'][2];
}
}
}
if (parameterWS['kleur3']) {
if (procent >= parameterWS['kleur3'][0]) {
if (procent <= parameterWS['kleur3'][1]) {
haakjenodig = /[G-Za-z]/.test(parameterWS['kleur3'][2]) ? '' : '#';
pages[y].filterShow = haakjenodig + parameterWS['kleur3'][2];
}
}
}
if (parameterWS['kleur4']) {
if (procent >= parameterWS['kleur4'][0]) {
if (procent <= parameterWS['kleur4'][1]) {
haakjenodig = /[G-Za-z]/.test(parameterWS['kleur4'][2]) ? '' : '#';
pages[y].filterShow = haakjenodig + parameterWS['kleur4'][2];
}
}
}
}
}
return pages;
}
function gotoGeschiedenisVanPaginaWS(){
parameterWS = {};
parameterWS['page'] = document.getElementById('lc-searchbar').value.replace(/ /g, '_');
changeURLWS();
startLC();
}
function searchContainsButtonWS() {
searchQuery = document.getElementById('lc-searchbar').value.replace(/ /g, '_');
parameterWS['exactzoeken'] = undefined;
parameterWS['action'] = undefined;
parameterWS['page'] = undefined;
parameterWS['pagenr'] = 1;
parameterWS['bevatzoeken'] = searchQuery;
changeURLWS();
startLC();
}
function searchContainsWS(searchQuery) {
if (!searchQuery) {
searchQuery = parameterWS['bevatzoeken'];
}
var searchResult = [];
for (let i = 0; i < allPagesWS.length; i++) {
if (parameterWS['regex']) {
regex = new RegExp(searchQuery, "i");
if (regex.test(allPagesWS[i]['t'].toLowerCase())) {
searchResult.push(allPagesWS[i]);
}
} else {
if (allPagesWS[i]['t'].toLowerCase().includes(searchQuery.toLowerCase())) {
searchResult.push(allPagesWS[i]);
}
}
}
setTimeout(function () {
if (!searchResult.length) {
const printToScreen = '<br>Er is geen pagina die <a href="https://wikikids.nl/Speciaal:Zoeken/' + searchQuery + '">' + searchQuery + '</a> bevat, en die in deze periode views heeft ontvangen.'
+ 'Kijk voor meer <a href="https://wikikids.nl/WikiKids:Statistieken">informatie op deze pagina</a>.';
document.getElementById('bodyContent').innerHTML = terugnaarWS + searchBarWS + printToScreen;
} else {
showProjectWS(searchResult, searchQuery);
}
}, 750);
}
function searchExactButtonWS() {
searchQuery = document.getElementById('lc-searchbar').value.replace(/ /g, '_');
parameterWS['bevatzoeken'] = undefined;
parameterWS['action'] = undefined;
parameterWS['page'] = undefined;
parameterWS['pagenr'] = 1;
parameterWS['exactzoeken'] = searchQuery;
changeURLWS();
startLC();
}
function searchExactWS(searchQuery) {
if (!searchQuery) {
searchQuery = parameterWS['exactzoeken'];
}
let searchResult = [];
for (let i = 0; i < allPagesWS.length; i++) {
if (allPagesWS[i]['t'].toLowerCase() === searchQuery.toLowerCase()) {
searchResult.push(allPagesWS[i]);
}
}
setTimeout(function () {
if (!searchResult.length) {
let printToScreen = '<br>De pagina <a href="https://wikikids.nl/' + searchQuery + '">' + searchQuery + '</a> heeft geen views ontvangen, voldoet niet aan het ingestelde filter of bestaat niet. ';
document.getElementById('bodyContent').innerHTML = terugnaarWS + searchBarWS + printToScreen;
} else {
console.log(searchResult);
showProjectWS(searchResult, searchQuery);
}
}, 750);
}
function getInfoPageWS(urlInfoLogCounter) {
var infoHistorytemp;
var request = new XMLHttpRequest();
request.open('GET', urlInfoLogCounter, false);
request.send(null);
if (request.status === 200) {
infoHistorytemp = JSON.parse(request.responseText);
}
return infoHistorytemp;
}
function terugWS(dateparameter, specialeweekparameter) {
parameterWS = {};
if (dateparameter || specialeweekparameter) {
parameterWS['date'] = dateparameter;
parameterWS['specialeweek'] = specialeweekparameter;
changeURLWS();
startLC();
} else {
changeURLWS();
startLC(true);
}
}
function changeURLWS() {
var urlPath = '/Speciaal:Statistieken WikiKids?';
if (parameterWS['rows']) {
if (parameterWS['rows'] !== 25) {
urlPath += 'rows=' + parameterWS['rows'] + '&';
}
}
if (parameterWS['action']) {
urlPath += 'action=' + parameterWS['action'] + '&';
}
if (parameterWS['date']) {
urlPath += 'date=' + parameterWS['date'] + '&';
}
if (parameterWS['page']) {
urlPath += 'page=' + parameterWS['page'] + '&';
}
if (parameterWS['pagenr']) {
if (parameterWS['pagenr'] < 1 || (parameterWS['pagenr'] > Math.ceil(allPagesWS.length / parameterWS['rows']) || parameterWS['pagenr'] === 1)) {
parameterWS['pagenr'] = 1;
} else {
urlPath += 'pagenr=' + parameterWS['pagenr'] + '&';
}
}
if (parameterWS['bevatzoeken']) {
urlPath += 'bevatzoeken=' + parameterWS['bevatzoeken'] + '&';
}
if (parameterWS['regex']) {
urlPath += 'regex=' + parameterWS['regex'] + '&';
}
if (parameterWS['exactzoeken']) {
urlPath += 'exactzoeken=' + parameterWS['exactzoeken'] + '&';
}
if (parameterWS['seconddata']) {
urlPath += 'seconddata=' + parameterWS['seconddata'] + '&';
}
if (parameterWS['specialeweek']) {
urlPath += 'specialeweek=' + parameterWS['specialeweek'] + '&';
}
if (JSON.stringify(parameterWS['only']) !== JSON.stringify([0, 100, 0, Infinity])) {
urlPath += 'only=' + JSON.stringify(parameterWS['only']) + '&';
}
if (parameterWS['kleur1']) {
urlPath += 'kleur1=' + JSON.stringify(parameterWS['kleur1']) + '&';
}
if (parameterWS['kleur2']) {
urlPath += 'kleur2=' + JSON.stringify(parameterWS['kleur2']) + '&';
}
if (parameterWS['kleur3']) {
urlPath += 'kleur3=' + JSON.stringify(parameterWS['kleur3']) + '&';
}
if (parameterWS['kleur4']) {
urlPath += 'kleur4=' + JSON.stringify(parameterWS['kleur4']) + '&';
}
if (parameterWS['specialdata']) {
urlPath += 'specialdata=' + parameterWS['specialdata'] + '&';
}
urlPath += 'v=2.0';
window.history.pushState("","", urlPath);
//window.history.replaceState("","", urlPath);
}
// Tabel
function tabelWS() {
var allHistoryPages;
var request = new XMLHttpRequest();
// Geeft alle subpagina's van WikiKids:Statistieken/Logs, /StatistiekenExtra staan in naamruimte Rots, en doen dus niet mee
request.open('GET', 'https://wikikids.nl/api.php?action=query&list=allpages&apminsize=1000&apnamespace=4&apprefix=Statistieken/Logs&aplimit=500&format=json', false);
request.send(null);
if (request.status === 200) {
allHistoryPages = JSON.parse(request.responseText);
}
allHistoryPages = allHistoryPages.query.allpages;
var tableOutputWS = `<table class="wikitable" id="LogCounterHistory"><thead><tr><th onclick="sortTableWS('LogCounterHistory',0)">Link</th><th onclick="sortTableWS('LogCounterHistory',1)">Datum</th><th onclick="sortTableWS('LogCounterHistory',2, true)">Aantal bezoekers</th><th onclick="sortTableWS('LogCounterHistory',3, true)">Aantal pagina's</th><th onclick="sortTableWS('LogCounterHistory',4)">Extra informatie</th></tr></thead><tbody>
<tr><td><a href="https://wikikids.nl/Special:Statistieken_WikiKids">Live</a></td><td>Sinds zaterdag</td><td>0</td><td>0</td></tr>`;
requests = new Array(allHistoryPages.length);
setTimeout(function () {
for (let i = 0; i < allHistoryPages.length; i++) {
var url = "https://wikikids.nl/" + allHistoryPages[i]['title'] + '/info?action=raw';
requests[i] = new XMLHttpRequest();
requests[i].open("GET", url);
requests[i].onload = function() {
var datainfo = JSON.parse(requests[i].responseText);
tableOutputWS += `<tr><td><a href="https://wikikids.nl/Special:Statistieken_WikiKids?date=${allHistoryPages[i]['title'].slice(-8)}${allHistoryPages[i]['specialeweek'] ? '&specialeweek=true' : ''}">${datainfo['Jaar-Week']}</a></td>`;
var xStarttime = new Date(datainfo.Starttime);
var xEndtime = new Date(datainfo.Endtime);
var firstDateString = addZeroWS(xStarttime.getDate()) + "-" + addZeroWS((xStarttime.getMonth() + 1)) + "-" + xStarttime.getFullYear() + " " + addZeroWS(xStarttime.getHours()) + ":" + addZeroWS(xStarttime.getMinutes());
var lastDateString = addZeroWS(xEndtime.getDate()) + "-" + addZeroWS((xEndtime.getMonth() + 1)) + "-" + xEndtime.getFullYear() + " " + addZeroWS(xEndtime.getHours()) + ":" + addZeroWS(xEndtime.getMinutes());
tableOutputWS += `<td>van ${firstDateString} tot ${lastDateString}</td><td>${datainfo.Totalviews}</td><td>${datainfo.Totalpages}</td><td><a href="/WikiKids:Statistieken#${datainfo.Types.replace(/ /g, '_')}">${datainfo.Types}</a></td></tr>`;
};
requests[i].send();
}
document.getElementsByTagName("h1")[0].textContent = "Speciaal:" + mw.config.get('wgTitle');
document.title = "Voorgaande statistieken - WikiKids";
infotext = 'Elke zaterdag worden, de statistieken opnieuw opgeslagen. Een week loopt dus van zaterdag tot zaterdag. Het real-time registreren van de bezoekers wordt mogelijk gemaakt door Rots61. Voor vragen kun je terecht bij Rots61. <br>'
+ 'Deze lijst wordt automatisch bijgewerkt, zodat alle vorige statistieken worden getoont. (Als niet alles is getoond, herlaad de pagina dan.)<br>';
setTimeout( function () {
document.getElementById('bodyContent').innerHTML = terugnaarWS + infotext + tableOutputWS + '</tbody></table>';
sortTableWS('LogCounterHistory',0);
}, 500);
}, 500);
}
// Download functies
function downloadWS(tss) {
let downloadResult = 'Paginatitel' + tss + 'Views' + tss + 'Speciale statistiek \n';
for (let x = 0; x < allPagesWS.length; x++){
if (!allPagesWS[x].mPV) {
downloadResult += allPagesWS[x].t.replace(/,/g, '.') + tss + (allPagesWS[x].nV) + tss + '0' + tss + '\n';
} else if (!allPagesWS[x].nV) {
downloadResult += allPagesWS[x].t.replace(/,/g, '.') + tss + (allPagesWS[x].mPV) + tss + allPagesWS[x].mPV + tss + '\n';
} else {
downloadResult += allPagesWS[x].t.replace(/,/g, '.') + tss + (allPagesWS[x].mPV + allPagesWS[x].nV) + tss + allPagesWS[x].mPV + tss + '\n';
}
}
if (parameterWS['date']) {
downloadfileWS(downloadResult, 'Statistieken WikiKids ' + parameterWS['date'] +'.csv', 'csv');
} else {
downloadfileWS(downloadResult, 'Statistieken WikiKids live.csv', 'csv');
}
}
function downloadfileWS(data, filename, type) {
var file = new Blob([data], {type: type});
if (window.navigator.msSaveOrOpenBlob)
window.navigator.msSaveOrOpenBlob(file, filename+"." + type);
else {
var a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
// Functies van het internet, of die iets veel makkelijker maken, zonder dat er onderhoud voor nodig is.
function sortTableWS(id, n, getal) {
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
table = document.getElementById(id);
switching = true;
// Set the sorting direction to ascending:
dir = "asc";
/* Make a loop that will continue until
no switching has been done: */
while (switching) {
// Start by saying: no switching is done:
switching = false;
rows = table.rows;
/* Loop through all table rows (except the
first, which contains table headers): */
for (i = 1; i < (rows.length - 1); i++) {
// Start by saying there should be no switching:
shouldSwitch = false;
/* Get the two elements you want to compare,
one from current row and one from the next: */
x = rows[i].getElementsByTagName("TD")[n];
y = rows[i + 1].getElementsByTagName("TD")[n];
/* Check if the two rows should switch place,
based on the direction, asc or desc: */
if (getal) {
if (dir === "asc") {
if (parseInt(x.innerHTML) > parseInt(y.innerHTML)) {
// If so, mark as a switch and break the loop:
shouldSwitch = true;
break;
}
} else if (dir == "desc") {
if (parseInt(x.innerHTML) < parseInt(y.innerHTML)) {
// If so, mark as a switch and break the loop:
shouldSwitch = true;
break;
}
}
} else {
if (dir == "asc") {
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
// If so, mark as a switch and break the loop:
shouldSwitch = true;
break;
}
} else if (dir == "desc") {
if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
// If so, mark as a switch and break the loop:
shouldSwitch = true;
break;
}
}
}
}
if (shouldSwitch) {
/* If a switch has been marked, make the switch
and mark that a switch has been done: */
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
switching = true;
// Each time a switch is done, increase this count by 1:
switchcount++;
} else {
/* If no switching has been done AND the direction is "asc",
set the direction to "desc" and run the while loop again. */
if (switchcount === 0 && dir === "asc") {
dir = "desc";
switching = true;
}
}
}
}
function checkJsonWS(item, returnvalue) {
let value = typeof item !== "string" ? JSON.stringify(item) : item;
try {
value = JSON.parse(value);
} catch (e) {
return returnvalue;
}
if (typeof value === "object" && value !== null) {
return JSON.parse(item);
} else {
return returnvalue;
}
}
function clearSecondStatsWS() {
var settings = {
"url": "https://wikikids.wikirots61.workers.dev/pages/delete",
"method": "POST",
"timeout": 0,
"headers": {
"Host": "wikikids.wikirots61.workers.dev/",
"Content-Type": "application/json"
},
"data": JSON.stringify({
"message": 'gek'
}),
};
$.ajax(settings).done(function (response) {
mw.notify("Reseten statistieken gelukt", { autoHide: false });
window.onbeforeunload = null;
}).catch(function (error) {
if (error.responseText || JSON.parse(error.responseText).succes) {
mw.notify("Reseten statistieken2 gelukt", { autoHide: false });
window.onbeforeunload = null;
} else {
mw.notify('Resetten mislukt, stuur Rots61 aub direct een berichtje.', {autoHide: false});
}
});
}
function renamekeyWS(new_key, old_key, x){
Object.defineProperty(pages[x], new_key,
Object.getOwnPropertyDescriptor(pages[x], old_key));
delete pages[x][old_key];
}
// Einde functies van het internet
function startLC(reloadlc, firsttime) {
parameterWS['version'] = mw.util.getParamValue('v') ? mw.util.getParamValue('v') : false;
// worden ondersteund door versie 1 & 2
parameterWS['rows'] = mw.util.getParamValue('rows') ? mw.util.getParamValue('rows') : 25;
parameterWS['action'] = mw.util.getParamValue('action');
parameterWS['date'] = mw.util.getParamValue('date');
parameterWS['page'] = mw.util.getParamValue('page');
parameterWS['pagenr'] = mw.util.getParamValue('pagenr') ? mw.util.getParamValue('pagenr') : 1;
parameterWS['bevatzoeken'] = mw.util.getParamValue('bevatzoeken');
parameterWS['regex'] = mw.util.getParamValue('regex');
parameterWS['exactzoeken'] = mw.util.getParamValue('exactzoeken');
parameterWS['specialeweek'] = mw.util.getParamValue('specialeweek');
parameterWS['seconddata'] = mw.util.getParamValue('seconddata');
parameterWS['specialdata'] = mw.util.getParamValue('specialdata');
var allowedUsersSpecialData = ["Rots61", "Hanssain", "Mike1023", "Hippogryph", "PaulD", "Wouter15", "S.Perquin", "Gerarddummer", "Groempdebeer", "DeHelpendePenny", "FreekKraak"];
if (!allowedUsersSpecialData.includes(mw.config.get('wgUserName')) && parameterWS['specialdata']) {
parameterWS['specialdata'] = false;
mw.notify( 'Helaas, je hebt geen toegang tot deze specifieke gegevens. Je kunt wel de normale statistieken bekijken. Controleer of je ingelogd bent. ', { autoHideSeconds : 30 } );
}
if (parameterWS['version'] === '1.0' || parameterWS['version'] === '1.1') {
parameterWS['percentmin'] = mw.util.getParamValue('percentmin') ? mw.util.getParamValue('percentmin') : -1;
parameterWS['percentmax'] = mw.util.getParamValue('percentmax') ? mw.util.getParamValue('percentmax') : 100;
parameterWS['only'] = mw.util.getParamValue('only');
parameterWS['aantalmax'] = mw.util.getParamValue('aantalmax') ? mw.util.getParamValue('aantalmax') : Infinity;
parameterWS['aantalmin'] = mw.util.getParamValue('aantalmin') ? mw.util.getParamValue('aantalmin') : 0;
if (parameterWS['only']) {
parameterWS['only'] = [parameterWS['percentmin'] ? parameterWS['percentmin'] : 0 , parameterWS['percentmax'] ? parameterWS['percentmax'] : 100, parameterWS['aantalmin'] ? parameterWS['aantalmin'] : 0, parameterWS['aantalmax'] ? parameterWS['aantalmax'] : Infinity];
} else if (parameterWS['version'] === '1.1') {
parameterWS['only'] = [0, 100, 0, Infinity];
parameterWS['kleur1'] = [0, parameterWS['percentmin'], 'aqua'];
parameterWS['kleur2'] = [parameterWS['percentmax'], 100, 'orange'];
} else {
parameterWS['only'] = [0, 100, 0, Infinity];
parameterWS['kleur1'] = [parameterWS['percentmin'], parameterWS['percentmax'], 'lightgreen'];
}
} else {
parameterWS['only'] = checkJsonWS(mw.util.getParamValue('only'), [0, 100, 0, Infinity]);
parameterWS['kleur1'] = checkJsonWS(mw.util.getParamValue('kleur1'), false);
parameterWS['kleur2'] = checkJsonWS(mw.util.getParamValue('kleur2'), false);
parameterWS['kleur3'] = checkJsonWS(mw.util.getParamValue('kleur3'), false);
parameterWS['kleur4'] = checkJsonWS(mw.util.getParamValue('kleur4'), false);
if (!parameterWS['only'][1]) {
parameterWS['only'][1] = 100;
}
if (!parameterWS['only'][2]) {
parameterWS['only'][2] = 0;
}
if (!parameterWS['only'][3]) {
parameterWS['only'][3] = Infinity;
}
if (!parameterWS['kleur1'][2] && parameterWS['kleur1']) {
parameterWS['kleur1'][2] = 'lightblue';
}
if (!parameterWS['kleur2'][2] && parameterWS['kleur2']) {
parameterWS['kleur2'][2] = 'lightgreen';
}
if (!parameterWS['kleur3'][2] && parameterWS['kleur3']) {
parameterWS['kleur3'][2] = 'pink';
}
if (!parameterWS['kleur4'][2] && parameterWS['kleur4']) {
parameterWS['kleur4'][2] = 'orange';
}
}
// zorgt ervoor dat er bovenin een link terug verwijst naar de basisinstellingen van de logcounter.
terugnaarWS = '<div id="contentSub"><span class="subpages">< <a href="javascript:terugWS();" title="Speciaal:Statistieken WikiKids">Speciaal:Statistieken WikiKids</a>';
if (parameterWS['date']) {
terugnaarWS += ' | <a href="javascript:terugWS(' + parameterWS['date'];
if (parameterWS['specialeweek']) {
terugnaarWS += ', true';
}
terugnaarWS += ');" title="Speciaal:Statistieken/' + parameterWS['date'] + '">' + parameterWS['date'] + '</a>';
}
terugnaarWS += '</span></div>';
if (parameterWS['date']) {
if (parameterWS['specialeweek']) {
urlWS = 'https://wikikids.nl/User:Rots61/StatistiekenExtra/' + parameterWS['date'] + '?action=raw';
infoHistoryWS = getInfoPageWS('https://wikikids.nl/User:Rots61/StatistiekenExtra/' + parameterWS['date'] + '/info?action=raw');
} else {
urlWS = 'https://wikikids.nl/Wikikids:Statistieken/Logs/' + parameterWS['date'] + '?action=raw';
infoHistoryWS = getInfoPageWS('https://wikikids.nl/Wikikids:Statistieken/Logs/' + parameterWS['date'] + '/info?action=raw');
}
historyWS = true;
} else if (parameterWS['seconddata']) {
if (parameterWS['seconddata'].startsWith('http')) {
urlWS = parameterWS['seconddata'];
} else {
urlWS = 'https://wikikids.wikirots61.workers.dev/pages';
}
historyWS = false;
} else {
urlWS = 'https://wikikids.dekenos.nl/pages';
historyWS = false;
}
if (parameterWS['action'] === 'tabel') {
tabelWS();
} else if (parameterWS['page']) { // Views voor een pagina, de hele tijd;
mw.notify('Deze functie is niet meer beschikbaar. Omdat hij niet goed werkt. ');
} else {
if (firsttime) {
allPagesWS = getPagesWS();
changeURLWS();
} else if (reloadlc) {
allPagesWS = getPagesWS();
} else {
allPagesWS = fullPagesWS;
}
if (parameterWS['bevatzoeken'] || parameterWS['regex']) {
searchContainsWS(parameterWS['bevatzoeken']);
} else if (parameterWS['exactzoeken']) {
searchExactWS(parameterWS['exactzoeken']);
} else {
showProjectWS(allPagesWS, '');
}
}
}
var pages = [];
if (mw.config.get('wgNamespaceNumber') === -1 && (mw.config.get('wgTitle') === "LogCounter" || (mw.config.get('wgTitle') === "Statistieken Wikikids" || (mw.config.get('wgTitle') === "Statistieken WikiKids" || mw.config.get('wgTitle') === "WikiStats")))) {
document.getElementById('bodyContent').innerHTML = 'WikiStats is aan het opstarten. Dit kan enkele seconden duren. ';
var parameterWS = {};
var historyWS, urlWS, allPagesWS, fullPagesWS, terugnaarWS, historyOutputWS, searchBarWS;
//var downloadAllWS = [];
// deze variabele regelt wat er bovenin de tabel te zien is als speciale statistiek. Ook regelt hij dingen zoals de dubbele requests. Zodat het goed geregeld kan worden.
var infoHistoryWS = {"Types":"Mobiel", Live:true};
var waarschuwingenWS = ['wie', 'leuk', 'zoek', 'is een', 'ooit', 'waar ', 'woont', 'in de ', 'geschiedenis van', 'belangrijk', 'beroemd', 'welk', 'wanneer', 'waarom', 'hoe', 'belangerijk', ' de ', ' het ', 'weetjes', 'Waar ', 'Woont', 'In de ', 'Geschiedenis ', 'Belangrijk', 'Beroemd', 'Welk', 'Wanneer', 'Waarom', 'Hoe', 'Belangerijk', 'De ', 'Het ', 'Weetjes', 'over ', 'Over ', 'Wat is een ', 'wat is een ', 'hoofstad', 'Bekend', 'Bijzonder', 'Bizonder', 'Hoofd stad', 'Wat ', 'Beste ', 'weetje'];
var verwijderenWS = [];
mw.loader.using('mediawiki.util', function() {
mw.util.addPortletLink('p-namespaces',
'https://wikikids.nl/index.php?title=Overleg_gebruiker:Rots61&action=edit§ion=new',
'Vragen? ', '#linkNaarOverlegPaginaR61', "Vragen over de statistieken");
});
mw.loader.using('mediawiki.util', function() {
mw.util.addPortletLink('p-namespaces',
'https://wikikids.nl/WikiKids:Statistieken',
'Info ', '#linkNaarWKStatistieken', "Informatie over de statistieken");
}); $.when($.ready, mw.loader.using(['mediawiki.util'])).done(function () {
document.getElementById("footer-places").innerHTML += '<li id="footer-places-gadget-LogCounter">Script gemaakt door <a href="/User:MakiBoy" title="Gebruiker:MakiBoy">MakiBoy</a> en <a href="/User:Rots61" title="Gebruiker:Rots61">Rots61</a></li>';
});
startLC(true, 'first');
}
if ((!mw.storage.get('disableLoggingWS')) || mw.config.get('wgNamespaceNumber') !== 0) {
mw.storage.set('disableLoggingWS', true, 604800);
}