Jump to content

User:SHOTHA/vector.js

From 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.
// <nowiki>
///NOTE TO SELF: switch to monobook skin to use production scripts

importScript("User:PleaseStand/segregate-refs.js");
importScript("User:Ohconfucius/test/EngvarB.js");	//Engvar
importScript("User:GregU/dashes.js");
mw.loader.load('https://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');

importScript("User:Splarka/diffreveal.js");       //reveals unicode characters when viewing diffs
importScript("User:Ohconfucius/test/test.js"); 
importScript("User:Ohconfucius/test/custom.js"); 	//flagcruft, tablesort
importScript("User:Ohconfucius/test/formatgeneral.js"); 
importScript("User:Ohconfucius/test/MOSNUM dates code.js");
importScript("User:Ohconfucius/test/Common Terms.js");
importScript("User:Ohconfucius/script/Sources.js");
importScript("User:Ohconfucius/script/foreigndates.js");

/**** navpop ****/
// [[User:Lupin/popups.js]]

importScript('User:Lupin/popups.js');

/**** dyk ****/
// [[User:Dr pda/prosesize.js]]
importScript('User:Dr pda/prosesize.js'); //[[User:Dr pda/prosesize.js]]


/**** afd helper ****/
document.write('<script type="text/javascript"' +
'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' +
'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */

/** ------------------------------------------------------------------------ **/
/// EDIT SUMMARIES & USE DMY TEMPLATE

function Ohc_edit_summary1(){
	//Add a tag to the summary box
//	setoptions(minor='true'); 		//removed ",watch='false'" in response to user notification 13 Nov. 2010
	setreason('[[User:Ohconfucius/script|Script]]-assisted fixes: per [[MOS:NUM]], [[MOS:CAPS]], [[MOS:LINK]]', 'appendonce');
//	doaction('save');
}

function Ohc_edit_summary2(){
	//Add a tag to the summary box
	setoptions(minor='false',watch='false'); 		
	setreason('[[User:Ohconfucius/script|Script]]-assisted fixes per [[WP:TIES]], [[MOS:NUM]], [[MOS:CAPS]], [[MOS:LINK]]', 'appendonce');
//	doaction('save');
}
 
function Ohc_for_AWB(){
	regex(/([\s\t]+)(?:regex|txt.value=txt.value.replace)\(\//gi, '$1ArticleText=Regex.Replace(ArticleText, @"(?i)');
	regex(/\/gi, [\'\"]/gi, '", "');
	regex(/\'(\);[\s\t]*)/gi, '"$1');

}
 

function Ohc_insert_tag(){
 var txt=document.editform.wpTextbox1;
// current month-year
    var currentDate = new Date();
    var currmonth = currentDate.getMonth();
    var curryear  = currentDate.getFullYear();
    var myMonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    var curryyyymm = myMonths[currmonth] + ' ' + curryear;
 
/// insert 'use British English' template
    txt.value=txt.value.replace(/\{\{(Use Scottish English)(\|[^}]*)?\}\}/gi, '{{Use British English|date='+curryyyymm+'}}');
    txt.value=txt.value.replace(/\{\{(Use (?:Pakistani|Irish|Hong Kong) English)(\|[^}]*)?\}\}/gi, '');
    txt.value=txt.value.replace(/\{\{(?:use British (?:\(Oxford\) |)English)(\|[^}]*)?\}\}/gi, '{{Use British English|date='+curryyyymm+'}}');
    txt.value=txt.value.replace(/\{\{(Use (?:Australian|Indian|New Zealand|South African) English|EngvarB)(\|[^}]*)?\}\}/gi, '{{$1|date='+curryyyymm+'}}');
 
    var rxpdd = new RegExp("{{(Use (?:Australian|British|Indian|New Zealand|South African) English|EngvarB)\\|date="+curryyyymm+"}}", "gi");
    var dflagfound = txt.value.search(rxpdd);
    if (dflagfound == -1)
    {
        txt.value='{{EngvarB|date='+curryyyymm+'}}\r\n'+txt.value;
    }
}

/** ------------------------------------------------------------------------ **/
/// COMPOSITE SCRIPT DRIVERS

function ONETOUCH_ENG() {
 var txt=document.editform.wpTextbox1;
//	Ohc_ref_format();
	Ohc_CommonTerms();
ohc_removeflag(); 
	ohc_delink_dates();
	ohc_protect_dates();
	ohc_fix_unambiguous_dates();
	ohc_body_dates_to_dmy();
	ohc_delink_year_in_X();
	ohc_expand_ref_dates(); 
	ohc_unprotect_dates();
	ohc_dmy_publication_dates();
	ohc_delink_ISO_to_dmy();
	autoEdFunctions(); //dashes

	ohc_protect_ENGVAR();
	Ohc_plain_english();
	Ohc_ENGVARSimple();
	zwords();
	ohc_unprotect_ENGVAR();
	Ohc_insert_tag();
	Ohc_formatgeneral();

	Ohc_edit_summary2();
}
 
function ONETOUCH_DMY(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
//	Ohc_ref_format();
	Ohc_CommonTerms();
//ohc_removeflag(); 
	ohc_delink_dates();
	ohc_protect_dates();
	ohc_fix_unambiguous_dates();
	ohc_body_dates_to_dmy();
	ohc_delink_year_in_X();
	ohc_expand_ref_dates(); 
	ohc_unprotect_dates();
	ohc_dmy_publication_dates();
	ohc_delink_ISO_to_dmy();
	autoEdFunctions(); //dashes
	Ohc_formatgeneral();
	Ohc_edit_summary1();
}
 
function ONETOUCH_MDY(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
//	Ohc_ref_format();
	Ohc_CommonTerms();
 
	ohc_delink_dates();
	ohc_protect_dates();
	ohc_fix_unambiguous_dates();
	ohc_body_dates_to_mdy();
	ohc_delink_year_in_X();
	ohc_expand_ref_dates(); 
	ohc_unprotect_dates();
	ohc_mdy_publication_dates();
	ohc_delink_ISO_to_mdy();
	autoEdFunctions(); //dashes
	Ohc_formatgeneral();
	Ohc_edit_summary1();
}

function ohc_body_to_dmy_driver()
{
	ohc_delink_dates();
	ohc_protect_dates();
	ohc_body_dates_to_dmy();
	ohc_unprotect_dates();
 
	Ohc_edit_summary1();
}
 
function ohc_body_to_mdy_driver()
{
	ohc_delink_dates();
	ohc_protect_dates();
	ohc_body_dates_to_mdy();
	ohc_unprotect_dates();
 
	Ohc_edit_summary1();
}
 
function ONETOUCH_FMT(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
	Ohc_formatgeneral();
	Ohc_ref_format();
	Ohc_CommonTerms();
	autoEdFunctions(); //dashes
//	Ohc_edit_summary1();
}

function linked_YEARS(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
	Ohc_errorsunlink();
	autoEdFunctions(); //dashes
	Ohc_edit_summary3();

	doaction('save');
}
 
/** ------------------------------------------------------------------------ **/
/// SIDEBAR BUTTONS

// Add [[WP:Reflinks]] launcher in the toolbox on left
$(function () {
 mw.util.addPortletLink(
  "p-tb",     // toolbox portlet
  "http://toolserver.org/~dispenser/cgi-bin/webreflinks.py/" + wgPageName 
   + "?client=script&citeweb=on&overwrite=simple&limit=200&lang=" + wgContentLanguage,
  "Reflinks Citeweb"  // link label
)});
$(function () {
 mw.util.addPortletLink(
  "p-tb",     // toolbox portlet
  "http://toolserver.org/~dispenser/cgi-bin/webreflinks.py/" + wgPageName 
   + "?client=script&overwrite=simple&limit=200&lang=" + wgContentLanguage,
  "Reflinks plain"  // link label
)});

$(function () {
 if(document.forms.editform) {
    mw.util.addPortletLink('p-tb', 'javascript:ohc_zap_accessdates()', 'ZAPaccess', 't-dmy', 'ZAP access dates placed by Reflinks', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:linked_YEARS()', 'Linked YEARS', 't-dmy', '', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ONETOUCH_ENG()', 'One Touch: ENGVAR', 't-eng', 'Engvar + all', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ONETOUCH_DMY()', 'One Touch: DMY', 't-dmy', 'day month + CT', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ONETOUCH_MDY()', 'One Touch: MDY', 't-mdy', 'month day + CT', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ohc_body_to_dmy_driver()', 'Body dates to dmy', 't-dmy', 'day month', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ohc_body_to_mdy_driver()', 'Body dates to mdy', 't-mdy', 'month day', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ONETOUCH_FMT()', 'One Touch: FMT', 't-fmt', 'general fmt, CT + cites', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:Ohc_for_AWB()', 'Make AWB', 'AWB', 'Make AWB code', '', '');
//    mw.util.addPortletLink('p-tb', 'javascript:ohc_ISO_to_mdy_anywhere()', 'ALL ISO MDY', 't-mdy', 'month day', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ohc_protect_ENGVAR()', 'ENGVAR protection', 't-dmy', 'day month', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ohc_US_slash_dates_to_mdy()', 'US-slash dates', 't-US', 'US-slash', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:ohc_UK_slash_dates_to_dmy()', 'UK-slash dates', 't-UK', 'UK-slash', '', '');
  }
});
// </nowiki>