مدیاویکی:Gadget-decodesummary.js: تفاوت میان نسخهها
ظاهر
imported>Ebrahim اگر decodeURI ناموفقیا آمیز بود بقیهٔ نتایج را حداقل نگه دار |
imported>Dalba #mw-input-wpReason-other (خلاصهویرایش بستن) |
||
| خط ۲: | خط ۲: | ||
'use strict'; | 'use strict'; | ||
mw.loader.using('jquery.byteLimit', function () { | mw.loader.using('jquery.byteLimit', function () { | ||
$('#wpSummary, #wpReason, #mwProtect-reason').byteLimit(Infinity); | $('#wpSummary, #wpReason, #mwProtect-reason, #mw-input-wpReason-other').byteLimit(Infinity); | ||
}); | }); | ||
$('#wpSummary, #wpReason, #mwProtect-reason').on('paste keyup change', | $('#wpSummary, #wpReason, #mwProtect-reason, #mw-input-wpReason-other').on('paste keyup change', | ||
function (e) { | function (e) { | ||
var that, val, bytes; | var that, val, bytes; | ||
نسخهٔ ۵ مارس ۲۰۱۵، ساعت ۰۷:۴۰
$(function () {
'use strict';
mw.loader.using('jquery.byteLimit', function () {
$('#wpSummary, #wpReason, #mwProtect-reason, #mw-input-wpReason-other').byteLimit(Infinity);
});
$('#wpSummary, #wpReason, #mwProtect-reason, #mw-input-wpReason-other').on('paste keyup change',
function (e) {
var that, val, bytes;
that = $(this);
val = that.val();
// from https://stackoverflow.com/questions/2219526/
bytes = encodeURI(val).split(/%(?:u[0-9A-F]{2})?[0-9A-F]{2}|./).length - 1;
that.css('background-color', bytes > 255 ? '#FFEBEB' : 'white');
val = val.replace(
/(?:(^| )|https?:\/\/([a-zA-Z\-]+)\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?diff=(\d+|next|prev|cur)&oldid=(\d+)(#[^ \\^`#<>\[\]\"\t\n{|}]*)?/g,
'$1[[$2:Special:Diff/$4/$3$5]]'
).replace(
/(?:(^| )|https?:\/\/([a-zA-Z\-]+)\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?oldid=(\d+)(#[^ \\^`#<>\[\]\"\t\n{|}]*)?/g,
'$1[[$2:Special:Permalink/$3$4]]'
).replace(
'[[fa:',
'[['
);
try {
val = decodeURI(val.replace(/%20/g, '')).replace(//g, '%20'); // three zwnj
} catch(ignore) {}
if (val !== that.val()) {
that.val(val);
}
});
});