MediaWiki:Gadget-topIcons.js

From Old School Near-Reality Wiki
Revision as of 17:57, 3 October 2022 by Jacmob (talk | contribs) (Created page with "→‎* * Moves icons from [[Template:External]] to the top bar; rewritten from scratch for modern mediawiki * @author Gaz Lloyd: $(function () { if (mw.config.get('wgNamespaceNumber') === -1 || mw.config.get('wgNamespaceNumber') === 8) { mw.util.addPortletLink( 'p-namespaces', mw.util.getUrl('rsw:'+mw.config.get('wgPageName')), '', 'ca-nstab-external-link-rs', 'Open this '+(mw.config.get('wgNamespaceNumber') === -1 ? 'Special page':'system message')+' on...")
(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.
 1 /**
 2 * Moves icons from [[Template:External]] to the top bar; rewritten from scratch for modern mediawiki
 3 * @author Gaz Lloyd
 4 */
 5 $(function () {
 6 	if (mw.config.get('wgNamespaceNumber') === -1 || mw.config.get('wgNamespaceNumber') === 8) {
 7 		mw.util.addPortletLink(
 8 			'p-namespaces',
 9 			mw.util.getUrl('rsw:'+mw.config.get('wgPageName')),
10 			'',
11 			'ca-nstab-external-link-rs',
12 			'Open this '+(mw.config.get('wgNamespaceNumber') === -1 ? 'Special page':'system message')+' on the RuneScape Wiki'
13 		);
14 		mw.util.addPortletLink(
15 			'p-namespaces',
16 			mw.util.getUrl('classicrsw:'+mw.config.get('wgPageName')),
17 			'',
18 			'ca-nstab-external-link-rsc',
19 			'Open this '+(mw.config.get('wgNamespaceNumber') === -1 ? 'Special page':'system message')+' on the RuneScape Classic Wiki'
20 		);
21 	} else {
22 		$('div.rs-external-header-links span.rs-header-icon').each(function(i,e){
23 			var $e = $(e);
24 			var url, site, tooltip;
25 			url = $e.find('a').attr('href');
26 			site = $e.attr('data-site');
27 			tooltip = $e.attr('data-title');
28 			text = $e.attr('data-text');
29 			
30 			mw.util.addPortletLink(
31 				'p-namespaces',
32 				url,
33 				'',
34 				'ca-nstab-external-link-'+site,
35 				tooltip
36 			);
37 		});
38 		$('div.rs-external-header-links').remove();
39 	}
40 })