Misplaced Pages

User:Ohconfucius/vector.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Ohconfucius Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 10:13, 26 February 2021 view sourceOhconfucius (talk | contribs)Autopatrolled, Extended confirmed users, Pending changes reviewers328,947 edits Replaced content with '///NOTE TO SELF: switch to monobook skin to use production scripts // <nowiki><pre> mw.loader.load( "https://meta.wikimedia.org/search/?title=User:Zhaofe...'Tags: Replaced Reverted← Previous edit Revision as of 10:17, 26 February 2021 view source Ohconfucius (talk | contribs)Autopatrolled, Extended confirmed users, Pending changes reviewers328,947 edits Revert to revision 1005674118 dated 2021-02-08 21:59:31 by Ladsgroup using popupsTag: Manual revertNext edit →
Line 2: Line 2:
// <nowiki><pre> // <nowiki><pre>
mw.loader.load( "https://meta.wikimedia.org/search/?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );//importScript('User:Ucucha/HarvErrors.js'); mw.loader.load( "https://meta.wikimedia.org/search/?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );//importScript('User:Ucucha/HarvErrors.js');
importScript("User:Nehme1499/common.js"); importScript("User:PleaseStand/segregate-refs.js");
importScript("User:Ohconfucius/test/EngvarB.js"); //Engvar
importScript("User:Ohconfucius/dashes.js");
mw.loader.load('https://meta.wikimedia.org/search/?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/script/flagcruft.js"); //flagcruft, tablesort
//importScript("User:Ohconfucius/test/custom.js"); //
importScript("User:Ohconfucius/test/formatgeneral.js");
importScript("User:Ohconfucius/test/MOSNUM dates code.js");
importScript("User:Ohconfucius/test/Common Terms.js");
importScript("User:Ohconfucius/test/Sources.js");
importScript("User:Ohconfucius/script/foreigndates.js");
importScript("User:Ohconfucius/test/YMD dot dates.js");


importScript('User:Evad37/duplinks-alt.js'); // ]

// a collection of single-purpos regexes are stored at "User:Ohconfucius/test/throwaway_regexes"

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


/**** afd helper ****/
mw.loader.load//en.wikipedia.org/search/?title=User:Jnothman/afd_helper/script.js&action=raw&ctype=text/javascript');

/* This is to keep track of who is using this extension: ] */

/** ------------------------------------------------------------------------ **/
/// 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(']-assisted fixes: per ], ], ]', 'appendonce');
doaction('diff');
}

function Ohc_edit_summary2(){
//Add a tag to the summary box
setoptions(minor='false',watch='false');
setreason(']-assisted fixes per ], ] and ]', 'appendonce');
doaction('diff');
}

function Ohc_edit_summary3(){
//Add a tag to the summary box
setoptions(minor='false',watch='false');
setreason('should not be using ] to denote locations', 'appendonce');
doaction('diff');
}

function Ohc_edit_summary4(){
//Add a tag to the summary box
// setoptions(minor='true') //removed ",watch='false'" in response to user notification 13 Nov. 2010
setreason(']-assisted fixes: per ], ], ]', 'appendonce');
doaction('diff');
}

function Ohc_for_AWB(){
regex(/(+)(?:regex|txt.value=txt.value.replace)\(\//gi, '$1ArticleText=Regex.Replace(ArticleText, @"(?i)');
regex(/\/gi, /gi, '", "');
regex(/\'(\);*)/gi, '"$1');

}

function Ohc_for_Petscan(){
regex(/\\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
regex(/\\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
regex(/\\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
regex(/\\s]+) (\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
regex(/\\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
regex(/\\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
regex(/\\s]+) (\s]+)\|(]*)\]\]/gi, '');
regex(/\\s]+)\|(]*)\]\]/gi, '');
}

function Baskerville(){
regex(/(\w)\n(\w)/gi, '$1 $2');
regex(/(\w,)\n(\w)/gi, '$1 $2');
regex(/(\n)\n(\")/gi, '$1$2');

}

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 + ' ' + curryear;

/// insert 'use British English' template
txt.value=txt.value.replace(/\{\{(Use Australian English\s?)(\|*)?\}\}/gi, '{{$1|date='+curryyyymm+'}}');
txt.value=txt.value.replace(/\{\{(Use (?:Bangladeshi|Commonwealth|Pakistani|Irish|Scottish|Singapore|Hong Kong|Indian|New Zealand|South African) English\s?)(\|*)?\}\}/gi, '{{EngvarB|date='+curryyyymm+'}}');
txt.value=txt.value.replace(/\{\{(?:use British(?: \(Oxford\)|) English)(\|*)?\}\}/gi, '{{EngvarB|date='+curryyyymm+'}}');
txt.value=txt.value.replace(/\{\{Engvar*\s?(\|*)?\}\}/gi, '{{EngvarB|date='+curryyyymm+'}}');

var rxpdd = new RegExp("{{(Use (?:Australian|Scottish|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_DMY(){
// Add a tag to the summary box
var txt=document.editform.wpTextbox1;
// Ohc_ref_format();
Ohc_retrain_links();
Ohc_CommonTerms();
//ohc_replaceflag();
ohc_delink_dates();
ohc_expand_ref_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_dmy();
ohc_delink_year_in_X();
ohc_dmy_publication_dates();
ohc_delink_ISO_to_dmy();
ohc_unprotect_dates();
autoEdFunctions(); //dashes
Ohc_formatgeneral();
ohc_sources_driver();
Ohc_edit_summary4();
}

function ONETOUCH_MDY(){
// Add a tag to the summary box
var txt=document.editform.wpTextbox1;
// Ohc_ref_format();
Ohc_CommonTerms();

ohc_delink_dates();
ohc_expand_ref_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_mdy();
ohc_delink_year_in_X();
ohc_mdy_publication_dates();
ohc_delink_ISO_to_mdy();
ohc_unprotect_dates();
autoEdFunctions(); //dashes
Ohc_formatgeneral();
ohc_sources_driver();
Ohc_edit_summary4();
}

function ohc_sources_driver()
{
Ohc_remove_urls();
ohc_protect_urls();
Ohc_sources_prep();
ohc_foreign_dates();
Ohc_unpipe();
Ohc_dab_news_sources();
Ohc_sourcename();
Ohc_sourcework();
Ohc_sourcepub();
Ohc_sourceagency();
Ohc_redo_pipe();
Ohc_publishers();
Ohc_sources_cleanup();
ohc_unprotect_urls();
}

function ohc_body_to_dmy_driver()
{
Ohc_CommonTerms();

ohc_delink_dates();
ohc_protect_dates();
ohc_body_dates_to_dmy();
ohc_BIGENDIAN_dates();
ohc_unprotect_dates();
autoEdFunctions(); //dashes
Ohc_formatgeneral();
ohc_sources_driver();

Ohc_edit_summary1();
}

function ohc_body_to_mdy_driver()
{
Ohc_CommonTerms();

ohc_delink_dates();
ohc_protect_dates();
ohc_body_dates_to_mdy();
ohc_BIGENDIAN_dates();
ohc_unprotect_dates();
autoEdFunctions(); //dashes
Ohc_formatgeneral();
ohc_sources_driver();

Ohc_edit_summary1();
}

function ONETOUCH_FMT(){
// Add a tag to the summary box
var txt=document.editform.wpTextbox1;
Ohc_CommonTerms();
autoEdFunctions(); //dashes
ohc_sources_driver();
Ohc_formatgeneral();
Ohc_edit_summary2();
}

/** ------------------------------------------------------------------------ **/


$(function () {
if(document.forms.editform) {
mw.util.addPortletLink('p-tb', 'javascript:ohc_delink_dates()', 'delink dates', 't-eng', 'delink dates', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_for_Petscan()', 'PetScan', 't-pet', 'Create open PetScan list', '', '');
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: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_refs_to_yyyymmdd()', 'Expand dates', 't-ISO', 'yyyy-mm-dd', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_edit_summary_schools()', 'Information overload', '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', '', '');

}
});
// </pre></nowiki> // </pre></nowiki>

Revision as of 10:17, 26 February 2021

///NOTE TO SELF: switch to monobook skin to use production scripts
// <nowiki><pre>
mw.loader.load( "https://meta.wikimedia.org/search/?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );//importScript('User:Ucucha/HarvErrors.js');
importScript("User:PleaseStand/segregate-refs.js");
importScript("User:Ohconfucius/test/EngvarB.js");	//Engvar
importScript("User:Ohconfucius/dashes.js");
mw.loader.load('https://meta.wikimedia.org/search/?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/script/flagcruft.js");   //flagcruft, tablesort
//importScript("User:Ohconfucius/test/custom.js");   //
importScript("User:Ohconfucius/test/formatgeneral.js");
importScript("User:Ohconfucius/test/MOSNUM dates code.js");
importScript("User:Ohconfucius/test/Common Terms.js");
importScript("User:Ohconfucius/test/Sources.js");
importScript("User:Ohconfucius/script/foreigndates.js");
importScript("User:Ohconfucius/test/YMD dot dates.js");

importScript('User:Evad37/duplinks-alt.js'); // ]

// a collection of single-purpos regexes are stored at "User:Ohconfucius/test/throwaway_regexes"

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


/**** afd helper ****/
mw.loader.load//en.wikipedia.org/search/?title=User:Jnothman/afd_helper/script.js&action=raw&ctype=text/javascript');

/* This is to keep track of who is using this extension: ] */

/** ------------------------------------------------------------------------ **/
/// 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(']-assisted fixes: per ], ], ]', 'appendonce');
	doaction('diff');
}

function Ohc_edit_summary2(){
	//Add a tag to the summary box
	setoptions(minor='false',watch='false'); 		
	setreason(']-assisted fixes per ], ] and ]', 'appendonce');
	doaction('diff');
}

function Ohc_edit_summary3(){
	//Add a tag to the summary box
	setoptions(minor='false',watch='false'); 				
	setreason('should not be using ] to denote locations', 'appendonce');
	doaction('diff');
}

function Ohc_edit_summary4(){
	//Add a tag to the summary box
//	setoptions(minor='true')	//removed ",watch='false'" in response to user notification 13 Nov. 2010
	setreason(']-assisted fixes: per ], ], ]', 'appendonce');
	doaction('diff');
}

function Ohc_for_AWB(){
	regex(/(+)(?:regex|txt.value=txt.value.replace)\(\//gi, '$1ArticleText=Regex.Replace(ArticleText, @"(?i)');
	regex(/\/gi, /gi, '", "');
	regex(/\'(\);*)/gi, '"$1');

}

function Ohc_for_Petscan(){
	regex(/\\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
	regex(/\\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
	regex(/\\s]+) (\s]+) (\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
	regex(/\\s]+) (\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
	regex(/\\s]+) (\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
	regex(/\\s]+) (\s]+) (\s]+)\|(]*)\]\]/gi, '');
	regex(/\\s]+) (\s]+)\|(]*)\]\]/gi, '');
	regex(/\\s]+)\|(]*)\]\]/gi, '');
}

function Baskerville(){
	regex(/(\w)\n(\w)/gi, '$1 $2');
	regex(/(\w,)\n(\w)/gi, '$1 $2');
	regex(/(\n)\n(\")/gi, '$1$2');

}

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 + ' ' + curryear;

/// insert 'use British English' template
    txt.value=txt.value.replace(/\{\{(Use Australian English\s?)(\|*)?\}\}/gi, '{{$1|date='+curryyyymm+'}}');
    txt.value=txt.value.replace(/\{\{(Use (?:Bangladeshi|Commonwealth|Pakistani|Irish|Scottish|Singapore|Hong Kong|Indian|New Zealand|South African) English\s?)(\|*)?\}\}/gi, '{{EngvarB|date='+curryyyymm+'}}');
    txt.value=txt.value.replace(/\{\{(?:use British(?: \(Oxford\)|) English)(\|*)?\}\}/gi, '{{EngvarB|date='+curryyyymm+'}}');
    txt.value=txt.value.replace(/\{\{Engvar*\s?(\|*)?\}\}/gi, '{{EngvarB|date='+curryyyymm+'}}');

    var rxpdd = new RegExp("{{(Use (?:Australian|Scottish|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_DMY(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
//	Ohc_ref_format();
    Ohc_retrain_links();
	Ohc_CommonTerms();
 //ohc_replaceflag();
	ohc_delink_dates();
	ohc_expand_ref_dates();
	ohc_protect_dates();
	ohc_fix_unambiguous_dates();
	ohc_body_dates_to_dmy();
	ohc_delink_year_in_X();
	ohc_dmy_publication_dates();
	ohc_delink_ISO_to_dmy();
	ohc_unprotect_dates();
	autoEdFunctions(); //dashes
	Ohc_formatgeneral();
	ohc_sources_driver();
	Ohc_edit_summary4();
}

function ONETOUCH_MDY(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
//	Ohc_ref_format();
	Ohc_CommonTerms();

	ohc_delink_dates();
	ohc_expand_ref_dates();
	ohc_protect_dates();
	ohc_fix_unambiguous_dates();
	ohc_body_dates_to_mdy();
	ohc_delink_year_in_X();
	ohc_mdy_publication_dates();
	ohc_delink_ISO_to_mdy();
	ohc_unprotect_dates();
	autoEdFunctions(); //dashes
	Ohc_formatgeneral();
	ohc_sources_driver();
	Ohc_edit_summary4();
}

function ohc_sources_driver()
{
      Ohc_remove_urls();
      ohc_protect_urls();
      Ohc_sources_prep();
      ohc_foreign_dates();
      Ohc_unpipe();
      Ohc_dab_news_sources();
      Ohc_sourcename();
      Ohc_sourcework();
      Ohc_sourcepub();
      Ohc_sourceagency();
      Ohc_redo_pipe();
      Ohc_publishers();
      Ohc_sources_cleanup();
      ohc_unprotect_urls();
}

function ohc_body_to_dmy_driver()
{
	Ohc_CommonTerms();

	ohc_delink_dates();
	ohc_protect_dates();
	ohc_body_dates_to_dmy();
	ohc_BIGENDIAN_dates();
	ohc_unprotect_dates();
	autoEdFunctions(); //dashes
	Ohc_formatgeneral();
	ohc_sources_driver();

	Ohc_edit_summary1();
}

function ohc_body_to_mdy_driver()
{
	Ohc_CommonTerms();

	ohc_delink_dates();
	ohc_protect_dates();
	ohc_body_dates_to_mdy();
	ohc_BIGENDIAN_dates();
	ohc_unprotect_dates();
	autoEdFunctions(); //dashes
	Ohc_formatgeneral();
	ohc_sources_driver();

	Ohc_edit_summary1();
}

function ONETOUCH_FMT(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
	Ohc_CommonTerms();
	autoEdFunctions(); //dashes
	ohc_sources_driver();
	Ohc_formatgeneral();
	Ohc_edit_summary2();
}

/** ------------------------------------------------------------------------ **/


$(function () {
 if(document.forms.editform) {
    mw.util.addPortletLink('p-tb', 'javascript:ohc_delink_dates()', 'delink dates', 't-eng', 'delink dates', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:Ohc_for_Petscan()', 'PetScan', 't-pet', 'Create open PetScan list', '', '');
    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: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_refs_to_yyyymmdd()', 'Expand dates', 't-ISO', 'yyyy-mm-dd', '', '');
    mw.util.addPortletLink('p-tb', 'javascript:Ohc_edit_summary_schools()', 'Information overload', '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', '', '');

  }
});
// </pre></nowiki>