Gebruiker:Rots61/Gadget-EditCount.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 56: | Regel 56: | ||
document.getElementById("ECoutput").innerHTML = statusText; | document.getElementById("ECoutput").innerHTML = statusText; | ||
}); | }); | ||
− | |||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function Button() { | function Button() { | ||
Regel 127: | Regel 97: | ||
document.title = "EditCount - WikiKids"; | document.title = "EditCount - WikiKids"; | ||
document.getElementById(bodyContent).innerHTML = '<form id="ECform" name="ECform">' | document.getElementById(bodyContent).innerHTML = '<form id="ECform" name="ECform">' | ||
− | + '<b>Bekijk hier hoeveel bewerkingen iemand heeft gedaan | + | + '<b>Bekijk hier hoeveel bewerkingen iemand heeft gedaan.<br>' |
− | + | + 'Druk op enter, om het aantal bewerkingen op te halen. Dit kan een paar seconden duren. </b></br>' | |
+ 'Vul hier de naam in: ' | + 'Vul hier de naam in: ' | ||
+ '<input type="text" name="user" id="user" size="30"></textarea>' | + '<input type="text" name="user" id="user" size="30"></textarea>' |
Versie van 7 dec 2022 20:23
/**
* EDITCOUNT2.JS
*
* Features: [[WikiKids:EditCount]]
* Made by [[User:Rots61]]
**/
const api = new mw.Api();
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; }}
api.get( {
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;
});
}
function Button() {
var ECgebruikersnaam = document.getElementById('user').value ;
location.href = "https://wikikids.nl/Speciaal:Editcount2?user=" + ECgebruikersnaam;
}
function ECsjabloon() {
var ECgebruikersnaam = document.getElementById("EditCount").innerHTML;
api.get( {
action: 'query',
list: 'users',
usprop: 'editcount',
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;
user = query.users[0];
invalid = typeof user.invalid != "undefined";
missing = typeof user.missing != "undefined";
editcount = (typeof user.editcount == "number") ? user.editcount : null;
var statusText;
// Edit count
if(editcount !== null) {
statusText = editcount ;
}
if (missing||invalid) {
statusText = "ERROR";
} document.getElementById("EditCount").innerHTML = statusText;
});
}
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>Bekijk hier hoeveel bewerkingen iemand heeft gedaan.<br>'
+ 'Druk op enter, om het aantal bewerkingen op te halen. Dit kan een paar seconden duren. </b></br>'
+ 'Vul hier de naam in: '
+ '<input type="text" name="user" id="user" size="30"></textarea>'
+ '<button onclick="Button()">Gaan!</button>'
+ '</form><br><div id="ECoutput"></div><div id="ECarticleoutput"></div>';
if (document.location.href.indexOf('?user=') != -1) { getEC(); }
}
if(mw.config.get('wgNamespaceNumber') === -1 && (mw.config.get('wgTitle') === "Editcount" || mw.config.get('wgTitle') === "EditCount")
) {
$.when( $.ready, mw.loader.using(['mediawiki.util'])).done( ECpage );
} else if (document.getElementById("DisabledEditCount").innerHTML) {
document.getElementById("DisabledEditCount").innerHTML = "";
ECsjabloon();}