کارن:Ibrahim khashrowdi/Gadget-fixRefs.js
يادښت: د غوره توبونو د خوندي کولو وروسته، خپل د کتنمل (بروزر) ساتل شوې حافظه تازه کړی.د نور تفصيل لپاره د غځول په تنۍ کلېک وکړئ.
- فايرفاکس/ سفري: په دې کتنمل کې د Reload د ټکوهلو په وخت د Shift تڼۍ نيولې وساتی، او يا هم Ctrl-F5 يا Ctrl-Rتڼۍ کېښکاږۍ (په Apple Mac کمپيوټر باندې ⌘-R کېښکاږۍ)
- گووگل کروم: په دې کتنمل کې د Ctrl-Shift-R تڼۍ کېښکاږۍ (د مک لپاره ⌘-Shift-R)
- انټرنټ اېکسپلورر: په دې کتنمل کې د Refresh د ټکوهلو په وخت کې د Ctrl تڼۍ کېښکاږلې ونيسۍ، او يا هم د Ctrl-F5 تڼۍ کېښکاږۍ
- اوپرا: په دې کتنمل کې د خپل براوزر ساتل شوې حافظه پدې توگه سپينولی شی Tools→Preferences
لاسوند[جوړول]
سمونگران د دې کينډۍ په ازمونمخ (جوړول | هېنداره) او ازمونځايونه (جوړول) مخونو کې خپلې تجربې کولای شي. لطفا وېشنيزې د /لاسوند څېرمه مخ کې ورگډې کړئ. د دې مخ څېرمه مخونه. |
//<pre><code>
//
// [[User:Gimmetrow/fixRefs.js]]
function fixRefMarks() {
var qt = String.fromCharCode(34)
// var hb = String.fromCharCode(124)
var txt = document.editform.wpTextbox1;
// fact and other templates (geographic reference template, ref/note)
var FactTag = "({{ *سند *}}|{{ *سرچینې +اړتیا *}}|{{[ ]*fact[ ]*}}|{{[ ]*fact[ ]*[\|][^}]*}}|{{[ ]*facts[ ]*}}|{{[ ]*citequote[ ]*}}|{{[ ]*citation needed[ ]*}}|{{[ ]*citation needed[ ]*[\|][^}]*}}|{{[ ]*cn[ ]*}}|{{[ ]*verification needed[ ]*}}|{{[ ]*verify source[ ]*}}|{{[ ]*verify credibility[ ]*}}|{{[ ]*who[ ]*}}|{{[ ]*failed verification[ ]*}}|{{[ ]*nonspecific[ ]*}}|{{[ ]*dubious[ ]*}}|{{[ ]*or[ ]*}}|{{[ ]*lopsided[ ]*}}|{{[ ]*GR[ ]*[\|][ ]*[^ ]+[ ]*}}|{{[ ]*[c]?r[e]?f[ ]*[\|][^}]*}}|{{[ ]*ref[ _]label[ ]*[\|][^}]*}}|{{[ ]*ref[ _]num[ ]*[\|][^}]*}})";
txt.value = txt.value
.replace(new RegExp("[\n\r\f\t ]+?"+FactTag, "gi"), "$1")
// one+ space/linefeed, avoid matching references tag as a named ref
.replace(new RegExp("[\n\r\f\t ]+?<ref([ >])", "gi"), "<ref$1")
// remove trailing spaces from named refs
.replace(new RegExp("<ref ([^>]*[^> ])[ ]*>", "gi"), "<ref $1>")
// remove some superscripted punctuation between refs (is between necessary?)
.replace(new RegExp("(</ref>|<ref[^>]*?/>)<sup>[ ]*[,;-]?[ ]*</sup><ref", "gi"), "$1<ref")
.replace(new RegExp("(</ref>|<ref[^>]*?/>)[ ]*[,;-]?[ ]*<ref", "gi"), "$1<ref")
.replace(new RegExp("(</ref>|<ref[^>]*?/>)[ \n\r\f\t]*([\.,])", "gi"), "$1$2");
var LacksPunctuation = "([^\.،؛,;:!؟\?"+qt+"'’])";
var QuestionOrExclam = "([!؟\?])";
var MinorPunctuation = "([\.،؛,;:])";
var Blockquote = "(</blockquote>)";
var Quote = "([" + qt + "'’]*)";
//var Space = "[\n\r\f\t ]*"; // to handle http://en.wikipedia.org/w/index.php?title=Cat&diff=99697351&oldid=99697026
var Space = "[ ]*";
var Space2 = "[\n\r\f\t ]*";
var AnyPunctuation = "([\.،؛,;:!؟\?])";
var MajorPunctuation = "([،؛,;:!؟\?])";
var Period = "([\.])";
// can this complicated close tag be simplified?
//var closetag = "(([^<]|<[^/]|</[^r]|</r[^e]|</re[^f]|</ref[^>])*?)</ref>";
//var closetag = "((.*?))</ref>";
var RefTag1 = "(<ref>([^<]|<[^/]|</[^r]|</r[^e]|</re[^f]|</ref[^>])*?</ref>)";
var RefTag2 = "(<ref[^>]*?[^/]>([^<]|<[^/]|</[^r]|</r[^e]|</re[^f]|</ref[^>])*?</ref>)";
var RefTag3 = "(<ref[^>]*?/>)";
//var Note = "("+RefTag1 + "|(" + RefTag2 + ")|(" + FactTag + "))";
var match0a = LacksPunctuation+Quote+FactTag+Space+AnyPunctuation;
var match0b = QuestionOrExclam+Quote+FactTag+Space+MajorPunctuation;
var match0c = MinorPunctuation+Quote+FactTag+Space+AnyPunctuation;
var match0d = QuestionOrExclam+Quote+FactTag+Space+Period;
var match1a = LacksPunctuation+Quote+RefTag1+Space+AnyPunctuation;
var match1b = QuestionOrExclam+Quote+RefTag1+Space+MajorPunctuation;
var match1c = MinorPunctuation+Quote+RefTag1+Space+AnyPunctuation;
var match1d = QuestionOrExclam+Quote+RefTag1+Space+Period;
var match2a = LacksPunctuation+Quote+RefTag2+Space+AnyPunctuation;
var match2b = QuestionOrExclam+Quote+RefTag2+Space+MajorPunctuation;
var match2c = MinorPunctuation+Quote+RefTag2+Space+AnyPunctuation;
var match2d = QuestionOrExclam+Quote+RefTag2+Space+Period;
var match3a = LacksPunctuation+Quote+RefTag3+Space+AnyPunctuation;
var match3b = QuestionOrExclam+Quote+RefTag3+Space+MajorPunctuation;
var match3c = MinorPunctuation+Quote+RefTag3+Space+AnyPunctuation;
var match3d = QuestionOrExclam+Quote+RefTag3+Space+Period;
for (var j=0; j<5; j++) // repeat for multiple refs together
{
txt.value = txt.value
.replace(new RegExp(match0a, "gi"), "$1$2$4$3")
.replace(new RegExp(match0b, "gi"), "$1$2$4$3")
.replace(new RegExp(match0c, "gi"), "$2$4$3")
.replace(new RegExp(match0d, "gi"), "$1$2$3")
.replace(new RegExp(match1a, "gi"), "$1$2$5$3")
.replace(new RegExp(match1b, "gi"), "$1$2$5$3")
.replace(new RegExp(match1c, "gi"), "$2$5$3")
.replace(new RegExp(match1d, "gi"), "$1$2$3")
.replace(new RegExp(match2a, "gi"), "$1$2$5$3")
.replace(new RegExp(match2b, "gi"), "$1$2$5$3")
.replace(new RegExp(match2c, "gi"), "$2$5$3")
.replace(new RegExp(match2d, "gi"), "$1$2$3")
.replace(new RegExp(match3a, "gi"), "$1$2$4$3")
.replace(new RegExp(match3b, "gi"), "$1$2$4$3")
.replace(new RegExp(match3c, "gi"), "$2$4$3")
.replace(new RegExp(match3d, "gi"), "$1$2$3");
}
// blockquotes (if trapped punctuation exists, remove it, and move blockquote past at least one ref)
txt.value = txt.value
.replace(new RegExp(Blockquote + AnyPunctuation + FactTag, "gi"), "$3$1")
.replace(new RegExp(Blockquote + AnyPunctuation + RefTag1, "gi"), "$3$1")
.replace(new RegExp(Blockquote + AnyPunctuation + RefTag2, "gi"), "$3$1")
.replace(new RegExp(Blockquote + AnyPunctuation + RefTag3, "gi"), "$3$1")
.replace(new RegExp(Blockquote + FactTag, "gi"), "$2$1")
.replace(new RegExp(Blockquote + RefTag1, "gi"), "$2$1")
.replace(new RegExp(Blockquote + RefTag2, "gi"), "$2$1")
.replace(new RegExp(Blockquote + RefTag3, "gi"), "$2$1");
var summary = document.editform.wpSummary;
//summary.value = summary.value + " various minor fixes ";
}
$(document).ready(function () {
if(document.forms.editform) {
mw.util.addPortletLink('p-tb', 'javascript:fixRefMarks()', 'د سرچینې سمبولونو سمول', 't-reffix', 'Ref fix', '', '');
}
});
//</code></pre>