پرش به محتوا

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

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