MediaWiki:Gadget-morebits.js: Difference between revisions

Content deleted Content added
Repo at b92c23d: load RL modules required for previews
Repo at 49207b0: Revert "morebits.date: Don't import methods that collide with PageTriage (T268513)" (#1619); fix handling of hard errors (#1651)
Line 2,139:
// Allow native Date.prototype methods to be used on Morebits.date objects
Object.getOwnPropertyNames(Date.prototype).forEach(function(func) {
Morebits.date.prototype[func] = function() {
// Exclude methods that collide with PageTriage's Date.js external, which clobbers native Date: [[phab:T268513]]
return this._d[func].apply(this._d, Array.prototype.slice.call(arguments));
if (['add', 'getDayName', 'getMonthName'].indexOf(func) === -1) {
};
Morebits.date.prototype[func] = function() {
return this._d[func].apply(this._d, Array.prototype.slice.call(arguments));
};
}
});
 
Line 4,065 ⟶ 4,062:
// hard error, give up
} else {
var response = ctx.saveApi.getResponse();
var errorData = response.error || // bc error format
response.errors[0].data; // html/wikitext/plaintext error format
 
switch (errorCode) {
Line 4,074:
 
case 'abusefilter-disallowed':
ctx.statusElement.error('The edit was disallowed by the edit filter: "' + ctx.saveApi.getResponse().errorerrorData.abusefilter.description + '".');
break;
 
case 'abusefilter-warning':
ctx.statusElement.error([ 'A warning was returned by the edit filter: "', ctx.saveApi.getResponse().errorerrorData.abusefilter.description, '". If you wish to proceed with the edit, please carry it out again. This warning will not appear a second time.' ]);
// We should provide the user with a way to automatically retry the action if they so choose -
// I can't see how to do this without creating a UI dependency on Morebits.wiki.page though -- TTO
Line 4,085:
case 'spamblacklist':
// If multiple items are blacklisted, we only return the first
var spam = ctx.saveApi.getResponse().errorerrorData.spamblacklist.matches[0];
ctx.statusElement.error('Could not save the page because the URL ' + spam + ' is on the spam blacklist');
break;