Bureaucrats, editor, Interface administrators, Administrators (Semantic MediaWiki), Curators (Semantic MediaWiki), Editors (Semantic MediaWiki), Administrators
47,327
edits
No edit summary Tag: Manual revert |
No edit summary |
||
Line 1:
"use strict";
/**
* Moves icons from [[Template:External]] to the top bar, next to "Article" and "Talk" tabs;
Line 4 ⟶ 6:
*/
(function ($, mw) {
// automatically show externals on Special and MediaWiki namespaces▼
if (namespace === -1 || namespace === 8) {▼
let page = mw.config.get('wgPageName');▼
addLink('the RuneScape Wiki', 'rsw', page);▼
addLink('the RuneScape Classic Wiki', 'classicrsw', page);▼
addLink('the Meta Weird Gloop Wiki', 'meta', page);▼
else {▼
// make this work when "Show preview without reloading the page" is checked▼
mw.hook('wikipage.content').add(function ($content) {▼
if (!$content.has('.rs-external-header-links').length) return;▼
// clear existing externals first so previewing doesn't add an infinite amount▼
$('.gadget-external-icon').remove();▼
// convert whatever [[Template:External]] gives us▼
$('.rs-header-icon').each(function (index, icon) {▼
addLink(icon.dataset.wikiname, icon.dataset.interwiki, icon.dataset.page);▼
});▼
// clean up▼
function addLink(wikiname, interwiki, page) {▼
let url = mw.util.getUrl(interwiki + ':' + page);▼
let title = wikiname + ' also has an article on ' + page + '.';▼
});
// wikipedia links aren't forwarded - see [[Special:Interwiki]]▼
url = '//en.wikipedia.org/wiki/' + encodeURIComponent(page);▼
// Special and MediaWiki namespaces▼
url += window.location.search; // include url parameters▼
}
title = 'Open this page on ' + wikiname + '.';▼
let link = mw.util.addPortletLink(▼
if (namespace === -1 || namespace === 8) {
'', // no text - use background-image instead▼
}
'gadget-external-' + interwiki, // button id▼
title // title text shown on hover▼
// button id
);
})(jQuery, mediaWiki);
|