This is an old revision of this page, as edited by Ohconfucius (talk | contribs) at 15:11, 13 September 2011 (Undid revision 449975352 by Ohconfucius (talk)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Revision as of 15:11, 13 September 2011 by Ohconfucius (talk | contribs) (Undid revision 449975352 by Ohconfucius (talk))(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)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. |
This user script seems to have a documentation page at User:Ohconfucius/test/EngvarB. |
// ********************************************************************************************* //This is a test (non-production) script, and may have untested errors. Please exercise due care should you decide to use it. // ********************************************************************************************* /************* *** 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('• Flip Convert','Ohc_flip()'); 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) 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 = [ '( ag)(ing)', '(ai)(rplane)', '(al)(uminum)', '(ad)(renalin\\b)', '(an)(nex\\b)', '(anti)(+\\b)', '(ar)(mor)', '(ar)(tifact)', '(ana|breatha|cata|hydro|para)(lyz)', '(be)(stsell)', '(di)(arrhea)', '(de|of)(fense)', '(pr)(actic)', '(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)', '(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?|ation|ing)', '(iz)(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_ENGVARCprotectwords(){ 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)', '(be)(stsell)', '(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_ENGVAR-Cprotectwords(), 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 infobox field names regex(/(\|*?ship hon)(ou?rs*?\=)/g, '$1♫$2'); //protect from function re_z-words regex(/(enterpri|promi|surpri)(se?|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|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', // '(\\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 '((?:\\w{3,9}|)(?:fu|pan))el(e|ist|ing)': '$1$2ell$3', '(bev|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('()' + 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 '()(flav|hum)or(ed|ful|fully|ings?|less|lessly|s?\\W)': '$1$2our$3', '()color(e|ful|fully|ings?|less|lessly)': '$1colour$2', '()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 '()(counc)l(e|ing|ors?)(\\b)': '$1$2ll$3$4', '(\\s*)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) } 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); } } //remove US spelling from {{convert}} template output regex(/({{convert\|*)\|(?:sp|spell)*=*us/gi, '$1'); regex(/({{(?:in|ft|yd|?m)?+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|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 '((?:\\w{3,9}|)(?:fu|pan))el(e|ist|ing)': '$1$2ell$3', '(bev|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_ENGVAR-CSimple(), 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_ENGVAR-CSimple(), when changing '"+ word + "' => '"+ table +"'.\n\n"; txt+="Error: " + err.message + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); } } //remove US spelling from {{convert}} template output regex(/({{convert\|*)\|(?:sp|spell)*=*us/gi, '$1'); regex(/({{(?:in|ft|yd|?m)?+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 '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(/({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_flip(){ // measurements and perception // regex(/\\]/gi, '$1$2'); //Template:{{convert}} regex(/(\{\{convert\|+?\|(?:(?:sq|cu|)(?:?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\|+?\|(?:(?:sq|)(?:k?m)(?:2|3|)|hectare))(\|(?:sp|adj|abbr|lk|sigfig|sortable)=*)*?(?=\})/gi, '$1$2|disp=flip'); //putting metres and hectares behind regex(/(\{\{convert\|+?\|(?:hectares?|ha)(?:\|\d)?(\|(?:sp|adj|abbr|lk|sigfig|sortable)=*)*)(?=\})/gi, '$1$2|disp=flip'); //rem linking within convert template (input units only) regex(/(\{\{convert\|+?\|(?:to|by)(?:\|+?\|(?:?m))(\|(?:sp|adj|abbr|lk|sigfig|sortable)=*)*)(?=\})/gi, '$1$2|disp=flip'); //rem linking within convert template (input ranges only) regex(/(\{\{convert\|+?\|nmi)(\|km mi|)/gi, '$1|mi km'); //putting miles first in nautical mile conversion regex(/(\{\{convert\|+?\|(?:kg|°?F))(\|(?:sp|adj|abbr|lk|sigfig|sortable)=+?)*(?=\})/gi, '$1$2|disp=flip'); //putting pounds and °C first // regex(/(\{\{(?:in|ft|mi|?m)?\sto\s(?:in|ft|mi|?m)?*?)\|wiki=(?:yes|no)/gi, '$1'); } function Ohc_ENGVARunprotectwords(){ regex(/(\w)♫(\w)/g, '$1$2'); // and reconvert regex(/(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.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'); // Matches Use Canadian English or EngvarC var reC = new RegExp('{{*(?:se+Canadian+English|ngvarC)*(?:|\\|*date*=*)*}}', 'gi'); switch (v) { case 'Ox': // Replace British/Canadian with British (Oxford) txt = txt.replace( reB, '{{Use British (Oxford) English|date=' + datestr + '}}'); txt = txt.replace( reC, '{{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; } break; case 'B': // Replace British (Oxford)/Canadian with British txt = txt.replace( reOx, '{{Use British English|date=' + datestr + '}}'); txt = txt.replace( reC, '{{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; } break; case 'C': // Replace British/British (Oxford) with Canadian txt = txt.replace( reB, '{{Use Canadian English|date=' + datestr + '}}'); txt = txt.replace( reOx, '{{Use Canadian English|date=' + datestr + '}}'); // Prepend Canadian template if not already tagged if( txt.search(reC) == -1 ) { txt = '{{Use Canadian English|date=' + datestr + '}}\r\n' + txt; } break; } 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_ENGVARCedit_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'); }