Misplaced Pages

User:Ohconfucius/test/EngvarB.js: Difference between revisions

Article snapshot taken from[REDACTED] with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Ohconfucius Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 01:39, 23 December 2010 view sourceOhconfucius (talk | contribs)Autopatrolled, Extended confirmed users, Pending changes reviewers328,951 edits straight copy of EngvarB.js← Previous edit Revision as of 01:45, 23 December 2010 view source Ohconfucius (talk | contribs)Autopatrolled, Extended confirmed users, Pending changes reviewers328,951 edits overlay canadian variants tableNext edit →
Line 41: Line 41:
Ohc_ENGVARprotectall() Ohc_ENGVARprotectall()
var table = [ var table = [
'( ag)(ing)', '(\\bage)(ing)',
'(ai)(rplane)', '(aero)(plane)',
'(al)(uminum)', '(al)(uminium)',
'(ad)(renalin\\b)', '(ad)(renalin\\b)',
'(an)(nex\\b)', '(an)(nex\\b)',
Line 49: Line 49:
'(ar)(mor)', '(ar)(mor)',
'(ar)(tifact)', '(ar)(tifact)',
'(ana|breatha|cata|hydro|para)(lyz)', '(ana|breatha|cata|hydro|para)(lys)',
'(di)(arrhea)', '(di)(arrhoea)',
'(de|of)(fense)', '(de|of)(fense)',
'(pr)(actic)', '(pr)(actic)',
Line 59: Line 59:
'(ma)(neuver)', '(ma)(neuver)',
'(lo)(uver)', '(lo)(uver)',
'(pe)(dia|dic)', '(pae)(dia|dic)',
'(pe)(dophil)', '(pae)(dophil)',
'(sk)(eptic)', '(sk)(eptic)',
'(mo)(llusk)', '(mo)(llusk)',
'(in)(quiry)', '(in)(quiry)',
'(va)(por)', '(va)(por)',
'(li)(coric)', '(li)(quoric)',
'(on)(stage)', '(on)(stage)',
'(break|drop|clean|line|lock|pick)(out|up)', '(break|drop|clean|line|lock|pick)(out|up)',
'(he)(mo)', '(hae)(mo)',
'(or)(thopedic)', '(or)(thopaedic)',
'(ar)(cheo)', '(ar)(chaeo)',
'(pa)(leonto)', '(pa)(leonto)',
'(en)(ology)', '(en)(ology)',
Line 76: Line 76:
'(es)(trogen)', '(es)(trogen)',
'(es)(the)', '(es)(the)',
'(ho)(meopath)', '(ho)(moeopath)',
'(me)(dieval)', '(me)(diaeval)',
'(om)(elet\\b)', '(om)(elet\\b)',
'(ri)(gor)', '(ri)(gor)',
'(an|leuk|septic|tox)(emi)', '(an|leuk|septic|tox)(aemi)',
'(sp)(ecialty)', '(sp)(eciality)',
'(su)(lfur)', '(su)(lfur)',
'(lik|liv|rat|sal|siz|shak)(able)', '(lik|liv|rat|sal|siz|shak)(able)',
Line 94: Line 94:
'(dema|peda|mono|syna)(gog)', '(dema|peda|mono|syna)(gog)',
'(ana|cata|dia|epi|homo|mono|pro)(log)', '(ana|cata|dia|epi|homo|mono|pro)(log)',
'(iz)(e?|ation|ing)', '(is)(e?|ation|ing)',
'(iz)(e?|ation|ing)', //repeating to catch second instances within protected strings (quotations in particular) '(is)(e?|ation|ing)', //repeating to catch second instances within protected strings (quotations in particular)
'(bev|fu|jew|lev|mod|pan|rev|trav)(el\\w)', '(bev|fu|jew|lev|mod|pan|rev|trav)(el\\w)',
'({2,8}\\wel)(e|est|ing)', '({2,8}\\wel)(e|est|ing)',
Line 141: Line 141:


var table = { var table = {
'aging': '$1ageing', 'ageing': '$1aging',
'aluminum': '$1aluminium', 'aluminium': '$1aluminum',
'adrenalin(\\b)': '$1adrenaline$2', 'adrenalin(\\b)': '$1adrenaline$2',
'annex(\\b)': '$1annexe$2', 'annex(\\b)': '$1annexe$2',
'anti(+\\b)': '$1anti-$2', 'anti(+\\b)': '$1anti-$2',
'artifact': '$1artefact',
'(ana|breatha|cata|hydro|para)lyz(e|ing|is)': '$1$2lys$3', '(ana|breatha|cata|hydro|para)lyz(e|ing|is)': '$1$2lys$3',
'diarrhea': '$1diarrhoea', 'diarrhoea': '$1diarrhea',
'(de|of)fense': '$1$2fence', '(de|of)fense': '$1$2fence',
'(pract)ici': '$1$2isi', '(pract)ici': '$1$2isi',
Line 155: Line 154:
'(light-|dark-|\\b)gray': '$1$2grey', '(light-|dark-|\\b)gray': '$1$2grey',
'guerilla': '$1guerilla', 'guerilla': '$1guerilla',
'jewelry': '$1jewellery',
'maneuver(ab|ed|ing)': '$1manoeuvr$2', 'maneuver(ab|ed|ing)': '$1manoeuvr$2',
'maneuver': '$1manoeuvre', 'maneuver': '$1manoeuvre',
'louver': '$1louvre', 'louver': '$1louvre',
'ped(iatric|ophil)': '$1paed$2', 'paed(iatric|ophil)': '$1ped$2',
'encyclopedi(a|c)': '$1encyclopaedi$2', 'encyclopaedi(a|c)': '$1encyclopedi$2',
'skeptic': '$1sceptic', 'skeptic': '$1sceptic',
'mollusk': '$1mollusc', 'mollusk': '$1mollusc',
'in(quir(?:e|ing))': '$1en$2', 'in(quir(?:e|ing))': '$1en$2',
'vapor(s?\\b)': '$1vapour$2', 'vapor(s?\\b)': '$1vapour$2',
'licorice': '$1liquorice', 'liquorice': '$1licorice',

//composite words //composite words
// 'onstage': '$1on-stage', // 'onstage': '$1on-stage',
'(break|drop|clean|line|lock|pick)(out|up)': '$1$2-$3', '(break|drop|clean|line|lock|pick)(out|up)': '$1$2-$3',

//oe/ae words //oe/ae words
'gyneco': '$1gynaeco', 'gyneco': '$1gynaeco',
'hemo(globin|ly|phil|rr)': '$1haemo$2', 'hemo(globin|ly|phil|rr)': '$1haemo$2',
'orthopedic': '$1orthopaedic', 'orthopaedic': '$1orthopedic',
'archeo': '$1archaeo', 'archaeo': '$1archeo',
'paleonto': '$1palaeonto', 'palaeonto': '$1paleonto',
'enology': '$1oenology', 'oenology': '$1enology',
'esophag': '$1oesophag', 'oesophag': '$1esophag',
'estrogen': '$1oestrogen', 'oestrogen': '$1estrogen',
'(an|)esthe(sia|tic|tist)': '$1$2aesthe$3', '(an|)aesthe(sia|tic|tist)': '$1$2esthe$3',
'anesthesiologist': '$1anaesthetist', 'anaesthesiologist': '$1anesthetist',
'homeopath': '$1homoeopath', 'homoeopath': '$1homeopath',
// 'medieval(\\b)': '$1mediaeval$2',
'omelet(\\b)': '$1omelette$2', 'omelet(\\b)': '$1omelette$2',
'rigor(\\b)': '$1rigour$2', 'rigor(\\b)': '$1rigour$2',
'(an|leuk|septic|tox)emi(a|c)': '$1$2aemi$3', '(an|leuk|septic|tox)aemi(a|c)': '$1$2emi$3',

//'f' words //'f' words
'sulfur': '$1sulphur', 'sulfur': '$1sulphur',

'anymore': '$1any more', 'anymore': '$1any more',
'specialty': '$1speciality', 'speciality': '$1specialty',

// non-redundant e // non-redundant e
'(lik|liv|rat|sal|siz|shak)(able)': '$1$2e$3', '(lik|liv|rat|sal|siz|shak)(able)': '$1$2e$3',

//'~our' words //'~our' words
'(arm|clam|glam|harb|neighb|rum|savi?)or(ed|ful|ing|less|ly|s|\\b)': '$1$2our$3', '(arm|clam|glam|harb|neighb|rum|savi?)or(ed|ful|ing|less|ly|s|\\b)': '$1$2our$3',
Line 205: Line 202:
'(endeav|lab)or(e|ing|s|\\W)': '$1$2our$3', '(endeav|lab)or(e|ing|s|\\W)': '$1$2our$3',
'mol(d|t)(ed|ing|s|\\W)': '$1moul$2$3', 'mol(d|t)(ed|ing|s|\\W)': '$1moul$2$3',

//'~re~' words //'~re~' words
'(calib|fib|goit|lust|mit|nit|och|reconnoit|sab|saltpet|spect|theat|tit)er(s?\\W)': '$1$2re$3', '(calib|fib|goit|lust|mit|nit|och|reconnoit|sab|saltpet|spect|theat|tit)er(s?\\W)': '$1$2re$3',
Line 211: Line 208:
'(centi|milli|deci|pico|hecto|\\b)liter(s?\\b)': '$1$2litre$3', '(centi|milli|deci|pico|hecto|\\b)liter(s?\\b)': '$1$2litre$3',
'(dema|peda|mono|syna)gog(s?\\W)': '$1$2gogue$3', '(dema|peda|mono|syna)gog(s?\\W)': '$1$2gogue$3',
// '(\\W{3,12})iz(e?|ation(s|al|)|ing)': '$1$2is$3',
// '(empha)siz(e|ing)': '$1$2sis$3', //rem synthesiser conversion - equally common

//'~l' words where the 'l' doubles as past and present participle //'~l' words where the 'l' doubles as past and present participle
'(pan)el(ist)': '$1$2ell$3', '(pan)el(ist)': '$1$2ell$3',
Line 220: Line 215:
'(app|di|enthr|equ|journ|riv|sign|tot)al(e|ing)': '$1$2all$3', '(app|di|enthr|equ|journ|riv|sign|tot)al(e|ing)': '$1$2all$3',
} }

for (var word in table) { for (var word in table) {
var txt=""; var txt="";
try { try {
var re = new RegExp('()' + word, 'g') var re = new RegExp('(\\b)' + word, 'g')
regex(re, table) regex(re, table)
} }
Line 234: Line 229:
} }
} }

var table = { var table = {
//'~our' words //'~our' words
'()(flav|hum)or(ed|ful|fully|ings?|less|lessly|s?\\W)': '$1$2our$3', '\\b(flav|hum)or(ed|ful|fully|ings?|less|lessly|s?\\W)': '$1our$2',
'()color(e|ful|fully|ings?|less|lessly)': '$1colour$2', '\\bcolor(e|ful|fully|ings?|less|lessly)': 'colour$1',
'()colors(|*)': '$1colours$2', '()colors(|*)': '$1colours$2',

//'~re~' words //'~re~' words
'()(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)er(ed|ing)': '$1$2r$3', '()(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)er(ed|ing)': '$1$2r$3',
Line 248: Line 243:
'()(ana|cata|dia|epi|homo|mono|pro)log(ed|ing)': '$1$2logu$3', '()(ana|cata|dia|epi|homo|mono|pro)log(ed|ing)': '$1$2logu$3',
'()(ana|cata|dia|epi|homo|mono|pro)log(s?\\b)': '$1$2logue$3', '()(ana|cata|dia|epi|homo|mono|pro)log(s?\\b)': '$1$2logue$3',

//'~l' words where the 'l' doubles as past and present participle //'~l' words where the 'l' doubles as past and present participle
'()(counc)l(e|ing|ors?)(\\b)': '$1$2ll$3$4', '\\b(counc)l(e|ing|ors?)\\b': '$1ll$2',
'(\\s*)ll(ful|ment)': '$1l$2', '\\b(*)ll(ful|ment)': '$1l$2',
'(movie theat(er|re))': 'cinema', // '(movie theat(er|re))': 'cinema',

'()airplane': '$1aeroplane',
} }

for (var word in table) { for (var word in table) {
var txt=""; var txt="";
Line 270: Line 264:
} }
} }

//to add //to add
//protestors //protestors

Revision as of 01:45, 23 December 2010

// This script converts American English spellings into British spellings.
// PLEASE READ THE DOCUMENTATION at ] (click on the link above) before using.

// Feedback and constructive criticism are welcome. 
// As I am a scripting newbie, any technical advice on the 'hows and the wherefores' are especially welcome.

/*************
*** Regex menu framework
*** by ] <http://meta.wikimedia.org/User:Pathoschild/Scripts/Regex_menu_framework>
***	- adds a sidebar menu of user-defined scripts.
*************/
importScriptURI('http://meta.wikimedia.org/search/?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');
 
/* menu links */
// In the function below, add more lines like "regexTool('link text','function_name()')" to add
// links to the sidebar menu. The function name is the function defined in rfmscripts() below.
function rmflinks() {
	regexTool('Custom regex','custom()'); // a default tool which performs regex input in a dynamic form
	regexTool('Edit my regexes ↗','function opennew(url) { window.open(url); }; opennew(wgServer + wgScript + "?title=User:" + wgUserName + "/EngvarB.js&action=edit");');

	regexTool('• Protect words','Ohc_ENGVARprotectwords()');
	regexTool('• BRITISH spelling','SetEnglish("B")');
//	regexTool('• BRITISH (Oxford) passive','SetEnglish("P")');
	regexTool('• BRITISH (Oxford)','SetEnglish("Ox")');

	//Fix formatting of links in the sidebar
	var r = document.getElementById('p-regex')
	if (r){
		r.className += ' portal'
		var d = r.getElementsByTagName('div')
		if (d) d.className += ' pBody body'
	}
}
 
/* scripts */
// Below, define the functions linked to from rmflinks() above. These functions can use any JavaScript,
// but there is a set of simplified tools documented at
// http://meta.wikimedia.org/User:Pathoschild/Script:Regex_menu_framework .

function Ohc_ENGVARprotectwords(){
	Ohc_ENGVARprotectall()
	var table = [
		'(\\bage)(ing)',
		'(aero)(plane)',
		'(al)(uminium)',
		'(ad)(renalin\\b)',
		'(an)(nex\\b)',
		'(anti)(+\\b)',
		'(ar)(mor)',
		'(ar)(tifact)',
		'(ana|breatha|cata|hydro|para)(lys)',
		'(di)(arrhoea)',
		'(de|of)(fense)',
		'(pr)(actic)',
		'(fu)(ror\\b)',
		'(gr)(ay)',
		'(gu)(erilla)',
		'(je)(welry)',
		'(ma)(neuver)', 
		'(lo)(uver)', 
		'(pae)(dia|dic)',
		'(pae)(dophil)',
		'(sk)(eptic)',
		'(mo)(llusk)',
		'(in)(quiry)',
		'(va)(por)',
		'(li)(quoric)',
		'(on)(stage)',
		'(break|drop|clean|line|lock|pick)(out|up)',
		'(hae)(mo)',
		'(or)(thopaedic)',
		'(ar)(chaeo)',
		'(pa)(leonto)',
		'(en)(ology)',
		'(es)(ophag)',
		'(es)(trogen)',
		'(es)(the)',
		'(ho)(moeopath)',
		'(me)(diaeval)',
		'(om)(elet\\b)',
		'(ri)(gor)',
		'(an|leuk|septic|tox)(aemi)',
		'(sp)(eciality)',
		'(su)(lfur)',
		'(lik|liv|rat|sal|siz|shak)(able)',
		'(clam|glam|harb|neighb|rum|savi?)(or)',
		'(behavi|col|fl?av|hon|hum|lab)(or)',
		'(behavi|col|fl?av|hon|hum|lab)(or)', //repeating to catch second instances within protected strings (quotations in particular)
		'(mo)(l)',
		'(calib|fib|goit|lust|mit|nit|och|reconnoit|sab|saltpet|spect|theat|tit)(er)',
		'(cent)(er)',
		'(me)(ter)',
		'(centi|milli|deci|pico|hecto)(liter)',
		'(dema|peda|mono|syna)(gog)',
		'(ana|cata|dia|epi|homo|mono|pro)(log)',
		'(is)(e?|ation|ing)',
		'(is)(e?|ation|ing)', //repeating to catch second instances within protected strings (quotations in particular)
		'(bev|fu|jew|lev|mod|pan|rev|trav)(el\\w)',
		'({2,8}\\wel)(e|est|ing)',
		'(counci|dia)(le|ling|lor)',
		'(app|di|enthr|equ|journ|riv|sign|tot)(ale|aling)',
	];

	for (i=0; i<table.length; i++) {
		var expr = [
			+?)',				'(+?<\\/.+?>)'],
			*?(?:image|title)*?=*?)',			'(*?\\|)'],
			]*?)',			'(]*?\\])'],
			ile|mage):*?)',		'({0,20}\\.)'],
			{0,6}(?:uot{1,7}\\s?||sic)\\|*?)', '(*?})'], 
		];
		for (j=0; j<expr.length; j++) {
			try {
				var re = new RegExp(expr + table + expr, 'g')
				regex(re, '$1$2♫$3$4')
			}
			catch(err) {

				txt="There was an error on function Ohc_ENGVARprotectwords(), when changing '"+ expr + table + expr + "' => '$1$2♫$3$4'.\n\n";
				txt+="Error: " + err.message + "\n\n";
				txt+="Click OK to continue.\n\n";
				alert(txt);
			}
		}
	}
}
function Ohc_ENGVARprotectall(){
	//protect from function re_z-words
	regex(/(enterpri|promi|surpri)(se?|ing)/g, '$1♫$2'); 
	regex(/\b(ant)(iq|ic|imon)/g, '$1♫$2');  
	regex(/(nobelpri|imagesi|picsi)(ze)/g, '$1♫$2');  
	regex(/({{cleanup)/g, '{{Cleanup');
	regex(/(\|*?)cleanup(*?\=)/g, '$1clean♫up$2');

	regex(/(\|*?enroll?)(ment*?=)/g, '$1♫$2');  

//	regex(/(foo)(bar)/g, '$1♫$2');
}
function Ohc_ENGVARSimple(){
	//Ohc_ENGVARprotectwords()

	var table = {
		'ageing':	'$1aging',
		'aluminium':	'$1aluminum',
		'adrenalin(\\b)':	'$1adrenaline$2',
		'annex(\\b)':	'$1annexe$2',
		'anti(+\\b)':	'$1anti-$2',
		'(ana|breatha|cata|hydro|para)lyz(e|ing|is)':	'$1$2lys$3',
		'diarrhoea':	'$1diarrhea',
		'(de|of)fense':	'$1$2fence',
		'(pract)ici':	'$1$2isi',
		'(pract)ic(ed)':	'$1$2is$3',
		'furor(\\b)':	'$1furore$2',
		'(light-|dark-|\\b)gray':	'$1$2grey',
		'guerilla':	'$1guerilla',
		'maneuver(ab|ed|ing)':	'$1manoeuvr$2',
		'maneuver':	'$1manoeuvre',
		'louver':	'$1louvre',
		'paed(iatric|ophil)':	'$1ped$2',
		'encyclopaedi(a|c)':	'$1encyclopedi$2',
		'skeptic':	'$1sceptic',
		'mollusk':	'$1mollusc',
		'in(quir(?:e|ing))':	'$1en$2',
		'vapor(s?\\b)':	'$1vapour$2',
		'liquorice':	'$1licorice',
 
		//composite words
//		'onstage':	'$1on-stage',
		'(break|drop|clean|line|lock|pick)(out|up)':	'$1$2-$3',
 
		//oe/ae words
		'gyneco':	'$1gynaeco',
		'hemo(globin|ly|phil|rr)':	'$1haemo$2',
		'orthopaedic':	'$1orthopedic',
		'archaeo':	'$1archeo',
		'palaeonto':	'$1paleonto',
		'oenology':	'$1enology',
		'oesophag':	'$1esophag',
		'oestrogen':	'$1estrogen',
		'(an|)aesthe(sia|tic|tist)':	'$1$2esthe$3',
		'anaesthesiologist':	'$1anesthetist',
		'homoeopath':	'$1homeopath',
		'omelet(\\b)':	'$1omelette$2',
		'rigor(\\b)':	'$1rigour$2',
		'(an|leuk|septic|tox)aemi(a|c)':	'$1$2emi$3',
 
		//'f' words
		'sulfur':	'$1sulphur',
 
		'anymore':	'$1any more',
		'speciality':	'$1specialty',
 
		// non-redundant e
		'(lik|liv|rat|sal|siz|shak)(able)':	'$1$2e$3',
 
		//'~our' words
		'(arm|clam|glam|harb|neighb|rum|savi?)or(ed|ful|ing|less|ly|s|\\b)':	'$1$2our$3',
		'neighborhood':	'$1neighbourhood',
		'behavior(al|s|\\b)':	'$1behaviour$2',
		'favor(abl|ed|i*|s|\\b)':	'$1favour$2',
		'honor(abl|ed|ing|s|\\b)':	'$1honour$2',
		'(endeav|lab)or(e|ing|s|\\W)':	'$1$2our$3',
		'mol(d|t)(ed|ing|s|\\W)':	'$1moul$2$3',
 
		//'~re~' words
		'(calib|fib|goit|lust|mit|nit|och|reconnoit|sab|saltpet|spect|theat|tit)er(s?\\W)':	'$1$2re$3',
		'(centi|kilo|micro|milli|nano|-|\\d\\s)meter':	'$1$2metre',
		'(centi|milli|deci|pico|hecto|\\b)liter(s?\\b)':	'$1$2litre$3',
		'(dema|peda|mono|syna)gog(s?\\W)':	'$1$2gogue$3',
 
		//'~l' words where the 'l' doubles as past and present participle
		'(pan)el(ist)':	'$1$2ell$3', 
		'(bev|fu|jew|lev|mod|rev|trav)el(e|ing)':	'$1$2ell$3', 
		'({2,8})el(e|est|ing)(\\b)':	'$1$2ell$3$4',
		'(app|di|enthr|equ|journ|riv|sign|tot)al(e|ing)':	'$1$2all$3',
	}
 
	for (var word in table) {
		var txt="";
		try {
			var re = new RegExp('(\\b)' + word, 'g')
			regex(re, table)
		}
		catch(err) {
			txt="There was an error on function Ohc_ENGVARSimple(), when changing '"+ word + "' => '"+ table +"'.\n\n";
			txt+="Error: " + err.message + "\n\n";
			txt+="Click OK to continue.\n\n";
			alert(txt);
		}
	}
 
	var table = {
		//'~our' words
		'\\b(flav|hum)or(ed|ful|fully|ings?|less|lessly|s?\\W)':	'$1our$2',
		'\\bcolor(e|ful|fully|ings?|less|lessly)':	'colour$1',
		'()colors(|*)':	'$1colours$2',
 
		//'~re~' words
		'()(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)er(ed|ing)':	'$1$2r$3',
		'( *\\-)(col|flav|hum)ored':	'$1$2oured',
		'()(cent|epicent|recent)er(ed|ing)':	'$1$2r$3',
		'()(cent|epicent|recent)ers':	'$1$2res',
		'()(ana|cata|dia|epi|homo|mono|pro)log(ed|ing)':	'$1$2logu$3',
		'()(ana|cata|dia|epi|homo|mono|pro)log(s?\\b)':	'$1$2logue$3',
 
		//'~l' words where the 'l' doubles as past and present participle
		'\\b(counc)l(e|ing|ors?)\\b':	'$1ll$2',
		'\\b(*)ll(ful|ment)':	'$1l$2',
//		'(movie theat(er|re))':	'cinema',
 
	}
 
	for (var word in table) {
		var txt="";
		try {
			var re = new RegExp(word, 'g')
			regex(re, table)			
		}
		catch(err) {
			txt="There was an error on function Ohc_ENGVARSimple(), when changing '"+ word + "' => '"+ table +"'.\n\n";
			txt+="Error: " + err.message + "\n\n";
			txt+="Click OK to continue.\n\n";
			alert(txt);
		}
	}
 
	//to add
	//protestors
	//reconvert special cases
}

function SetEnglish(v) {
	Ohc_ENGVARunprotectwords();
	Ohc_ENGVARprotectwords();
	Ohc_ENGVARSimple();
	switch (v) {
		case 'Ox':
			re_zwords();
			Ohc_ENGVARXedit_summary();
			break;
		case 'B':
			zwords();
			Ohc_ENGVARBedit_summary();
			break;
		case 'P':
			alert('Feature not implemented');
			break;
	}
	Ohc_ENGVARunprotectwords();
	insert_Engvar(v);
	doaction('diff');
//	Ohc_ENGVARedit_summary();
}

function Simpleplus() {
	Ohc_ENGVARunprotectwords();
	Ohc_ENGVARSimple();
	zwords();
	Ohc_ENGVARunprotectwords();
	insert_Engvar('B')
	Ohc_ENGVARedit_summary();
}

function zwords(){
	regex(/({3,12})iz(e?|ations?|abl|ing)(\W)/g, '$1is$2$3');
	regex(/(empha|synthe)siz(e|ing)/g, '$1sis$2'); 
}
 
function re_zwords(){
	//converts s-words into Oxford z-words
 
	regex(/()(ar|de|improv|parad|(?:com|)pr|rev|surm|telev)is(e|ing)/g, '$1$2♫is$3'); 
	regex(/({5,12})is(ations?)(\W)/g, '$1iz$2$3');
	regex(/({0,12}(?:|ph|rd|thes))is(e?|ing)(\W)/g, '$1iz$2$3');
}
function Ohc_ENGVARunprotectwords(){
	regex(/(\w)♫(\w)/g, '$1$2');
}

function insert_Engvar(v1){
	// Add a template to the article identifying English variant
	var box = document.editform.wpTextbox1;
	var txt = box.value;

        // Build a string with "Month YYYY"
        var dateobj=new Date();
        var month=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
        var datestr= month + ' ' + dateobj.getFullYear();

        // Matches Use British English or EngvarB
        var reB = new RegExp('{{*(?:se+British+English|ngvarB)*(?:|\\|*date*=*)*}}', 'gi');
        // Matches Use British (Oxford) English or EngvarOx
        var reOx = new RegExp('{{*(?:se+British+\\(Oxford\\)+English|ngvarOx)*(?:|\\|*date*=*)*}}', 'gi');

        if( 'Ox' == v1 ) {
            // Replace British with British (Oxford)
            txt = txt.replace( reB, '{{Use British (Oxford) English|date=' + datestr + '}}');
            // Prepend British (Oxford) template if not already tagged
            if( txt.search(reOx) == -1 ) {
                txt = '{{Use British (Oxford) English|date=' + datestr + '}}\r\n' + txt;
            }
        } else {
           // Replace British (Oxford) with British
           txt = txt.replace( reOx, '{{Use British English|date=' + datestr + '}}');
           // Prepend British template if not already tagged
           if( txt.search(reB) == -1 ) {
               txt = '{{Use British English|date=' + datestr + '}}\r\n' + txt;
           }
        }

	box.value = txt;
}


function Ohc_ENGVARBedit_summary(){
	//Add a tag to the summary box
	setoptions(minor='true'); //removed ",watch='false'" in response to user notification 13 Nov. 2010
	setreason('] by ]', 'append');
//	doaction('diff');
}
function Ohc_ENGVARXedit_summary(){
	//Add a tag to the summary box
	setoptions(minor='true'); //removed ",watch='false'" in response to user notification 13 Nov. 2010
	setreason('all to ] by ]', 'append');
//	doaction('diff');
}
User:Ohconfucius/test/EngvarB.js: Difference between revisions Add topic