Misplaced Pages

User:Animum/count.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Animum Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 01:19, 19 February 2008 view sourceAnimum (talk | contribs)30,489 editsm hm.← Previous edit Revision as of 01:21, 19 February 2008 view source Animum (talk | contribs)30,489 editsm ...Next edit →
Line 28: Line 28:
addOnloadHook(addcountedit); addOnloadHook(addcountedit);


function docountedit() {
var req = new XMLHttpRequest();
req.open("GET", "http://en.wikipedia.org/w/api.php?action=query&list=users&usprop=editcount&ususers=" + encodeURIComponent(countuser) + "&format=xml", true);
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
var user = req.responseXML.getElementsByTagName('user');
var count = user.getAttribute('editcount');
if (count != null)
alert(user.getAttribute('name') + " has " + count + " surviving edit" + (count == 1 ? "." : "s."));
}
}
req.send();
}
//</nowiki></pre> //</nowiki></pre>

Revision as of 01:21, 19 February 2008

//<pre><nowiki>
importScript('User:Voice of All/Addtabs/monobook.js');

function addcountedit() { 
  var subpagename = wgTitle.split( '/' );
  if( (wgNamespaceNumber == '2' || wgNamespaceNumber == '3' || ( wgNamespaceNumber == '-1' && wgTitle == 'Contributions' )) && !subpagename ) { 
    var countuser = wgTitle.split( '/' );
    if( wgNamespaceNumber == '-1' && wgTitle == 'Contributions') {
     if(!document.getElementById( 'contentSub' )) return; 
    countuser = document.getElementById( 'contentSub' ).getElementsByTagName( 'a' ).getAttribute('title').split(':');
    }
    docountedit = function() {
     var req = new XMLHttpRequest();
     req.open("GET", "http://en.wikipedia.org/w/api.php?action=query&list=users&usprop=editcount&ususers=" + encodeURIComponent(countuser) + "&format=xml", true);
      req.onreadystatechange = function() {
        if (req.readyState == 4 && req.status == 200) {
         var user = req.responseXML.getElementsByTagName('user');
         var count = user.getAttribute('editcount');
         if (count != null)
         alert(user.getAttribute('name') + " has " + count + " surviving edit" + (count == 1 ? "." : "s."));
      } 
     }
    req.send();
    }
     addPortletLink("p-tb", 'javascript:docountedit()', "Edit count", '', 't-count');
  }
}
addOnloadHook(addcountedit);

//</nowiki></pre>