User:Hohum/date.js
// --------------------------------------- --------------------------------------- //
// ----------------------------------- Credits ------------------------------------ //
//
// This script was created by modifying the following scripts:
//
// This script is intended to change date formats to ISO inside tables - It will likely do it to the whole page though
// ---------------------------------- Disclaimer ---------------------------------- //
//
// Use at your own risk and make sure you check the edit changes before you save
//
// [Date: dates to ISO] All dates to YYYY-MM-DD
// Set Default Button Names
if( typeof( SporkConfig ) == 'undefined' ) SporkConfig = {};
if( typeof( SporkConfig.unc ) == 'undefined' ) SporkConfig.unc = "Date: dates to ISO";
// --------------------------------------- --------------------------------------- //
// Import Spork-Tools scripts
importScript('User:Hohum/datetools.js');
// --------------------------------------- --------------------------------------- //
// Unspork: cite date
function spork_cite_to_yyyymmdd(clk) {
var txt = document.editform.wpTextbox1;
txt.value = spork_mdy_to_yyyymmdd(txt.value); // See User:Plastikspork/datetools.js
txt.value = spork_dmy_to_yyyymmdd(txt.value); // See User:Plastikspork/datetools.js
spork_edit_summary_date();
if(clk) document.editform.wpDiff.click();
}
// ----------------------------- interface Functions ----------------------------- //
function spork_edit_summary_date() {
// Add a tag to the summary box
var summary = "date formatting";
var txt = document.editform.wpSummary;
var fullsummary = "Script assisted " + summary;
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match( /Script assisted [A-Za-z]/ )) {
txt.value = txt.value.replace( /Script assisted /, fullsummary + "/");
} else if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
txt.value += " | " + fullsummary;
} else {
txt.value += fullsummary;
}
}
}
addOnloadHook(function () {
if(document.forms.editform) {
if( SporkConfig.unc != "" )
mw.util.addPortletLink('p-tb', 'javascript:spork_cite_to_yyyymmdd(1)', SporkConfig.unc);
}
});