MediaWiki:Gadget-twinkleblock.js: Difference between revisions

Content deleted Content added
Repo at 5152750: revert $.extend autofixes (#2107)
Repo at 04d11bb: add regression test (#2110); fix no-useless-concat (#2100); fix prefer-const (#2099)
Line 3:
(function() {
 
letconst api = new mw.Api(),;
let relevantUserName, blockedUserName;
const menuFormattedNamespaces = $.extend({}, mw.config.get('wgFormattedNamespaces'));
menuFormattedNamespaces[0] = '(Article)';
Line 157 ⟶ 158:
// Twinkle.block.fetchUserInfo to allow reprocessing of already-fetched data
Twinkle.block.processUserInfo = function twinkleblockProcessUserInfo(data, fn) {
let blockinfo = data.query.blocks[0],;
const userinfo = data.query.users[0];
// If an IP is blocked *and* rangeblocked, the above finds
// whichever block is more recent, not necessarily correct.
Line 297 ⟶ 298:
 
Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction(e) {
let field_preset, field_template_options, field_block_options,;
const $form = $(e.target.form);
// Make ifs shorter
const blockBox = $form.find('[name=actiontype][value=block]').is(':checked');
Line 1,535 ⟶ 1,537:
Twinkle.block.callback.toggle_see_alsos = function twinkleblockCallbackToggleSeeAlso() {
const reason = this.form.reason.value.replace(
new RegExp('( <!--|;) ' + 'see also ' + Twinkle.block.seeAlsos.join(' and ') + '( -->)?'), ''
);
 
Line 1,573 ⟶ 1,575:
 
Twinkle.block.callback.update_form = function twinkleblockCallbackUpdateForm(e, data) {
letconst form = e.target.form,;
let expiry = data.expiry;
 
// don't override original expiry if useInitialOptions is set
Line 1,724 ⟶ 1,727:
 
Twinkle.block.callback.evaluate = function twinkleblockCallbackEvaluate(e) {
letconst $form = $(e.target),
toBlock = $form.find('[name=actiontype][value=block]').is(':checked'),
toWarn = $form.find('[name=actiontype][value=template]').is(':checked'),
toPartial = $form.find('[name=actiontype][value=partial]').is(':checked'),;
let blockoptions = {}, templateoptions = {};
 
Twinkle.block.callback.saveFieldset($form.find('[name=field_block_options]'));
Line 1,900 ⟶ 1,903:
const userTalkPage = 'User_talk:' + mw.config.get('wgRelevantUserName');
 
const params = $Twinkle.extendblock.combineFormDataAndFieldTemplateOptions(formData, {
messageData: formData,
Twinkle.block.blockPresetsInfo[formData.template],
reason: Twinkle.block.field_template_options.block_reason,
disabletalk: Twinkle.block.field_template_options.notalk,
noemail: Twinkle.block.field_template_options.noemail_template,
nocreate: Twinkle.block.field_template_options.nocreate_template
});
 
Morebits.wiki.actionCompleted.redirect = userTalkPage;
Line 1,914 ⟶ 1,918:
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.block.callback.main);
};
 
Twinkle.block.combineFormDataAndFieldTemplateOptions = function(formData, messageData, reason, disabletalk, noemail, nocreate) {
return $.extend(formData, {
messageData: messageData,
reason: reason,
disabletalk: disabletalk,
noemail: noemail,
nocreate: nocreate
});
};
 
Twinkle.block.callback.getBlockNoticeWikitext = function(params) {
let text = '{{',;
const settings = Twinkle.block.blockPresetsInfo[params.template];
if (!settings.nonstandard) {
text += 'subst:' + params.template;
Line 1,991 ⟶ 2,006:
 
Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) {
letconst params = pageobj.getCallbackParameters(),
date = new Morebits.Date(pageobj.getLoadTime()),
messageData = params.messageData,;
let text;
 
params.indefinite = Morebits.string.isInfinity(params.expiry);
Line 2,004 ⟶ 2,019:
text = pageobj.getPageText();
 
letconst dateHeaderRegex = date.monthHeaderRegex(),;
let dateHeaderRegexLast, dateHeaderRegexResult;
while ((dateHeaderRegexLast = dateHeaderRegex.exec(text)) !== null) {
dateHeaderRegexResult = dateHeaderRegexLast;