User:Renard Migrant/vector.js

// THE FOLLOWING IS BASED ON User:Msh210/vector.js BUT HAS BEEN MODIFIED SINCE. THANKS MSH210! // //importScript('Transwiki:Gadget-HotCat.js'); document.getElementById('firstHeading').setAttribute('style','color:green'); 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/FindTrans.js'); importScript('User:Yair rand/languagenametocode.js'); importScript('User:Yair rand/orangelinks2.js'); importScript('User:Kephir/gadgets/xte.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 */ function minorFormat {

//use Roman not Latin in translation tables (other than for the Latin language, of course) txt = txt.replace(/\*\: Latin\: (\[|\{)/gi, "\*\: Roman\: $1"); // first unnamed parameter instead of lang in prefix and suffix txt = txt.replace(/\{\{(suffix|prefix)\|([\ -9\;-\\\^-z\}-ퟻ\-]+)\|([\ -9\;-\\\^-z\}-ퟻ\-]+)\|lang=([\ -9\;-\\\^-z\}-ퟻ\-]+)(\||\}\})/gi, "{{$1|$4|$2|$3$5"); // term with no first parameter and asterisk sorted. Latin default for no real reason txt = txt.replace(/\*\{\{term\|\|([\ -9\;-\\\^-z\}-ퟻ\-]+)\}\}/gi, "\{\{m\|la\|\*$1\}\}"); // term with no first parameter but no asterisk. These two lines must appear in this order txt = txt.replace(/\{\{term\|\|([\ -9\;-\\\^-z\}-ퟻ\-]+)\}\}/gi, "$1"); // convert (r) to (ɹ). Experimental, will be removed if it goes wrong too often txt = txt.replace(/\(r\)/gi, "(ɹ)"); //Convert term to m when only one, named parameter txt = txt.replace(/\{\{term\|([\ -9\;-\\\^-z\}-ퟻ\-]+)\|lang=([\ -9\;-\\\^-z\}-ퟻ\-]+)\}\}/gi, "");

// Always use head= instead of inf, pos=, sg= or current= txt = txt.replace(/\{\{(en|fr)\-(adj|adv|noun|plural\-noun|pronoun|proper noun|verb|verb form)\|(current|inf|pos|sg)=/gi, "{{$1-$2|head=");

//Merge or update gender and number templates txt = txt.replace(/\{\{m\|p\}\}/gi, "{{g|m-p}}"); txt = txt.replace(/\{\{f\|p\}\}/gi, "{{g|g-p}}"); txt = txt.replace(/\{\{n\|p\}\}/gi, "{{g|n-p}}"); txt = txt.replace(/\{\{m\}\} \{\{s\}\}/gi, "{{g|m}}"); txt = txt.replace(/\{\{m\}\} \{\{p\}\}/gi, "{{g|m-p}}"); txt = txt.replace(/\{\{m\}\} \{\{f\}\}/gi, "{{g|m|f}}"); txt = txt.replace(/\{\{f\}\} \{\{s\}\}/gi, "{{g|f}}"); txt = txt.replace(/\{\{f\}\} \{\{p\}\}/gi, "{{g|f-p}}"); txt = txt.replace(/\{\{n\}\} \{\{p\}\}/gi, "{{g|n-p}}"); txt = txt.replace(/\{\{n\}\} \{\{s\}\}/gi, "{{g|n}}"); txt = txt.replace(/\{\{m\}\} \{\{f\|p\}\}/gi, "{{g|m-p|f-p}}"); txt = txt.replace(/\{\{m\|f\}\} \{\{p\}\}/gi, "{{g|m-p|f-p}}"); txt = txt.replace(/\{\{m\}\} \{\{inv\}\}/gi, "{{g|m}}"); txt = txt.replace(/\{\{f\}\} \{\{inv\}\}/gi, "{{g|f}}"); txt = txt.replace(/\{\{m\}\} \{\{f\|inv\}\}/gi, "{{g|m|f}}"); txt = txt.replace(/\{\{m\|f\}\} \{\{inv\}\}/gi, "{{g|m|f}}");

//Convert *: to * before { {a}} { {audio}}, { {homophones}}, { {IPA}} and { {rhymes}} txt = txt.replace(/\*\: \{\{(a|audio|homophones|IPA|rhymes)(\||\})/gi, "* {{$1$2");

//Replace obsolete IPA characters txt = txt.replace(/ʣ/gi, "dz"); txt = txt.replace(/ʤ/gi, "dʒ"); txt = txt.replace(/ʥ/gi, "dʑ"); txt = txt.replace(/ʧ/gi, "tʃ"); txt = txt.replace(/ʦ/gi, "ts"); txt = txt.replace(/ʨ/gi, "tɕ");

//Adding { {qualifier}}. In some cases, you'll want to switch qualifier to context or gloss txt=txt.replace(/\(([a-zA-Z\ \-\,\:\;][a-zA-Z\ \-\,\:\;]*)\)/g, "{{qualifier|$1}}");//converts (foo) to {{qualifier|foo}} txt=txt.replace(/\(([a-zA-Z\ \-\,\:\;][a-zA-Z\ \-\,\:\;]*)\)/g, "{{qualifier|$1}}");//converts (foo) to {{qualifier|foo}} txt=txt.replace(/\{\{qualifier\|([a-zA-Z\ \-\,\:\;][a-zA-Z\ \-\,\:\;]*)\}\}\:/g, "{{sense|$1}}");//converts {{qualifier|foo}}: to {{sense|foo}} txt = txt.replace(/British/gi, "{{qualifier|British}}"); txt = txt.replace(/UK/gi, "{{qualifier|UK}}"); txt = txt.replace(/US/gi, "{{qualifier|US}}");

//Remove wikilinks from some common form of templates, but not piped links txt = txt.replace(/\{\{([\ -9\;-\\\^-z\}-ퟻ\-]+) of\|\[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\](\||\}\})/gi, "{{$1 of|$2$3");

//Actual { {form of}} txt = txt.replace(/\{\{form of\|([\ -9\;-\\\^-z\}-ퟻ]+)\|\[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\](\||\})/gi, "{{form of|$1|$2$3");

//Add { {homophones}} txt=txt.replace(/([hH])omophones\: \[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\]/g, "{"+"{homophones|$2}}"); //If two txt=txt.replace(/\{\{homophones\|([\ -9\;-\\\^-z\}-ퟻ]+)\}\}, \[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\]/g, "{"+"{homophones|$1|$2}}");

//Add lang=en to several templates. Change by hand if required txt = txt.replace(/\{\{(defn|etystub|rfc|rfd|rfe|rfp|rfap|rfdef|rfv|rfv\-etymology|rfv\-pronunciation)\}\}/g, "{{$1|lang=en}}");

//Put { {wikipedia}} under ==English== header, not above it txt=txt.replace(/\{\{wikipedia\}\}\n==English==/g, "==English==\n{{wikipedia}}"); txt=txt.replace(/\{\{wikipedia\}\}\n=/g, "{{wikipedia}}\n\n=");

//Bullet point before certain templates, but only when they are the first item on a line:

txt = txt.replace(/\n\{\{(a|AHD|audio|enPR|IPA|homophones|l|pedia|pedialite|qualifier|rhymes|seeCites|sense)(\||\}\})/g, "\n* {{$1$2");

//Remove needless complexity from WT:ACCEL generated entries txt=txt.replace(/\|\[\[([\ -9\;-\\\^-z\}-ퟻ\-]+) \#([\ -9\;-\\\^-z\}-ퟻ\-]+)\|([\ -9\;-\\\^-z\}-ퟻ\-]+)\]\]/g, "|$1");

//Term with no lang to { {m}}. Obviously, if the word is not English, change the first parameter

txt=txt.replace(/\{\{term\|([\ -9\;-\\\^-z\}-ퟻ\-]+)\}\}/g, "");

//Text replacement other than replacing headers and template redirects, which come later on txt = txt.replace(/\|skey\=/gi, "|sort="); txt = txt.replace(/\ \}\}/g, "}}"); txt = txt.replace(/\{\{ /g, "{{"); txt = txt.replace(/\ \|/g, "\|"); txt = txt.replace(/\|\ /g, "\|"); txt = txt.replace(/\ \n/g, "\n"); txt = txt.replace(/\=\= /g, "=="); txt = txt.replace(/ \=\=/g, "=="); txt = txt.replace(/\n\n\n/g, "\n\n"); txt = txt.replace(/==\n==/g, "==\n\n=="); txt = txt.replace(/\-\-\-\-\n=/g, "\n\n="); txt = txt.replace(/==\n\n([a-zA-Z\*|\[|\{'])/g, "==\n$1"); txt = txt.replace(/\n\=(\=*)([A-ȳ\ ]*)(\=*)\<\!/g, "\n=$1$2$3\n<!"); txt = txt.replace(/===\n\'\'\'(.*)\'\'\'\n#/gi, "===\n$1\n\n#"); txt = txt.replace(/===\n\{\{(.*)\}\}\n#/gi, "===\n{{$1}}\n\n#"); txt = txt.replace(/\{\{PAGENAME\}\}/gi, "{"+"{subst:PAGENAME}}"); txt = txt.replace(/ m/g, " {{g|m}}"); txt = txt.replace(/m /g, "{{g|m}} "); txt = txt.replace(/ f/g, " {{g|f}}"); txt = txt.replace(/f /g, "{{g|f}} "); txt = txt.replace(/ n/g, " {{g|n}}"); txt = txt.replace(/n /g, "{{g|n}} "); txt = txt.replace(/ c/g, " {{g|c}}"); txt = txt.replace(/c /g, "{{g|c}} "); txt = txt.replace(/ pl/g, " {{g|p}}"); txt = txt.replace(/pl /g, "{{g|p}} "); txt = txt.replace(/ s/g, " {{g|s}}"); txt = txt.replace(/s /g, "{{g|s}} "); txt = txt.replace(/m, f/g, "{{g|m|f}}"); txt = txt.replace(/\{\{mf\}\}/g, "{{g|m|f}}"); txt = txt.replace(/m pl/g, "{{g|m-p}}"); txt = txt.replace(/f pl/g, "{{g|f-p}}"); txt = txt.replace(/m plural/g, "{{g|m-p}}"); txt = txt.replace(/f plural/g, "{{g|f-p}}"); txt = txt.replace(/\*(\ *)([1-9][0-9][0-9]*)\:/g, "* $2,"); txt = txt.replace(/\*(\ *)([1-9][0-9][0-9]*)\:/g, "* $2,"); txt=txt.replace(/\ (\ *)/g, " "); txt=txt.replace(/\n([\*\#\:\;]+)(\ *)([\'\{\[a-zA-Z])/g, "\n$1 $3");//Thanks, Conrad.Irwin. txt=txt.replace(/\n\{\{template\:PL\:/g, "\n* {"+"{template:PL:");//as previous txt=txt.replace(/\n\{\{pedia([\}\|])/g, "\n* {{pedia$1"); txt=txt.replace(/\n\{\{versity([\}\|])/g, "\n* {{versity$1"); txt=txt.replace(/\{\{form\ of\|([a-zA-Z\ \-\,\'\[\]\(\)\"\/]*)\ of\|/g, "{"+"{form of|$1|"); txt=txt.replace(/\{\{onym([\}\|])/g, "{"+"{l$1");//straight swap  txt = txt.replace(/lang=Italian/gi, "lang=it");  txt = txt.replace(/(first|First|second|Second|third|Third) person (singular|plural)/gi, "$1-person $2");  txt = txt.replace(/Sinhala/gi, "Sinhalese");//Common misuse of secondary language name  txt = txt.replace(/\[\[(WS|WikiSaurus)\:/gi, "[[Wikisaurus:");  txt = txt.replace(/\#\:\*/gi, "#:");

//Redirect snaps for non-context labels. //Uses a fairly simple regex system, thus can occasionally cause problems. If so, do section editing only //Achieves not a lot, slows down editing, and has to be updated any time one of these templates is renamed txt=txt.replace(/\{\{alternate form of\|/g, "{"+"{alternative form of|"); txt=txt.replace(/\{\{alt form\|/g, "{"+"{alternative form of|"); txt=txt.replace(/\{\{altform\|/g, "{"+"{alternative form of|"); txt=txt.replace(/\{\{alt form of\|/g, "{"+"{alternative form of|"); txt=txt.replace(/\{\{altcaps\|/g, "{"+"alternative case form of|"); txt=txt.replace(/\{\{alternative capitalisation of\|/g, "{"+"alternative case form of|"); txt=txt.replace(/\{\{alternative capitalization of\|/g, "{"+"alternative case form of|"); txt=txt.replace(/\{\{alternate spelling of\|/g, "{"+"{alternative spelling of|"); txt=txt.replace(/\{\{altspelling\|/g, "{"+"{alternative spelling of|"); txt=txt.replace(/([\|\{])bottom2([\}\|])/g, "$1bottom$2"); txt=txt.replace(/([\|\{])(checktrans\-mid|reqtrans\-mid|ttbc\-mid)([\}\|])/g, "$1trans-mid$3"); txt=txt.replace(/([\|\{])(checktrans\-bottom|reqtrans\-bottom|ttbc\-bot|ttbc\-bottom)([\}\|])/g, "$1trans-bottom$3"); txt=txt.replace(/\{\{cmn\-def\|/g, "{"+"{pinyin reading of|"); txt=txt.replace(/\{\{cx\|/g, "{"+"{context|"); txt=txt.replace(/\{\{(en|fr)\-adjective([\}\|])/g, "{"+"{$1-adj$2"); txt=txt.replace(/\{\{(en|fr)\-adverb([\}\|])/g, "{"+"{$1-adv$2"); txt=txt.replace(/\{\{en\-conjunction([\}\|])/g, "{"+"{en-con$1"); txt=txt.replace(/\{\{en\-conj([\}\|])/g, "{"+"{en-con$1"); txt=txt.replace(/\{\{en\-interjection([\|\}])/g, "{"+"{en-interj$1"); txt=txt.replace(/\{\{en\-intj([\|\}])/g, "{"+"{en-interj$1"); txt=txt.replace(/\{\{en\-particle([\}\|])/g, "{"+"{en-part$1"); txt=txt.replace(/\{\{en\-preposition([\}\|])/g, "{"+"{en-prep$1"); txt=txt.replace(/\{\{en\-plural\-noun([\}\|])/g, "{"+"{en-plural noun$1"); txt=txt.replace(/\{\{en\-pronoun([\}\|])/g, "{"+"{en-pron$1"); txt=txt.replace(/\{\{en\-adj\-more([\}\|])/g, "{"+"{en-adj$1"); txt=txt.replace(/\{\{en\-proper\-noun([\}\|])/g, "{"+"{en-proper noun$1"); txt=txt.replace(/\{\{eye dialect([\|\}])/g, "{"+"{eye dialect of$1"); txt=txt.replace(/\{\{Flowbreak([\|\}])/g, "{"+"{flowbreak$1"); txt=txt.replace(/\{\{fr\-pp([\}\|])/g, "{"+"{fr-past participle$1"); txt=txt.replace(/\{\{fr\-verb form([\}\|])/g, "{"+"{fr-verb-form$1"); txt=txt.replace(/\{\{i([\}\|])/g, "{"+"{qualifier$1"); txt=txt.replace(/\{\{infl\|/g, "{"+"{head|"); txt=txt.replace(/\{\{italbrac([\|\}])/g, "{"+"{qualifier$1");//straight swap txt=txt.replace(/\{\{i-c([\|\}])/g, "{"+"{sense$1"); txt=txt.replace(/\{\{italbrac-colon([\|\}])/g, "{"+"{sense$1"); txt=txt.replace(/\{\{q([\}\|])/g, "{"+"{qualifier$1"); txt=txt.replace(/\{\{qual([\}\|])/g, "{"+"{qualifier$1"); txt=txt.replace(/\{\{non gloss definition([\|\}])/g, "{"+"{non-gloss definition$1"); txt=txt.replace(/\{\{n\-g([\|\}])/g, "{"+"{non-gloss definition$1"); txt=txt.replace(/\{\{PL\:pedia([\}\|])/g, "{"+"{pedia$1"); txt=txt.replace(/\{\{pf\}\}/g, "{"+"{pf.}}"); txt=txt.replace(/([\|\{])R\:ANOLH([\}\|])/g, "$1R:Anglo-Norman On-Line Hub$2"); txt=txt.replace(/\{\{SAMPA\|/g, "{"+"{X\-SAMPA|"); txt=txt.replace(/\{\{see also\|/g, "{"+"{also|"); txt=txt.replace(/\{\{short of\|/g, "{"+"{short for|"); txt=txt.replace(/\{\{sic([\|\}])/g, "{"+"{SIC$1"); txt=txt.replace(/\{\{sic\.([\|\}])/g, "{"+"{SIC$1"); txt=txt.replace(/\{\{(webster|Webster|webster 1913|1913)([\|\}])/g, "{"+"{Webster 1913$2"); txt=txt.replace(/\{\{Wikipedia([\|\}])/g, "{"+"{wikipedia$1"); txt=txt.replace(/\{\{Wikipedia\-inline([\}\|])/g, "{"+"{pedia$1"); txt=txt.replace(/\{\{xalso\|/g, "{"+"{xsee|");

//

txt=txt.replace(/\[\[#English\|([\ -9\;-\\\^-z\}-ퟻ\-]+)\]\]/g, "{"+"{l|en|{"+"{subst:PAGENAME}}}}");

} // get all the {-header-} templates replaced function headLevel { txt = txt.replace(/==adjective form==/gi, "==Adjective=="); txt = txt.replace(/==(alternative spellings|alternative spellings|alternative spelling|alternate spelling|alternate form|alternative form|alternate forms)==/gi, "==Alternative forms=="); txt = txt.replace(/==cardinal number==/gi, "==Cardinal numeral=="); txt = txt.replace(/==citations==/gi, "==Quotations=="); txt = txt.replace(/==derivation==/gi, "==Etymology=="); txt = txt.replace(/==derivatives==/gi, "==Derived terms=="); 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(/==Number==/gi, "==Numeral=="); txt = txt.replace(/==ordinal number==/gi, "==Ordinal numeral=="); txt = txt.replace(/==(pinyin|pinyin syllable)==/gi, "==Romanization=="); 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=="); //Fix User:2.125.74.117 stuff txt = txt.replace(/==see Also==/gi, "==See also=="); txt = txt.replace(/\n====Also See====\n/gi, "{"+"{subst:blank}}"); //Header levels, L3 to L4 txt=txt.replace(/\n===(Antonyms|Coordinate terms|Derived terms|Descendants|Related terms|Synonyms|Translations|Usage notes)===\n/gi, "\n====$1====\n"); //Header levels, L2 to L3 txt=txt.replace(/\n==(Etymology|References|See also)==\n/gi, "\n===$1===\n"); }

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}}|{{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. pagetitle = $('#firstHeading').text;//Thanks, Ruakh! 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 */