User:MGSpiller/monobook.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

This JavaScript is executed for MGSpiller on every page load, when User:MGSpiller is using the Monobook skin.


/*
<pre>
*/

function considerChangingExpiryFocus() {
  return true;
}

 //todo
function fixCreationLinks() {
  //fix the links created in the table for preload templates, to allow multi-word terms
  // get page title
  var pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue;
  if (pagetitle.search(/Search/) != -1) {
    pagetitle = document.getElementById('contentSub').firstChild.nodeValue;
    pagetitle = pagetitle.replace(/For query /g, "");
    pagetitle = pagetitle.replace(/\"/g, "");
  }
  if (pagetitle.search(/^Search results/) != -1) {
    // find the spot to add our new tab
    var edittabli = document.getElementById('preload-table');
    //http://en.wiktionary.org/w/wiki.phtml?title=$1&action=edit&preload=Template:new_en_verb_past
/*
 //so now, determine what the page name *should* be, and find the broken part in these links, and replace.
 javascript:(function(){var i,c,x,h,t; for(i=0;x=document.links[i];++i)
 { h=x.getAttribute(%22href%22);
   t=x.text;
   if (t.search(/&action=edit&preload=Template:new/) != -1) {
     h = h + t ;
     t = t.replace(t, "basic");
     x.text = t ;
     x.href = h ;
   //todo: make this work
   }
   //x.title += %22 %22 + x.innerHTML; 
   //x.appendChild(document.createTextNode(h));
  } })()
*/
  }
}


 // add "favorites" to navigation box thing on left column
function addToNav() {
  var lastnav = document.getElementById('n-sitesupport');
  var newnav;
  var newa;

  // get page title
  var pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue;
  if (pagetitle.search(/Search/) != -1) {
    pagetitle = document.getElementById('contentSub').firstChild.nodeValue;
    pagetitle = pagetitle.replace(/For query /g, "");
    pagetitle = pagetitle.replace(/\"/g, "");
  }
  pagetitle = pagetitle.replace(/Editing /g, "");
  var pageexternal = pagetitle.replace(/\ /g, "_");
  var pageext =      pagetitle.replace(/\ /g, "+");

  newnav = document.createElement('li');
  newa = document.createElement('a');
  newa.href='/wiki/Wiktionary:Beer parlour';
  newa.appendChild(document.createTextNode('Beer Parlor'));
  newnav.appendChild(newa);
  lastnav.parentNode.appendChild(newnav);
  ta['Beer Parlor'] = new Array('','The rowdy place where policies are discussed in a chaotic manner');

 //[[w:pagetitleexternal|w:pagetitle]]
  newnav = document.createElement('li');
  newa = document.createElement('a');
  newa.href='/wiki/w:' + pageexternal;
  newa.appendChild(document.createTextNode('w: ' + pagetitle));
  newnav.appendChild(newa);
  lastnav.parentNode.appendChild(newnav);
  ta['w: ' + pagetitle] = new Array('','Wikipedia quicklink for this same title');

 if (pagetitle == 'User:Connel MacKenzie') return;

 //[http://machaut.uchicago.edu/cgi-bin/WEBSTER.sh?WORD={{PAGENAME}} ARTFL:{{PAGENAME}}]
  newnav = document.createElement('li');
  newa = document.createElement('a');
  newa.href='http://machaut.uchicago.edu/?action=search&word=' + pageext + '&resource=Webster\'s&quicksearch=on' ;
  newa.appendChild(document.createTextNode('ARTFL:' + pagetitle));
  newnav.appendChild(newa);
  lastnav.parentNode.appendChild(newnav);
  ta['ARTFL:' + pagetitle] = new Array('','Check for this title in Websters 1913 Dictionary');

 //[http://print.google.com/print?q={{PAGENAME}}&btnG=Google+Search Google:{{PAGENAME}}]
  newnav = document.createElement('li');
  newa = document.createElement('a');
  newa.href='http://print.google.com/print?q=' + pageext + '&btnG=Google+Search';
  newa.appendChild(document.createTextNode('Google:' + pagetitle));
  newnav.appendChild(newa);
  lastnav.parentNode.appendChild(newnav);
  ta['Google:' + pagetitle] = new Array('','Check for this title using Google');

 //www.diclogos.org
/*  newnav = document.createElement('li') ;
  newf = document.createElement('form') ;
  newm = newf.createElement('method') ;
  newm.value = 'post' ; 
  newf.appendChild(newm) ;
  newm = newf.createElement('action') ;
  newm.value = 'http://www.dicologos.org/pls/dictionary/new_dictionary.dic.main' ;
  newf.appendChild(newm) ;
  newIname = newf.form.createElement('input');
  newm = newIname.createElement('type') ;
  newm.value = 'text' ;
  newIname.appendChild(newm) ;
  newm = newIname.createElement('name') ;
  newm.value = 'word' ;
  newIname.appendChild(newm) ;
  newm = newIname.createElement('size') ;
  newm.value = 12 ;
  newIname.appendChild(newm) ;
  newf.appendChild(newIname) ;
  newIname = newf.form.createElement('input') ;
  newm = newIname.createElement('type') ;
  newm.value = 'submit' ;
  newIname.appendChild(newm) ;
  newm = newIname.createElement('value') ;
  newm.value = 'Search' ;
  newIname.appendChild(newm) ;
  newf.appendChild(newIname) ;
  newnav.appendChild(newf) ;
  lastnav.parentNode.appendChild(newnav);
*/

 //http://www.cogsci.princeton.edu/cgi-bin/webwn2.0?stage=1&word={{PAGENAME}} WordNet:{{PAGENAME}}

 //http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query={{PAGENAME}}&action=Search FOLDOC:{{PAGENAME}}

 //http://www.altavista.com/web/results?itag=wrx&q={{PAGENAME}}&kgs=0&kls=0 Altavista:{{PAGENAME}}

 //Probably good to have these links, to prove that our defs are generally different? 
 //www.m-w.com + www.dictionary.com + collins + about.com + wordreference.com etc.
 //perhaps also to search for copyvios quickly.  Hmmm.
}



    /* The variables "oldtxt" and "oldtext" determine which summary comments are added, 
    AND whether or not to click the "Show changes" button.  "oldtxt" is for clicking, 
    while "oldtext" is used section-by-section. */

function minorFormat() {
  var oldtext = txt;
  //note the regexp ?(onething|notherthing|otherthing) syntax that doesn't work as I thought
  txt = txt.replace(/\<i\>/gi, "''");  //italics is '' in wiki syntax
  txt = txt.replace(/\<\/i\>/gi, "''");  //italics is '' in wiki syntax
  txt = txt.replace(/\<b\>/gi, "'''");  //bold is ''' in wiki syntax
  txt = txt.replace(/\<\/b\>/gi, "'''");  //bold is ''' in wiki syntax
 // txt = txt.replace(/\<br\>/gi, "\n\n");  //break is <LF><LF> in wiki syntax
 // txt = txt.replace(/\<\/br\>/gi, "\n\n");  //break is <LF><LF> in wiki syntax
  txt = txt.replace(/\=\= /g, "==");
  txt = txt.replace(/ \=\=/g, "==");
  txt = txt.replace(/\{\{-en-\}\}/g, "==English==");
  txt = txt.replace(/==\{\{en\}\}==/g, "==English==");
  txt = txt.replace(/Morobashi/gi, "Morohashi");
  txt = txt.replace(/\[\[comparative\]\]/gi, "{{compar}}"); 
  txt = txt.replace(/\[\[superlative\]\]/gi, "{{superl}}"); 
  txt = txt.replace(/\'\'comparative\'\'/gi, "{{compar}}");
  txt = txt.replace(/\'\'superlative\'\'/gi, "{{superl}}");
  txt = txt.replace(/\{\{top\}\}\</gi, "{{top}}\n<");
  txt = txt.replace(/\{\{mid\}\}\</gi, "{{mid}}\n<");
  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "minor fmt";
  }
  oldtext = txt;
    txt = txt.replace(/\[\[wikipedia:en:/gi, "[[w:"); //ancient syntax
    txt = txt.replace(/\[\[en:/gi, "[[w:"); //ancient syntax
    txt = txt.replace(/\(\'\'mass noun\'\'\)/gi, "{{uncountable}}");
    txt = txt.replace(/\<\!--This is a comment.  Please remove comments before saving. --\>\n\n\<\!-- Change Part-Of-Speech on next line \(inside the======\'s\) to be correct.--\>\n/gi, "");
    txt = txt.replace(/\<\!--\{\{wikipedia\}\} uncomment if you know there is a Wikipedia article--\>\n/gi, "");
  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "format";
  }
}


function genderFmt() {
  var oldtext = txt;
  //txt = txt.replace(/plural/gi, "plural"); // NOTE: this only "/gi" case insensitive search in this section - all others must be just "/g".
  txt = txt.replace(/ ''m''/g, " {{m}}");  // test this ''m'' {{m}}
  txt = txt.replace(/''m'' /g, "{{m}} ");  // test this ''m'' {{m}}
  txt = txt.replace(/ ''f''/g, " {{f}}");
  txt = txt.replace(/''f'' /g, "{{f}} ");
  txt = txt.replace(/ ''n''/g, " {{n}}");
  txt = txt.replace(/''n'' /g, "{{n}} ");
  txt = txt.replace(/ ''c''/g, " {{c}}");
  txt = txt.replace(/''c'' /g, "{{c}} ");
  txt = txt.replace(/ ''pl''/g, " {{p}}");
  txt = txt.replace(/''pl'' /g, "{{p}} ");
  txt = txt.replace(/ ''s''/g, " {{s}}");
  txt = txt.replace(/''s'' /g, "{{s}} ");
  txt = txt.replace(/''m, f''/g, "{{m}}, {{f}}");
  txt = txt.replace(/''m pl''/g, "{{m}} {{p}}");
  txt = txt.replace(/''f pl''/g, "{{f}} {{p}}");
  txt = txt.replace(/''m plural''/g, "{{m}} {{p}}");
  txt = txt.replace(/''f plural''/g, "{{f}} {{p}}");
  txt = txt.replace(/\(plural \[/gi, "(''plural:'' [");
  txt = txt.replace(/\(''plural'' /gi, "(''plural:'' ");
  txt = txt.replace(/, plural '/gi, "  (''plural:'' '"); //note: this requires human help
  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "{{gender}}";
  }
}


// get all the {{-header-}} templates replaced
function headLevel() {
  // improper heading levels
  txt = txt.replace(/===English===\n/gi, "==English==\n");
    //Insert a blank line after "==English=="
    txt = txt.replace(/==English==\n=/gi, "==English==\n\n=");
    txt = txt.replace(/==English==\n\{/gi, "==English==\n\n\{");

  var oldtext = txt;  

  //depricated templates
  txt = txt.replace(/\{\{-noun-\}\}/g, "===Noun===");
  txt = txt.replace(/\{\{-verb-\}\}/g, "===Verb===");
  txt = txt.replace(/\{\{-etym-\}\}/g, "===Etymology===");
  txt = txt.replace(/\{\{-adj-\}\}/g, "===Adjective===");
  txt = txt.replace(/\{\{-syn-\}\}/g, "===Synonyms===");

  txt = txt.replace(/\{\{trans\}\}/g, "Translations");

  //really far-off entries
  txt = txt.replace(/\n'''adjective'''\n/gi, "\n===Adjective===\n");
  txt = txt.replace(/\n'''adverb'''\n/gi, "\n===Adverb===\n");
  txt = txt.replace(/\n'''noun'''\n/gi, "\n===Noun===\n");
  txt = txt.replace(/\n'''verb'''\n/gi, "\n===Verb===\n");
  txt = txt.replace(/\n'''translation'''\n/gi, "\n===Translations===\n");
  txt = txt.replace(/\n'''translations'''\n/gi, "\n===Translations===\n");

  //first, correct case
  txt = txt.replace(/==adjective==/gi, "==Adjective==");
  txt = txt.replace(/==\[\[adjective\]\]==/gi, "==Adjective==");
  txt = txt.replace(/==adverb==/gi, "==Adverb==");
  txt = txt.replace(/==\[\[adverb\]\]==/gi, "==Adverb==");
  txt = txt.replace(/==antonyms==/gi, "==Antonyms==");
  txt = txt.replace(/==\[\[antonyms\]\]==/gi, "==Antonyms==");
  txt = txt.replace(/==cardinal number==/gi, "==Cardinal number==");
  txt = txt.replace(/==number==/gi, "==Cardinal number==");
  txt = txt.replace(/==derived expresson==/gi, "==Derived terms==");
  txt = txt.replace(/==derived expression==/gi, "==Derived terms==");
  txt = txt.replace(/==\[\[derived expression\]\]==/gi, "==Derived terms==");
  txt = txt.replace(/==derived expressions==/gi, "==Derived terms==");
  txt = txt.replace(/==\[\[derived expressions\]\]==/gi, "==Derived terms==");
  txt = txt.replace(/==derived term==/gi, "==Derived terms==");
  txt = txt.replace(/==\[\[derived term\]\]==/gi, "==Derived terms==");
  txt = txt.replace(/==derived terms==/gi, "==Derived terms==");
  txt = txt.replace(/==\[\[derived terms\]\]==/gi, "==Derived terms==");
  txt = txt.replace(/==derived word==/gi, "==Derived terms==");
  txt = txt.replace(/==\[\[derived word\]\]==/gi, "==Derived terms==");
  txt = txt.replace(/==derived words==/gi, "==Derived terms==");
  txt = txt.replace(/==\[\[derived words\]\]==/gi, "==Derived terms==");
  txt = txt.replace(/==etymology==/gi, "==Etymology==");
  txt = txt.replace(/==\[\[etymology\]\]==/gi, "==Etymology==");
  txt = txt.replace(/==noun==/gi, "==Noun==");
  txt = txt.replace(/==\[\[noun\]\]==/gi, "==Noun==");
  txt = txt.replace(/==noun phrase==/gi, "==Noun==");
  txt = txt.replace(/==\[\[noun phrase\]\]==/gi, "==Noun==");
  txt = txt.replace(/==verbal phrase==/gi, "==Phrase==");
  txt = txt.replace(/==\[\[verbal phrase\]\]==/gi, "==Phrase==");
  txt = txt.replace(/==pronunciation==/gi, "==Pronunciation==");
  txt = txt.replace(/==\[\[pronunciation\]\]==/gi, "==Pronunciation==");
  txt = txt.replace(/==proper name==/gi, "==Proper noun==");
  txt = txt.replace(/==\[\[proper name\]\]==/gi, "==Proper noun==");
  txt = txt.replace(/==proper noun==/gi, "==Proper noun==");
  txt = txt.replace(/==\[\[proper noun\]\]==/gi, "==Proper noun==");
  txt = txt.replace(/==related words==/gi, "==Related terms==");
  txt = txt.replace(/==\[\[related words\]\]==/gi, "==Related terms==");
  txt = txt.replace(/==see also==/gi, "==See also==");
  txt = txt.replace(/==\[\[see also\]\]==/gi, "==See also==");
  txt = txt.replace(/==symbol==/gi, "==Symbol==");
  txt = txt.replace(/==\[\[symbol\]\]==/gi, "==Symbol==");
  txt = txt.replace(/==symbols==/gi, "==Symbol==");
  txt = txt.replace(/==\[\[symbols\]\]==/gi, "==Symbol==");
  txt = txt.replace(/==synonyms==/gi, "==Synonyms==");
  txt = txt.replace(/==\[\[synonyms\]\]==/gi, "==Synonyms==");
  txt = txt.replace(/==translation==/gi, "==Translations==");
  txt = txt.replace(/==\[\[translation\]\]==/gi, "==Translations==");
  txt = txt.replace(/==translations==/gi, "==Translations==");
  txt = txt.replace(/==\[\[translations\]\]==/gi, "==Translations==");
  txt = txt.replace(/==note==/gi, "==Usage notes==");
  txt = txt.replace(/==\[\[note\]\]==/gi, "==Usage notes==");
  txt = txt.replace(/==notes==/gi, "==Usage notes==");
  txt = txt.replace(/==\[\[notes\]\]==/gi, "==Usage notes==");
  txt = txt.replace(/==\[\[usage note\]\]==/gi, "==Usage notes==");
  txt = txt.replace(/==usage==/gi, "==Usage notes==");
  txt = txt.replace(/==\[\[usage\]\]==/gi, "==Usage notes==");
  txt = txt.replace(/==\[\[usage notes\]\]==/gi, "==Usage notes==");
  txt = txt.replace(/==usages==/gi, "==Usage notes==");
  txt = txt.replace(/==\[\[usages\]\]==/gi, "==Usage notes==");
  txt = txt.replace(/==usage note==/gi, "==Usage notes==");
  txt = txt.replace(/==\[\[intransitive verb\]\]==/gi, "==Verb==");
  txt = txt.replace(/==verb==/gi, "==Verb==");
  txt = txt.replace(/==\[\[verb\]\]==/gi, "==Verb==");
  //Ironically, all these spelling variations have been spotted in Wiktionary...
   txt = txt.replace(/==Variant form==/gi, "==Alternative forms==");
   txt = txt.replace(/==Variant forms==/gi, "==Alternative forms==");
   txt = txt.replace(/==Alternate form==/gi, "==Alternative forms==");
   txt = txt.replace(/==Alternate forms==/gi, "==Alternative forms==");
   txt = txt.replace(/==Alternative form==/gi, "==Alternative forms==");
   txt = txt.replace(/==Alternative forms==/gi, "==Alternative forms==");
  //Ironically, all these spelling variations have been spotted in Wiktionary...
   txt = txt.replace(/==Alternate spelling==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Alternate spellings==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Alternative spelling==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Other spellings==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Spelling variant==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Spelling variants==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Spelling variation==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Spelling variations==/gi, "==Alternative spellings==");
   txt = txt.replace(/==spellings==/gi, "==Alternative spellings==");
   txt = txt.replace(/==variant==/gi, "==Alternative spellings==");
   txt = txt.replace(/==\[\[variant\]\]==/gi, "==Alternative spellings==");
   txt = txt.replace(/==variant spelling==/gi, "==Alternative spellings==");
   txt = txt.replace(/==variant spellings==/gi, "==Alternative spellings==");
   txt = txt.replace(/==variants==/gi, "==Alternative spellings==");
   txt = txt.replace(/==variation==/gi, "==Alternative spellings==");
   txt = txt.replace(/==variations==/gi, "==Alternative spellings==");
   txt = txt.replace(/==varieties==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Typographic variants==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Variant spelling==/gi, "==Alternative spellings==");
   txt = txt.replace(/==Variant spellings==/gi, "==Alternative spellings==");
  //then correct levels
  txt = txt.replace(/==Adjective==\n/gi, "===Adjective===\n");
  txt = txt.replace(/==Adverb==\n/gi, "===Adverb===\n");
  txt = txt.replace(/==Derived terms==\n/gi, "===Derived terms===\n");
  txt = txt.replace(/==Etymology==\n/gi, "===Etymology===\n");
  txt = txt.replace(/==Noun==\n/gi, "===Noun===\n");
  txt = txt.replace(/==Pronunciation==\n/gi, "===Pronunciation===\n");
  txt = txt.replace(/==See also==\n/gi, "===See also===\n");
  txt = txt.replace(/==Related terms==\n/gi, "===Related terms===\n");
  txt = txt.replace(/==Symbol==\n/gi, "===Symbol===\n");
  txt = txt.replace(/==Symbols==\n/gi, "===Symbol===\n");
  txt = txt.replace(/==Synonyms==\n/gi, "===Synonyms===\n");
  txt = txt.replace(/==Translation==\n/gi, "====Translations====\n");
  txt = txt.replace(/==Translations==\n/gi, "====Translations====\n");
  txt = txt.replace(/==Usage note==\n/gi, "===Usage note===\n");
  txt = txt.replace(/==Verb==\n/gi, "===Verb===\n");
  txt = txt.replace(/\#\*\ \[\[Synonym\]\]s\n/gi, "===Synonyms===\n");
  txt = txt.replace(/\#\*\ Synonyms\n/gi, "===Synonyms===\n");
  //next line is controvercial?
  txt = txt.replace(/====Alternative spellings====\n/g, "===Alternative spellings===\n");
  txt = txt.replace(/==Alternative spellings==\n/g, "===Alternative spellings===\n");
  txt = txt.replace(/===Alternative spellings===\n\[/g, "===Alternative spellings===\n* [");
  txt = txt.replace(/====Alternative forms====\n/g, "===Alternative forms===\n");
  txt = txt.replace(/==Alternative forms==\n/g, "===Alternative forms===\n");
  txt = txt.replace(/===Alternative forms===\n\[/g, "===Alternative forms===\n* [");
  //todo: Ensure all headers are in Sentence case, not in Title Case.  <-- BAH!  Go after valid headers only.  Leave all others on exception "todo2" list.
  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "===Hdr===";
  }
}


function langHdrs() {
  var oldtext = txt;
  txt = txt.replace(/===icelandic===\n/gi, "==Icelandic==\n");
  txt = txt.replace(/===german===\n/gi, "==German==\n");
  txt = txt.replace(/===french===\n/gi, "==French==\n");
  txt = txt.replace(/===indonesian===\n/gi, "==Indonesian==\n");
  txt = txt.replace(/===interlingua===\n/gi, "==Interlingua==\n");
  txt = txt.replace(/===\[\[interlingua\]\]===\n/gi, "==Interlingua==\n");
  txt = txt.replace(/===italian===\n/gi, "==Italian==\n");
  txt = txt.replace(/===latin===\n/gi, "==Latin==\n");
  txt = txt.replace(/===portuguese===\n/gi, "==Portuguese==\n");
  txt = txt.replace(/===novial===\n/gi, "==Novial==\n");
  txt = txt.replace(/===romanica===\n/gi, "==Romanica==\n");
  txt = txt.replace(/===\[\[romanica\]\]===\n/gi, "==Romanica==\n");
  txt = txt.replace(/===spanish===\n/gi, "==Spanish==\n");
  txt = txt.replace(/===slovak===\n/gi, "==Slovak==\n");
  txt = txt.replace(/==volapuk==/gi, "==[[Volapük]]==");
  txt = txt.replace(/==\[\[volapuk\]\]==/gi, "==[[Volapük]]==");
  txt = txt.replace(/==volapük==/gi, "==[[Volapük]]==");
  txt = txt.replace(/==\[\[volapük\]\]==/gi, "==[[Volapük]]==");
  txt = txt.replace(/==volapük word==/gi, "==[[Volapük]]==");
  txt = txt.replace(/==\[\[volapük\]\] word==/gi, "==[[Volapük]]==");
  txt = txt.replace(/===\[\[volapük\]\]===\n/gi, "==[[Volapük]]==\n");
  txt = txt.replace(/===welsh===\n/gi, "==Welsh==\n");
  txt = txt.replace(/===\[\[Chickasaw\]\]===\n/gi, "==[[Chickasaw]]==\n");
  txt = txt.replace(/===Meanings===\n/gi, "");
  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "==Lang==";
  }
}


// do not do generic code here!  Only sway two letter templates that *are* language names for translations
// TODO: A smarter person would have list="af,am,an,ar,az,be..."
function langSubsts() {
  var oldtext = txt;
  txt = txt.replace(/\{\{en\}\}/g, "{{subst"+":en}}");
  txt = txt.replace(/\{\{af\}\}/g, "{{subst"+":af}}");
  txt = txt.replace(/\{\{am\}\}/g, "{{subst"+":am}}");
  txt = txt.replace(/\{\{an\}\}/g, "{{subst"+":an}}");
  txt = txt.replace(/\{\{ar\}\}/g, "{{subst"+":ar}}");
  txt = txt.replace(/\{\{az\}\}/g, "{{subst"+":az}}");
  txt = txt.replace(/\{\{be\}\}/g, "{{subst"+":be}}");
  txt = txt.replace(/\{\{bg\}\}/g, "{{subst"+":bg}}");
  txt = txt.replace(/\{\{bh\}\}/g, "{{subst"+":bh}}");
  txt = txt.replace(/\{\{br\}\}/g, "{{subst"+":br}}");
  txt = txt.replace(/\{\{bs\}\}/g, "{{subst"+":bs}}");
  txt = txt.replace(/\{\{ca\}\}/g, "{{subst"+":ca}}");
  txt = txt.replace(/\{\{ch\}\}/g, "{{subst"+":ch}}");
  txt = txt.replace(/\{\{cr\}\}/g, "{{subst"+":cr}}");
  txt = txt.replace(/\{\{cs\}\}/g, "{{subst"+":cs}}");
  txt = txt.replace(/\{\{cy\}\}/g, "{{subst"+":cy}}");
  txt = txt.replace(/\{\{da\}\}/g, "{{subst"+":da}}");
  txt = txt.replace(/\{\{de\}\}/g, "{{subst"+":de}}");
  txt = txt.replace(/\{\{el\}\}/g, "{{subst"+":el}}");
  txt = txt.replace(/\{\{eo\}\}/g, "{{subst"+":eo}}");
  txt = txt.replace(/\{\{es\}\}/g, "{{subst"+":es}}");
  txt = txt.replace(/\{\{et\}\}/g, "{{subst"+":et}}");
  txt = txt.replace(/\{\{eu\}\}/g, "{{subst"+":eu}}");
  txt = txt.replace(/\{\{fa\}\}/g, "{{subst"+":fa}}");
  txt = txt.replace(/\{\{fi\}\}/g, "{{subst"+":fi}}");
  txt = txt.replace(/\{\{fj\}\}/g, "{{subst"+":fj}}");
  txt = txt.replace(/\{\{fo\}\}/g, "{{subst"+":fo}}");
  txt = txt.replace(/\{\{fr\}\}/g, "{{subst"+":fr}}");
  txt = txt.replace(/\{\{fy\}\}/g, "{{subst"+":fy}}");
  txt = txt.replace(/\{\{ga\}\}/g, "{{subst"+":ga}}");
  txt = txt.replace(/\{\{gl\}\}/g, "{{subst"+":gl}}");
  txt = txt.replace(/\{\{gn\}\}/g, "{{subst"+":gn}}");
  txt = txt.replace(/\{\{gu\}\}/g, "{{subst"+":gu}}");
  txt = txt.replace(/\{\{gv\}\}/g, "{{subst"+":gv}}");
  txt = txt.replace(/\{\{he\}\}/g, "{{subst"+":he}}");
  txt = txt.replace(/\{\{hi\}\}/g, "{{subst"+":hi}}");
  txt = txt.replace(/\{\{hr\}\}/g, "{{subst"+":hr}}");
  txt = txt.replace(/\{\{hu\}\}/g, "{{subst"+":hu}}");
  txt = txt.replace(/\{\{hy\}\}/g, "{{subst"+":hy}}");
  txt = txt.replace(/\{\{ia\}\}/g, "{{subst"+":ia}}");
  txt = txt.replace(/\{\{id\}\}/g, "{{subst"+":id}}");
  txt = txt.replace(/\{\{io\}\}/g, "{{subst"+":io}}");
  txt = txt.replace(/\{\{is\}\}/g, "{{subst"+":is}}");
  txt = txt.replace(/\{\{it\}\}/g, "{{subst"+":it}}");
  txt = txt.replace(/\{\{ja\}\}/g, "{{subst"+":ja}}");
  txt = txt.replace(/\{\{jp\}\}/g, "{{subst"+":jp}}");
  txt = txt.replace(/\{\{jv\}\}/g, "{{subst"+":jv}}");
  txt = txt.replace(/\{\{ka\}\}/g, "{{subst"+":ka}}");
  txt = txt.replace(/\{\{kk\}\}/g, "{{subst"+":kk}}");
  txt = txt.replace(/\{\{km\}\}/g, "{{subst"+":km}}");
  txt = txt.replace(/\{\{kn\}\}/g, "{{subst"+":kn}}");
  txt = txt.replace(/\{\{ko\}\}/g, "{{subst"+":ko}}");
  txt = txt.replace(/\{\{kr\}\}/g, "{{subst"+":kr}}");
  txt = txt.replace(/\{\{ku\}\}/g, "{{subst"+":ku}}");
  txt = txt.replace(/\{\{kw\}\}/g, "{{subst"+":kw}}");
  txt = txt.replace(/\{\{la\}\}/g, "{{subst"+":la}}");
  txt = txt.replace(/\{\{lb\}\}/g, "{{subst"+":lb}}");
  txt = txt.replace(/\{\{li\}\}/g, "{{subst"+":li}}");
  txt = txt.replace(/\{\{lo\}\}/g, "{{subst"+":lo}}");
  txt = txt.replace(/\{\{lt\}\}/g, "{{subst"+":lt}}");
  txt = txt.replace(/\{\{lv\}\}/g, "{{subst"+":lv}}");
  txt = txt.replace(/\{\{ma\}\}/g, "{{subst"+":ma}}");
  txt = txt.replace(/\{\{mh\}\}/g, "{{subst"+":mh}}");
  txt = txt.replace(/\{\{mi\}\}/g, "{{subst"+":mi}}");
  txt = txt.replace(/\{\{mk\}\}/g, "{{subst"+":mk}}");
  txt = txt.replace(/\{\{ml\}\}/g, "{{subst"+":ml}}");
  txt = txt.replace(/\{\{mn\}\}/g, "{{subst"+":mn}}");
  txt = txt.replace(/\{\{mr\}\}/g, "{{subst"+":mr}}");
  txt = txt.replace(/\{\{ms\}\}/g, "{{subst"+":ms}}");
  txt = txt.replace(/\{\{mt\}\}/g, "{{subst"+":mt}}");
  txt = txt.replace(/\{\{my\}\}/g, "{{subst"+":my}}");
  txt = txt.replace(/\{\{ne\}\}/g, "{{subst"+":ne}}");
  txt = txt.replace(/\{\{nl\}\}/g, "{{subst"+":nl}}");
  txt = txt.replace(/\{\{nn\}\}/g, "{{subst"+":nn}}");
  txt = txt.replace(/\{\{no\}\}/g, "{{subst"+":no}}");
  txt = txt.replace(/\{\{oc\}\}/g, "{{subst"+":oc}}");
  txt = txt.replace(/\{\{pl\}\}/g, "{{subst"+":pl}}");
  txt = txt.replace(/\{\{pt\}\}/g, "{{subst"+":pt}}");
  txt = txt.replace(/\{\{ro\}\}/g, "{{subst"+":ro}}");
  txt = txt.replace(/\{\{ru\}\}/g, "{{subst"+":ru}}");
  txt = txt.replace(/\{\{sa\}\}/g, "{{subst"+":sa}}");
  txt = txt.replace(/\{\{si\}\}/g, "{{subst"+":si}}");
  txt = txt.replace(/\{\{sk\}\}/g, "{{subst"+":sk}}");
  txt = txt.replace(/\{\{sl\}\}/g, "{{subst"+":sl}}");
  txt = txt.replace(/\{\{sm\}\}/g, "{{subst"+":sm}}");
  txt = txt.replace(/\{\{sq\}\}/g, "{{subst"+":sq}}");
  txt = txt.replace(/\{\{sr\}\}/g, "{{subst"+":sr}}");
  txt = txt.replace(/\{\{su\}\}/g, "{{subst"+":su}}");
  txt = txt.replace(/\{\{sv\}\}/g, "{{subst"+":sv}}");
  txt = txt.replace(/\{\{Sv\}\}/g, "{{subst"+":sv}}");
  txt = txt.replace(/\{\{sw\}\}/g, "{{subst"+":sw}}");
  txt = txt.replace(/\{\{ta\}\}/g, "{{subst"+":ta}}");
  txt = txt.replace(/\{\{te\}\}/g, "{{subst"+":te}}");
  txt = txt.replace(/\{\{th\}\}/g, "{{subst"+":th}}");
  txt = txt.replace(/\{\{tl\}\}/g, "{{subst"+":tl}}");
  txt = txt.replace(/\{\{tm\}\}/g, "{{subst"+":tm}}");
  txt = txt.replace(/\{\{tr\}\}/g, "{{subst"+":tr}}");
  txt = txt.replace(/\{\{tt\}\}/g, "{{subst"+":tt}}");
  txt = txt.replace(/\{\{ua\}\}/g, "{{subst"+":ua}}");
  txt = txt.replace(/\{\{uk\}\}/g, "{{subst"+":uk}}");
  txt = txt.replace(/\{\{ur\}\}/g, "{{subst"+":ur}}");
  txt = txt.replace(/\{\{uz\}\}/g, "{{subst"+":uz}}");
  txt = txt.replace(/\{\{vi\}\}/g, "{{subst"+":vi}}");
  txt = txt.replace(/\{\{vo\}\}/g, "{{subst"+":vo}}");
  txt = txt.replace(/\{\{wa\}\}/g, "{{subst"+":wa}}");
  txt = txt.replace(/\{\{xh\}\}/g, "{{subst"+":xh}}");
  txt = txt.replace(/\{\{yi\}\}/g, "{{subst"+":yi}}");
  txt = txt.replace(/\{\{yo\}\}/g, "{{subst"+":yo}}");
  txt = txt.replace(/\{\{zh\}\}/g, "{{subst"+":zh}}");
  txt = txt.replace(/\{\{zu\}\}/g, "{{subst"+":zu}}");
  txt = txt.replace(/\{\{alb\}\}/g, "{{subst"+":alb}}");
  txt = txt.replace(/\{\{ang\}\}/g, "{{subst"+":ang}}");
  txt = txt.replace(/\{\{arm\}\}/g, "{{subst"+":arm}}");
  txt = txt.replace(/\{\{arn\}\}/g, "{{subst"+":arn}}");
  txt = txt.replace(/\{\{ast\}\}/g, "{{subst"+":ast}}");
  txt = txt.replace(/\{\{bns\}\}/g, "{{subst"+":bns}}");
  txt = txt.replace(/\{\{bos\}\}/g, "{{subst"+":bos}}");
  txt = txt.replace(/\{\{chr\}\}/g, "{{subst"+":chr}}");
  txt = txt.replace(/\{\{cic\}\}/g, "{{subst"+":cic}}");
  txt = txt.replace(/\{\{fur\}\}/g, "{{subst"+":fur}}");
  txt = txt.replace(/\{\{gmh\}\}/g, "{{subst"+":gmh}}");
  txt = txt.replace(/\{\{goh\}\}/g, "{{subst"+":goh}}");
  txt = txt.replace(/\{\{got\}\}/g, "{{subst"+":got}}");
  txt = txt.replace(/\{\{grc\}\}/g, "{{subst"+":grc}}");
  txt = txt.replace(/\{\{haw\}\}/g, "{{subst"+":haw}}");
  txt = txt.replace(/\{\{kky\}\}/g, "{{subst"+":kky}}");
  txt = txt.replace(/\{\{kld\}\}/g, "{{subst"+":kld}}");
  txt = txt.replace(/\{\{mdf\}\}/g, "{{subst"+":mdf}}");
  txt = txt.replace(/\{\{nap\}\}/g, "{{subst"+":nap}}");
  txt = txt.replace(/\{\{non\}\}/g, "{{subst"+":non}}");
  txt = txt.replace(/\{\{pap\}\}/g, "{{subst"+":pap}}");
  txt = txt.replace(/\{\{pms\}\}/g, "{{subst"+":pms}}");
  txt = txt.replace(/\{\{rap\}\}/g, "{{subst"+":rap}}");
  txt = txt.replace(/\{\{scn\}\}/g, "{{subst"+":scn}}");
  txt = txt.replace(/\{\{sco\}\}/g, "{{subst"+":sco}}");
  txt = txt.replace(/\{\{tlh\}\}/g, "{{subst"+":tlh}}");
  txt = txt.replace(/\{\{tyv\}\}/g, "{{subst"+":tyv}}");
  txt = txt.replace(/\{\{vec\}\}/g, "{{subst"+":vec}}");
  txt = txt.replace(/\{\{wen\}\}/g, "{{subst"+":wen}}");
// to me, these next few need to be reviewed quite closely!  Obviously, not ISO 639-3.
       txt = txt.replace(/\{\{it-bo\}\}/g, "{{subst"+":it-bo}}");
       txt = txt.replace(/\{\{it-br\}\}/g, "{{subst"+":it-br}}");
       txt = txt.replace(/\{\{it-ge\}\}/g, "{{subst"+":it-ge}}");
       txt = txt.replace(/\{\{it-mn\}\}/g, "{{subst"+":it-mn}}");
       txt = txt.replace(/\{\{it-mo\}\}/g, "{{subst"+":it-mo}}");
       txt = txt.replace(/\{\{it-pr\}\}/g, "{{subst"+":it-pr}}");
       txt = txt.replace(/\{\{el-it\}\}/g, "{{subst"+":el-it}}");
       txt = txt.replace(/\{\{pt-br\}\}/g, "{{subst"+":pt-br}}");
       txt = txt.replace(/\{\{pt-pt\}\}/g, "{{subst"+":pt-pt}}");
       txt = txt.replace(/\{\{zh-tc\}\}/g, "{{subst"+":zh-tc}}");
     txt = txt.replace(/\{\{nl-vla\}\}/g, "{{subst"+":nl-vla}}");
   txt = txt.replace(/\{\{nap-cal\}\}/g, "{{subst"+":nap-cal}}");
   txt = txt.replace(/\{\{eml-rom\}\}/g, "{{subst"+":eml-rom}}");
   txt = txt.replace(/\{\{gstr/g, "{{subst"+":gstr");
  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "{{subst:lang}}";
  }
}


// Get all the wikified common languages [[French]], [[Dutch]], [[German]] etc. de-wikified.
//From a list of langs, search for translation style and heading style and correct both
//italian,french,german,spanish,japanese,serbian,latin,swedish,dutch,finnish,russian,norwegian,bosnian, 
//esperanto,chinese,portuguese,irish,polish,slovak,czech,danish,greek,hebrew,turkish,welsh,
//hungarian,korean,arabic,romanian,indonesian,croatian,vietnamese,bulgarian,hindi,
//filipino,icelandic,albanian,sanskrit,slovene,thai,yiddish,   **TOP40**
//,tamil,urdu,balinese,afrikaans,kurdish,hawaiian,swahili,scots,fijian,zulu,cantonese,
function deWikify() {
  var oldtext = txt;
  txt = txt.replace(/\*\[\[Italian\]\]:/gi, "*Italian:");
  txt = txt.replace(/\*\[\[French\]\]:/gi, "*French:");
  txt = txt.replace(/\*\[\[German\]\]:/gi, "*German:");
  txt = txt.replace(/\*\[\[Spanish\]\]:/gi, "*Spanish:");
  txt = txt.replace(/\*\[\[Japanese\]\]:/gi, "*Japanese:");
  txt = txt.replace(/\*\[\[Serbian\]\]:/gi, "*Serbian:");
  txt = txt.replace(/\*\[\[Latin\]\]:/gi, "*Latin:");
  txt = txt.replace(/\*\[\[Swedish\]\]:/gi, "*Swedish:");
  txt = txt.replace(/\*\[\[Dutch\]\]:/gi, "*Dutch:");
  txt = txt.replace(/\*\[\[Finnish\]\]:/gi, "*Finnish:");
  txt = txt.replace(/\*\[\[Russian\]\]:/gi, "*Russian:");
  txt = txt.replace(/\*\[\[Norwegian\]\]:/gi, "*Norwegian:");
  txt = txt.replace(/\*\[\[Bosnian\]\]:/gi, "*Bosnian:");
//  txt = txt.replace(/\*\[\[Esperanto\]\]:/gi, "*Esperanto:");
  txt = txt.replace(/\*\[\[Chinese\]\]:/gi, "*Chinese:");
  txt = txt.replace(/\*\[\[Portuguese\]\]:/gi, "*Portuguese:");
//  txt = txt.replace(/\*\[\[Irish\]\]:/gi, "*Irish:");
  txt = txt.replace(/\*\[\[Polish\]\]:/gi, "*Polish:");
  txt = txt.replace(/\*\[\[Slovak\]\]:/gi, "*Slovak:");
  txt = txt.replace(/\*\[\[Czech\]\]:/gi, "*Czech:");
  txt = txt.replace(/\*\[\[Danish\]\]:/gi, "*Danish:");
  txt = txt.replace(/\*\[\[Greek\]\]:/gi, "*Greek:");
  txt = txt.replace(/\*\[\[Hebrew\]\]:/gi, "*Hebrew:");
  txt = txt.replace(/\*\[\[Turkish\]\]:/gi, "*Turkish:");
  txt = txt.replace(/\*\[\[Welsh\]\]:/gi, "*Welsh:");
  txt = txt.replace(/\*\[\[Hungarian\]\]:/gi, "*Hungarian:");
  txt = txt.replace(/\*\[\[Korean\]\]:/gi, "*Korean:");
  txt = txt.replace(/\*\[\[Arabic\]\]:/gi, "*Arabic:");
  txt = txt.replace(/\*\[\[Romanian\]\]:/gi, "*Romanian:");
  txt = txt.replace(/\*\[\[Indonesian\]\]:/gi, "*Indonesian:");
  txt = txt.replace(/\*\[\[Croatian\]\]:/gi, "*Croatian:");
  txt = txt.replace(/\*\[\[Vietnamese\]\]:/gi, "*Vietnamese:");
  txt = txt.replace(/\*\[\[Bulgarian\]\]:/gi, "*Bulgarian:");
  txt = txt.replace(/\*\[\[Hindi\]\]:/gi, "*Hindi:");
  txt = txt.replace(/\*\[\[Filipino\]\]:/gi, "*Filipino:");
  txt = txt.replace(/\*\[\[Icelandic\]\]:/gi, "*Icelandic:");
  txt = txt.replace(/\*\[\[Albanian\]\]:/gi, "*Albanian:");
  txt = txt.replace(/\*\[\[Sanskrit\]\]:/gi, "*Sanskrit:");
  txt = txt.replace(/\*\[\[Slovene\]\]:/gi, "*Slovene:");
  txt = txt.replace(/\*\[\[Thai\]\]:/gi, "*Thai:");
//  txt = txt.replace(/\*\[\[Yiddish\]\]:/gi, "*Yiddish:");
  //txt = txt.replace(/\*\[\[Tamil\]\]:/gi, "*Tamil:");
  //txt = txt.replace(/\*\[\[Urdu\]\]:/gi, "*Urdu:");
  //txt = txt.replace(/\*\[\[Balinese\]\]:/gi, "*Balinese:");
  //txt = txt.replace(/\*\[\[Afrikaans\]\]:/gi, "*Afrikaans:");
  //txt = txt.replace(/\*\[\[Kurdish\]\]:/gi, "*Kurdish:");
  //txt = txt.replace(/\*\[\[Hawaiian\]\]:/gi, "*Hawaiian:");
  //txt = txt.replace(/\*\[\[Swahili\]\]:/gi, "*Swahili:");
  //txt = txt.replace(/\*\[\[Scots\]\]:/gi, "*Scots:");
  //txt = txt.replace(/\*\[\[Fijian\]\]:/gi, "*Fijian:");
  //txt = txt.replace(/\*\[\[Zulu\]\]:/gi, "*Zulu:");
  //txt = txt.replace(/\*\[\[Cantonese\]\]:/gi, "*Cantonese:");
  txt = txt.replace(/==\[\[Italian\]\]==/gi, "==Italian==");
  txt = txt.replace(/==\[\[French\]\]==/gi, "==French==");
  txt = txt.replace(/==\[\[German\]\]==/gi, "==German==");
  txt = txt.replace(/==\[\[Spanish\]\]==/gi, "==Spanish==");
  txt = txt.replace(/==\[\[Japanese\]\]==/gi, "==Japanese==");
  txt = txt.replace(/==\[\[Serbian\]\]==/gi, "==Serbian==");
  txt = txt.replace(/==\[\[Latin\]\]==/gi, "==Latin==");
  txt = txt.replace(/==\[\[Swedish\]\]==/gi, "==Swedish==");
  txt = txt.replace(/==\[\[Dutch\]\]==/gi, "==Dutch==");
  txt = txt.replace(/==\[\[Finnish\]\]==/gi, "==Finnish==");
  txt = txt.replace(/==\[\[Russian\]\]==/gi, "==Russian==");
  txt = txt.replace(/==\[\[Norwegian\]\]==/gi, "==Norwegian==");
  txt = txt.replace(/==\[\[Bosnian\]\]==/gi, "==Bosnian==");
//  txt = txt.replace(/==\[\[Esperanto\]\]==/gi, "==Esperanto==");
  txt = txt.replace(/==\[\[Chinese\]\]==/gi, "==Chinese==");
  txt = txt.replace(/==\[\[Portuguese\]\]==/gi, "==Portuguese==");
//  txt = txt.replace(/==\[\[Irish\]\]==/gi, "==Irish==");
  txt = txt.replace(/==\[\[Polish\]\]==/gi, "==Polish==");
  txt = txt.replace(/==\[\[Slovak\]\]==/gi, "==Slovak==");
  txt = txt.replace(/==\[\[Czech\]\]==/gi, "==Czech==");
  txt = txt.replace(/==\[\[Danish\]\]==/gi, "==Danish==");
  txt = txt.replace(/==\[\[Greek\]\]==/gi, "==Greek==");
  txt = txt.replace(/==\[\[Hebrew\]\]==/gi, "==Hebrew==");
  txt = txt.replace(/==\[\[Turkish\]\]==/gi, "==Turkish==");
//  txt = txt.replace(/==\[\[Welsh\]\]==/gi, "==Welsh==");
  txt = txt.replace(/==\[\[Hungarian\]\]==/gi, "==Hungarian==");
  txt = txt.replace(/==\[\[Korean\]\]==/gi, "==Korean==");
  txt = txt.replace(/==\[\[Arabic\]\]==/gi, "==Arabic==");
  txt = txt.replace(/==\[\[Romanian\]\]==/gi, "==Romanian==");
  txt = txt.replace(/==\[\[Indonesian\]\]==/gi, "==Indonesian==");
  txt = txt.replace(/==\[\[Croatian\]\]==/gi, "==Croatian==");
  txt = txt.replace(/==\[\[Vietnamese\]\]==/gi, "==Vietnamese==");
  txt = txt.replace(/==\[\[Bulgarian\]\]==/gi, "==Bulgarian==");
  txt = txt.replace(/==\[\[Hindi\]\]==/gi, "==Hindi==");
  txt = txt.replace(/==\[\[Filipino\]\]==/gi, "==Filipino==");
  txt = txt.replace(/==\[\[Icelandic\]\]==/gi, "==Icelandic==");
  txt = txt.replace(/==\[\[Albanian\]\]==/gi, "==Albanian==");
  txt = txt.replace(/==\[\[Sanskrit\]\]==/gi, "==Sanskrit==");
  txt = txt.replace(/==\[\[Slovene\]\]==/gi, "==Slovene==");
  txt = txt.replace(/==\[\[Thai\]\]==/gi, "==Thai==");
//  txt = txt.replace(/==\[\[Yiddish\]\]==/gi, "==Yiddish==");
  //txt = txt.replace(/==\[\[Tamil\]\]==/gi, "==Tamil==");
  //txt = txt.replace(/==\[\[Urdu\]\]==/gi, "==Urdu==");
  //txt = txt.replace(/==\[\[Balinese\]\]==/gi, "==Balinese==");
  //txt = txt.replace(/==\[\[Afrikaans\]\]==/gi, "==Afrikaans==");
  //txt = txt.replace(/==\[\[Kurdish\]\]==/gi, "==Kurdish==");
  //txt = txt.replace(/==\[\[Hawaiian\]\]==/gi, "==Hawaiian==");
  //txt = txt.replace(/==\[\[Swahili\]\]==/gi, "==Swahili==");
  //txt = txt.replace(/==\[\[Scots\]\]==/gi, "==Scots==");
  //txt = txt.replace(/==\[\[Fijian\]\]==/gi, "==Fijian==");
  //txt = txt.replace(/==\[\[Zulu\]\]==/gi, "==Zulu==");
  //txt = txt.replace(/==\[\[Cantonese\]\]==/gi, "==Cantonese==");
  txt = txt.replace(/==\[\[w\:Koine Greek\|Koine Greek\]\]==/gi, "==Ancient Greek==");
  txt = txt.replace(/==\[\[w:Koine Greek\|Koine Greek\]\]==/gi, "==Ancient Greek==");
  txt = txt.replace(/==\[\[w\:Koine Greek|Koine Greek\]\]==/gi, "==Ancient Greek==");
  txt = txt.replace(/==\[\[w:Koine Greek|Koine Greek\]\]==/gi, "==Ancient Greek==");
  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "dewikify common langs";
  }
}


function notEnglishInflection() {
  var oldtext = txt;

//On lines following heading lines (===Noun===) that start with "#", ensure stem plus [c]
// or [u] or plural form are present, wikified properly.  If not, add "s" to end of 
//stem-word, pop up a warning saying that this may be pluralizing it wrong, and go.

//for now, quick and dirty replacement if missing entirely.  (Should the 'often' incorrect plural just be skipped?)
  txt = txt.replace(/===Noun===\n\#/g, "===Noun===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");
  txt = txt.replace(/===Proper noun===\n\#/g, "===Proper noun===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");

//On lines following "===Adjective===" that start with a "#", ensure {{compar}} and {{superl}} are there (even if they say "none".)  <--bogus.
  txt = txt.replace(/===Adjective===\n\#/g, "===Adjective===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");

//On lines following "===Adverb===" that start with a "#", ensure {{compar}} and {{superl}} are there (even if they say "none".) <-- bogus
  txt = txt.replace(/===Adverb===\n\#/g, "===Adverb===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");

//todo: rework this section once Polyglot has the template politics sorted out
//on lines following "===Verb===" that start with "'", ensure that past, participle and third person forms are mentioned, otherwise add a {{en-infl... template
  txt = txt.replace(/===Verb===\n\#/g, "===Verb===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");

  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "{{infl}}";
  }
}

function englishInflection() {
  var oldtext = txt;

//On lines following heading lines (===Noun===) that start with "#", ensure stem plus [c]
// or [u] or plural form are present, wikified properly.  If not, add "s" to end of 
//stem-word, pop up a warning saying that this may be pluralizing it wrong, and go.

//for now, quick and dirty replacement if missing entirely.  (Should the 'often' incorrect plural just be skipped?)
  txt = txt.replace(/===Noun===\n\#/g, "===Noun===\n'''{{subst" + ":PAGENAME}}'''\n{{en-noun-reg}}\n{{en-noun-reg-y|{{subst" + ":PAGENAME}}|y}}{{en-noun-reg-es}}\n{{en-noun-irreg|{{subst" + ":PAGENAME}}}}\n\n\#");
  txt = txt.replace(/===Proper noun===\n\#/g, "===Proper noun===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");

//On lines following "===Adjective===" that start with a "#", ensure {{compar}} and {{superl}} are there (even if they say "none".)  <--bogus.
//  txt = txt.replace(/===Adjective===\n\#/g, "===Adjective===\n\<\!--Pick one or more of the following:-->\n'''{{subst" + ":PAGENAME}}'''\n'''{{subst" + ":PAGENAME}}'''  (''no'' {{compar}} ''or'' {{superl}})\n'''{{subst" + ":PAGENAME}}'''  ({{compar}}: '''more {{subst" + ":PAGENAME}}''', {{superl}}: '''most {{subst" + ":PAGENAME}}''')\n'''{{subst" + ":PAGENAME}}'''\n\n\#");
  txt = txt.replace(/===Adjective===\n\#/g, "===Adjective===\n\<\!--Pick one or more of the following:-->\n'''{{subst" + ":PAGENAME}}'''\n'''{{subst" + ":PAGENAME}}'''  (''no'' {{compar}} ''or'' {{superl}})\n'''{{subst" + ":PAGENAME}}'''  ({{compar}}: '''more {{subst" + ":PAGENAME}}''', {{superl}}: '''most {{subst" + ":PAGENAME}}''')\n'''{{subst" + ":PAGENAME}}'''  ({{compar}}: '''[[{{subst" + ":PAGENAME}}er]]''', {{superl}}: '''[[{{subst" + ":PAGENAME}}est]]''')\n\n\#");

//On lines following "===Adverb===" that start with a "#", ensure {{compar}} and {{superl}} are there (even if they say "none".) <-- bogus
  txt = txt.replace(/===Adverb===\n\#/g, "===Adverb===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");
//  txt = txt.replace(/===Adverb===\n\#/g, "===Adverb===\n'''{{subst" + ":PAGENAME}}'''  ({{compar}}: '''[[{{subst" + ":PAGENAME}}er]]''', {{superl}}: '''[[{{subst" + ":PAGENAME}}est]]''')\n\n\#");

//todo: rework this section once Polyglot has the template politics sorted out
//on lines following "===Verb===" that start with "'", ensure that past, participle and third person forms are mentioned, otherwise add a {{en-infl... template
  txt = txt.replace(/Verb===\n\#/gi, "Verb===\n{{en-infl-reg-consonant-y|{{subst" + ":PAGENAME}}||}}\n{{en-infl-reg-consonant|{{subst" + ":PAGENAME}}||}}\n{{en-infl-reg-sibilant|{{subst" + ":PAGENAME}}||}}\n{{en-infl-reg-other-e|{{subst" + ":PAGENAME}}|e}}\n{{en-infl-reg-ie|{{subst" + ":PAGENAME}}|e}}\n{{en-infl-reg-vowel-e|{{subst" + ":PAGENAME}}|e}}\n\n\#");

  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "{{infl}} (en)";
  }
}


//Inflection lines: TODO separate code for entries that have ==English==.
//this gets about 80% right.  Perfectly acceptable to have many languages, but for 
//horribly formatted entries, there is usually only one language.  Entries with 
//multiple languages tend to be pretty clean, comparatively.  This code needs to be 
//rewritten when I figure out the Russian technique of selecting text-sections.  (Or
//rather, how to implement that here.)
function inflLine() {

  //momentarily remove extra blank lines
  txt = txt.replace(/verb===\n\n/gi, "Verb===\n");
  txt = txt.replace(/===noun===\n\n/gi, "===Noun===\n");
  txt = txt.replace(/===proper noun===\n\n/gi, "===Proper noun===\n");
  txt = txt.replace(/===adjective===\n\n/gi, "===Adjective===\n");
  txt = txt.replace(/===adverb===\n\n/gi, "===Adverb===\n");

  if (txt.search(/==English==\n/) == -1) {
     notEnglishInflection();
  } else {
     englishInflection();
  }
  //todo then do the ones that are common to both...Proper noun...Phrase...etc.
}


//Next, on lines that start with "#" (therefore definitions) skip the {{qualifiers}}, (qualifiers) and
// punctuation: then capitalize first letter of first sentence, pipe-syntax-wikified if needed.  Ensure
// period is at end of line (except quotes and parens, of course.)

//todo: make sure templates that are not in all upper-case start with a lower case character

//todo: flag or just replace "===Transitive verb===" with "===Verb==="  <-- WS:BP first

//todo: count heading level.  If heading level is four, and last heading level was 2, warn or fix or something.  (Note: if level is 2, and last level was 2, 3, 4, or 5, it is still ok)

//todo: If English not first heading, and there is no 2nd level header, add "==English=="

//todo: If English appears elsewhere, and another language is in front, swap sections (Separate w/ "----".)

//todo: Remove "----" except once between English and all other language.

//todo: move all category links to bottom

//todo: move all interwiki links even more bottomer.

//todo: "subst:" all etymology Webster templates ending in a period.  Discuss on WS:BP first.

//todo: Alphabetize Part Of Speech sections


//prep tables for balancing...
function transTable() {
  var oldtext = txt;
  txt = txt.replace(/\<\!--left column--\>\n/gi, "");
  txt = txt.replace(/\<\!--right column--\>\n/gi, "");
  txt = txt.replace(/\<\!--languages from A to I go here--\>\n/gi, "");
  txt = txt.replace(/\<\!--Put translations for languages from A to I here--\>\n/gi, "");
  txt = txt.replace(/\<\!--languages from A to M go here--\>\n/gi, "");
  txt = txt.replace(/\<\!--languages from N to Z go here--\>\n/gi, "");
  txt = txt.replace(/\<\!--languages from J to Z go here--\>\n/gi, "");
  txt = txt.replace(/\<\!--Put translations for languages from J to Z here--\>\n/gi, "");
  txt = txt.replace(/\{\| border=0  width=100\%\n\|-\n\|bgcolor=\"\#FFFFE0\" valign=top width=48\%\|\n\{\|/gi, "{{top}}");
  txt = txt.replace(/\{\| border=0 width=100\%\n\|-\n\|bgcolor=\"\#FFFFE0\" valign=top width=48\%\|\n\{\|/gi, "{{top}}");
  txt = txt.replace(/\|\}\n\| width=1\% \|\n\|bgcolor=\"\#FFFFE0\" valign=top width=48\%\|\n\{\|/gi, "{{mid}}");
  txt = txt.replace(/\|\}\n\|\}/gi, "{{bottom}}");

//rewrite the tables auto-balancing code here...
//Note that it will need the Russian's area-selection logic applied to it
/* 
pg	;balance columns for a "Names" page (all in 4 columns)
	w !,"Paste text of entire page with sections to be balanced:",!
	k x,y
	r y(1) f k=2:1 r !,y(k):5 q:'$t
	w #,!!!,y(1)
	f m=2:1:k d
	.i y(m)'?1"==".e w !,y(m) q
	.w !,y(m) s x(1)=y(m)
	.f l=2:0 q:'$d(y(m+1))  q:y(m+1)?1"==".e  q:y(m+1)?1"{{".e1"index-".e  d
	..s m=m+1
	..s x(l)=y(m)
	..s l=l+1
	.s i=l-1 d mid4 w !
	q
top4	;balance columns
	w !,"Paste text of section to be balanced:",!
	r x(1)
	f i=2:1 r !,x(i):5 q:'$t
	w #,!!!,x(1)
mid4	s cnt=0,i=i-1,c=0
	f j=2:1:i i x(j)?1"{".e k x(j)
	f j=2:1:i i $g(x(j))?1"|".e k x(j)
	f j=2:1:i i $tr($g(x(j))," ","")="" k x(j)
	f j=2:1:i i $g(x(j))?1"''Section".e w !,x(j) k x(j)
	f j=2:1:i i $d(x(j)) s cnt=cnt+1
	i x(1)["Translation" d  q
	.w !,"{{top}}"
	.f j=2:1:i i $d(x(j)) s c=c+1 w:c=cnt\2 !,"{{mid}}" w !,x(j)
	.w !,"{{bottom}}"
	q:cnt<1
	w !,"{{top4}}" s tcnt=cnt,cnt=$s(cnt#4:1,1:0)+(cnt\4),md=0
	f j=2:1:i i $d(x(j)) s c=c+1 d:c>cnt  w !,x(j)
	.w !,"{{mid4}}" s c=1 s md=md+1
	.i j=4,tcnt=5 s cnt=cnt-1
	.i j=4,tcnt=6 s cnt=cnt-1
	.i j=7,tcnt=9 s cnt=cnt-1
	i md<3 w:md<1 !,"{{mid4}}" w:md<2 !,"{{mid4}}" w !,"{{mid4}}"
	w !,"{{bottom}}"
	q
*/
  if (txt != oldtext) {
    if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    document.editform.wpSummary.value += "{{top/mid/bot}}";
  }
}


function superAutoFormat() {
  // get page title
  pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue;
  if (pagetitle.search(/Editing /) == -1) return;
  pagetitle = pagetitle.replace(/Editing /g, "");
  pageexternal = pagetitle.replace(/\ /g, "_");

  // is this in the main namespace?  If not, stop.
  if (pagetitle.search(/\:/) != -1) return;

  txt = " " + document.editform.wpTextbox1.value;
  txt = txt.substr (1, txt.length-1);
  var oldtxt = txt;
  if (txt.length < 2) txt = " " + txt;

// change me, if not exiting properly {{PAGENAME}} / {{PAGENAMEE}}

  txt = txt.replace(/\{\{PAGENAMEE\}\}/g, pageexternal);
  txt = txt.replace(/\{\{PAGENAME\}\}/g, pagetitle);
  txt = txt.replace(/\{\{subst:PAGENAME\}\}/g, pagetitle);

    minorFormat(); //minor format problems that must be dealt with first
  //  genderFmt();   //format gender from italics to template
    langHdrs();    //spap 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
    deWikify();    //de-wikify all "common" languages
      //todo: limit formatting of inflections and such to ==English== section only?
      inflLine();    //add an "inflection" line if missing
    transTable();  //reformat translations tables, balance columns (todo)

  txt = txt.replace(/\{\{PAGENAMEE\}\}/g, pageexternal);
  txt = txt.replace(/\{\{PAGENAME\}\}/g, pagetitle);
  txt = txt.replace(/\{\{subst:PAGENAME\}\}/g, pagetitle);

 if (txt == " ") txt = "";

 document.editform.wpTextbox1.value = txt;

 //document.editform.wpSummary.value = document.forms.length;

  if (txt != oldtxt) {
    //comments now added for specific sections only. 
    if (document.editform.wpSummary.value == "") document.editform.wpSummary.value = "fmt";
    //if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";
    //document.editform.wpSummary.value += "+format";
    document.editform.wpDiff.click();
  }
}

function punishWikiServers() {
  /* No, this is not a crazy mass attack.  OK, I should rename the function,
  but you get the idea...every 5 seconds load a new window in edit mode, and 
  let the other portions of this javascript do the dirtywork to the given page.
  So, when I load one of my three special cleanup pages...my generated "todo" list,
  this section of code will start opening new windows like a porn site gone mad.
  The auto-formatting of those pages is not perfect (especially considering that
  these are "cleanup" lists) so I'll have to come back and ALT-S them each after 
  the show changes, anyway.  

  I actually think this will be nicer to the servers.  They seem to choke when I try 
  to manually open 20 pages.  At least this way, there'll be *some* delay between 
  each new page open. */
  
  var i,x,h,url,z
  document.editform.wpSummary.value  = "";
  for (i=0; i<160; i++) {
    h = document.links[i] ; //.getAttribute(%22href%22);
    url = h.toString();
    if (url.search(/action=edit/) != -1)  {
      z = window.open(url);
      //sleep(5000); //milliseconds, right?
    }
  }  
}


function reformatMyPage() {
  addToNav() ;
  //fixCreationLinks() ;
  superAutoFormat() ;
  //if (pagetitle.search("MacKenzie\/todo") != -1) {
    //punishWikiServers();
  //}

  //Let this happen on MediaWiki:Nogomatch instead.  
  //nogomatchHideInputBoxen();  
}

 
var hack = 'failed';
var hack_pagetitle ='';
 
if (window.addEventListener) window.addEventListener("load",reformatMyPage,false);
else if (window.attachEvent) window.attachEvent("onload",reformatMyPage);

//Remember to start by opening Tools, Web Development, JavaScript Console...

/*
</pre>
*/

//Remember to start by opening Tools, Web Development, JavaScript Console...

// [[User:Lupin/popups.js]]

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');