User:AHRtbA==/wpAPI.js

// /*
 * Wikipedia Javascript API v0.1.9b4
 * Created by AHRtbA==

wpAPI={Page:{},core:{Page:{},pageLoads:[]}};wpAPI.init=function{wpAPI.core.getEditToken};wpAPI.Page.load=function(a,b){wpAPI.core.pageLoads[a]={textLoad:false,infoLoad:false,data:{}};wpAPI.ajax({url:"title="+a+"&redirect=no&action=raw&ctype=text/plain&dontcountme=s",success:function(c,d){wpAPI.core.pageLoads[a].data.title=a;wpAPI.core.pageLoads[a].data.text=c;wpAPI.core.pageLoads[a].textLoad=true;wpAPI.core.checkPageLoad(a,b)},error:function{throw"There was an error when loading the page you requested ("+a+")"}});wpAPI.callAPI({param:"prop=revisions&titles="+encodeURI(a),success:function(d,e){var c=wpAPI.core.getFirstObject(d.query.pages);wpAPI.core.pageLoads[a].data.lastRevision={date:wpAPI.core.convertStrToDate(c.revisions[0].timestamp),user:c.revisions[0].user,comment:c.revisions[0].comment};wpAPI.core.pageLoads[a].infoLoad=true;wpAPI.core.checkPageLoad(a,b)}},"query")};wpAPI.core.checkPageLoad=function(b,d){var a=wpAPI.core.pageLoads[b];if(a.textLoad==true&&a.infoLoad==true){var c=wpAPI.core.combineObj(a.data,wpAPI.core.Page);d(c)}};wpAPI.core.Page.tplExists=function(a){return new RegExp("","i").test(this.text)};wpAPI.core.Page.replaceTpl=function(a,b){return this.text.replace(new RegExp("","gi"),"")};wpAPI.core.Page.save=function(c,b,a,d){wpAPI.callAPI({type:"POST",data:"title="+this.title+"&summary="+b+" (wpAPI)&text="+c+((a==true)?"&minor=true":"")+"&token="+wpAPI.core.editToken,success:function(e,f){if(e.edit.result=="Success"){if(typeof(d)=="function"){d}}else{throw"Error when saving page"}}},"edit")};wpAPI.callAPI=function(a,b){a.file="api.php";a.url="action="+b+"&format=json"+((a.param)?("&"+a.param):"");a.dataType="json";a.error=function{throw"Error making call to API"};wpAPI.ajax(a)};wpAPI.ajax=function(a){a.url=wpAPI.site+((a.file)?a.file:"index.php")+"?"+a.url;a.cache=false;return $.ajax(a)};wpAPI.core.getWikiSite=function{if(window.location.protocol=="https:"){return"/wikipedia/en/w/"}else{return"/w/"}};wpAPI.core.getEditToken=function{wpAPI.callAPI({param:"prop=info&intoken=edit&titles=Main%20Page",success:function(a,b){wpAPI.core.editToken=wpAPI.core.getFirstObject(a.query.pages).edittoken.replace("+\\","%2B%5C")}},"query")};wpAPI.core.getFirstObject=function(a){for(key in a){return a[key]}return""};wpAPI.core.combineObj=function{var a={};for(var b=0;b<arguments.length;b++){if(typeof(arguments[b])=="object"){for(key in arguments[b]){a[key]=arguments[b][key]}}}return a};wpAPI.core.convertStrToDate=function(b){var f=b.substring(b.indexOf("T")+1,b.indexOf("Z"));var c=b.substring(0,b.indexOf("T"));var a=c.substring(c.lastIndexOf("-")+1,c.length);var e=c.substring(c.indexOf("-")+1,c.lastIndexOf("-"));var d=c.substring(0,c.indexOf("-"));return new Date(Date.parse(e+" "+a+" "+d+" "+f))};wpAPI.core.encodeRE=function(a){return a.replace(/([.*+?^${}|[\]\/\\])/g,"\\$1")};wpAPI.site=wpAPI.core.getWikiSite; //