Jump to content

User:Moondyne/AUDfixes.js

From Wikipedia, the free encyclopedia
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.
// <nowiki>
function AUDfixes() {
  var	txt=document.editform.wpTextbox1;

  txt.value=txt.value.replace(/{{AUD\|([^}]+)}}/, '{{A\$|$1}}');
  txt.value=txt.value.replace(/\[\[Australian\sdollar\|AU\$\]\]/gi, '{{A\$}}');
  txt.value=txt.value.replace(/AU\$/gi, 'A\$');

}
 
function run_AUDfixes() {
  AUDfixes();
  var txt=document.editform.wpSummary;    // Update the summary box
  var summary = "[[WP:$]] AUD fixes";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
  document.editform.wpDiff.click();
}

$(function () {
 if(document.forms.editform) {
  mw.util.addPortletLink('p-tb', 'javascript:run_AUDfixes()', 'AUDfixes', 't-addmetric', 'Fixes', '', '');
  }
});
// </nowiki>