User:WhoSaidThat/MyScript.js

/*

October 2011 Coding Challenge http://creativecommons.org/licenses/by-sa/3.0/

Description: Launch Script Author: J Wyatt, Nov 2011



(function{

function begin{ importScriptsInOrder( 		['User:WhoSaidThat/RevisionData.js','User:WhoSaidThat/RDSet.js' ,'User:WhoSaidThat/RevisionsUI.js',		function(hist){	 var r=new RevisionsData(wgPageName,loadCompleted,function(a,b,c,d){ alert(a+' '+b+' '+c+' '+d) });	}],		true,		'http://en.wikipedia.org/w/index.php'	);

}

$( document ). ready( begin );

// A function using $.getWikiScript to load wiki user scripts and/or execute functions in a specific order (storing and passing the results) //

// function	importScriptsInOrder	Array of Strings	Boolean			String //					user script pages	force reload		alternative base path (default - wgScript) //								(prevent browser cache)

function importScriptsInOrder(pages,forceRefresh,basePath) {

var order={ 'pages':pages, 'success':[], 'index':0, 'returnValues':[], 'forceRefresh':forceRefresh, 'basePath':basePath?basePath:wgScript, 'getNext':function{ if(typeof(this.pages[this.index])=='function'){

this.returnValues[this.index]=this.pages[this.index](this); this.index++; this.getNext;

}else{ var sFn=function(data){ this.returnValues[this.index]=data; this.success[this.index]=true; this.index++; this.getNext; };					var fFn=function(a,b,c){ this.returnValues[this.index]=[a,b,c]; this.success[this.index]=false; this.index++; this.getNext; };					var jQparams={'success':sFn,'error':fFn,'context':this} $.getWikiScript(this.pages[this.index],jQparams,this.forceRefresh,this.basePath); }			}	}

order.getNext;

}

if(!$.getWikiScript){

$.getWikiScript=function(pageName,params,forceRefresh,basePath){ if(!pageName) return false; if(!basePath) basePath="http://en.wikipedia.org/w/index.php"; if(!params) params={}; params.dataType='script'; if(!params.success) params.success=(function{}); params.url = basePath + "?title=" + pageName.replace(/ /g, "_").replace(/%2F/gi, "/").replace(/%3A/gi, ":") + "&action=raw&ctype=text/javascript";

if(forceRefresh) params.url+='&random='+(new Date).getTime;

$.ajax(params); }

}

});