MediaWiki:Gadget-gadgetLinks.js

From Zeah RSPS - Wiki
Revision as of 08:33, 16 February 2022 by Soulgazer (talk | contribs) (Created page with "// Add gadget links to the gadgets that are being defined on MediaWiki:Gadgets-definition $(function() { function gadgetLink(page) { return '<a href="/w/MediaWiki:Gadget-'+page+'" title="MediaWiki:Gadget-'+page+'">'+page+'</a>'; } $('.page-MediaWiki_Gadgets-definition #bodyContent ul li').not('#toc li').each(function() { var txt = this.innerHTML; var links = txt.replace(/([a-zA-Z-]+)(\^\+\]\|)(.*)/, function(match, name, options, filelist) {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.
// Add gadget links to the gadgets that are being defined on [[MediaWiki:Gadgets-definition]]

$(function() {
	function gadgetLink(page) {
	    return '<a href="/w/MediaWiki:Gadget-'+page+'" title="MediaWiki:Gadget-'+page+'">'+page+'</a>';
	}
	$('.page-MediaWiki_Gadgets-definition #bodyContent ul li').not('#toc li').each(function() {
	    var txt = this.innerHTML;
	    var links = txt.replace(/([a-zA-Z-]+)(\[[^\]]+\]\|)(.*)/, function(match, name, options, filelist) {
	        var files = filelist.split('|');
	        files = files.map(function(file) { return gadgetLink(file); });
	        return gadgetLink(name) + options + files.join('|');
	    });
	    $(this).html(links);
	});
});