User:Bobblewik/monobook.js/dates.js

This is an old revision of this page, as edited by Bobblewik (talk | contribs) at 22:07, 26 January 2006. 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.
function formatdates() {
    var s = prompt("Search regexp?");
    if(s) {
        var s = "/(_Century)\]\]/gi";
        var r = "$1";
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(s, r);
    }

    // Add a tag to the summary box
    var txt = document.editform.wpSummary;
    var summary = "reduce linking to date elements";
	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:formatdates()', '1Jan2001', 'ca-datefixer', 'Fixes some date formatting', '', '');
    }
});