//'winc' function allows buttons to be added toolbar
winc('User:Omegatron/monobook.js/addlink.js');
function formatdatebits() {
var txt = document.editform.wpTextbox1;
// months
txt.value = txt.value.replace(/\[\[(January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[January\|(Jan)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[February\|(Feb)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[March\|(Mar)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[April\|(Apr)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[May\|(May)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[June\|(Jun)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[July\|(Jul)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[August\|(Aug)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[September\|(Sep)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[October\|(Oct)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[November\|(Nov)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[December\|(Dec)\]\]/gi, '$1');
// month+year
txt.value = txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]/gi, '$1');
//Month+day_number "March 7th" -> "March 7"
txt.value = txt.value.replace(/\[\[(January|February|March|April|May|June|July|August|September|October|November|December) (\d?\d)(?:th|st|nd|rd)\]\]/gi, '\[\[$1 $2\]\]');
txt.value = txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](?:th|st|nd|rd)/gi, '\[\[$1\]\]');
txt.value = txt.value.replace(/\[\[(\d?\d)(?:th|st|nd|rd) (January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '\[\[$1 $2\]\]');
// days of the week in full. Optional plurals
txt.value = txt.value.replace(/\[\[(Mondays?|Tuesdays?|Wednesdays?|Thursdays?|Fridays?|Saturdays?|Sundays?)\]\]/gi, '$1');
// days of the week abbreviated. Leave out 'Sun' as potentially valid link to the Sun. Leave out 'SAT' in upper case as potential link to 'Scholastic achievement/aptitude test'.
txt.value = txt.value.replace(/\[\[(Mon|Tue|Tues|Wed|Thu|Thur|Thurs|Fri)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[(Sat)\]\]/g, '$1');
txt.value = txt.value.replace(/\[\[Mondays?\|(Mondays?)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[Tuesdays?\|(Tuesdays?)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[Wednesdays?\|(Wednesdays?)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[Thursdays?\|(Thursdays?)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[Fridays?\|(Fridays?)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[Saturdays?\|(Saturdays?)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[Sundays?\|(Sundays?)\]\]/gi, '$1');
// Add a tag to the summary box
var txt = document.editform.wpSummary;
//Made summary more accurate: not all links are removed. Keep summary brief
var summary = "Delink solitary months/weekdays. See:\[\[WP:DATE\]\]";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
txt.value += " | ";
}
txt.value += summary;
}
// Press the diff button to check it
document.editform.wpDiff.click()
}
addOnloadHook(function () {
if(document.forms.editform) {
addLink('p-cactions', 'javascript:formatdatebits()', 'datebits', 'ca-datefixer', 'Fixes some date formatting', '', '');
}
});