Gebruiker:Rots61/Gadget-LinkTeller.js
< Gebruiker:Rots61
Naar navigatie springen
Naar zoeken springen
Versie door Rots61 (overleg | bijdragen) op 8 dec 2022 om 16:49 (Nieuwe pagina aangemaakt met '→* * LinkTeller.JS * Features: [[WikiKids:LinkTeller]] * Made by [[User:Rots61]] *: // Create variables function startAP() { // Get the number of articles...')
Let op! Nadat je de veranderingen hebt opgeslagen, moet je de cache van je browser nog legen om ze daadwerkelijk te zien.
Mozilla (incl. Firefox) | ctrl-shift-r |
IE | ctrl-f5 |
Opera | f5 |
Safari | cmd-r |
Konqueror | f5 |
/**
* LinkTeller.JS
* Features: [[WikiKids:LinkTeller]]
* Made by [[User:Rots61]]
**/
// Create variables
function startAP() {
// Get the number of articles
console.log("b");
getPageCount().then( function (ECarticlecount) { // The new page count we got will be passed here.
document.getElementById("ooui-php-9").innerHTML +=
"<p>Er zijn " + ECarticlecount + " pagina's die aan deze voorwaarden voldoen.</p>";
} );
}
function getPageCount( apiContinue ) {
console.log("d");
return api.get( {
action: "query",
list: "allpages",
apfrom: urlfrom ? urlfrom : undefined,
aplimit: "5000",
apto: urlto ? urlto : undefined,
apnamespace: urlns ? urlns : undefined,
apfilterredir: urlredirect ? "nonredirects" : "all",
apcontinue: apiContinue ? apiContinue.apcontinue : undefined
} ).then( function (data) {
if ( data.continue ) {
return getPageCount( data.continue )
.then( function ( addedLength ) {
return addedLength + data.query.allpages.length;
} );
} else {
return data.query.allpages.length;
}
} );
}
if(mw.config.get('wgNamespaceNumber') === -1 && (mw.config.get('wgTitle') === "AllePaginas" || mw.config.get('wgTitle') === "Allepaginas")
) {
var api = new mw.Api();
var queryString = window.location.search;
var urlParams = new URLSearchParams(queryString);
var urlfrom = urlParams.get('from');
var urlto = urlParams.get('to');
var urlns = urlParams.get('namespace');
var urlredirect = urlParams.get('hideredirects');
console.log("a");
$.when( $.ready, mw.loader.using(['mediawiki.util'])).done( startAP());
}
console.log("z");