User:Aseditor/vector.js

Source: 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.
/ 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... however, please don't tell me something I know already 
// As I am a scripting newbie, any technical advice on the 'hows and the wherefores' are especially welcome.
 
 
 
function protectwords(){
 var txt=document.editform.wpTextbox1;
//txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(?:xx)([^\.]{0,20}\.)/g, '$1$2$3');
 unprotectwords();
 
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(al)(uminum)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(ar)(tifact)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(ana|cata|hydro|para)(lyz)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(ly)(zing)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(di)(arrhea)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(de)(fense)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(of)(fense)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(fu)(ror)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(gr)(ay)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(je)(welry)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(ma)(neuver)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(pe)(diatric)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(pe)(dophil)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(sk)(eptic)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(va)(por)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(on)(stage)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(break|clean|lock|pick)(up)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(he)(mo)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(or)(thopedic)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(ar)(cheo)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(pa)(leonto)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(en)(ology)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(es)(ophag)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(es)(trogen)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(es)(thetic)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(ho)(meopath)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(me)(dieval)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(ri)(gor)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(an|leuk|septic|tox)(emi)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(su)(lfur)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(lik|liv|rat|sal|siz|shak)(able)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(clam|glam|harb|neighb|rum|savi?)(or)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(behavi|col|fl?av|hon|hum|lab)(or)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(mo)(ld)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)(er)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(cent|epicent|recent)(er)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(centi|kilo|milli|\d\s)(meter)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(centi|milli|deci|pico|hecto)(liter)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(dema|peda|mono|syna)(gog)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(ana|cata|dia|epi|homo|mono|pro)(log)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(iz)(e[drs]?|ations?|ing)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(el)(e[dr]|est|ing)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(counci|dia)(le[dr]|ling|lor)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 txt.value=txt.value.replace(/(<.+?>[^<]+?)(app|enthr|riv|sign|tot)(ale[dr]|aling)([^<]+?<\/.+?>)/g, '$1$2xXx$3$4');
 
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(al)(uminum)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(ar)(tifact)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(ana|cata|hydro|para)(lyz)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(ly)(zing)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(di)(arrhea)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(de)(fense)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(of)(fense)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(fu)(ror)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(gr)(ay)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(je)(welry)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(ma)(neuver)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(pe)(diatric)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(pe)(dophil)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(sk)(eptic)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(va)(por)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(on)(stage)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(break|clean|lock|pick)(up)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(he)(mo)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(or)(thopedic)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(ar)(cheo)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(pa)(leonto)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(en)(ology)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(es)(ophag)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(es)(trogen)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(es)(thetic)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(ho)(meopath)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(me)(dieval)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(ri)(gor)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(an|leuk|septic|tox)(emi)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(su)(lfur)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(lik|liv|rat|sal|siz|shak)(able)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(clam|glam|harb|neighb|rum|savi?)(or)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(behavi|col|fl?av|hon|hum|lab)(or)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(mo)(ld)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)(er)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(cent|epicent|recent)(er)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(centi|kilo|milli|\d\s)(meter)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(centi|milli|deci|pico|hecto)(liter)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(dema|peda|mono|syna)(gog)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(ana|cata|dia|epi|homo|mono|pro)(log)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(iz)(e[drs]?|ations?|ing)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(el)(e[dr]|est|ing)([^\]]*?\])/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[Category:[^\]]*?)(counci|dia)(le[dr]|ling|lor)([^\]]*?\])/g, '$1$2xXx$3$4');
//txt.value=txt.value.replace(/(\[Category:[^\]]*?)(app|enthr|riv|sign|tot)(ale[dr]|aling)([^\]]*?\])/g, '$1$2xXx$3$4');
 
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(al)(uminum)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(ar)(tifact)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(ana|cata|hydro|para)(lyz)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(ly)(zing)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(di)(arrhea)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(de)(fense)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(of)(fense)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(fu)(ror)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(gr)(ay)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(je)(welry)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(ma)(neuver)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(pe)(diatric)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(pe)(dophil)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(sk)(eptic)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(va)(por)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(on)(stage)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(break|clean|lock|pick)(up)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(he)(mo)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(or)(thopedic)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(ar)(cheo)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(pa)(leonto)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(en)(ology)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(es)(ophag)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(es)(trogen)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(es)(thetic)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(ho)(meopath)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(me)(dieval)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(ri)(gor)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(an|leuk|septic|tox)(emi)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(su)(lfur)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(lik|liv|rat|sal|siz|shak)(able)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(clam|glam|harb|neighb|rum|savi?)(or)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(behavi|col|fl?av|hon|hum|lab)(or)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(mo)(ld)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)(er)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(cent|epicent|recent)(er)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(centi|kilo|milli|\d\s)(meter)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(centi|milli|deci|pico|hecto)(liter)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(dema|peda|mono|syna)(gog)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(ana|cata|dia|epi|homo|mono|pro)(log)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(iz)(e[drs]?|ations?|ing)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(bev|jew|lev|mod|rev|trav)(el)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})([a-z]{2,8}[^egl\b])(el)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(counci|dia)(le[dr]|ling|lor)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/(\[(?:file|image):[^\.]{0,20})(app|enthr|riv|sign|tot)(ale[dr]|aling)([^\.]{0,20}\.)/g, '$1$2xXx$3$4');
 
//protection for quotations in templates
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(al)(uminum)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(ar)(tifact)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(ana|cata|hydro|para)(lyz)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(ly)(zing)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(di)(arrhea)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(de)(fense)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(of)(fense)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(fu)(ror)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(gr)(ay)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(je)(welry)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(ma)(neuver)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(pe)(diatric)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(pe)(dophil)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(sk)(eptic)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(va)(por)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(on)(stage)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(break|clean|lock|pick)(up)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(he)(mo)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(or)(thopedic)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(ar)(cheo)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(pa)(leonto)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(en)(ology)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(es)(ophag)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(es)(trogen)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(es)(thetic)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(ho)(meopath)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(me)(dieval)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(ri)(gor)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(an|leuk|septic|tox)(emi)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(su)(lfur)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(lik|liv|rat|sal|siz|shak)(able)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(clam|glam|harb|neighb|rum|savi?)(or)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(behavi|col|fl?av|hon|hum|lab)(or)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(mo)(ld)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)(er)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(cent|epicent|recent)(er)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(centi|kilo|milli|\d\s)(meter)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(centi|milli|deci|pico|hecto)(liter)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(dema|peda|mono|syna)(gog)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(ana|cata|dia|epi|homo|mono|pro)(log)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(iz)(e[drs]?|ations?|ing)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(el)(e[dr]|est|ing)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(counci|dia)(le[dr]|ling|lor)([^}]*?})/g, '$1$2xXx$3$4');
txt.value=txt.value.replace(/({[^{]{0,6}quot[^\|]{1,7}\s?\|[^}]*?)(app|enthr|riv|sign|tot)(ale[dr]|aling)([^}]*?})/g, '$1$2xXx$3$4');
 
}
 
function Simple(){
 var txt=document.editform.wpTextbox1;
 
//protectwords()
 
txt.value=txt.value.replace(/aluminum/g, 'aluminium');
txt.value=txt.value.replace(/artifact/g, 'artefact');
txt.value=txt.value.replace(/(ana|cata|hydro|para)lyz(e|ing)/g, '$1lys$2');
txt.value=txt.value.replace(/diarrhea/g, 'diarrhoea');
txt.value=txt.value.replace(/(de|of)fense/g, '$1fence');
txt.value=txt.value.replace(/(\W)furor(\W)/g, '$1furore$2');
txt.value=txt.value.replace(/(light\s|dark\s|\s)gray/g, '$1grey');
//txt.value=txt.value.replace(/judgment/g, 'judgement');
txt.value=txt.value.replace(/(\W)jewelry(\W)/g, '$1jewellery$2');
txt.value=txt.value.replace(/maneuver(ab|ed|ing)/g, 'manoeuvr$1');
txt.value=txt.value.replace(/maneuver/g, 'manoeuvre');
txt.value=txt.value.replace(/ped(iatric|ophil)/g, 'paed$1');
txt.value=txt.value.replace(/skeptic/g, 'sceptic');
txt.value=txt.value.replace(/vapor(s?\W)/g, 'vapour$1');
 
//composite words
//txt.value=txt.value.replace(/onstage/g, 'on-stage');
txt.value=txt.value.replace(/(break|lock|pick)up/g, '$1-up');
 
 //latin words
txt.value=txt.value.replace(/gyneco/g, 'gynaeco');
txt.value=txt.value.replace(/hemo(globin|ly|phil)/g, 'haemo$1');
txt.value=txt.value.replace(/orthopedic/g, 'orthopaedic');
txt.value=txt.value.replace(/archeo/g, 'archaeo');
txt.value=txt.value.replace(/paleonto/g, 'palaeonto');
txt.value=txt.value.replace(/(\W)enology/g, '$1oenology');
txt.value=txt.value.replace(/(\W)esophag/g, '$1oesophag');
txt.value=txt.value.replace(/(\W)estrogen/g, '$1oestrogen');
txt.value=txt.value.replace(/(\W)esthetic/g, '$1aesthetic');
txt.value=txt.value.replace(/homeopath/g, 'homoeopath');
//txt.value=txt.value.replace(/medieval\b/g, 'mediaeval');
txt.value=txt.value.replace(/(\W)rigor(\W)/g, '$1rigour');
txt.value=txt.value.replace(/(an|leuk|septic|tox)emi(a|c)/g, '$1aemi$2'); 
 
 //'f' words
txt.value=txt.value.replace(/sulfur/g, 'sulphur');
 
// non-redundant e
txt.value=txt.value.replace(/(lik|liv|rat|sal|siz|shak)(able)/g, '$1e$2'); 
 
//'~our' words
txt.value=txt.value.replace(/(clam|glam|harb|neighb|rum|savi?)or(ed|ful|ing|less|ly|s|)\b/g, '$1our$2');
txt.value=txt.value.replace(/neighborhood/g, 'neighbourhood');
txt.value=txt.value.replace(/behavior(al|s?\W)/g, 'behaviour$1');
txt.value=txt.value.replace(/(fav|hon)or(abl[ey]|ed|ing|s|)\b/g, '$1our$2');
txt.value=txt.value.replace(/(\W)labor(ed|ing|s?\W)/g, '$1labour$2');
txt.value=txt.value.replace(/(col|flav|hum)or(ed|ful|fully|ings?|less|lessly|s\W)/g, '$1our$2');
 
txt.value=txt.value.replace(/(\W)mold(ed|ing|s?\W)/g, '$1mould$2');
 
//'~re~' words
txt.value=txt.value.replace(/\b(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)er/g, '$1re');
txt.value=txt.value.replace(/(cent|epicent|recent)er(ed|ing|s)/g, '$1r$2'); 
txt.value=txt.value.replace(/centers/g, 'centres'); 
txt.value=txt.value.replace(/(centi|kilo|milli|-|\d\s)meter/g, '$1metre');
txt.value=txt.value.replace(/(centi|milli|deci|pico|hecto|\b)liter(s?\b)/g, '$1litre$2');
txt.value=txt.value.replace(/(dema|peda|mono|syna)gog(s?\W)/g, '$1gogue$2');
txt.value=txt.value.replace(/([^\\|\/|\-])(ana|cata|dia|epi|homo|mono|pro)log\b/g, '$1$2logue');
//txt.value=txt.value.replace(/(\W[a-z]{3,12}[^s])[^\b]iz(e[drs]?|ations?|ing)(\W)/g, '$1is$2$3');
//txt.value=txt.value.replace(/(empha|synthe)siz(e|ing)/g, '$1sis$2'); 
 
//'~l' words where the 'l' doubles as past and present participle
txt.value=txt.value.replace(/(bev|jew|lev|mod|rev|trav)el(e[dr]|ing)/g, '$1ell$2'); 
txt.value=txt.value.replace(/(\b[a-z]{2,8}[^egl ])el(e[dr]|est|ing)\b/g, '$1ell$2');
txt.value=txt.value.replace(/(counci|dia)l(e[dr]|ing|or)\b/gi, '$1ll$2');
txt.value=txt.value.replace(/(app|enthr|riv|sign|tot)al(e[dr]|ing)/g, '$1all$2'); 
txt.value=txt.value.replace(/(\s[\w]*)ll(ful|ment)/g, '$1l$2');
 
//reconvert special cases
txt.value=txt.value.replace(/(nobelpr|pics)ise/g, '$1ize');  
 
// unprotectwords()
 
}
function OxEnglish() {
  unprotectwords();
  protectwords();
  Simple();
  unprotectwords();
  insert_EngvarOx()
  edit_summary();
}
function BritishEnglish() {
  unprotectwords();
  protectwords();
  Simple();
  zwords();
  unprotectwords();
  insert_EngvarB()
  edit_summary();
}
function Simpleplus() {
  unprotectwords();
  Simple();
  zwords();
  unprotectwords();
  insert_EngvarB()
  edit_summary();
}
function zwords(){
 var txt=document.editform.wpTextbox1;
 
txt.value=txt.value.replace(/(\W[a-z]{3,12}[^s ])iz(e[drs]?|ations?|ing)(\W)/g, '$1is$2$3');
txt.value=txt.value.replace(/(empha|synthe)siz(e|ing)/g, '$1sis$2'); 
 
}
 
function unprotectwords(){
 var txt=document.editform.wpTextbox1;
 
 txt.value=txt.value.replace(/(\w)xXx(\w)/g, '$1$2');
 
}
 
function insert_EngvarB(){
 var txt=document.editform.wpTextbox1;
// Add a template to the article identifying English variant
if (txt.value.search(/{{EngvarB}}/gi) == -1)
{
txt.value='{{EngvarB}}\r\n'+txt.value;
}
}
 
function insert_EngvarOx(){
 var txt=document.editform.wpTextbox1;
// Add a template to the article identifying English variant
if (txt.value.search(/{{EngvarB}}/gi) == -1)
{
txt.value='{{EngvarOx}}\r\n'+txt.value;
}
}
 
function edit_summary(){
 
// Add a tag to the summary box
 var txt=document.editform.wpSummary;
    var summary = "per [[WP:ENGVAR|British English]]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
//   document.forms.editform.wpMinoredit.checked = true;
   document.editform.wpDiff.click();
}
$(function () {
 if(document.forms.editform) {
//  addPortletLink('p-tb', 'javascript:CommonTerms()', 'Delink common terms', 't-dmy', 'Regexp common terms', '', '');
//  addPortletLink('p-tb', 'javascript:run_formatgeneral()', 'Add metric units', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
//  addPortletLink('p-tb', 'javascript:button_delink_dates_to_dmy()', 'Delink dates to dmy', 't-dmy', 'day month', '', '');
 
  addPortletLink('p-tb', 'javascript:OxEnglish()', 'Oxford English', 'OED spelling ', 'converts to Oxford English', '', '');
  addPortletLink('p-tb', 'javascript:BritishEnglish()', 'British English', 'British spelling ', 'converts to Brit English', '', '');
  addPortletLink('p-tb', 'javascript:protectwords()', 'Protect Words', 't-mdy', 'month day', '', '');
  addPortletLink('p-tb', 'javascript:Simpleplus()', 'Speedy convert to British', 'British spelling ', 'converts everything to Brit English', '', '');
  }
});