///NOTE TO SELF: switch to monobook skin to use production scripts
// <nowiki><pre>
mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );
importScript("User:Ohconfucius/test/EngvarB-test.js");
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript');
/**** dyk ****/
// [[User:Dr pda/prosesize.js]]
importScript('User:Dr pda/prosesize.js'); //[[User:Dr pda/prosesize.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 [[WP:MOS|style]] fixes', 'appendonce');
doaction('diff');
}
function Ohc_edit_summary2(editor) {
editor
.options({ minor: false, watch: false })
.appendEditSummary('[[User:Ohconfucius/script|Script]]-assisted [[WP:MOS|style]] fixes')
.clickDiff();
}
function Ohc_for_Petscan() {
regex(/([^\]])(\n)([^\*])/gi, '$1]]$2*[[$3'); //adding wikilinks
regex(/\[\[([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+)(?:\|([^\]]*)|)\]\]/gi, '[https://en.wikipedia.org/w/index.php?title=$1_$2_$3_$4_$5_$6_$7_$8&action=edit $1_$2_$3_$4_$5_$6_$7_$8]');
regex(/\[\[([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+)(?:\|([^\]]*)|)\]\]/gi, '[https://en.wikipedia.org/w/index.php?title=$1_$2_$3_$4_$5_$6_$7&action=edit $1_$2_$3_$4_$5_$6_$7]');
regex(/\[\[([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+)(?:\|([^\]]*)|)\]\]/gi, '[https://en.wikipedia.org/w/index.php?title=$1_$2_$3_$4_$5_$6&action=edit $1_$2_$3_$4_$5_$6]');
regex(/\[\[([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+)(?:\|([^\]]*)|)\]\]/gi, '[https://en.wikipedia.org/w/index.php?title=$1_$2_$3_$4_$5&action=edit $1_$2_$3_$4_$5]');
regex(/\[\[([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+)(?:\|([^\]]*)|)\]\]/gi, '[https://en.wikipedia.org/w/index.php?title=$1_$2_$3_$4&action=edit $1_$2_$3_$4]');
regex(/\[\[([^|\]\s]+) ([^|\]\s]+) ([^|\]\s]+)(?:\|([^\]]*)|)\]\]/gi, '[https://en.wikipedia.org/w/index.php?title=$1_$2_$3&action=edit $1_$2_$3]');
regex(/\[\[([^|\]\s]+) ([^|\]\s]+)(?:\|([^\]]*)|)\]\]/gi, '[https://en.wikipedia.org/w/index.php?title=$1_$2&action=edit $1_$2]');
regex(/\[\[([^|\]\s]+)(?:\|([^\]]*)|)\]\]/gi, '[https://en.wikipedia.org/w/index.php?title=$1&action=edit $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 (?:Australian|British) 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[A-Z][a-z]*\s?(\|[^}]*)?\}\}/gi, '{{EngvarB|date='+curryyyymm+'}}');
var rxpdd = new RegExp("{{(Use (?:Australian|Scottish|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(editor) {
// Add a tag to the summary box
var txt=document.editform.wpTextbox1;
//Ohc_ref_format();
Ohc_retrain_links();
Ohc_CommonTerms();
//ohc_replaceflag();
ohc_extend_editor(editor);
ohc_delink_dates(editor);
ohc_protect_dates(editor);
ohc_fix_unambiguous_dates(editor);
ohc_body_dates_to_dmy(editor);
ohc_delink_ISO_to_dmy(editor);
//ohc_delink_year_in_X(editor);
ohc_customize_all_to_dmy(editor);
ohc_ISO_to_dmy_in_citations(editor);
ohc_unprotect_dates(editor);
autoEdFunctions(); //dashes
Ohc_formatgeneral();
// ohc_sources_driver(editor);
Ohc_edit_summary2(editor);
}
function ONETOUCH_MDY(editor) {
// Add a tag to the summary box
var txt=document.editform.wpTextbox1;
// Ohc_ref_format();
Ohc_CommonTerms();
ohc_all_to_mdy_driver(editor);
autoEdFunctions(); //dashes
Ohc_formatgeneral();
ohc_sources_driver(editor);
Ohc_edit_summary2(editor);
}
function ohc_sources_driver(editor) {
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 ONETOUCH_FMT(editor) {
// Add a tag to the summary box
var txt=document.editform.wpTextbox1;
Ohc_CommonTerms();
autoEdFunctions(); //dashes
ohc_sources_driver(editor);
Ohc_formatgeneral();
Ohc_edit_summary2(editor);
}
/** ------------------------------------------------------------------------ **/
/**
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
* @see https://meta.wikimedia.org/wiki/TemplateScript
* @update-token [[File:Pathoschild/templatescript.js]]
*/
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add(
[
//{ name: 'delink dates', script: function(editor) { ohc_delink_dates(editor); }, tooltip: 'delink dates' },
{ name: 'One Touch: DMY', script: function(editor) { ONETOUCH_DMY(editor); }, tooltip: 'day month + CT' },
{ name: 'One Touch: MDY', script: function(editor) { ONETOUCH_MDY(editor); }, tooltip: 'month day + CT' },
// { name: 'One Touch: FORMAT', script: function(editor) { ONETOUCH_FMT(editor); }, tooltip: 'general fmt, CT + cites' },
{ name: 'Make WORKLIST', script: function(editor) { Ohc_for_Petscan(editor); }, tooltip: 'Make worklist' },
// { name: 'SLASH-US', script: function(editor) { ohc_US_slash_dates_to_mdy(editor); }, tooltip: 'US-slash' },
// { name: 'SLASH-UK', script: function(editor) { ohc_UK_slash_dates_to_dmy(editor); }, tooltip: 'UK-slash' },
],
{ category: 'General' }
);
});
// </pre></nowiki>