User:AussieLegend/vector.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:Ioeth/friendly.js');
importScript('User:AWeenieMan/furme.js');
importScript('User:AWeenieMan/furmeScroller.js');
importScript('User:Ohconfucius/script/MOSNUM dates.js');  //[[User:Ohconfucius/script/MOSNUM dates.js]]
importScript('User:AussieLegend/script/Spelling.js');  //[[User:AussieLegend/script/Spelling.js]]
importScript("User:GregU/dashes.js");
importScript('User:Dr pda/prosesize.js'); //[[User:Dr pda/prosesize.js]]
importScript('User:Ebrahames/Advisor.js');
importScript('User:Dr pda/editrefs.js'); // [[User:Dr pda/editrefs.js]]


//<pre><code>
//
// Based on: User:Trilobite/Tools, User:Omegatron/monobook.js/replacetab.js
function regExp() {
    var s = prompt("Search regexp?");
    if(s) {
        var r = prompt("Replace regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}

function accessISO(option) {
   var txt = document.editform.wpTextbox1;
   var atg = "(\\|[ ]*accessdate[ ]*=|[Aa]ccessed |[Aa]ccessed on |[Rr]etrieved |[Rr]etrieved on )[ ]*";
   // atg = "(\\|[ ]*accessdate[ ]*=[ ]*)";
   if (option == 1) { atg = "(\\|[ ]*archivedate[ ]*=)[ ]*"; }
   if (option == 2) { atg = "(\\|[ ]*date[ ]*=)[ ]*"; }
   if (option == 9) { atg = "(.)"; }
   var btg = "";
   var dig = "";
   for (var opt=1; opt<13; opt++)
   {
      dig = "0" + opt;
      if (opt== 1) { btg = "(January|Jan\\.|Jan)"; }
      if (opt== 2) { btg = "(February|Feb\\.|Feb)"; }
      if (opt== 3) { btg = "(March|Mar\\.|Mar)"; }
      if (opt== 4) { btg = "(April|Apr\\.|Apr)"; }
      if (opt== 5) { btg = "(May|May\\.)"; }
      if (opt== 6) { btg = "(June|Jun\\.|Jun)"; }
      if (opt== 7) { btg = "(July|Jul\\.|Jul)"; }
      if (opt== 8) { btg = "(August|Aug\\.|Aug)"; }
      if (opt== 9) { btg = "(September|Sep\\.|Sep|Sept\\.|Sept)"; }
      if (opt==10) { btg = "(October|Oct\\.|Oct)"; dig = "10";}
      if (opt==11) { btg = "(November|Nov\\.|Nov)"; dig = "11";}
      if (opt==12) { btg = "(December|Dec\\.|Dec)"; dig = "12";}

      txt.value = txt.value.replace(/[Rr]etrieved on/g, 'Retrieved');

      txt.value = txt.value
         .replace(new RegExp(atg+"([1-3][0-9]) "+btg+",? *([1-2][0-9][0-9][0-9])", "g"), "$1$4-"+dig+"-$2")
         .replace(new RegExp(atg+btg+   " ([1-3][0-9]),? *([1-2][0-9][0-9][0-9])", "g"), "$1$4-"+dig+"-$3")
         .replace(new RegExp(atg+   "0?([0-9]) "+btg+",? *([1-2][0-9][0-9][0-9])", "g"), "$1$4-"+dig+"-0$2")
         .replace(new RegExp(atg+btg+      " 0?([0-9]),? *([1-2][0-9][0-9][0-9])", "g"), "$1$4-"+dig+"-0$3");
   }

}


$(function () {
    if(document.forms.editform) {
        mw.util.addPortletLink('p-tb', 'javascript:accessISO(9)', 'ALL dates to ISO ', 't-alltoISO', 'Regexp alltoISO', '', '');
    }
});
//</code></pre>