پرش به محتوا

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

از دانشنامه علوم انسانی
imported>Dalba
imported>Dalba
برای پیوند ویکی‌های زبان‌های دیگر
خط ۱۵: خط ۱۵:
/(?:(^| )|https?:\/\/fa\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?diff=(\d+|next|prev|cur)&oldid=(\d+)/g,
/(?:(^| )|https?:\/\/fa\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?diff=(\d+|next|prev|cur)&oldid=(\d+)/g,
'$1[[Special:Diff/$3/$2]]'
'$1[[Special:Diff/$3/$2]]'
).replace(
/(?:(^| )|https?:\/\/([a-zA-Z\-]+)\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?diff=(\d+|next|prev|cur)&oldid=(\d+)/g,
'$1[[$2:Special:Diff/$4/$3]]'
).replace(
).replace(
/(?:(^| )|https?:\/\/fa\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?oldid=(\d+)/g,
/(?:(^| )|https?:\/\/fa\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?oldid=(\d+)/g,
'$1[[Special:Permalink/$2]]'
'$1[[Special:Permalink/$2]]'
).replace(
/(?:(^| )|https?:\/\/([a-zA-Z\-]+)\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?oldid=(\d+)/g,
'$1[[$2:Special:Permalink/$3]]'
);
);
val = decodeURI(val.replace(/%20/g, '‍‍‍')).replace(/‍‍‍/g, '%20'); // three zwnj
val = decodeURI(val.replace(/%20/g, '‍‍‍')).replace(/‍‍‍/g, '%20'); // three zwnj

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

$(function () {
	'use strict';
	mw.loader.using('jquery.byteLimit', function () {
		$('#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(
				/(?:(^| )|https?:\/\/([a-zA-Z\-]+)\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?diff=(\d+|next|prev|cur)&oldid=(\d+)/g,
				'$1[[$2:Special:Diff/$4/$3]]'
			).replace(
				/(?:(^| )|https?:\/\/fa\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?oldid=(\d+)/g,
				'$1[[Special:Permalink/$2]]'
			).replace(
				/(?:(^| )|https?:\/\/([a-zA-Z\-]+)\.wikipedia\.org\/[^ \\^`#<>\[\]\"\t\n{|}]*)&?oldid=(\d+)/g,
				'$1[[$2:Special:Permalink/$3]]'
			);
			val = decodeURI(val.replace(/%20/g, '‍‍‍')).replace(/‍‍‍/g, '%20'); // three zwnj
			if (val !== that.val()) {
				that.val(val);
			}
		});
});