Gebruiker:Rots61/TestJS.js
Naar navigatie springen
Naar zoeken springen
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 |
/**
* EDITCOUNT.JS
*
* Loads the editcount for users
* 'Adds' special page [[Speciaal:EditCount]]
* But it doesn't really exist though
* Based on [[c:en:User:PleaseStand/userinfo.js]], [[c:en:User:Frietjes/masspurge.js]] and [[MediaWiki:Gadget-EditCount.js]]
* Made by [[User:Rots61]]
**/
function getEC() {
// Request the user's information from the API.
var ECgebruikersnaam = "";
if (document.getElementById("user").value.length == 0) {
if (document.location.href.indexOf('?user=') != -1) {
ECgebruikersnaam = document.location.href.substring(document.location.href.indexOf('?user=')+6, document.location.href.length);}
else { ECgebruikersnaam = document.getElementById("user").value; }}
$.getJSON(mw.config.get("wgScriptPath") + "/api.php?format=json&action=query&list=users&usprop=blockinfo|editcount|gender&ususers=" + ECgebruikersnaam)
.done(function(query) {
// When response arrives extract the information we need.
if(!query.query) { return; } // Suggested by Gary King to avoid JS errors --PS 2010-08-25
query = query.query;
var user, invalid, missing, editcount, blocked, gender;
try {
user = query.users[0];
invalid = typeof user.invalid != "undefined";
missing = typeof user.missing != "undefined";
editcount = (typeof user.editcount == "number") ? user.editcount : null;
blocked = typeof user.blockedby != "undefined";
gender = (typeof user.gender == "string") ? user.gender : null;
} catch(e) {
return; // Not much to do if the server is returning an error (e.g. if the username is malformed).
}
// Format the information for on-screen display
var statusText = "";
if (missing||invalid) {
statusText += "<i>" + ECgebruikersnaam + "</i> bestaat niet.";
} else {
statusText = "<a href=\"" + mw.config.get("wgScriptPath") + encodeURIComponent(mw.config.get("wgFormattedNamespaces")[2] + ":" + ECgebruikersnaam) + "\">" + ECgebruikersnaam + "</a> ";
}
if(blocked) {
statusText += "<a href=\"" + mw.config.get("wgScriptPath") +
"/index.php?title=Special:Log&page=" +
encodeURIComponent(mw.config.get("wgFormattedNamespaces")[2] + ":" + ECgebruikersnaam) +
"&type=block\">is geblokkeerd</a> en ";
}
// Edit count
if(editcount !== null) {
statusText += " heeft " + editcount + " bewerkingen gedaan.";
}
document.getElementById("ECoutput").innerHTML = statusText;
});
$.getJSON(mw.config.get("wgScriptPath") + "/api.php?action=query&format=json&list=usercontribs&ucprop=timestamp&uclimit=5000&ucshow=new&ucnamespace=0&ucuser=" + ECgebruikersnaam)
.done(function(query) {
query = query.query;
var ECarticlecount = query.usercontribs.length;
document.getElementById("ECarticleoutput").innerHTML = ECgebruikersnaam + " heeft " + ECarticlecount + " artikels aangemaakt.";
});
}
function Button() {
var ECgebruikersnaam = document.getElementById('user').value ;
location.href = "https://wikikids.nl/Speciaal:Editcount2?user=" + ECgebruikersnaam;
}
function ECpage() {
var bodyContent = 'bodyContent';
document.getElementsByTagName("h1")[0].textContent = "EditCount";
document.title = "EditCount - WikiKids";
document.getElementById(bodyContent).innerHTML = '<form id="ECform" name="ECform">'
+ '<b>Vul eerst het verzoek in, zie <a href="https://wikikids.nl/api.php">de hulppagina.</a> Vul daarna het gewenste in, bijvoorbeeld query.query.allpages.lenght</b></br>'
+ 'Vul hier het verzoek in: '
+ '<input type="text" name="verzoek" id="verzoek" size="100">'
+ 'Vul hier de output in: '
+ '<input type="text" name="wens" id="wens" size="100">'
+ '<button onclick="getEC()">Gaan!</button>'
+ '</form><br><div id="output1"></div><div id="output2"></div>';
}
if(mw.config.get('wgNamespaceNumber') === -1 && (mw.config.get('wgTitle') === "Testjs" || mw.config.get('wgTitle') === "TestJS")
) {
$.when( $.ready, mw.loader.using(['mediawiki.util'])).done( ECpage );
}