MediaWiki:Gadget-twinkleunlink.js: Difference between revisions
Jump to navigation
Jump to search
m (1 revision imported) |
(Localise) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
**************************************** | **************************************** | ||
* Mode of invocation: Tab ("Unlink") | * Mode of invocation: Tab ("Unlink") | ||
* Active on: Non-special pages, except | * Active on: Non-special pages, except Sarkarverse:Sandbox | ||
* Config directives in: TwinkleConfig | * Config directives in: TwinkleConfig | ||
*/ | */ | ||
Twinkle.unlink = function twinkleunlink() { | Twinkle.unlink = function twinkleunlink() { | ||
if( mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgPageName') === ' | if( mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgPageName') === 'Sarkarverse:Sandbox' ) { | ||
return; | return; | ||
} | } | ||
Twinkle.addPortletLink( Twinkle.unlink.callback, "Unlink", "tw-unlink", "Unlink backlinks" ); | // Restrict to extended confirmed users. This is done here instead of above to avoid an unnecessary API call. | ||
mw.user.getRights().then(function (rights) { | |||
if( rights.indexOf('extendedconfirmed') !== -1 ) { | |||
Twinkle.addPortletLink( Twinkle.unlink.callback, "Unlink", "tw-unlink", "Unlink backlinks" ); | |||
} | |||
}); | |||
}; | }; | ||
Line 39: | Line 44: | ||
Window.setTitle( "Unlink backlinks" + (mw.config.get('wgNamespaceNumber') === 6 ? " and file usages" : "") ); | Window.setTitle( "Unlink backlinks" + (mw.config.get('wgNamespaceNumber') === 6 ? " and file usages" : "") ); | ||
Window.setScriptName( "Twinkle" ); | Window.setScriptName( "Twinkle" ); | ||
Window.addFooterLink( "Twinkle help", " | Window.addFooterLink( "Twinkle help", "SV:TW/DOC#unlink" ); | ||
var form = new Morebits.quickForm( Twinkle.unlink.callback.evaluate ); | var form = new Morebits.quickForm( Twinkle.unlink.callback.evaluate ); | ||
// prepend some basic documentation | // prepend some basic documentation | ||
var node1 = Morebits.htmlNode("code", "[[" + Morebits.pageNameNorm + "|link text]]") | var node1 = Morebits.htmlNode("code", "[[" + Morebits.pageNameNorm + "|link text]]"); | ||
var node2 = Morebits.htmlNode("code", "link text"); | var node2 = Morebits.htmlNode("code", "link text"); | ||
node1.style.fontFamily = node2.style.fontFamily = "monospace"; | node1.style.fontFamily = node2.style.fontFamily = "monospace"; | ||
Line 169: | Line 174: | ||
type: 'div', | type: 'div', | ||
label: "Selected namespaces: " + namespaces.join(', '), | label: "Selected namespaces: " + namespaces.join(', '), | ||
tooltip: "You can change this with your Twinkle preferences, at [[ | tooltip: "You can change this with your Twinkle preferences, at [[SV:TWPREFS]]" | ||
}); | }); | ||
if ($(xmlDoc).find('query-continue').length) { | if ($(xmlDoc).find('query-continue').length) { | ||
Line 215: | Line 220: | ||
type: 'div', | type: 'div', | ||
label: "Selected namespaces: " + namespaces.join(', '), | label: "Selected namespaces: " + namespaces.join(', '), | ||
tooltip: "You can change this with your Twinkle preferences, at [[ | tooltip: "You can change this with your Twinkle preferences, at [[SV:TWPREFS]]" | ||
}); | }); | ||
if ($(xmlDoc).find('query-continue').length) { | if ($(xmlDoc).find('query-continue').length) { | ||
Line 266: | Line 271: | ||
var wikiPage = new Morebits.wikitext.page(oldtext); | var wikiPage = new Morebits.wikitext.page(oldtext); | ||
var summaryText = "", warningString = false; | var summaryText = "", warningString = false; | ||
var text; | var text; |