Jump to content

User:Ais523/sandbox.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ais523 (talk | contribs) at 08:43, 12 October 2007 (maybe using += will be more efficient?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
//Example to find approx total edit count as of 12 October 2007:
//http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Wikipedia:Sandbox&rvprop=ids&rvlimit=1&rvdir=older&rvstart=2007101200000&format=xml

var esjwpajax;
// From [[WP:US]] mainpage (wpajax renamed to esjwpajax)
esjwpajax={
        download:function(bundle) {
                // mandatory: bundle.url
                // optional:  bundle.onSuccess (xmlhttprequest, bundle)
                // optional:  bundle.onFailure (xmlhttprequest, bundle)
                // optional:  bundle.otherStuff OK too, passed to onSuccess and onFailure
 
                var x = window.XMLHttpRequest ? new XMLHttpRequest()
                : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
                : false;
 
                if (x) {
                        x.onreadystatechange=function() {
                                x.readyState==4 && esjwpajax.downloadComplete(x,bundle);
                        };
                        x.open("GET",bundle.url,true);
                        x.send(null); 
                }
                return x;
        },
 
        downloadComplete:function(x,bundle) {
                x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true )
                || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText));
        }
};

var dldate;

if(location.href=="http://en.wikipedia.org/w/index.php?title=User:Ais523/Stats&action=edit")
{
addOnloadHook(function(){
  document.getElementById('wpTextbox1').value='';
  dldate=new Date();
  dl1day();
});
}

function dl1daycomplete(x,d)
{
  var a=x.responseText.split('revid="')[1].split('"')[0];
  document.getElementById('wpTextbox1').value+=a+"\n";
  dl1day();
}

function dl1day()
{
  var datestamp=(dldate.getUTCFullYear()*10000+dldate.getUTCMonth()*100+dldate.getUTCDate()+100);
  document.getElementById('wpTextbox1').value+=" "+datestamp+" ";
  dldate.setUTCDate(dldate.getUTCDate()-1);
  esjwpajax.download({url:
"http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Wikipedia:Sandbox&rvprop=ids&rvlimit=1&rvdir=older&rvstart="+
                          datestamp+"000000&format=xml",onSuccess:dl1daycomplete});
}