MediaWiki:Gadget-morebits.js: Difference between revisions

Content deleted Content added
Repo at 04d11bb: fix no-underscore-dangle (#2114); fix no-throw-literal (#2102); fix no-useless-concat (#2100); fix prefer-const (#2099)
Repo at ac3c1e3: replace es-x/no-array-prototype-includes with unicorn/prefer-includes (#2125)
 
Line 132:
*/
Morebits.userIsInGroup = function (group) {
return mw.config.get('wgUserGroups').indexOfincludes(group) !== -1;
};
/**
Line 270:
let regex;
$.each(mw.config.get('wgNamespaceIds'), (name, number) => {
if (namespaces.indexOfincludes(number) !== -1) {
// Namespaces are completely agnostic as to case,
// and a regex string is more useful/compatible than a RegExp object,
Line 1,558:
*/
isInfinity: function morebitsStringIsInfinity(expiry) {
return ['indefinite', 'infinity', 'infinite', 'never'].indexOfincludes(expiry) !== -1;
},
 
Line 1,654:
 
if (result && params.term &&
data.text.toUpperCase().indexOfincludes(params.term.toUpperCase()) !== -1) {
result.children = data.children;
}
Line 2,285:
this.query.assert = 'user';
// Enforce newer error formats, preferring html
if (!query.errorformat || !['wikitext', 'plaintext'].indexOfincludes(query.errorformat) === -1) {
this.query.errorformat = 'html';
}
Line 2,306:
} else if (query.format === 'json' && !query.formatversion) {
this.query.formatversion = '2';
} else if (!['xml', 'json'].indexOfincludes(query.format) === -1) {
this.statelem.error('Invalid API format: only xml and json are supported.');
}
 
// Ignore tags for queries and most common unsupported actions, produces warnings
if (query.action && ['query', 'review', 'stabilize', 'pagetriageaction', 'watch'].indexOfincludes(query.action) !== -1) {
delete query.tags;
} else if (!query.tags && morebitsWikiChangeTag) {
Line 2,901:
}
 
if (['recreate', 'createonly', 'nocreate'].indexOfincludes(ctx.createOption) !== -1) {
query[ctx.createOption] = '';
}
Line 3,433:
/** @return {boolean} whether or not you can edit the page */
this.canEdit = function() {
return !!ctx.testActions && ctx.testActions.indexOfincludes('edit') !== -1;
};
 
Line 3,595:
this.triage = function() {
// Fall back to patrol if not a valid triage namespace
if (!mw.config.get('pageTriageNamespaces').indexOfincludes(new mw.Title(ctx.pageName).getNamespaceId()) === -1) {
this.patrol();
} else {
Line 3,779:
// so this neatly handles nonexistent pages
const editRestriction = mw.config.get('wgRestrictionEdit');
if (!editRestriction || editRestriction.indexOfincludes('sysop') !== -1) {
return false;
}
Line 4,232:
 
// No undelete as an existing page could have deleted revisions
const actionMissing = missing && ['delete', 'stabilize', 'move'].indexOfincludes(action) !== -1;
const protectMissing = action === 'protect' && missing && (ctx.protectEdit || ctx.protectMove);
const saltMissing = action === 'protect' && !missing && ctx.protectCreate;
Line 4,945:
// For most namespaces, unlink both [[User:Test]] and [[:User:Test]]
// For files and categories, only unlink [[:Category:Test]]. Do not unlink [[Category:Test]]
const isFileOrCategory = [6, 14].indexOfincludes(namespaceID) !== -1;
const colon = isFileOrCategory ? ':' : ':?';