User:Jimp/vector.js

$.holdReady(true); mediaWiki.loader.load("https://toolserver.org/~netaction/wikitrust.js");

// User:ais523/bracketmatch.js - Colour matching brackets in a copy of the edit box. // By User:ais523, on a suggestion by User:Absidy.

addOnloadHook(function{ var p=document.getElementById('wikiPreview');  if(p==null) p=document.getElementById('viewsourcetext');  if(p)    p.innerHTML+="Parse ";  try  {    var edh=document.getElementsByClassName('editHelp')[0];    if(bm_useparsebutton)      edh.innerHTML='  '+edh.innerHTML;  } catch(x) {} });

function bm_parsebrackets { var t=document.getElementById('wpTextbox1').value; var a=sajax_init_object; var p='action=expandtemplates&generatexml=1&format=json&callback=bm_callback&text='+encodeURIComponent(t); a.open('POST', mw.config.get('wgServer')+mw.config.get('wgScriptPath')+'/api.php'); a.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); a.setRequestHeader("Content-length", p.length); a.setRequestHeader("Connection", "close"); a.onreadystatechange=function{bm_apirespond(a)}; a.send(p); }

function bm_showparsed { bm_parsebrackets; return 0; }

function bm_apirespond(a) { try {   if(a.readyState==4) eval(a.responseText); } catch(e) {   document.getElementById('bm_parseres').innerHTML= "Could not parse due to a server error. Parse"; } }

var colang;

function bm_hexdigit(n) { var i=Math.floor(n); if(i<10) return i+''; if(i==10) return 'A'; if(i==11) return 'B'; if(i==12) return 'C'; if(i==13) return 'D'; if(i==14) return 'E'; if(i==15) return 'F'; }

function bm_tohex(n) { var i=Math.floor(n); return bm_hexdigit(i/16)+bm_hexdigit(i%16); }

function bm_gencol(ang) { var r=Math.sin(ang)+1; var g=Math.sin(ang+3.14159*2/3)+1; var b=Math.sin(ang-3.14159*2/3)+1; return bm_tohex(r*127.5)+bm_tohex(g*127.5)+bm_tohex(b*127.5); }

function bm_callback(o) { var subs={"tplarg":"", "template":"", "part":"|", "ext":"&"+"lt;", "/attr":"&"+"gt;", "attr/":"&"+"gt;"}; var h=o.parsetree["*"].split("<"); var i=h.length; var r; var n;  var sp=0; var st=new Array; var col; colang=0; while(--i) {   col=""; n=1; h[i]=h[i].split(">"); h[i][0]=h[i][0].split(" "); r=subs[h[i][0][0]]; if(r==undefined) r=""; if(r=='}}}'||r=='}}') {     st[sp]=bm_gencol(colang); col=st[sp]; sp++; colang+=2.4; //golden angle in radians, approx }   else if(r=='{{{'||r=='{{') {     sp--; col=st[sp]; n=2; }   if(col!="") r=""+r+" "; h[i][0]=r; h[i]=h[i].join(""); } document.getElementById('bm_parseres').innerHTML= " "+h.join("").split("\n").join(" ")+ " Parse "; }

function bm_highlight(x,c) { document.getElementById('bm_f'+x+'1').style.backgroundColor=c; document.getElementById('bm_f'+x+'2').style.backgroundColor=c; if(c=="black") window.setTimeout("bm_highlight('"+x+"','transparent')",3000); }

// This script converts American English spellings into British spellings. // PLEASE READ THE DOCUMENTATION at User:Ohconfucius/EngvarB (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.

/************* mw.loader.load('https://meta.wikimedia.org/w/index.php?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(mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=User:" + wgUserName + "/EngvarB.js&action=edit");');
 * Regex menu framework
 * by m:user:Pathoschild 
 * - adds a sidebar menu of user-defined scripts.

regexTool('• Protect words','Ohc_ENGVARprotectwords'); regexTool('• Flip Convert','Ohc_flip'); regexTool('• AUS spelling','SetEnglish("A")'); regexTool('• BRITISH spelling','SetEnglish("B")'); regexTool('• BRITISH (Oxford)','SetEnglish("Ox")'); regexTool('• CANADIAN','SetEnglish("C")');

//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[0]) d[0].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/wiki/User:Pathoschild/Script:Regex_menu_framework.

function Ohc_ENGVARprotectwords{ Ohc_ENGVARprotectall var table = [ '( ag)(ing)', '(ai)(rplane)', '(al)(uminum)', '(ad)(renalin\\b)', '(an)(nex\\b)', '(anti)([\\w]+\\b)', '(ar)(mor)', '(ar)(tifact)', '(ana|breatha|cata|hydro|para)(lyz)', '(be)(stsell)', '(di)(arrhea)', '(de|of)(fense)', '(pr)(actic[ei])', '(fu)(ror\\b)', '(gr)(ay)', '(gu)(erilla)', '(je)(welry)', '(ma)(neuver)', '(lo)(uver)', '(pe)(dia|dic)', '(pe)(dophil)', '(sk)(eptic)', '(mo)(llusk)', '(in)(quiry)', '(va)(por)', '(li)(coric)', '(on)(stage)', '(break|drop|clean|line|lock|pick)(out|up)', '(he)(mo)', '(or)(thopedic)', '(ar)(cheo)', '(pa)(leonto)', '(en)(ology)', '(es)(ophag)', '(es)(trogen)', '(es)(the)', '(ho)(meopath)', '(me)(dieval)', '(om)(elet\\b)', '(ri)(gor)', '(an|leuk|septic|tox)(emi)', '(sp)(ecialty)', '(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[dt])', '(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)', '(iz)(e[drs]?|ation|ing)', '(iz)(e[drs]?|ation|ing)', //repeating to catch second instances within protected strings (quotations in particular) '(bev|fu|jew|lev|mod|pan|rev|trav)(el\\w)', '([a-z]{2,8}\\wel)(e[dr]|est|ing)', '(counci|dia)(le[dr]|ling|lor)', '(app|di|enthr|equ|journ|riv|sign|tot)(ale[dr]|aling)', ];

for (i=0; i[^<]+?)',				'([^<]+?)'],			['(\\|[ ]*?(?:image|title)[ ]*?=[^\\|]*?)',			'([^\\|]*?\\|)'], ['(\\[Category:[^\\]]*?)',			'([^\\]]*?\\])'], ['(\\[(?:[Ff]ile|[Ii]mage):[^\\.]*?)',		'([^\\.]{0,20}\\.)'], ['({[^{]{0,6}(?:[Qq]uot[^\\|]{1,7}\\s?|[Qq]|sic)\\|[^}]*?)', '([^}]*?})'], ];		for (j=0; j '$1$2♫$3$4'.\n\n"; txt+="Error: " + err.message + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); }		}	} }

function Ohc_ENGVARCprotectwords{ Ohc_ENGVARprotectall var table = [ '(\\bage)(ing)', '(aero)(plane)', '(al)(uminium)', '(ad)(renalin\\b)', '(an)(nex\\b)', '(anti)([\\w]+\\b)', '(ar)(mor)', '(ar)(tifact)', '(ana|breatha|cata|hydro|para)(lys)', '(be)(stsell)', '(di)(arrhoea)', '(de|of)(fense)', '(pr)(actic[ei])', '(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[dt])', '(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[drs]?|ation|ing)', '(is)(e[drs]?|ation|ing)', //repeating to catch second instances within protected strings (quotations in particular) '(bev|fu|jew|lev|mod|pan|rev|trav)(el\\w)', '([a-z]{2,8}\\wel)(e[dr]|est|ing)', '(counci|dia)(le[dr]|ling|lor)', '(app|di|enthr|equ|journ|riv|sign|tot)(ale[dr]|aling)', ];

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

txt="There was an error on function Ohc_ENGVAR-Cprotectwords, when changing '"+ expr[j][0] + table[i] + expr[j][1] + "' => '$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 infobox field names regex(/(\|[ ]*?ship hon)(ou?rs[ ]*?\=)/g, '$1♫$2');

//protect from function re_z-words regex(/(enterpri|promi|surpri)(se[drs]?|ing)/g, '$1♫$2'); regex(/\b(ant)(ic|idote|imon|ipath|iq)/g, '$1♫$2'); regex(/(nobelpri|imagesi|picsi)(ze)/g, '$1♫$2'); regex(/(\|[ ]*?)cleanup([ ]*?\=)/g, '$1clean♫up$2'); regex(/((?:cite|\|)[ ]*?encyclop)(edia[ ]*?\=)/g, '$1♫$2'); regex(/(\|[ ]*?enroll?)(ment[ ]*?=)/g, '$1♫$2');

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

var table = { 'aging':	'$1ageing', 'aluminum':	'$1aluminium', 'adrenalin(\\b)':	'$1adrenaline$2', 'annex(\\b)':	'$1annexe$2', 'artifact':	'$1artefact', '(ana|breatha|cata|hydro|para)lyz(e|ing|is)':	'$1$2lys$3', 'bestsell':	'$1best-sell', 'diarrhea':	'$1diarrhoea', '(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', 'jewelry':	'$1jewellery', 'maneuver(ab|ed|ing)':	'$1manoeuvr$2', 'maneuver':	'$1manoeuvre', 'louver':	'$1louvre', 'ped(iatric|ophil)':	'$1paed$2', 'encyclopedi(a|c)':	'$1encyclopaedi$2', 'skeptic':	'$1sceptic', 'mollusk':	'$1mollusc', 'in(quir(?:e|ing))':	'$1en$2', 'vapor(s?\\b)':	'$1vapour$2', 'licorice':	'$1liquorice',

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

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

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

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

// 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', '(arm|sav)or(ies|y|s|\\b)':	'$1$2our$3', 'neighborhood':	'$1neighbourhood', 'behavior(al|s|\\b)':	'$1behaviour$2', 'favor(abl[ey]|ed|i[\\w]*|s|\\b)':	'$1favour$2', 'honor(abl[ey]|ed|ing|s|\\b)':	'$1honour$2', '(endeav|lab)or(e[dr]|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', //		'(\\W[a-z]{3,12}[^s\\b])iz(e[drs]?|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 '((?:\\w{3,9}[-–—]|)(?:fu|pan))el(e[dr]|ist|ing)':	'$1$2ell$3', '(bev|jew|lev|mod|rev|trav)el(e[dr]|ing)':	'$1$2ell$3', '([a-z]{2,8}[^egl ])el(e[dr]|est|ing)(\\b)':	'$1$2ell$3$4', '(app|di|enthr|equ|journ|riv|sign|tot)al(e[dr]|ing)':	'$1$2all$3', }

for (var word in table) { var txt=""; try { var re = new RegExp('([ \\|\\[\\*])' + word, 'g') regex(re, table[word]) }		catch(err) { txt="There was an error on function Ohc_ENGVARSimple, when changing '"+ word + "' => '"+ table[word] +"'.\n\n"; txt+="Error: " + err.message + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); }	}

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

//'~re~' words '([^\\w\\d\\-\\/=])(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)er(ed|ing)':	'$1$2r$3', '( [\\w\\D]*\\-)(col|flav|hum)ored':	'$1$2oured', '([^\\w\\d\\-\\/=])(cent|epicent|recent)er(ed|ing)':	'$1$2r$3', '([^\\w\\d\\-\\/=])(cent|epicent|recent)ers':	'$1$2res', '([^\\w\\d\\-\\/])(ana|cata|dia|epi|homo|mono|pro)log(ed|ing)':	'$1$2logu$3', '([^\\w\\d\\-\\/])(ana|cata|dia|epi|homo|mono|pro)log(s?\\b)':	'$1$2logue$3',

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

'([ \\|\\[\\*])airplane':	'$1aeroplane', }

for (var word in table) { var txt=""; try { var re = new RegExp(word, 'g') regex(re, table[word]) }		catch(err) { txt="There was an error on function Ohc_ENGVARSimple, when changing '"+ word + "' => '"+ table[word] +"'.\n\n"; txt+="Error: " + err.message + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); }	}

//remove US spelling from undefined undefined template output regex(/({{convert\|[^\}]*)\|(?:sp|spell)[ ]*=[ ]*us/gi, '$1'); regex(/({{(?:in|ft|yd|[mck]?m)[23]?[ ]+to[ ]+[^\}]*)\|(?:sp|spell)[ ]*=[ ]*(?:American|us)/gi, '$1'); regex(/({{(?:pd|pop[ ]+density[ ])+(?:km|mi)2[^\}]*)\|(?:sp|spell)[ ]*=[ ]*(?:American|us)/gi, '$1');

//protestors //reconvert special cases }

function Ohc_ENGVARCSimple{

var table = { 'ageing':	'$1aging', 'aluminium':	'$1aluminum', 'adrenalin(\\b)':	'$1adrenaline$2', 'annex(\\b)':	'$1annexe$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', '(arm|sav)or(ies|y|s|\\b)':	'$1$2our$3', 'neighborhood':	'$1neighbourhood', 'behavior(al|s|\\b)':	'$1behaviour$2', 'favor(abl[ey]|ed|i[\\w]*|s|\\b)':	'$1favour$2', 'honor(abl[ey]|ed|ing|s|\\b)':	'$1honour$2', '(endeav|lab)or(e[dr]|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 '((?:\\w{3,9}[-–—]|)(?:fu|pan))el(e[dr]|ist|ing)':	'$1$2ell$3', '(bev|jew|lev|mod|rev|trav)el(e[dr]|ing)':	'$1$2ell$3', '([a-z]{2,8}[^egl ])el(e[dr]|est|ing)(\\b)':	'$1$2ell$3$4', '(app|di|enthr|equ|journ|riv|sign|tot)al(e[dr]|ing)':	'$1$2all$3', }

for (var word in table) { var txt=""; try { var re = new RegExp('(\\b)' + word, 'g') regex(re, table[word]) }		catch(err) { txt="There was an error on function Ohc_ENGVAR-CSimple, when changing '"+ word + "' => '"+ table[word] +"'.\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[dr]|ful|fully|ings?|less|lessly)':	'colour$1', '([ \\|\\[\\*])colors([^\\W\\s]|[\\s]*[^=])':	'$1colours$2',

//'~re~' words '([^\\w\\d\\-\\/=])(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)er(ed|ing)':	'$1$2r$3', '( [\\w\\D]*\\-)(col|flav|hum)ored':	'$1$2oured', '([^\\w\\d\\-\\/=])(cent|epicent|recent)er(ed|ing)':	'$1$2r$3', '([^\\w\\d\\-\\/=])(cent|epicent|recent)ers':	'$1$2res', '([^\\w\\d\\-\\/])(ana|cata|dia|epi|homo|mono|pro)log(ed|ing)':	'$1$2logu$3', '([^\\w\\d\\-\\/])(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[ie])l(e[dr]|ing|ors?)\\b':	'$1ll$2', '\\b([\\w]*)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[word]) }		catch(err) { txt="There was an error on function Ohc_ENGVAR-CSimple, when changing '"+ word + "' => '"+ table[word] +"'.\n\n"; txt+="Error: " + err.message + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); }	}

//remove US spelling from undefined undefined template output regex(/({{convert\|[^\}]*)\|(?:sp|spell)[ ]*=[ ]*us/gi, '$1'); regex(/({{(?:in|ft|yd|[mck]?m)[23]?[ ]+to[ ]+[^\}]*)\|(?:sp|spell)[ ]*=[ ]*(?:American|us)/gi, '$1'); regex(/({{(?:pd|pop[ ]+density)[ ]+(?:km|mi)2[^\}]*)\|(?:sp|spell)[ ]*=[ ]*(?:American|us)/gi, '$1'); }

function SetEnglish(v) { Ohc_ENGVARunprotectwords; switch (v) { case 'Ox': Ohc_ENGVARprotectwords; Ohc_ENGVARSimple; re_zwords; Ohc_ENGVARXedit_summary; break; case 'A': Ohc_ENGVARprotectwords; Ohc_ENGVARSimple; zwords; Ohc_ENGVARAedit_summary; break; case 'B': Ohc_ENGVARprotectwords; Ohc_ENGVARSimple; zwords; Ohc_ENGVARBedit_summary; break; case 'C': Ohc_ENGVARCprotectwords; Ohc_ENGVARCSimple; re_zwords; Ohc_ENGVARCedit_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(/([^\w\d\-\.][a-z]{3,12}[^s ])iz(e[drs]?|ations?|abl[ey]|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(/([^\w\d\-\.\/])(ar|de[mv]|improv|parad|(?:com|)pr[eo][cm]|rev|surm|telev)is(e|ing)/g, '$1$2♫is$3'); regex(/([^\w\d\-\.\/][a-z]{5,12})is(ations?)(\W)/g, '$1iz$2$3'); regex(/([^\w\d\-\.\/][a-z]{0,12}(?:[aeiou][^aeiosuw]|ph|rd|thes))is(e[drs]?|ing)(\W)/g, '$1iz$2$3'); } function Ohc_flip{ // measurements and perception //	regex(/\[\[(foobar)(s|)\]\]/gi, '$1$2'); //Template:undefined undefined regex(/(\{\{convert\|[\d\.,]+?\|(?:(?:sq|cu|)(?:[mck]?m)(?:2|3|))(?:\|(?:sq|cu|)(?:in|ft|yd|mi)(?:2|3|))?(\|\d)?(\|(?:sp|adj|abbr|lk|sigfig|sortable)=[^\|\}]*)*)(?=\})/gi, '$1$2|disp=flip'); //rem linking within convert template (area) regex(/(\{\{convert\|[\d\.,]+?\|(?:(?:sq|)(?:k?m)(?:2|3|)|hectare))(\|(?:sp|adj|abbr|lk|sigfig|sortable)=[^\|\}]*)*?(?=\})/gi, '$1$2|disp=flip'); //putting metres and hectares behind regex(/(\{\{convert\|[\d\.,]+?\|(?:hectares?|ha)(?:\|\d)?(\|(?:sp|adj|abbr|lk|sigfig|sortable)=[^\|\}]*)*)(?=\})/gi, '$1$2|disp=flip'); //rem linking within convert template (input units only) regex(/(\{\{convert\|[\d\.,]+?\|(?:to|by)(?:\|[\d\.,]+?\|(?:[mck]?m))(\|(?:sp|adj|abbr|lk|sigfig|sortable)=[^\|\}]*)*)(?=\})/gi, '$1$2|disp=flip'); //rem linking within convert template (input ranges only) regex(/(\{\{convert\|[\d\.,]+?\|nmi)(\|km mi|)/gi, '$1|mi km'); //putting miles first in nautical mile conversion regex(/(\{\{convert\|[\d\.,]+?\|(?:kg|°?F))(\|(?:sp|adj|abbr|lk|sigfig|sortable)=[^\|\}]+?)*(?=\})/gi, '$1$2|disp=flip'); //putting pounds and °C first //	regex(/(\{\{(?:in|ft|mi|[mck]?m)[23]?\sto\s(?:in|ft|mi|[mck]?m)[23]?[^\}]*?)\|wiki=(?:yes|no)/gi, '$1'); }

function Ohc_ENGVARunprotectwords{ regex(/(\w)♫(\w)/g, '$1$2'); //	and reconvert regex(/([Cc]ite encyclop)aedia/gi, '$1edia'); }

function insert_Engvar(v){ // 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.getMonth] + ' ' + dateobj.getFullYear;

// Matches Use Australian English or EngvarA var reA = new RegExp('', 'gi'); var reB = new RegExp('', 'gi'); // Matches Use British (Oxford) English or EngvarOx var reOx = new RegExp('', 'gi'); // Matches Use Canadian English or EngvarC var reC = new RegExp('', 'gi');

switch (v) { case 'A': // Replace existing variants with Australian txt = txt.replace( reOx, ''); txt = txt.replace( reB, ''); txt = txt.replace( reC, ''); // Prepend Australian template if not already tagged if( txt.search(reA) == -1 ) { txt = '\r\n' + txt; }          break; case 'Ox': // Replace with British (Oxford) txt = txt.replace( reA, ''); txt = txt.replace( reB, ''); txt = txt.replace( reC, ''); // Prepend British (Oxford) template if not already tagged if( txt.search(reOx) == -1 ) { txt = '\r\n' + txt; }          break; case 'B': // Replace with British txt = txt.replace( reA, ''); txt = txt.replace( reOx, ''); txt = txt.replace( reC, ''); // Prepend British template if not already tagged if( txt.search(reB) == -1 ) { txt = '\r\n' + txt; }          break; case 'C': // Replace with Canadian txt = txt.replace( reA, ''); txt = txt.replace( reB, ''); txt = txt.replace( reOx, ''); // Prepend Canadian template if not already tagged if( txt.search(reC) == -1 ) { txt = '\r\n' + txt; }          break; }

box.value = txt; }

function Ohc_ENGVARAedit_summary{ //Add a tag to the summary box setoptions(minor='true'); //removed ",watch='false'" in response to user notification 13 Nov. 2010 setreason('all Australian spelling by script', 'append'); //	doaction('diff'); } 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('all British spelling by script', 'append'); //	doaction('diff'); } function Ohc_ENGVARCedit_summary{ //Add a tag to the summary box setoptions(minor='true'); //removed ",watch='false'" in response to user notification 13 Nov. 2010 setreason('all Canadian spelling by script', '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 Oxford spelling by script', 'append'); //	doaction('diff'); }