Jump to content

User:MusikAnimal/scriptManager.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MusikAnimal (talk | contribs) at 18:58, 16 November 2014. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
(function() {
	var scriptsToEnable;
	var $html = $("<div class='portal' role='navigation' id='p-enable_scripts' aria-labelledby='p-enable_scripts-label'></div>");
	$html.append("<h3 id='p-enable_scripts-label'>Enable scripts</h3>");
	$html.append("<div class='body'><ul></ul></div>");
 
	var loadScript = function(e) {
		$.getScript(e.data.src);
		$(e.target).parent().remove();
	};
 
 	if(scriptsToEnable) {
		$.each(scriptsToEnable, function(script, src) {
		  var scriptName = script.replace(/ /g,"_");
		  $html.find("ul").append("<li><a href='javascript:' id='t-enablescript-"+scriptName+"'>"+script+"</a></li>");
		  $("#mw-panel").append($html);
		  $("#t-enablescript-"+scriptName).click({
		  	script: script,
		  	src: src
		  }, loadScript);
		});
 	} else {
 		$html.find("ul").append("<li><a href='//en.wikipedia.org/User:MusikAnimal/scriptManager'>No scripts enabled!</a></li>")
 	}
}());