User:Mglovesfun/format.js

// THE FOLLOWING IS BASED ON User:Msh210/vector.js BUT HAS BEEN MODIFIED SINCE. THANKS MSH210! // //importScript('Transwiki:Gadget-HotCat.js'); importScript('User:Lupin/autoedit.js', 'en.wikipedia.org','46637295');//needed for other things importScript('User:Conrad.Irwin/creation.js');//automates inflected-form creation; requires autoedit.js importScript('User:Conrad.Irwin/isblocked.js');//nice display if user's blocked document.cookie="WiktNearbyPagesLangHeadings=true";//restricts nearbypages to header not navbar importScript('User:Ruakh/WiktEtylAlwaysLink.js');//link etyl's langnames importScript('User:Yair rand/checktbotentries.js'); importScript('User:Yair rand/checktransremove.js'); importScript('User:Yair rand/languagenametocode.js'); //start stuff copied from User:Connel_MacKenzie/clock.js and modified function makeTime { var timeGMT = new Date; var time = timeGMT.toUTCString; var li = document.createElement( 'li' ); li.id = 't-time'; li.appendChild( document.createTextNode( time ) ); var ul=document.getElementById('t-upload'); ul.parentNode.insertBefore(li,ul); } $( makeTime ); // end stuff from User:Connel_MacKenzie/clock.js /* begin stuff copied from User:Connel MacKenzie/reformat.js and amended */ //Text replacement other than replacing headers and template redirects, which come later on function minorFormat { txt=txt.replace(/\{\{bottom3([\}\|])/g, "{{bottom$1"); txt=txt.replace(/\{\{bottom4([\}\|])/g, "{{bottom$1"); txt=txt.replace(/\{\{bottom5([\}\|])/g, "{{bottom$1"); txt=txt.replace(/\{\{ca\.([\|\}])/g, "{{circa$1"); txt=txt.replace(/\{\{rfv\-etym([\}\|])/g, "{{rfv-etymology$1"); txt=txt.replace(/\{\{rfv\-pron([\}\|])/g, "{{rfv-pronunciation$1");

txt=txt.replace(/([\|\{])([aA])lggeom([\}\|])/g, "$1algebraic geometry$3"); txt=txt.replace(/([\|\{])Acting([\}\|])/g, "$1acting$2"); txt=txt.replace(/([\|\{])adslang([\}\|])/g, "$1ad slang$2"); txt=txt.replace(/([\|\{])Algebra([\}\|])/g, "$1algebra$2"); txt=txt.replace(/([\|\{])analyticgeom([\}\|])/g, "$1analytic geometry$2"); txt=txt.replace(/([\|\{])Anatomy([\}\|])/g, "$1anatomy$2"); txt=txt.replace(/([\|\{])Archaic([\}\|])/g, "$1archaic$2"); txt=txt.replace(/([\|\{])Architecture([\}\|])/g, "$1architecture$2"); txt=txt.replace(/([\|\{])arithmetics([\}\|])/g, "$1arithmetic$2"); txt=txt.replace(/([\|\{])Astronomy([\}\|])/g, "$1astronomy$2"); txt=txt.replace(/([\|\{])autoracing([\}\|])/g, "$1auto racing$2"); txt=txt.replace(/([\|\{])Baseball([\}\|])/g, "$1baseball$2"); txt=txt.replace(/([\|\{])Basketball([\}\|])/g, "$1basketball$2"); txt=txt.replace(/([\|\{])Biblical([\}\|])/g, "$1biblical$2"); txt=txt.replace(/([\|\{])Bingo([\}\|])/g, "$1bingo$2"); txt=txt.replace(/([\|\{])Biochemistry([\}\|])/g, "$1biochemistry$2"); txt=txt.replace(/([\|\{])Biology([\}\|])/g, "$1biology$2"); txt=txt.replace(/([\|\{])Botany([\}\|])/g, "$1botany$2"); txt=txt.replace(/([\|\{])Bridge([\}\|])/g, "$1bridge$2"); txt=txt.replace(/([\|\{])Business([\}\|])/g, "$1business$2"); txt=txt.replace(/([\|\{])buzzwords([\}\|])/g, "$1buzzword$2"); txt=txt.replace(/([\|\{])Calculus([\}\|])/g, "$1calculus$2"); txt=txt.replace(/([\|\{])Card games([\}\|])/g, "$1card games$2"); txt=txt.replace(/([\|\{])chem([\}\|])/g, "$1chemistry$2"); txt=txt.replace(/([\|\{])chemical compound([\}\|])/g, "$1inorganic compound$2"); txt=txt.replace(/([\|\{])Chemistry([\}\|])/g, "$1chemistry$2"); txt=txt.replace(/([\|\{])classical physics([\}\|])/g, "$1classical mechanics$2"); txt=txt.replace(/([\|\{])Climbing([\}\|])/g, "$1climbing$2"); txt=txt.replace(/([\|\{])colloquially([\}\|])/g, "$1colloquial$2"); txt=txt.replace(/([\|\{])Combinatorics([\}\|])/g, "$1combinatorics$2"); txt=txt.replace(/([\|\{])([Cc])omplang([\}\|])/g, "$1programming$3"); txt=txt.replace(/([\|\{])complex([\}\|])/g, "$1complex analysis$2"); txt=txt.replace(/([\|\{])computer language([\}\|])/g, "$1programming$2"); txt=txt.replace(/([\|\{])Computing([\}\|])/g, "$1computing$2"); txt=txt.replace(/([\|\{])Copyright([\}\|])/g, "$1copyright$2"); txt=txt.replace(/([\|\{])Countable([\}\|])/g, "$1countable$2"); txt=txt.replace(/([\|\{])Cricket([\}\|])/g, "$1cricket$2"); txt=txt.replace(/([\|\{])crypto([\}\|])/g, "$1cryptography$2"); txt=txt.replace(/([\|\{])CW([\}\|])/g, "$1Commonwealth$2"); txt=txt.replace(/([\|\{])Databases([\}\|])/g, "$1databases$2"); txt=txt.replace(/([\|\{])Drama([\}\|])/g, "$1drama$2"); txt=txt.replace(/([\|\{])Electronics([\}\|])/g, "$1electronics$2"); txt=txt.replace(/([\|\{])Entomology([\}\|])/g, "$1entomology$2"); txt=txt.replace(/([\|\{])farming([\}\|])/g, "$1agriculture$3"); txt=txt.replace(/([\|\{])[fF]ilmology([\}\|])/g, "$1cinematography$2"); txt=txt.replace(/([\|\{])Finance([\}\|])/g, "$1finance$2"); txt=txt.replace(/([\|\{])Forestry([\}\|])/g, "$1forestry$2"); txt=txt.replace(/([\|\{])gametheory([\}\|])/g, "$1game theory$2"); txt=txt.replace(/([\|\{])Geography([\}\|])/g, "$1geography$2"); txt=txt.replace(/([\|\{])Geology([\}\|])/g, "$1geology$2"); txt=txt.replace(/([\|\{])Geometry([\}\|])/g, "$1geometry$2"); txt=txt.replace(/([\|\{])Grammar([\}\|])/g, "$1grammar$2"); txt=txt.replace(/([\|\{])graphical user interfaces([\}\|])/g, "$1graphical user interface$2"); txt=txt.replace(/([\|\{])([gG])raphtheory([\}\|])/g, "$1graph theory$3"); txt=txt.replace(/([\|\{])greekmyth([\}\|])/g, "$1Greek mythology$2"); txt=txt.replace(/([\|\{])([gG])rouptheory([\}\|])/g, "$1group theory$3"); txt=txt.replace(/([\|\{])([hH])amradio([\}\|])/g, "$1ham radio$3"); txt=txt.replace(/([\|\{])History([\}\|])/g, "$1history$2"); txt=txt.replace(/([\|\{])([iI])cehockey([\}\|])/g, "$1ice hockey$3"); txt=txt.replace(/([\|\{])Impersonal([\}\|])/g, "$1impersonal$2"); txt=txt.replace(/([\|\{])informally([\}\|])/g, "$1informal$2"); txt=txt.replace(/([\|\{])internetslang([\}\|])/g, "$1internet slang$2"); txt=txt.replace(/([\|\{])landform([\}\|])/g, "$1landforms$2"); txt=txt.replace(/([\|\{])legalese([\}\|])/g, "$1legal$2"); txt=txt.replace(/([\|\{])Lexicography([\}\|])/g, "$1lexicography$2"); txt=txt.replace(/([\|\{])([lL])inearalg([\}\|])/g, "$1linear algebra$3"); txt=txt.replace(/([\|\{])Linux([\}\|])/g, "$1linux$2"); txt=txt.replace(/([\|\{])Logic([\}\|])/g, "$1logic$2"); txt=txt.replace(/([\|\{])Management([\}\|])/g, "$1management$2"); txt=txt.replace(/([\|\{])Mathematics([\}\|])/g, "$1mathematics$2"); txt=txt.replace(/([\|\{])Medicine([\}\|])/g, "$1medicine$2"); txt=txt.replace(/([\|\{])Microelectronics([\}\|])/g, "$1microelectronics$2"); txt=txt.replace(/([\|\{])military rank([\}\|])/g, "$1military ranks$2"); txt=txt.replace(/([\|\{])Mining([\}\|])/g, "$1mining$2"); txt=txt.replace(/([\|\{])motor sport([\}\|])/g, "$1motor racing$2"); txt=txt.replace(/([\|\{])mountaineering([\}\|])/g, "$1climbing$2"); txt=txt.replace(/([\|\{])Music([\}\|])/g, "$1music$2"); txt=txt.replace(/([\|\{])Mythology([\}\|])/g, "$1mythology$2"); txt=txt.replace(/([\|\{])([nN])anotech([\}\|])/g, "$1nanotechnology$3"); txt=txt.replace(/([\|\{])neologistic([\}\|])/g, "$1neologism$2"); txt=txt.replace(/([\|\{])Newtonian physics([\}\|])/g, "$1classical mechanics$2"); txt=txt.replace(/([\|\{])non\-standard([\}\|])/g, "$1nonstandard$2"); txt=txt.replace(/([\|\{])norse mythology([\}\|])/g, "$1Norse mythology$2"); txt=txt.replace(/([\|\{])notcomparable([\}\|])/g, "$1not comparable$2"); txt=txt.replace(/([\|\{])numbertheory([\}\|])/g, "$1number theory$2"); txt=txt.replace(/([\|\{])onomat([\}\|])/g, "$1onomatopoeia$2"); txt=txt.replace(/([\|\{])Onomatopoeia([\}\|])/g, "$1onomatopoeia$2"); txt=txt.replace(/([\|\{])Optics([\}\|])/g, "$1optics$2"); txt=txt.replace(/([\|\{])Paganism([\}\|])/g, "$1paganism$2"); txt=txt.replace(/([\|\{])pejoratives([\}\|])/g, "$1pejorative$2"); txt=txt.replace(/([\|\{])Pharmacology([\}\|])/g, "$1pharmacology$2"); txt=txt.replace(/([\|\{])Philosophy([\}\|])/g, "$1philosophy$2"); txt=txt.replace(/([\|\{])Physics([\}\|])/g, "$1physics$2"); txt=txt.replace(/([\|\{])Physiology([\}\|])/g, "$1physiology$2"); txt=txt.replace(/([\|\{])Pseudoscience([\}\|])/g, "$1pseudoscience$2"); txt=txt.replace(/([\|\{])Psychiatry([\}\|])/g, "$1psychiatry$2"); txt=txt.replace(/([\|\{])Rail transport([\}\|])/g, "$1rail transport$2"); txt=txt.replace(/([\|\{])railroading([\}\|])/g, "$1rail transport$2"); txt=txt.replace(/([\|\{])Rare([\}\|])/g, "$1rare$2"); txt=txt.replace(/([\|\{])Rasta([\}\|])/g, "$1rasta$2"); txt=txt.replace(/([\|\{])Rhetoric([\}\|])/g, "$1rhetoric$2"); txt=txt.replace(/([\|\{])Rugby([\}\|])/g, "$1rugby$2"); txt=txt.replace(/([\|\{])scrapbooking([\}\|])/g, "$1scrapbooks$2"); txt=txt.replace(/([\|\{])set\-phrase([\}\|])/g, "$1set phrase$2"); txt=txt.replace(/([\|\{])settheory([\}\|])/g, "$1set theory$2"); txt=txt.replace(/([\|\{])Slang([\}\|])/g, "$1slang$2"); txt=txt.replace(/([\|\{])([sS])ofteng([\}\|])/g, "$1software engineering$3"); txt=txt.replace(/([\|\{])([sS])oundeng([\}\|])/g, "$1sound engineering$3"); txt=txt.replace(/([\|\{])Software([\}\|])/g, "$1software$2"); txt=txt.replace(/([\|\{])spelunking([\}\|])/g, "$1caving$2"); txt=txt.replace(/([\|\{])Sports([\}\|])/g, "$1sports$2"); txt=txt.replace(/([\|\{])Taxonomy([\}\|])/g, "$1taxonomy$2"); txt=txt.replace(/([\|\{])Tennis([\}\|])/g, "$1tennis$2"); txt=txt.replace(/([\|\{])text messages([\}\|])/g, "$1text messaging$2"); txt=txt.replace(/([\|\{])Topology([\}\|])/g, "$1topology$2"); txt=txt.replace(/([\|\{])Transitive([\}\|])/g, "$1transitive$2"); txt=txt.replace(/([\|\{])transportation([\}\|])/g, "$1transport$2"); txt=txt.replace(/([\|\{])Typography([\}\|])/g, "$1typography$2"); txt=txt.replace(/([\|\{])uncomparable([\}\|])/g, "$1not comparable$2"); txt=txt.replace(/([\|\{])Uncountable([\}\|])/g, "$1uncountable$2"); txt=txt.replace(/([\|\{])wjargon([\}\|])/g, "$1Wiktionary and WMF jargon$2"); txt=txt.replace(/([\|\{])Zoology([\}\|])/g, "$1zoology$2"); txt=txt.replace(/([\|\{])Zoölogy([\}\|])/g, "$1zoology$2");

txt=txt.replace(/([\|\{])AAVE([\}\|])/g, "$African American Vernacular English$2"); txt=txt.replace(/([\|\{])American English([\}\|])/g, "$1US$2"); txt=txt.replace(/([\|\{])british([\}\|])/g, "$1British$2"); txt=txt.replace(/([\|\{])Austrian([\}\|])/g, "$1Austria$2"); txt=txt.replace(/([\|\{])America([\}\|])/g, "$1US$2"); txt=txt.replace(/([\|\{])Australian English([\}\|])/g, "$1Australia$2"); txt=txt.replace(/([\|\{])Brit([\}\|])/g, "$1British$2"); txt=txt.replace(/([\|\{])brit([\}\|])/g, "$1British$2"); txt=txt.replace(/([\|\{])cockney([\}\|])/g, "$1Cockney$2"); txt=txt.replace(/([\|\{])commonwealth([\}\|])/g, "$1Commonwealth$2"); txt=txt.replace(/([\|\{])CRS([\}\|])/g, "$1Cockney rhyming slang$2"); txt=txt.replace(/([\|\{])geordie([\}\|])/g, "$1Geordie$2"); txt=txt.replace(/([\|\{])Indian English([\}\|])/g, "$1India$2"); txt=txt.replace(/([\|\{])Irish English([\}\|])/g, "$1Ireland$2"); txt=txt.replace(/([\|\{])Liverpudlian([\}\|])/g, "$1Liverpool$2"); txt=txt.replace(/([\|\{])Northumbrian([\}\|])/g, "$1Northumbria$2"); txt=txt.replace(/([\|\{])Swiss([\}\|])/g, "$1Switzerland$2"); txt=txt.replace(/([\|\{])Welsh English([\}\|])/g, "$1Wales$2"); txt=txt.replace(/([\|\{])Yorkshire dialect([\}\|])/g, "$1Yorkshire$2");

txt=txt.replace(/([\|\{])especially([\}\|])/g, "$1chiefly$2"); txt=txt.replace(/([\|\{])mainly([\}\|])/g, "$1chiefly$2"); txt=txt.replace(/([\|\{])metaphorically([\}\|])/g, "$1figuratively$2"); txt=txt.replace(/([\|\{])mostly([\}\|])/g, "$1chiefly$2"); txt=txt.replace(/([\|\{])particularly([\}\|])/g, "$1chiefly$2"); txt=txt.replace(/([\|\{])primarily([\}\|])/g, "$1chiefly$2");

//Deprecated script templates, kept as redirects txt = txt.replace(/ARchar/gi, "Arab"); txt = txt.replace(/BNchar/gi, "Beng"); txt = txt.replace(/ELchar/gi, "Grek"); txt = txt.replace(/FAchar/gi, "fa-Arab"); txt = txt.replace(/HEchar/gi, "Hebr"); txt = txt.replace(/KOchar/gi, "Kore"); txt = txt.replace(/RUchar/gi, "Cyrl"); txt = txt.replace(/THchar/gi, "Thai"); txt = txt.replace(/URchar/gi, "ur-Arab"); txt = txt.replace(/ZHchar/gi, "Hani"); txt = txt.replace(/ZHsim/gi, "Hans"); txt = txt.replace(/ZHtra/gi, "Hant");

//Redirects, but not deprecated txt = txt.replace(/yi\-Hebr/gi, "Hebr"); txt = txt.replace(/sc=Polytonic/gi, "sc=polytonic"); txt = txt.replace(/\{\{Polytonic([\}\|])/gi, "{"+"{polytonic$1"); txt = txt.replace(/sc=Unicode/gi, "sc=unicode"); txt = txt.replace(/\{\{Unicode([\}\|])/gi, "{"+"{unicode$1"); } // get all the {-header-} templates replaced function headLevel { txt = txt.replace(/==adjective form==/gi, "==Adjective=="); txt=txt.replace(/==alternative spellings==/gi, "==Alternative forms=="); txt = txt.replace(/==citations==/gi, "==Quotations=="); txt = txt.replace(/==derivation==/gi, "==Etymology=="); txt = txt.replace(/==note==/gi, "==Usage notes=="); txt = txt.replace(/==notes==/gi, "==Usage notes=="); txt=txt.replace(/==NOun==/gi, "==Noun=="); txt=txt.replace(/==noun form==/gi, "==Noun=="); txt=txt.replace(/==proper Noun==/gi, "==Proper noun=="); txt = txt.replace(/==reference==/gi, "==References=="); txt = txt.replace(/==translation==/gi, "==Translations=="); txt = txt.replace(/==usage==/gi, "==Usage notes=="); txt = txt.replace(/==variants==/gi, "==Alternative forms=="); txt=txt.replace(/==verb form==/gi, "==Verb=="); txt=txt.replace(/==chinese==/gi, "==Mandarin==");//Chinese will usually refer to Mandarin. If the templates aren't cmn, change by hand }

function langHdrs { txt=txt.replace(/\n==(=*)([a-z])/gi, "\n==$1$2".toUpperCase ); txt=txt.replace(/==\[\[([a-zA-ZÀ-ž\-\ ]+)\]\]==/g, "==$1=="); }

function langSubsts { txt=txt.replace(/([=\ \*\:])\{\{([a-z]{2,3})\}\}/g, "$1{{subst"+":#ifexist:{{subst:"+"$2|l=}}|{{etyl|$2|-}}|{{"+"$2}}}}"); }

function wiktClickMyDiff { window.status = "[Show changes] has now been clicked."; document.editform.wpDiff.click; }

function superAutoFormat { // get page title pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue; //if (pagetitle.search(/Editing /) != 0) return; switch(wgAction){case 'submit': case 'edit': break; default: return}; // is this in the main namespace? If not, stop. if (wgNamespaceNumber) return;

// If editing a section, skip all of everything. if (pagetitle.search(/\(section\)/) != -1) return; txt = " " + document.editform.wpTextbox1.value; txt = txt.substr (1, txt.length-1); oldtxt = txt; if (txt.length < 2) txt = " " + txt; //safety valves if (txt.search(/^#redirect \[/i) != -1) return; minorFormat; //minor format problems that must be dealt with first langHdrs;   //swap out {-en-} and such headLevel;  //correct known 3rd level heading level problems langHdrs;   //correct known language heading level problems langSubsts; //subst: all the language templates if (txt == " ") txt = ""; document.editform.wpTextbox1.value = txt;

if (txt != oldtxt) { window.status = "...clicking the [Show changes] button..."; setTimeout( "wiktClickMyDiff;", 2000 ); } } $( superAutoFormat ); // /* end stuff copied from User:Connel MacKenzie/reformat.js */