Jump to content

User:Moondyne/infoboxschool.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
//
// stolen and adapted from User:Ohconfucius/formatgeneral.js
//

function infoboxschool() {
  var	txt=document.editform.wpTextbox1;
 
// infoboxschool
	txt.value=txt.value.replace(/(Infobox Aust school private)/i, 'Infobox school');
	txt.value=txt.value.replace(/(Infobox Australia school private)/i, 'Infobox school');
	txt.value=txt.value.replace(/(colors)/i, 'colours');
	txt.value=txt.value.replace(/(enrollment)/i, 'enrolment');
	txt.value=txt.value.replace(/(key_people)/i, 'principal ');
	txt.value=txt.value.replace(/\(Principal\)/gi, '');        
	txt.value=txt.value.replace(/(num_employ)/i, 'staff');
	txt.value=txt.value.replace(/(\|\s*revenue\s*=(.*?)\n)/i, '');
	txt.value=txt.value.replace(/(\|\s*products\s*=(.*?)\n)/i, '');
	txt.value=txt.value.replace(/(\|\s*fees\s*=(.*?)\n)/i, '');

}
 
function run_infoboxschool() {
 var txt=document.editform.wpTextbox1;
    infoboxschool();
 
// Update the summary box
 var txt=document.editform.wpSummary;
    var summary = "Replacing with Infobox school and other 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_infoboxschool()', 'infoboxschool', 't-addmetric', 'Fixes some stuff', '', '');
  }
});