Skip to content

Commit

Permalink
arrow-body-style
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae committed Nov 21, 2024
1 parent baa0e47 commit b780303
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 207 deletions.
32 changes: 8 additions & 24 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,35 +669,27 @@ Twinkle.arv.callback.evaluate = function(e) {
}

sockParameters.uid = puppetReport ? form.sockmaster.value.trim() : uid;
sockParameters.sockpuppets = puppetReport ? [uid] : Morebits.array.uniq($.map($('input:text[name=sockpuppet]', form), (o) => {
return $(o).val() || null;
}));
sockParameters.sockpuppets = puppetReport ? [uid] : Morebits.array.uniq($.map($('input:text[name=sockpuppet]', form), (o) => $(o).val() || null));

Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init(form);
Twinkle.arv.processSock(sockParameters);
break;

case 'an3':
var diffs = $.map($('input:checkbox[name=s_diffs]:checked', form), (o) => {
return $(o).data('revinfo');
});
var diffs = $.map($('input:checkbox[name=s_diffs]:checked', form), (o) => $(o).data('revinfo'));

if (diffs.length < 3 && !confirm('You have selected fewer than three offending edits. Do you wish to make the report anyway?')) {
return;
}

var warnings = $.map($('input:checkbox[name=s_warnings]:checked', form), (o) => {
return $(o).data('revinfo');
});
var warnings = $.map($('input:checkbox[name=s_warnings]:checked', form), (o) => $(o).data('revinfo'));

if (!warnings.length && !confirm('You have not selected any edits where you warned the offender. Do you wish to make the report anyway?')) {
return;
}

var resolves = $.map($('input:checkbox[name=s_resolves]:checked', form), (o) => {
return $(o).data('revinfo');
});
var resolves = $.map($('input:checkbox[name=s_resolves]:checked', form), (o) => $(o).data('revinfo'));
var free_resolves = $('input[name=s_resolves_free]').val();

var an3_next = function(free_resolves) {
Expand Down Expand Up @@ -817,9 +809,7 @@ Twinkle.arv.processSock = function(params) {

// prepare the SPI report
let text = '\n{{subst:SPI report|' +
params.sockpuppets.map((sock, index) => {
return (index + 1) + '=' + sock;
}).join('|') + '\n|evidence=' + params.evidence + ' \n';
params.sockpuppets.map((sock, index) => (index + 1) + '=' + sock).join('|') + '\n|evidence=' + params.evidence + ' \n';

if (params.checkuser) {
text += '|checkuser=yes';
Expand Down Expand Up @@ -914,17 +904,11 @@ Twinkle.arv.processAN3 = function(params) {
const label = 'Consecutive edits made from ' + new Morebits.date(first.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) to ' + new Morebits.date(last.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)';
ret = '# {{diff|oldid=' + first.parentid + '|diff=' + last.revid + '|label=' + label + '}}\n';
}
ret += sub.reverse().map((v) => {
return (sub.length >= 2 ? '#' : '') + '# {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v);
}).join('\n');
ret += sub.reverse().map((v) => (sub.length >= 2 ? '#' : '') + '# {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n');
return ret;
}).reverse().join('\n');
const warningtext = params.warnings.reverse().map((v) => {
return '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v);
}).join('\n');
let resolvetext = params.resolves.reverse().map((v) => {
return '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v);
}).join('\n');
const warningtext = params.warnings.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n');
let resolvetext = params.resolves.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n');

if (params.free_resolves) {
const page = params.free_resolves;
Expand Down
40 changes: 10 additions & 30 deletions modules/twinklebatchdelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,15 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() {
const wikipedia_api = new Morebits.wiki.api('loading...', query, ((apiobj) => {
const response = apiobj.getResponse();
let pages = (response.query && response.query.pages) || [];
pages = pages.filter((page) => {
return !page.missing && page.imagerepository !== 'shared';
});
pages = pages.filter((page) => !page.missing && page.imagerepository !== 'shared');
pages.sort(Twinkle.sortByNamespace);
pages.forEach((page) => {
const metadata = [];
if (page.redirect) {
metadata.push('redirect');
}

const editProt = page.protection.filter((pr) => {
return pr.type === 'edit' && pr.level === 'sysop';
}).pop();
const editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop();
if (editProt) {
metadata.push('fully protected' +
(editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.date(editProt.expiry).calendar('utc') + ' (UTC)'));
Expand Down Expand Up @@ -231,9 +227,7 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() {
name: 'pages',
id: 'tw-dbatch-pages',
shiftClickSupport: true,
list: $.map(Twinkle.batchdelete.pages, (e) => {
return e;
})
list: $.map(Twinkle.batchdelete.pages, (e) => e)
});
form.append({ type: 'submit' });

Expand Down Expand Up @@ -265,9 +259,7 @@ Twinkle.batchdelete.generateNewPageList = function(form) {
name: 'pages',
id: 'tw-dbatch-pages',
shiftClickSupport: true,
list: $.map(Twinkle.batchdelete.pages, (e) => {
return e;
})
list: $.map(Twinkle.batchdelete.pages, (e) => e)
}).render();
};

Expand Down Expand Up @@ -306,9 +298,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e)
const loadingText = '<strong id="dbatch-subpage-loading">Loading... </strong>';
$(e.target).after(loadingText);

const pages = $(form.pages).map((i, el) => {
return el.value;
}).get();
const pages = $(form.pages).map((i, el) => el.value).get();

const subpageLister = new Morebits.batchOperation();
subpageLister.setOption('chunkSize', Twinkle.getPref('batchChunks'));
Expand Down Expand Up @@ -343,9 +333,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e)
metadata.push('redirect');
}

const editProt = page.protection.filter((pr) => {
return pr.type === 'edit' && pr.level === 'sysop';
}).pop();
const editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop();
if (editProt) {
metadata.push('fully protected' +
(editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.date(editProt.expiry).calendar('utc') + ' (UTC)'));
Expand Down Expand Up @@ -422,9 +410,7 @@ Twinkle.batchdelete.callback.evaluate = function twinklebatchdeleteCallbackEvalu

const form = event.target;

const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => {
return element.checked && element.nextElementSibling.style.color === 'red';
}).length;
const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => element.checked && element.nextElementSibling.style.color === 'red').length;
if (numProtected > 0 && !confirm('You are about to delete ' + mw.language.convertNumber(numProtected) + ' fully protected page(s). Are you sure?')) {
return;
}
Expand Down Expand Up @@ -572,9 +558,7 @@ Twinkle.batchdelete.callbacks = {
deleteRedirectsMain: function(apiobj) {
const response = apiobj.getResponse();
let pages = response.query.pages[0].redirects || [];
pages = pages.map((redirect) => {
return redirect.title;
});
pages = pages.map((redirect) => redirect.title);
if (!pages.length) {
return;
}
Expand Down Expand Up @@ -605,9 +589,7 @@ Twinkle.batchdelete.callbacks = {
unlinkBacklinksMain: function(apiobj) {
const response = apiobj.getResponse();
let pages = response.query.backlinks || [];
pages = pages.map((page) => {
return page.title;
});
pages = pages.map((page) => page.title);
if (!pages.length) {
return;
}
Expand Down Expand Up @@ -658,9 +640,7 @@ Twinkle.batchdelete.callbacks = {
unlinkImageInstancesMain: function(apiobj) {
const response = apiobj.getResponse();
let pages = response.query.imageusage || [];
pages = pages.map((page) => {
return page.title;
});
pages = pages.map((page) => page.title);
if (!pages.length) {
return;
}
Expand Down
18 changes: 6 additions & 12 deletions modules/twinklebatchprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() {
name: 'movelevel',
label: 'Move protection:',
event: Twinkle.protect.formevents.movelevel,
list: Twinkle.protect.protectionLevels.filter((level) => {
list: Twinkle.protect.protectionLevels.filter((level) =>
// Autoconfirmed is required for a move, redundant
return level.value !== 'autoconfirmed';
})
level.value !== 'autoconfirmed'
)
});
form.append({
type: 'select',
Expand Down Expand Up @@ -189,9 +189,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() {

if (missing) {
metadata.push('page does not exist');
editProt = page.protection.filter((pr) => {
return pr.type === 'create' && pr.level === 'sysop';
}).pop();
editProt = page.protection.filter((pr) => pr.type === 'create' && pr.level === 'sysop').pop();
} else {
if (page.redirect) {
metadata.push('redirect');
Expand All @@ -204,9 +202,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() {
metadata.push(mw.language.convertNumber(page.revisions[0].size) + ' bytes');
}

editProt = page.protection.filter((pr) => {
return pr.type === 'edit' && pr.level === 'sysop';
}).pop();
editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop();
}
if (editProt) {
metadata.push('fully' + (missing ? ' create' : '') + ' protected' +
Expand Down Expand Up @@ -261,9 +257,7 @@ Twinkle.batchprotect.callback.evaluate = function twinklebatchprotectCallbackEva

const form = event.target;

const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => {
return element.checked && element.nextElementSibling.style.color === 'red';
}).length;
const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => element.checked && element.nextElementSibling.style.color === 'red').length;
if (numProtected > 0 && !confirm('You are about to act on ' + mw.language.convertNumber(numProtected) + ' fully protected page(s). Are you sure?')) {
return;
}
Expand Down
12 changes: 3 additions & 9 deletions modules/twinklebatchundelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,11 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() {
const wikipedia_api = new Morebits.wiki.api('loading...', query, ((apiobj) => {
const response = apiobj.getResponse();
let pages = (response.query && response.query.pages) || [];
pages = pages.filter((page) => {
return page.missing;
});
pages = pages.filter((page) => page.missing);
const list = [];
pages.sort(Twinkle.sortByNamespace);
pages.forEach((page) => {
const editProt = page.protection.filter((pr) => {
return pr.type === 'create' && pr.level === 'sysop';
}).pop();
const editProt = page.protection.filter((pr) => pr.type === 'create' && pr.level === 'sysop').pop();

const title = page.title;
list.push({
Expand Down Expand Up @@ -122,9 +118,7 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() {
Twinkle.batchundelete.callback.evaluate = function(event) {
Morebits.wiki.actionCompleted.notice = 'Batch undeletion is now complete';

const numProtected = Morebits.quickForm.getElements(event.target, 'pages').filter((element) => {
return element.checked && element.nextElementSibling.style.color === 'red';
}).length;
const numProtected = Morebits.quickForm.getElements(event.target, 'pages').filter((element) => element.checked && element.nextElementSibling.style.color === 'red').length;
if (numProtected > 0 && !confirm('You are about to undelete ' + numProtected + ' fully create protected page(s). Are you sure?')) {
return;
}
Expand Down
32 changes: 8 additions & 24 deletions modules/twinkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ Twinkle.block.processUserInfo = function twinkleblockProcessUserInfo(data, fn) {

Twinkle.block.isRegistered = !!userinfo.userid;
if (Twinkle.block.isRegistered) {
Twinkle.block.userIsBot = !!userinfo.groupmemberships && userinfo.groupmemberships.map((e) => {
return e.group;
}).indexOf('bot') !== -1;
Twinkle.block.userIsBot = !!userinfo.groupmemberships && userinfo.groupmemberships.map((e) => e.group).indexOf('bot') !== -1;
} else {
Twinkle.block.userIsBot = false;
}
Expand Down Expand Up @@ -315,9 +313,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction
prior.list = [{ label: 'Prior block settings', value: 'prior', selected: true }];

// Arrays of objects are annoying to check
if (!blockGroup.some((bg) => {
return bg.label === prior.label;
})) {
if (!blockGroup.some((bg) => bg.label === prior.label)) {
blockGroup.push(prior);
}

Expand All @@ -333,9 +329,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction
}
} else {
// But first remove any prior prior
blockGroup = blockGroup.filter((bg) => {
return bg.label !== prior.label;
});
blockGroup = blockGroup.filter((bg) => bg.label !== prior.label);
}

// Can be in preset or template field, so the old one in the template
Expand Down Expand Up @@ -521,9 +515,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction

Twinkle.block.dsinfo.then((dsinfo) => {
const $select = $('[name="dstopic"]');
const $options = $.map(dsinfo, (value, key) => {
return $('<option>').val(value.code).text(key).prop('label', key);
});
const $options = $.map(dsinfo, (value, key) => $('<option>').val(value.code).text(key).prop('label', key));
$select.append($options);
});

Expand Down Expand Up @@ -1547,9 +1539,7 @@ Twinkle.block.callback.toggle_see_alsos = function twinkleblockCallbackToggleSee
new RegExp('( <!--|;) ' + 'see also ' + Twinkle.block.seeAlsos.join(' and ') + '( -->)?'), ''
);

Twinkle.block.seeAlsos = Twinkle.block.seeAlsos.filter((el) => {
return el !== this.value;
});
Twinkle.block.seeAlsos = Twinkle.block.seeAlsos.filter((el) => el !== this.value);

if (this.checked) {
Twinkle.block.seeAlsos.push(this.value);
Expand Down Expand Up @@ -1643,9 +1633,7 @@ Twinkle.block.callback.update_form = function twinkleblockCallbackUpdateForm(e,
// Add any preset options; in practice, just used for prior block settings
if (data.restrictions) {
if (data.restrictions.pages && !$pageSelect.val().length) {
const pages = data.restrictions.pages.map((pr) => {
return pr.title;
});
const pages = data.restrictions.pages.map((pr) => pr.title);
// since page restrictions use an ajax source, we
// short-circuit that and just add a new option
pages.forEach((page) => {
Expand Down Expand Up @@ -1974,16 +1962,12 @@ Twinkle.block.callback.getBlockNoticeWikitext = function(params) {
};
text += '|area=' + (params.indefinite ? 'certain ' : 'from certain ');
if (params.pagerestrictions.length) {
text += 'pages (' + makeSentence(params.pagerestrictions.map((p) => {
return '[[:' + p + ']]';
}));
text += 'pages (' + makeSentence(params.pagerestrictions.map((p) => '[[:' + p + ']]'));
text += params.namespacerestrictions.length ? ') and certain ' : ')';
}
if (params.namespacerestrictions.length) {
// 1 => Talk, 2 => User, etc.
const namespaceNames = params.namespacerestrictions.map((id) => {
return menuFormattedNamespaces[id];
});
const namespaceNames = params.namespacerestrictions.map((id) => menuFormattedNamespaces[id]);
text += '[[Wikipedia:Namespace|namespaces]] (' + makeSentence(namespaceNames) + ')';
}
} else if (params.area) {
Expand Down
4 changes: 1 addition & 3 deletions modules/twinkledeprod.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ Twinkle.deprod.callback = function() {
metadata.push(concerns[title]);
}

const editProt = page.protection.filter((pr) => {
return pr.type === 'edit' && pr.level === 'sysop';
}).pop();
const editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop();
if (editProt) {
metadata.push('fully protected' +
(editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + editProt.expiry));
Expand Down
Loading

0 comments on commit b780303

Please sign in to comment.