Jump to content

User:Ohconfucius/test/MOSNUM dates.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ohconfucius (talk | contribs) at 03:28, 12 December 2012 (delink date function has been isolated and brought forward). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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:Ohconfucius/test/MOSNUM_dates_code.js"); 

/** ------------------------------------------------------------------------ **/
/// CUSTOMIZATION POINTS
function ohc_customize_all_to_dmy() {
    ohc_customize_all();
}
function ohc_customize_all_to_mdy() {
    ohc_customize_all();
}
function ohc_customize_body_to_dmy() {
    ohc_customize_all();
}
function ohc_customize_body_to_mdy() {
    ohc_customize_all();
}
function ohc_customize_ISO_to_dmy() {
    ohc_customize_all();
}
function ohc_customize_ISO_to_mdy() {
    ohc_customize_all();
}

function ohc_customize_all() {
    regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?![ -]*(?:Fox|[A-Z]\w*|''))/g, '$1c$2');
}

/** ------------------------------------------------------------------------ **/
/// DRIVER FUNCTIONS

function ohc_all_to_dmy_driver()
{
    ohc_delink_dates();
    ohc_protect_dates();
    ohc_fix_unambiguous_dates();
    ohc_body_dates_to_dmy();
    ohc_delink_ISO_to_dmy();
    ohc_delink_year_in_X();
    ohc_customize_all_to_dmy();
    ohc_unprotect_dates();
    ohc_ISO_to_dmy_in_citations();

    ohc_MOSNUM_edit_summary();
}

function ohc_all_to_mdy_driver()
{
    ohc_delink_dates();
    ohc_protect_dates();
    ohc_fix_unambiguous_dates();
    ohc_body_dates_to_mdy();
    ohc_delink_ISO_to_mdy();
    ohc_delink_year_in_X();
    ohc_customize_all_to_mdy();
    ohc_unprotect_dates();
    ohc_ISO_to_mdy_in_citations();

    ohc_MOSNUM_edit_summary();
}

function ohc_dmy_publication_dates_driver()
{
    ohc_delink_dates();
    ohc_protect_dates();
    ohc_body_dates_to_dmy();
    ohc_customize_body_to_dmy();
    ohc_unprotect_dates();
 
    ohc_dmy_publication_dates();
    ohc_MOSNUM_edit_summary();

}

function ohc_mdy_publication_dates_driver()
{
    ohc_delink_dates();
    ohc_protect_dates();
    ohc_body_dates_to_mdy();
    ohc_customize_body_to_mdy();
    ohc_unprotect_dates();
 
    ohc_mdy_publication_dates();
    ohc_MOSNUM_edit_summary();

}

function ohc_body_to_dmy_driver()
{
    ohc_delink_dates();
    ohc_protect_dates();
    ohc_body_dates_to_dmy();
    ohc_customize_body_to_dmy();
    ohc_unprotect_dates();
 
    ohc_MOSNUM_edit_summary();
}
 
function ohc_body_to_mdy_driver()
{
    ohc_delink_dates();
    ohc_protect_dates();
    ohc_body_dates_to_mdy();
    ohc_customize_body_to_mdy();
    ohc_unprotect_dates();
 
    ohc_MOSNUM_edit_summary();
}
 
function ohc_ISO_to_dmy_driver()
{
    ohc_protect_dates();
    ohc_delink_ISO_to_dmy();
    ohc_customize_ISO_to_dmy();
    ohc_unprotect_dates();
 
//  ohc_MOSNUM_edit_summary();
}
 
function ohc_ISO_to_mdy_driver()
{
    ohc_protect_dates();
    ohc_delink_ISO_to_mdy();
    ohc_customize_ISO_to_mdy();
    ohc_unprotect_dates();
 
    //  ohc_MOSNUM_edit_summary();
}
 
function ohc_delink_year_in_X_driver()
{
    ohc_delink_year_in_X();
}
 
function ohc_ISO_access_dates_driver(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
	 ohc_ISO_access_dates();
}
 
function ohc_unambiguous_dates_driver()
{
    ohc_protect_dates();
    ohc_fix_unambiguous_dates();
    ohc_unprotect_dates();
 
    ohc_slash_edit_summary();
}
 
function ohc_US_slash_dates_driver()
{
    ohc_protect_dates();
    ohc_US_slash_dates_to_mdy();
    ohc_unprotect_dates();
 
    ohc_slash_edit_summary();
}
 
function ohc_UK_slash_dates_driver()
{
    ohc_protect_dates();
    ohc_UK_slash_dates_to_dmy();
    ohc_unprotect_dates();
 
    ohc_slash_edit_summary();
}
 
function ohc_expand_ref_dates_driver()
{
    ohc_protect_dates();
    ohc_expand_ref_dates();
    ohc_unprotect_dates();
    ohc_expand_edit_summary();
}
 
function ohc_expand_all_dates_driver()
{
    ohc_protect_dates();
    ohc_expand_ref_dates();
    ohc_expand_all_dates();
    ohc_unprotect_dates();
    ohc_expand_edit_summary();
}
 
function ohc_abbrev_ref_dates_driver()
{
    ohc_protect_dates();
    ohc_abbrev_ref_dates();
    ohc_unprotect_dates();
    ohc_abbrev_edit_summary();
}
 
function Ohc_abbrev_all_dates_driver()
{
    ohc_protect_dates();
    ohc_abbrev_ref_dates();
    ohc_abbrev_all_dates();
    ohc_unprotect_dates();
    ohc_abbrev_edit_summary();
}
 

addOnloadHook(function () {
    if(document.forms.editform) {
    addPortletLink('p-tb', 'javascript:ohc_all_to_dmy_driver()', 'ALL dates to dmy', 'ca-unitfixer', 'Align all dates to dmy', '', '');
    addPortletLink('p-tb', 'javascript:ohc_all_to_mdy_driver()', 'ALL dates to mdy', 'ca-unitfixer', 'Align all dates to mdy', '', '');
    addPortletLink('p-tb', 'javascript:ohc_body_to_dmy_driver()', 'Body dates to dmy', 't-dmy', 'day month', '', '');
    addPortletLink('p-tb', 'javascript:ohc_body_to_mdy_driver()', 'Body dates to mdy', 't-mdy', 'month day', '', '');
    addPortletLink('p-tb', 'javascript:ohc_dmy_publication_dates_driver()', 'Body+pub dates to dmy', 't-dmy', 'Body and publication dates to dmy', '', '');
    addPortletLink('p-tb', 'javascript:ohc_mdy_publication_dates_driver()', 'Body+pub dates to mdy', 't-mdy', 'Body and publication dates to mdy', '', '');
    addPortletLink('p-tb', 'javascript:ohc_ISO_to_dmy_driver()', 'ISO to dmy', 't-ISOdmy', 'ISO day month', '', '');
    addPortletLink('p-tb', 'javascript:ohc_ISO_to_mdy_driver()', 'ISO to mdy', 't-ISOmdy', 'ISO month day', '', '');
    addPortletLink('p-tb', 'javascript:ohc_ISO_access_dates()', 'access 2 ISO', 't-ISOmdy', 'access dates to ISO', '', '');
    addPortletLink('p-tb', 'javascript:ohc_delink_year_in_X_driver()'  , 'Del year-in-X dates', 't-yearinX',  'Year in X', '', '');
    addPortletLink('p-tb', 'javascript:ohc_expand_ref_dates_driver()', 'Expand ref dates', 't-expand', 'Expand month names within refs', '', '');
    addPortletLink('p-tb', 'javascript:ohc_expand_all_dates_driver()', 'Expand all dates', 't-expand', 'Expand month names throughout', '', '');
    addPortletLink('p-tb', 'javascript:ohc_abbrev_ref_dates_driver()', 'Abbrev ref dates', 't-expand', 'Abbreviate month names within refs', '', '');
    addPortletLink('p-tb', 'javascript:ohc_abbrev_all_dates_driver()', 'Abbrev all dates', 't-expand', 'Abbreviate month names throughout', '', '');
//    addPortletLink('p-tb', 'javascript:ohc_unambiguous_dates_driver()', 'unambiguous dates', 't-slash', 'resolves slash date format', '', '');
    addPortletLink('p-tb', 'javascript:ohc_US_slash_dates_driver()', 'US-slash dates', 't-US', 'US-slash', '', '');
    addPortletLink('p-tb', 'javascript:ohc_UK_slash_dates_driver()', 'UK-slash dates', 't-UK', 'UK-slash', '', '');
    }
});