Get data from stats.grok.se
This is the most basic component of a script that is suppose to retrieve the rank and total number of views (by cycling through the result and adding all of the values together) of a random page on Wikipedia.
JavaScript
var visitRank = 0;
var pageHits = 0;
console.log("Attempting to get data from: http://stats.grok.se/json/en/latest30/foo");
$.ajax({
url: 'http://stats.grok.se/jsonp/en/latest30/foo',
dataType: 'jsonp',
jsonpCallback: 'pageviewsCallback',
success: function(getStats){
console.error("getStats contains: %o", getStats);
for(var date in getStats.daily_views){
console.info("date = %s and getStats.daily_views[date] = %o", date, getStats.daily_views[date]);
pageHits += getStats.daily_views[date];
}
visitRank = getStats.rank;
console.warn("%f in hits30 and %f in rank.", pageHits, visitRank);
}
});