User:Moondyne/infoboxschool.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Moondyne/infoboxschool. |
//
// 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', '', '');
}
});