پرش به محتوا

مدیاویکی:Gadget-decodesummary.js: تفاوت میان نسخه‌ها

از دانشنامه علوم انسانی
imported>Dalba
ادغام از special:diff/10567263/prev و special:diff/14791363/14791708 با کمی تفاوت که در بحث توضیح می‌دهم
imported>Dalba
جز 'use strict'
خط ۱: خط ۱:
$(function () {
$(function () {
'use strict';
$('#wpSummary, #wpReason, #mwProtect-reason').byteLimit(Infinity);
$('#wpSummary, #wpReason, #mwProtect-reason').byteLimit(Infinity);
$('#wpSummary, #wpReason, #mwProtect-reason').on('paste keyup change',
$('#wpSummary, #wpReason, #mwProtect-reason').on('paste keyup change',
function (e) {
function (e) {
var that = $(this)
var that, val, bytes;
var val = that.val();
that = $(this);
val = that.val();
// from https://stackoverflow.com/questions/2219526/
// from https://stackoverflow.com/questions/2219526/
bytes = encodeURI(val).split(/%(?:u[0-9A-F]{2})?[0-9A-F]{2}|./).length - 1;
bytes = encodeURI(val).split(/%(?:u[0-9A-F]{2})?[0-9A-F]{2}|./).length - 1;

نسخهٔ ۱۴ فوریهٔ ۲۰۱۵، ساعت ۱۵:۵۰

$(function () {
	'use strict';
	$('#wpSummary, #wpReason, #mwProtect-reason').byteLimit(Infinity);
	$('#wpSummary, #wpReason, #mwProtect-reason').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?:\/\/fa\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?diff=(\d+|next|prev|cur)&oldid=(\d+)/g,
				'$1[[special:diff/$3/$2]]'
			).replace(
				/(\/\/[\w\-]+\.wikipedia\.org\/w\/index\.php\?)title=[^&\s\]]*&(?=(?:diff=[^&\s]+&|)(?:oldid=\d+))/g,
				'$1'
			);
			val = decodeURI(val.replace(/%20/g, '‍‍‍')).replace(/‍‍‍/g, '%20'); // three zwnj
			if (val !== that.val()) {
				that.val(val);
			}
		});
});