MediaWiki:Gadget-twinkleblock.js: Difference between revisions

Content deleted Content added
Repo at ac3c1e3: replace es-x/no-array-prototype-includes with unicorn/prefer-includes (#2125)
deploy #2180: soft redirect to Special:Block for multi-blocked targets
 
Line 4:
 
const api = new mw.Api();
let relevantUserName, blockedUserName, blockWindow;
const menuFormattedNamespaces = $.extend({}, mw.config.get('wgFormattedNamespaces'));
menuFormattedNamespaces[0] = '(Article)';
Line 35:
Twinkle.block.field_template_options = {};
 
const WindowblockWindow = new Morebits.SimpleWindow(650, 530);
// need to be verbose about who we're blocking
WindowblockWindow.setTitle('Block or issue block template to ' + relevantUserName);
WindowblockWindow.setScriptName('Twinkle');
WindowblockWindow.addFooterLink('Block templates', 'Template:Uw-block/doc/Block_templates');
WindowblockWindow.addFooterLink('Block policy', 'WP:BLOCK');
WindowblockWindow.addFooterLink('Block prefs', 'WP:TW/PREF#block');
WindowblockWindow.addFooterLink('Twinkle help', 'WP:TW/DOC#block');
WindowblockWindow.addFooterLink('Give feedback', 'WT:TW');
 
// Always added, hidden later if actual user not blocked
WindowblockWindow.addFooterLink('Unblock this user', 'Special:Unblock/' + relevantUserName, true);
 
const form = new Morebits.QuickForm(Twinkle.block.callback.evaluate);
Line 126:
 
const result = form.render();
WindowblockWindow.setContent(result);
WindowblockWindow.display();
result.root = result;
 
Line 155:
// Store fetched user data, only relevant if switching IPv6 to a /64
Twinkle.block.fetchedData = {};
// Processes the data from a a query response, separated from
// Twinkle.block.fetchUserInfo to allow reprocessing of already-fetched data
Twinkle.block.processUserInfo = function twinkleblockProcessUserInfo(data, fn) {
let blockinfo = data.query.blocks[0];
// Soft redirect to Special:Block if the user is multi-blocked (#2178)
if (blockinfo && data.query.blocks.length > 1) {
// Remove submission buttons.
$(blockWindow.content).dialog('widget').find('.morebits-dialog-buttons').empty();
Morebits.Status.init(blockWindow.content.querySelector('form'));
Morebits.Status.warn(
`This target has ${data.query.blocks.length} active blocks`,
`Multiblocks is not supported by Twinkle. Use [[Special:Block/${relevantUserName}]] instead.`
);
return;
}
const userinfo = data.query.users[0];
// If an IP is blocked *and* rangeblocked, the above finds