MediaWiki:Gadget-dropdown.js

From Zeah RSPS - Wiki
Revision as of 08:35, 16 February 2022 by Soulgazer (talk | contribs) (Created page with "→‎* * add various useful links to the "More" dropdown menu * * References: * <https://www.mediawiki.org/wiki/ResourceLoader/Core_modules#addPortletLink> * <https://en.wikipedia.org/wiki/Help:Customizing_toolbars>: $( function () { var conf = mw.config.get([ 'wgPageName', 'wgNamespaceNumber', 'wgArticlePath' ]) if (conf.wgNamespaceNumber === -1) { return; // don't run on special pages } // link to the most recent diff à la Twinkle...")
(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 various useful links to the "More" dropdown menu
 * 
 * References:
 * <https://www.mediawiki.org/wiki/ResourceLoader/Core_modules#addPortletLink>
 * <https://en.wikipedia.org/wiki/Help:Customizing_toolbars>
 */
$( function () {
	var conf = mw.config.get([
		'wgPageName',
		'wgNamespaceNumber',
		'wgArticlePath'
    ])
    
    if (conf.wgNamespaceNumber === -1) {
    	return; // don't run on special pages
    }

	// link to the most recent diff à la Twinkle
	mw.util.addPortletLink(
		'p-cactions',
		conf.wgArticlePath.replace('$1', conf.wgPageName + '?diff=cur'),
		'Last',
		'ca-diff',
		'Show most recent diff'
	);

	// link to subpages of the current page
	mw.util.addPortletLink(
		'p-cactions',
		conf.wgArticlePath.replace('$1', 'Special:PrefixIndex/' + conf.wgPageName + '/'),
		'Subpages',
		'ca-subpages',
		'List this page\'s subpages'
	);
	
	// link to SMW properties for the current page
	mw.util.addPortletLink(
		'p-cactions',
		conf.wgArticlePath.replace('$1', 'Special:Browse/' + conf.wgPageName),
		'Page properties',
		'ca-properties',
		'List this page\'s semantic properties'
	);
});