User:WhoSaidThat/vector.js

// To save my sanity, a function to make sure the scripts I load are always refreshed and my f5 button remains unused.

// Not really the right way to add function to $. This function should properly be in mw.loader (maybe mw.loader.userScript) taking advantage of // http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/resources/mediawiki/mediawiki.js?view=markup#l706 mw.loaders improved private methods //

// function	getWikiScript		String			Object			Boolean/String			String //					Script page name	For jQuery	Force refresh using time based url	Url base path

$.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{}); if(!params.url){ params.url = basePath + "?title=" + pageName.replace(/ /g, "_").replace(/%2F/gi, "/").replace(/%3A/gi, ":") params.url += "&action=raw&ctype=text/javascript"; }

if(forceRefresh){ if(typeof forceRefresh != 'boolean') forceRefresh=forceRefresh+''; else forceRefresh='aZrandom'; params.url += '&' + forceRefresh + '='+(new Date).getTime; }

$.ajax(params); }

$.getWikiScript('User:WhoSaidThat/MyScript.js',null,true,'http://www.mediawiki.org/w/index.php');