Jump to content

User:Atrian/monobook.js/canenglish.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.
//'winc' function allows buttons to be added toolbar

winc('User:Omegatron/monobook.js/addlink.js');

function canenglish() {
    var txt = document.editform.wpTextbox1;

    // -our, not -or, eg. colour 
    txt.value = txt.value.replace(/color/g, 'colour');
    txt.value = txt.value.replace(/Color/g, 'Colour');
    txt.value = txt.value.replace(/vapor/g, 'vapour');
    txt.value = txt.value.replace(/Vapor/g, 'Vapour');
    txt.value = txt.value.replace(/neighbor/g, 'neighbour');
    txt.value = txt.value.replace(/Neighbor/g, 'Neighbour');

    // -re, not -er, eg. centre
    txt.value = txt.value.replace(/center/g, 'centre');
    txt.value = txt.value.replace(/Center/g, 'Centre');
    txt.value = txt.value.replace(/theater/g, 'theatre');
    txt.value = txt.value.replace(/Theater/g, 'Theatre');

    // Add a tag to the summary box
    var txt = document.editform.wpSummary;
    //Made summary more accurate: not all links are removed. Keep summary brief
    var summary = "Change to Canadian spelling";
	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()
}

$(function () {
    if(document.forms.editform) {
        addLink('p-cactions', 'javascript:canenglish()', 'canglish', 'ca-canadianenglish', 'Changes to Canadian spelling', '', '');
    }
});