MediaWiki:Gadget-calculatorNS.js

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 /**
 2  * Adds a link to the main calculators directory to every calculator namespace page
 3  *		in the same place as other subpage links (creates the element if required)
 4  *
 5  * @author Gaz Lloyd
 6  */
 7 $(function () {
 8 	if (mw.config.get('wgNamespaceNumber') !== 116) {
 9 		return;
10 	}
11 	
12 	function init() {
13 		// duplication prevention
14 		if ($('#contentSub .subpages .calculatorDirectoryLink').length) return;
15 		var link = $('<a>')
16 					.attr({
17 						href: mw.util.getUrl('Calculators'),
18 						title: 'Calculator directory',
19 					})
20 					.addClass('calculatorDirectoryLink')
21 					.text('All Calculators');
22 		if ($('#contentSub .subpages').length) {
23 			$('#contentSub .subpages a').first().before(link, ' | ');
24 		} else {
25 			$('#contentSub').append(
26 				$('<span>')
27 					.addClass('subpages')
28 					.append('< ', link)
29 			);
30 		}
31 	}
32 	
33 	init()
34 })