MediaWiki:Gadget-gadgetLinks.js

From Old School Near-Reality Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
 1 // Add gadget links to the gadgets that are being defined on [[MediaWiki:Gadgets-definition]]
 2 
 3 $(function() {
 4 	function gadgetLink(page) {
 5 	    return '<a href="/w/MediaWiki:Gadget-'+page+'" title="MediaWiki:Gadget-'+page+'">'+page+'</a>';
 6 	}
 7 	$('.page-MediaWiki_Gadgets-definition #bodyContent ul li').not('#toc li').each(function() {
 8 	    var txt = this.innerHTML;
 9 	    var links = txt.replace(/([a-zA-Z0-9-]+)(\[[^\]]+\]\|)(.*)/, function(match, name, options, filelist) {
10 	        var files = filelist.split('|');
11 	        files = files.map(function(file) { return gadgetLink(file); });
12 	        return gadgetLink(name) + options + files.join('|');
13 	    });
14 	    $(this).html(links);
15 	});
16 });