Jump to content

User:Paranomia/editcount.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Paranomia (talk | contribs) at 20:38, 21 April 2008 (fix). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// scraped from VoA's code
function get_editcount_json(user)
{
document.getElementById('contentSub').innerHTML += '<br><strong>Grabbing edit count.' + '\n' + 'Please wait...</strong>';
gml_xmlhttp = sajax_init_object();
if (!gml_xmlhttp)
{
return;
}
var pageurl = '/w/api.php?action=query&list=users&ususers=' + escape(user) + '&usprop=editcount&format=json';
gml_xmlhttp.open("GET", pageurl, true);
gml_xmlhttp.onreadystatechange = alertcount;
gml_xmlhttp.send(null);
}
function alertcount()
{
if (gml_xmlhttp.readyState !== 4)
{
return;
}
json = gml_xmlhttp.responseText;
var obj = eval('('+json+')');
var editcount = '(username invalid)';
document.getElementById('contentSub').innerHTML += '<br><span style="color:blue;"><strong>' + obj.query.users[0].editcount + '</strong></span>';
}