User:Quadell/monobook.js/dates.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
function formatdates() { var s = ";[;[(January|February|March|April|May|June|July|August|September|October|November|December) (;d;d?);];], ;[;[(;d;d;d;d);];]" var r = "[[$1 $2]] [[$3]]"; var s2 = prompt("Type backslash"); if(s2) { s = s.replace(new RegExp(/;/g), s2); var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } // Add a tag to the summary box var txt = document.editform.wpSummary; var summary = "Removing commas from dates per MoS. "; 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()', 'regexp', 'ca-datefixer', 'Fixes formatting with regexps', '', ''); } });