۳۳٬۷۴۹
ویرایش
جزبدون خلاصۀ ویرایش |
جزبدون خلاصۀ ویرایش |
||
خط ۱۰۹: | خط ۱۰۹: | ||
$(createCollapseButtons); | $(createCollapseButtons); | ||
if (new mw.Uri().query.redlink === "1" && mw.config.get('wgAction') === "edit" && mw.config.get('wgNamespaceNumber') === 0) { | |||
function fixarticletitle(instr) { // a simple text cleaner, can improved by gadget-extraeditbutton codes later | |||
for (var i = 0; i < 10; i++) { | |||
instr = instr.replace(new RegExp("(" + "٠١٢٣٤٥٦٧٨٩"[i] + "|" + i + ")", "g"), "۰۱۲۳۴۵۶۷۸۹"[i]); // arabic and latin numbers | |||
} | |||
return instr | |||
.replace(/[ىي]/g, "ی") | |||
.replace(/ك/g, "ک") | |||
.replace(/:(?=[^\s])/g, ": ") | |||
.replace(/([^\s])\(/, "$1 (") // look behind is not supported by javascript | |||
.replace(/([\.،«»\:؛\sزرذدواژؤإأآءةa-zA-Z])\u200c/g, "$1") | |||
.replace(/\u200c /g, " ") | |||
.replace(/(\u200c*$|^\u200c*)/g, "") | |||
.replace(/[\u200dـ]/g, "") | |||
.replace(/\(\s(.*?)\s\)/g, "($1)") | |||
.replace(/(ۀ|هٓ)/g, "هٔ") | |||
.replace(/ابهام ?زدایی/g, "ابهامزدایی"); | |||
} | } | ||
fixedtitle = fixarticletitle(mw.config.get('wgTitle')); | |||
if (fixedtitle !== mw.config.get('wgTitle')) { | |||
window.location.href = window.location.href.replace( | |||
encodeURI(mw.config.get('wgTitle').replace(/\s/g, "_")), | |||
encodeURI(fixedtitle.replace(/\s/g, "_")) | |||
) + "&redirected=1"; | |||
} | |||
} | |||
} | |||
} |