MediaWiki:Gadget-morebits.js: Difference between revisions

Content deleted Content added
Repo at 3825f474: Update statusElement on successful lookupCreation; status: add extra class on actionCompleted message (#1343); fnApplyWatchlistExpiry to decide whether/when to apply a watchlistexpiry; Expand setWatchlist handling of expiry, default to infinity for watch/preferences; Allow adding/subtracting weeks as 7 days; taskManager: enable failure handling and setting context
Repo at 582dbd50: Revert "Fixes after renaming of {{Rfd}} and Module:RfD"; fix typos
Line 63:
* Converts an IPv6 address to the canonical form stored and used by MediaWiki.
* JavaScript translation of the {@link https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/8eb6ac3e84ea3312d391ca96c12c49e3ad0753bb/includes/utils/IP.php#131|`IP::sanitizeIP()`}
* function from the IPUtils library. AdddressesAddresses are verbose, uppercase,
* normalized, and expanded to 8 words.
*
Line 77:
* Determines whether the current page is a redirect or soft redirect. Fails
* to detect soft redirects on edit, history, etc. pages. Will attempt to
* detect [[Module:Redirect for discussion]]RfD, with the same failure points.
*
* @returns {boolean}
*/
Morebits.isPageRedirect = function() {
return !!(mw.config.get('wgIsRedirect') || document.getElementById('softredirect') || $('.box-Redirect_for_discussionRfD').length);
};
 
Line 137:
if (namespaces.indexOf(number) !== -1) {
// Namespaces are completely agnostic as to case,
// and a regex string is more useful/compatibilecompatible than a RegExp object,
// so we accept any casing for any letter.
aliases.push(name.split('').map(function(char) {
Line 301:
Morebits.quickForm.element.prototype.compute = function QuickFormElementCompute(data, in_id) {
var node;
var childContainderchildContainer = null;
var label;
var id = (in_id ? in_id + '_' : '') + 'node_' + this.id;
Line 362:
}
}
childContainderchildContainer = select;
break;
case 'option':
Line 560:
}
 
childContainderchildContainer = subnode;
break;
case 'dyninput':
Line 695:
case 'submit':
node = document.createElement('span');
childContainderchildContainer = node.appendChild(document.createElement('input'));
childContainderchildContainer.setAttribute('type', 'submit');
if (data.label) {
childContainderchildContainer.setAttribute('value', data.label);
}
childContainderchildContainer.setAttribute('name', data.name || 'submit');
if (data.disabled) {
childContainderchildContainer.setAttribute('disabled', 'disabled');
}
break;
case 'button':
node = document.createElement('span');
childContainderchildContainer = node.appendChild(document.createElement('input'));
childContainderchildContainer.setAttribute('type', 'button');
if (data.label) {
childContainderchildContainer.setAttribute('value', data.label);
}
childContainderchildContainer.setAttribute('name', data.name);
if (data.disabled) {
childContainderchildContainer.setAttribute('disabled', 'disabled');
}
if (data.event) {
childContainderchildContainer.addEventListener('click', data.event, false);
}
break;
Line 750:
subnode.value = data.value;
}
childContainderchildContainer = subnode;
break;
default:
Line 756:
}
 
if (!childContainderchildContainer) {
childContainderchildContainer = node;
}
if (data.tooltip) {
Line 764:
 
if (data.extra) {
childContainderchildContainer.extra = data.extra;
}
if (data.style) {
childContainderchildContainer.setAttribute('style', data.style);
}
if (data.className) {
childContainderchildContainer.className = childContainderchildContainer.className ?
childContainderchildContainer.className + ' ' + data.className :
data.className;
}
childContainderchildContainer.setAttribute('id', data.id || id);
 
return [ node, childContainderchildContainer ];
};
 
Line 1,148:
* Converts an IPv6 address to the canonical form stored and used by MediaWiki.
* JavaScript translation of the {@link https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/8eb6ac3e84ea3312d391ca96c12c49e3ad0753bb/includes/utils/IP.php#131|`IP::sanitizeIP()`}
* function from the IPUtils library. AdddressesAddresses are verbose, uppercase,
* normalized, and expanded to 8 words.
*
Line 1,213:
/**
* Check that an IP range is within the CIDR limits. Most likely to be useful
* in conjunction with `wgRelevantUserName`. CIDR limits are harcodedhardcoded as /16
* for IPv4 and /32 for IPv6.
*
Line 2,644:
* previous `load()` callbacks to recover from edit conflicts! In this
* case, callers must make the same edit to the new pageText and
* reinvokere-invoke `save()`. This behavior can be disabled with
* `setMaxConflictRetries(0)`.
*
Line 2,714:
}
 
// Set bot edit attribute. If this paramterparameter is present with any value, it is interpreted as true
if (ctx.botEdit) {
query.bot = true;
Line 3,104:
* 1. If there are no revisions among the first 50 that are
* non-redirects, or if there are less 50 revisions and all are
* redirects, the original creation is retrivedretrieved.
* 2. Revisions that the user is not privileged to access
* (revdeled/suppressed) will be treated as non-redirects.
Line 3,922:
--Morebits.wiki.numberOfActionsLeft; // allow for normal completion if retry succeeds
 
// wait for sometime for client to regain connnectivityconnectivity
sleep(2000).then(function() {
ctx.saveApi.post(); // give it another go!
Line 4,775:
*/
removeLink: function(link_target) {
// RempveRemove a leading colon, to be handled later
if (link_target.indexOf(':') === 0) {
link_target = link_target.slice(1);
Line 4,837:
unbinder.unbind('<!--', '-->');
 
// Check free image usages, for example as template arguments, might have the File: prefix excluded, but must be preceededpreceded by an |
// Will only eat the image name and the preceedingpreceding bar and an eventual named parameter
var free_image_re = new RegExp('(\\|\\s*(?:[\\w\\s]+\\=)?\\s*(?:' + Morebits.namespaceRegex(6) + ':\\s*)?' + image_re_string + ')', 'mg');
unbinder.content = unbinder.content.replace(free_image_re, '<!-- ' + reason + '$1 -->');
Line 5,487:
 
/**
* To be called by worker before it terminates succesfullysuccessfully.
*
* @param {(Morebits.wiki.page|Morebits.wiki.api|string)} arg -