MediaWiki:Gadget-libExtraUtil.js: Difference between revisions

Content deleted Content added
add notice for unit tests to initial comment
Drop polyfills per request
 
(2 intermediate revisions by 2 users not shown)
Line 24:
// <nowiki>
 
window.extraJs = { version: '2.23.20' };
 
/* ========== Polyfills to support IE11 and Edge<14 ============================================= */
// Array.prototype.includes polyfill
if (!Array.prototype.includes) {
Array.prototype.includes = function(searchElement /*, fromIndex*/) {
return this.indexOf(searchElement) !== -1;
};
}
// String.prototype.includes polyfill, per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
 
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}
/* ============================================================================================== */
 
/**
Line 58 ⟶ 34:
*
* @param {string} code
* First paramaterparameter passed to failure callback function.
* @param {jQuery.jqXHR} jqxhr
* Second paramaterparameter passed to failure callback function.
* @return {string} Error message details, with in a format like
* "(API|HTTP) error: details"
Line 766 ⟶ 742:
}
// Mark any other list items with backlinks for manual review, using {{subst:void}}
var manual_review_regex = new RegExp(
'^(\\*+.*)(?:' + simple_regex_str + '|' +
simple_regex_str.replace(/([^\\])\(([^?])/g, "$1(?:$2") + // replace capturing groups with non-capturing groups
named_regex_str + ').*$', 'gm' );
'|' +
wikitext = wikitext.replace(manual_review_regex, '{{subst:void}}$&');
named_regex_str.replace(/([^\\])\(([^?])/g, "$1(?:$2") + // replace capturing groups with non-capturing groups
named_regex_str + ')(.*)$', 'gm' );
wikitext = wikitext.replace(manual_review_regex, '{{subst:void}}$&1{{subst:^|<strong>}}$2{{subst:^|</strong>}}$3');
 
// For all other links, replace with unlinked text