This is an old revision of this page, as edited by Technical 13(talk | contribs) at 21:10, 19 January 2014(Not sure why I'm getting a foo is not defined error... Trying to make this work with callbacks to deal with async issue...). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.Revision as of 21:10, 19 January 2014 by Technical 13(talk | contribs)(Not sure why I'm getting a foo is not defined error... Trying to make this work with callbacks to deal with async issue...)
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
// TODO -- make a [[User:AzaToth/morebits.js]] version of this input sequencefunctioncreateTable(){vartable="{| class=\"collapsible collapsed sortable\" width=\"95%\" border=\"1\"";table+="\n|-\n! colspan=\"5\"| Pageview stats for pages related to "+relatedTopic;table+="\n|-\n! Page Name !! width=\"15%\"| Hits in 30 days !! width=\"15%\"| Hits in 60 days !! width=\"15%\"| Hits in 90 days !! width=\"5%\"| Rank";for(varpageinallData){table+="\n|- style=\"text-align: center;\"";table+="\n| style=\"text-align: left; font-weight: bold;\" | [["+pageNames[pageName]+"]] ";table+="|| {{Plainlinks|url=http://stats.grok.se/"+lang+"/latest30/"+encodeURIComponent(pageNames[pageName])+"|name={{SUBST:formatnumber:"+allData[foo].hits30+"}}}} ";table+="|| {{Plainlinks|url=http://stats.grok.se/"+lang+"/latest60/"+encodeURIComponent(pageNames[pageName])+"|name={{SUBST:formatnumber:"+allData[foo].hits60+"}}}} ";table+="|| {{Plainlinks|url=http://stats.grok.se/"+lang+"/latest90/"+encodeURIComponent(pageNames[pageName])+"|name={{SUBST:formatnumber:"+allData[foo].hits90+"}}}} ";if(allData[foo].rank<1||allData[foo].rank>1000){table+="|| Not in the top 1,000";}else{table+="|| "+allData[foo].rank;}}table+="\n|}";alert(table);}//var lang = mw.config.get("wgPageContentLanguage");if(typeof(lang)==="undefined"){lang=prompt("Get results in what language?","en");}//var relatedTopic = mw.config.get("wgTitle").substr(0, mw.config.get("wgTitle").indexOf("/"));if(typeof(relatedTopic)==="undefined"||relatedTopic===""){relatedTopic=prompt("What are these pages related to?","{{PAGENAME}}");}varpageNames=prompt("Page names to get results for?",/*"Augustus Pablo|Avian Java|Bentley Java|Chrysler Java|Coffee|Coffee County, Alabama|HMS Java|Java|Java, Alabama|Java, New York|Java, Ohio|Java, South Dakota|Java, São Tomé and Príncipe|Java, Virginia|Java-eiland|JavaScript|Java (Martin Mystère)|Java (band)|Java (board game)|Java (chicken)|Java (cigarette)|Java (composition)|Java (dance)|Java (programming language)|Java (software platform)|Java (town)|Java District|Java Joel|Java Man|Java Road|Java Sea|Java Trench|Java class cruiser|Java coffee|Java virtual machine|Javanese (disambiguation)|Javanese alphabet|List of The Tribe characters|Metamorpho|SS Java|USS Java (1815)"*/"foo");if(pageNames.indexOf("|")===-1){pageNames=newArray(pageNames);}else{pageNames=pageNames.split("|");}varrangeToGet=newArray(30,60,90);varallData=[];varhits30=0;varhits60=0;varhits90=0;for(varpageNameinpageNames){for(vardaysToGetinrangeToGet){$.ajax({url:'http://stats.grok.se/jsonp/'+lang+'/latest'+rangeToGet[daysToGet]+'/'+encodeURIComponent(pageNames[pageName]),dataType:'jsonp',jsonpCallback:'pageviewsCallback',success:function(getStats){varpageHits=0;for(vardateingetStats.daily_views){pageHits+=getStats.daily_views[date];}switch(rangeToGet[daysToGet]){case30:allData[foo].rank=getStats.rank;allData[foo].hits30=pageHits;break;case60:allData[foo].hits60=pageHits;break;case90:allData[foo].hits90=pageHits;break;default:break;}},fail:function(errorMsg){alert("Failed to get results for: http://stats.grok.se/jsonp/"+lang+"/latest"+rangeToGet[daysToGet]+"/"+encodeURIComponent(pageNames[pageName])+"\nInstead received:"+errorMsg);}});}}