تضامنًا مع حق الشعب الفلسطيني |
ميدياويكي:Gadget-decodesummary.js
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.
/**
* DecodeSummary
*
* عن [[:fa:mediawiki:Gadget-decodesummary.js]]
*
*/
(function ($, mw) {
'use strict';
var nonLinkChars = / \\^`#<>\[\]"\t\n{\|}/.source;
var linkComponent = '[^' + nonLinkChars + ']*';
var linkEnd = '(?=$|[' + nonLinkChars + '])';
var siteCode = mw.config.get('wgServer').match(/\w+\./)[0].slice(0,-1);
var selfSiteIntLinkStart = '[[' + siteCode + ':';
var mwLinkStart = /(?:https?:)?\/\/([a-z\-]+)\.(?:wikipedia|wikimedia)(?:\.beta\.wmflabs)?\.org\//.source;
var simpleTitleLink = RegExp(
mwLinkStart
+ /(?:wiki\/|w\/index\.php\?title=)([^&]*)/.source
+ linkEnd
);
var diffRegex = RegExp(
'(?:' + mwLinkStart + linkComponent
+ ')?&?diff=(\\d+|next|prev|cur)(?:&oldid=(\\d+|next|prev|cur)?)?(#'
+ linkComponent + ')?' + linkEnd,
'gi'
);
var oldidRegex = RegExp(
'(?:' + mwLinkStart + linkComponent + ')?&?oldid=(\\d+|next|prev|cur)(#'
+ linkComponent + ')?' + linkEnd,
'gi'
);
function decodeSummary(e) {
var target, val, originalVal;
target = $(e.currentTarget);
val = originalVal = target.val();
try {
val = decodeURI(val.replace(/%20/g, '\uFFFF')).replace(/\uFFFF/g, '%20'); // uFFFF is a noncharacter
val = decodeSummarySpecial(val);
if (val !== originalVal) {
target.val(val);
}
} catch (ignore) {}
}
function decodeSummarySpecial(val) {
return val
// Put diff before oldid.
.replace(/(oldid=(?:\d+|next|prev|cur)?)&(diff=(?:\d+|next|prev|cur)?)/gi, '$2&$1')
// Special:Diff
.replace(diffRegex, '[[$1:Special:Diff/$3/$2$4]]')
// Special:Permalink
.replace(oldidRegex, '[[$1:Special:Permalink/$2$3]]')
// [[Special:Diff/12345678/prev]] is equal to [[Special:Diff/12345678]]
.replace(/\[\[([a-z\-]+:)Special:Diff\/(\d+|next|prev|cur)\/prev\]\]/gi, '[[$1Special:Diff/$2]]')
// no oldid
.replace('Special:Diff//', 'Special:Diff/')
.replace(simpleTitleLink, '[[$1:$2]]')
.replace(selfSiteIntLinkStart, '[[')
.replace('[[:', '[[');
}
if(['Emailuser', 'UrlShortener'].indexOf(mw.config.get('wgCanonicalSpecialPageName')) === -1) {
$(
'#wpSummary, #wpReason, [name=wpReason], #mwProtect-reason,' +
'#mw-input-wpReason-other, #wpComment,' +
' .mw-ui-input.summary, .oo-ui-inputWidget-input'
).on('paste keyup change', decodeSummary);
}
window.decodeSummarySpecial = decodeSummarySpecial;
})(jQuery, mediaWiki);