User:So9q/newentrywiz.js

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.

// Forked from https://en.wiktionary.org/w/index.php?title=User:Yair_rand/newentrywiz.js&oldid=54099266
// by So9q 19/9-2019
// 
// Comments from Yair_rand:
// todo: clean, jQuerize, use langmetadata, let users extend this
/* jshint sub:true, shadow:true, undef:true, unused:true, strict:true, forin:true, latedef:true */
/* global jQuery */
// <nowiki>

// Support prefilling via GET
/**
 * JavaScript Get URL Parameter
 * 
 * @param String prop The specific URL parameter you want to retreive the value for
 * @return String|Object If prop is provided a string value is returned, otherwise an object of all properties is returned
 */
function getUrlParams( prop ) {
    var params = {};
    var search = decodeURIComponent( window.location.href.slice( window.location.href.indexOf( '?' ) + 1 ) );
    var definitions = search.split( '&' );

    definitions.forEach( function( val, key ) {
        var parts = val.split( '=', 2 );
        params[ parts[ 0 ] ] = parts[ 1 ];
    } );

    return ( prop && prop in params ) ? params[ prop ] : params;
}i

// Initialize variables
if (getUrlParams('ct') == 'true') {
	const capitalize = (s) => {
		if (typeof s !== 'string') return ''
		return s.charAt(0).toUpperCase() + s.slice(1)
	}
	var pos = getUrlParams('pos');
	var pos_cap = capitalize(pos);
	var necdata = {
		pos: pos,
		pos2: pos_cap
	};
	var def = '[[' + getUrlParams('def') + ']]';
	var necdefs = [
		[def, [],
			[]
		]
	];
	var neccode = getUrlParams('lang');
}
else {
	var necdata = {
		pos: "noun",
		pos2: "Noun"
	};
	var necdefs = [
		['', [],
			[]
		]
	];
	var neccode = 'da';
}

// Initialize the rest
var necpost = [];

for (var i = 5; i <= 19; ++i) {
	necpost[i] = [];
}
var necpostlangtext = [];
var title = mw.config.get('wgTitle');

/*

Notes:
necfunction fills in the edit box
create-id creates the main menu stuff inside the span id'd so9q-nec
call-infl goes to infl (don't remember what this was for)
infl creates the inflections options by filling in necinfls
input-box-fix does some extra junk for the infl options input boxes
necdefupdate makes the definitions/example sentence options
necpostbox makes the extra junk ("More details") work (i think)

More recent note: I knew next to nothing about javascript when I originally wrote this, so the code is an utter mess. 
It's also probably never going to be fixed up because really, I'd rather work on making WT:EDIT stuff the primary easy-editing method instead of tools like this.

The necinfls object works like this:
Each language is its own object, containing an object for each pos, which contains the information for that pos.
The first part is the stuff that comes at the beginning of the template, the second is the stuff at the end, the third onward are the available parameters of the template and what stuff they produce.
Each template parameter is an array, which contains the word that shows up at the beginning of the section, then a blank value, and then subarrays of each option.
Each subarray contains the text that shows up in the editor, followed by the text that shows up in the textbox (the wikimarkup). Some onclick javascript can be added to an option as the third parameter in the array.
If the option is an input box, the first parameter should be "input", followed by the editor text (DON'T leave this blank or the whole thing will blow up), followed by the pre-inputbox-value wikimarkup, followed by post-inputbox-value wikimarkup, followed by any extra js. 

Does this make any sense to anyone? :)

Things to do:
1 Get quotations to work right
2 Fix up pronunciation section
3 Add little help thingies
4 Inflection tables
5 Get the example sentence auto-bolding to not stink
6 Build add-section stuff

There are little href=javascript: things littered all over the place because I don't know any other way to make things look like unvisited links without having to actually put anything in the href.

eh, sploot

*/


var necetym;
var necpron;
var necheadingorder = ['Usage notes', 'Inflection', 'Conjugation', 'Declension', 'Quotations', 'Synonyms', 'Antonyms', 'Hypernyms', 'Hyponyms', 'Meronyms', 'Holonyms', 'Derived terms', 'Related terms', 'Coordinate terms', 'Descendants', 'Translations', 'See also', 'External links', 'Categories', 'Images'];
var necinputadvanced = "";
var necposlist = ['Noun', 'Verb', 'Adjective', 'Adverb', 'Pronoun', 'Conjunction', 'Interjection', 'Preposition', 'Proper noun', 'Article', 'Prepositional phrase', 'Contraction', 'Prefix', 'Suffix', 'Symbol', 'Letter', 'Idiom', 'Phrase'];


function create_id() {
	/* CREATE OPTIONS */
	var x = "Language code: <input type=text value='da' id='necinput' onKeyUp='neccode=this.value;fill_in();call_infl();fill_in()' onblur=if (necCleanLangCode(this.value)){this.value=necCleanLangCode(this.value)};neccode=this.value;document.getElementById('nectransspan').style.display=((this.value=='en')?'':'none');if (/^[a-z]{2,3}(-[a-z\-]{1,7})?$/.test(this.value)){document.getElementById('neclangerror').style.display='none'}else{document.getElementById('neclangerror').style.display=''};fill_in();call_infl();fill_in();necdefupdate() title='The two or three letter ISO-639 language code'></input><span id=neclangerror style=display:none;color:red> ERROR: INVALID LANGUAGE CODE</span><br>Part of speech: ";

	for (var i = 0; i < 4; ++i) {
		x += "<a id='necinputpos" + necposlist[i] + "' href=javascript: onclick=document.getElementById('necinputpos'+necdata['pos2']).style.fontWeight='';necdata['pos2']='" + necposlist[i] + "';necdata['pos']='" + necposlist[i].toLowerCase() + "';this.style.fontWeight='bold';call_infl();fill_in()";

		if (!i) {
			x += " style='font-weight:bold'";
		}

		x += ">" + necposlist[i] + "</a>, ";
	}

	x += "<span id='necinputpos'>Other: <input type=text onKeyUp=\"document.getElementById('necinputpos'+necdata['pos2']).style.fontWeight='';necdata['pos2']=this.value;necdata['pos']=this.value.toLowerCase().replace(/ /g,'');this.parentNode.setAttribute('ID','necinputpos'+this.value);document.getElementById('necinputpos'+necdata['pos2']).style.fontWeight='bold';fill_in();call_infl()\" /><select onchange=\"document.getElementById('necinputpos'+necdata['pos2']).style.fontWeight='';necdata['pos2']=this.value;necdata['pos']=this.value.toLowerCase().replace(/ /g,'');this.parentNode.setAttribute('ID','necinputpos'+this.value);document.getElementById('necinputpos'+necdata['pos2']).style.fontWeight='bold';fill_in();call_infl()\"><option value=''>Select</option>";

	for (var i = 0; i < necposlist.length; ++i) {
		if (i > 3) {
			x += "<option>" + necposlist[i] + "</option>";
		}
	}

	x += "</select></span><span id=necinfls></span><br>More details: <a id=necquotbutton href=javascript: onclick=necpostbox(0);fill_in();this.style.fontWeight='bold' title='Add Usage Notes section'>Usage notes</a>, <a href=javascript: id=necSynonymsbutton onclick=necpost[5][necpost[5].length]=['',''];necpostbox();fill_in();this.style.fontWeight='bold' title='Add Synonyms section'>Synonyms</a>, <span id=nectransspan><a href=javascript: id=nectransbutton onclick=necpost[15].push('');necpostbox();fill_in();this.style.fontWeight='bold' title='Add Translations section'>Translations</a>, </span>More: <select onchange=necpostbox(this.value);this.selectedIndex=0;fill_in()><option select='selected'>Select</option>";

	for (var i = 0; i < necheadingorder.length; ++i) {
		if (i != 0 && i != 5 && i != 15) {
			x += "<option value=" + i + ">" + necheadingorder[i] + "</option>";
		}
	}

	x += "</select><br><span id=necpostbox></span><span id='necdefs'>Definition: <input type=text id='necinput3' onKeyUp=necdefs[0][0]=this.value;fill_in() /><br></span>Further information: <a href=javascript:necdefs.push(['',[],[]]);necdefupdate();fill_in() title='Add new definition'>Another definition</a>,  <a href=javascript: id=necetymbutton onclick=document.getElementById('necetymspan').style.display='';necetym=document.getElementById('necetyminput').value;fill_in();this.style.fontWeight='bold' title='Add etymology section'>Etymology</a>, <a href=javascript: id=necpronbutton onclick=document.getElementById('necpronspan').style.display='';necpron=document.getElementById('necproninput').value;fill_in();this.style.fontWeight='bold' title='Add pronunciation section'>Pronunciation</a>. <span id='necetymspan' style='display:none'><br>Etymology: <a href=javascript: onclick=necetym=undefined;document.getElementById('necetymspan').style.display='none';fill_in();document.getElementById('necetymbutton').style.fontWeight='' title='Delete etymology section'>(delete)</a><br><textarea id=necetyminput onKeyUp=necetym=this.value;fill_in()></textarea></span><span id=necpronspan style='display:none'><br>Pronunciation: <a href=javascript: onclick=necpron=undefined;document.getElementById('necpronspan').style.display='none';fill_in();document.getElementById('necpronbutton').style.fontWeight='' title='Delete pronunciation section'>(delete)</a><br><textarea id=necproninput onKeyUp=necpron=this.value;fill_in()></textarea></span><div style='float:right;'><a href=/w/index.php?title=User_talk:Yair_rand/newentrywiz.js&action=edit&section=new title='Give feedback'>Give feedback</a></div>";

	document.getElementById("editform").insertBefore(document.getElementById("so9q-nec"), document.getElementById("editform").firstChild);
	document.getElementById("so9q-nec").innerHTML = x;

	if (document.URL.match("&section=new")) {
		document.getElementById("wpSummaryLabel").parentNode.removeChild(document.getElementById("wpSummaryLabel"));
		document.getElementById("wpSummary").parentNode.removeChild(document.getElementById("wpSummary"));
	}
}


// Fill in the edit box.
function fill_in() {
	var k = "";

	if (document.URL.match("&section=new")) {
		k += "----\n{{rfc-auto}}\n";
	} else {
		var neceditsummary = "([[User:So9q/newentrywiz.js|So9qs NEC]]) +" + neccode + ":" + necdata['pos'] + ": "; //edit summary

		for (var i = 0; i < necdefs.length; ++i) {
			neceditsummary += ((i != 0) ? ', ' : '') + necdefs[i][0];
		}

		document.getElementById("wpSummary").value = neceditsummary;
	}

	k += "=={{subst:#invoke:languages/templates|getByCode|" + document.getElementById('necinput').value + "|getCanonicalName}}==";

	for (var i = 0; i < necpost[19].length; ++i) {
		k += "\n[[Image:" + necpost[19][i][0] + "|thumb|" + necpost[19][i][1] + "]]";
	}

	k += "\n\n";

	if (necetym != undefined) {
		k += "===Etymology===\n" + necetym + "\n\n";
	}

	if (necpron != undefined) {
		k += "===Pronunciation===\n" + necpron + "\n\n";
	}

	k += "===" + necdata['pos2'] + "===\n";

	if (!neccode) {
		neccode = '';
	}

	if (neccode != '' && necinfls[neccode] && necinfls[neccode][necdata['pos']] && necinfls[neccode][necdata['pos']][2]) {
		if (necdata[neccode + "-" + necdata['pos'] + "2"] != "Advanced") {
			if (necinfls[neccode][necdata['pos']][0] != undefined) {
				k += necinfls[neccode][necdata['pos']][0];
			}

			var x = necinfls[neccode][necdata['pos']];

			for (var z = 0; z < x.length; ++z) {
				if (z <= 1) {
					continue;
				}

				var zz = neccode + "-" + necdata['pos'] + z;

				for (var y = 0; y < x[z][2].length; ++y) // search for inflections
				{
					if (x[z][2][y][0] != "input" && necdata[zz] == x[z][2][y][0]) // is selected option, not input box
					{
						k += x[z][2][y][1];
						break;
					}

					if (x[z][2][y][0] == "input" && necfunction7(x[z][2], necdata[zz]) == false) {
						k += x[z][2][y][2] + necdata[zz];
					}
				}
			}

			if (necinfls[neccode][necdata['pos']][1] != undefined) {
				k += necinfls[neccode][necdata['pos']][1];
			}
		} else {
			k += necinputadvanced;
		}
	} else {
		if (necinputadvanced) {
			k += necinputadvanced;
		} else {
			// use inflection object data if it exist
			if (neccode != '' && necinfls[neccode] && necinfls[neccode][necdata['pos']]) {
				k += necinfls[neccode][necdata['pos']][0];

				k += necinfls[neccode][necdata['pos']][1];
			} else {
				// generic
				k += '{{head|' + neccode + '|' + necdata['pos2'].toLowerCase();

				k += '}}';
			}
		}
	}

	k += "\n";

	// Definitions handling
	for (var i = 0; i < necdefs.length; ++i) {
		k += "\n# " + necdefs[i][0];
		
		// Example sentences
		for (var l = 0; l < necdefs[i][1].length; ++l) {
			k += "\n#:''" + necdefs[i][1][l][0].replace(new RegExp("(" + title + ")", "ig"), "'''$1'''") + "''";

			if (neccode != "en" && necdefs[i][1][l][1] && (new LangMetadata()).guessScript(neccode) != 'Latn') {
				k += "\n#::''" + necdefs[i][1][l][1] + "''";
			}

			if (neccode != "en") {
				k += "\n#::''" + necdefs[i][1][l][2] + "''";
			}
		}

		// Quotations handling
		for (var l = 0; l < necdefs[i][2].length; ++l) {
			k += "\n#*'''" + necdefs[i][2][l][0] + "''', " + necdefs[i][2][l][1] + ", ''" + necdefs[i][2][l][2] + "''";

			if (necdefs[i][2][l][3]) {
				k += ", " + necdefs[i][2][l][3];
			}

			if (necdefs[i][2][l][4]) {
				k += ", page";

				if (necdefs[i][2][l][4].match(/(-|–)/)) {
					k += "s";
				}

				k += " " + necdefs[i][2][l][4];
			}

			k += "\n#*:";
			k += necdefs[i][2][l][5].replace(new RegExp("(" + title + ")", "ig"), "'''$1'''");

			if (neccode != "en") {
				k += "\n#*::" + necdefs[i][2][l][6];
			}
		}
	}

	/* SUBHEADERS */
	for (var o = 0; o <= 3; ++o) {
		if (necpost[o] != undefined) {
			k += "\n\n====" + necheadingorder[o] + "====\n" + necpost[o];
		}
	}

	if (necpost[4] != undefined) {
		k += "\n\n====Quotations====\n" + necpost[4];
	}

	for (var o = 5; o <= 17; ++o) {
		if (necpost[o][0] != undefined) {
			k += "\n\n====" + necheadingorder[o] + "===="
		}

		if (o < 11 || o == 13) {
			for (var i = 0; i < necpost[o].length; ++i) {
				k += "\n* {{sense|" + necpost[o][i][0] + "}} ";

				for (var u = 0; u < necpost[o][i].length; ++u) {
					if (u != 0) {
						if (u != 1) {
							k += ", ";
						}

						k += "{{l|" + neccode + "|" + necpost[o][i][u] + "}}";
					}
				}
			}
		} else if (o == 14) {
			for (var i = 0; i < necpost[o].length; ++i) {
				k += "\n* {{subst:#invoke:languages/templates|getByCode|" + necpost[o][i][0] + "|getCanonicalName}}: {{l|" + necpost[o][i][0];
				k += "|" + necpost[o][i][1] + "}}";
			}
		} else if (o == 15) {
			for (var i = 0; i < necpost[15].length; ++i) {
				k += "\n{{trans-top|" + necpost[15][i] + "}}\n{{trans-mid}}\n{{trans-bottom}}";
			}
		} else if (o == 16 || o == 17) {
			for (var i = 0; i < necpost[o].length; ++i) {
				k += "\n* " + necpost[o][i];
			}
		} else {
			for (var i = 0; i < necpost[o].length; ++i) {
				k += "\n* {{l|" + neccode + "|" + necpost[o][i] + "}}";
			}
		}
	}

	for (var i = 0; i < necpost[18].length; ++i) {
		k += "\n[[Category:" + necpost[18][i] + "]]";
	}

	$(document.editform.wpTextbox1).val(k);
}

function call_infl() {
	if (!neccode) {
		neccode = '';
	}

	if (neccode && necinfls[neccode] && necinfls[neccode][necdata['pos']] != undefined && necinfls[neccode][necdata['pos']][2] != undefined) {
		infl(necinfls[neccode][necdata['pos']]);
	} else {
		var qq = neccode + "-" + necdata['pos'] + '2';
		var xx = "<span class=msgfornonnewbies ";

		if (necinputadvanced) {
			xx += "style='font-weight:bold' ";
		}

		xx += "><br>Wikicode: <input type=text value='" + necinputadvanced + "' onKeyUp=\"necinputadvanced=this.value;if (this.value){this.parentNode.style.fontWeight='bold'}else{this.parentNode.style.fontWeight=''};fill_in()\" /></span>";
		document.getElementById("necinfls").innerHTML = xx;
		fill_in();
	}
}


function infl(a) {
	/* INFLECTION OPTIONS */

	var q = "";
	for (var r = 0; r < a.length; ++r) {
		if (r <= 1) {
			continue;
		}
		var qq = neccode + "-" + necdata['pos'] + r;
		if (necdata[qq] == undefined) {
			if (a[r][2][0][0] == 'input') {
				necdata[qq] = ''
			} else {
				necdata[qq] = a[r][2][0][0]
			}
		}
		q += "<br>" + a[r][0] + ": ";

		for (var i = 0; i < a[r][2].length; ++i) {
			if (a[r][2][i][0] != 'input') {
				q += "<a href=javascript: id='necinput" + qq + a[r][2][i][0] + "' onclick=\"";
				if (a[r][2][i][2]) {
					q += a[r][2][i][2] + ";"
				}
				q += "necdata[\'" + qq + "\']=\'" + a[r][2][i][0] + "\';call_infl();fill_in()\">" + a[r][2][i][0] + "</a>";
				if (i != a[r][2].length - 1) {
					q += ", "
				}
			} else {
				q += "<span id='necinput" + qq;
				if (necdata[qq] != "Advanced" && necfunction7(a[r][2], necdata[qq]) == false) {
					q += necdata[qq]
				}
				q += "'>" + a[r][2][i][1] + "<input type=text value='' id='";
				q += neccode + "-" + necdata['pos'] + "-" + r + "-" + i;
				q += "' onKeyUp=";
				if (a[r][2][i][4]) {
					q += a[r][2][i][4] + ";"
				}

				q += "input_box_fix('" + qq + "','" + neccode + "-" + necdata['pos'] + "-" + r + "-" + i + "');";

				q += "fill_in() /></span>";
				if (i != a[r][2].length - 1) {
					q += ", "
				}
			}
		}


		/* ADVANCED OPTIONS */
		if (r == 2) {
			q += "<span id='necinput" + qq + "Advanced' class=msgfornonnewbies><span style=font-weight:normal>, </span>Wikicode: <input type=text value='" + necinputadvanced + "' onKeyUp=necinputadvanced=this.value;document.getElementById('necinput" + qq + "'+necdata['" + qq + "']).style.fontWeight='';necdata['" + qq + "']='Advanced';document.getElementById('necinput" + qq + "'+necdata['" + qq + "']).style.fontWeight='bold';fill_in() /></span>";
		}
	}

	document.getElementById("necinfls").innerHTML = q;


	for (var r = 0; r < a.length; ++r) {
		if (r <= 1) {
			continue;
		}

		var qq = neccode + "-" + necdata['pos'] + r;
		document.getElementById('necinput' + qq + necdata[qq]).style.fontWeight = 'bold';

		if (document.getElementById('necinput' + qq + necdata[qq]).childNodes[1] && necdata[qq] != 'Advanced' && necfunction7(a[r][2], necdata[qq]) == false) {
			document.getElementById('necinput' + qq + necdata[qq]).childNodes[1].value = necdata[qq];
		}
	}
}


function necdefupdate() {
	/* DEFINITIONS */
	var def = "";
	for (var i = 0; i < necdefs.length; ++i) {
		def += "Definition: <input size=50 type=text value='" + necdefs[i][0] + "' onKeyUp=necdefs[" + i + "][0]=this.value;fill_in() />";
		if (i > 0) {
			def += "<a href=javascript:necdefs.splice(" + i + ",1);necdefupdate();fill_in() title='Delete this definition'>(–)</a>";
		}
		def += "<a href=javascript:necdefs[" + i + "][1].push(['','','']);necdefupdate();fill_in() title='Add example sentence'>(+example sentence)</a><a href=javascript:necdefs[" + i + "][2].push(['','','','','','','']);necdefupdate();fill_in() title='Add quotation'>(+quotation)</a>";
		for (var l = 0; l < necdefs[i][1].length; ++l) // Example sentences
		{
			def += "<br><span style='padding-left:30px;'>Example sentence: </span><input type=text size=40 value='" + necdefs[i][1][l][0] + "' onKeyUp=necdefs[" + i + "][1][" + l + "][0]=this.value;fill_in() /><a href=javascript:necdefs[" + i + "][1].splice(" + l + ",1);necdefupdate();fill_in() title='Delete this example sentence'>(–)</a>";
			if (neccode != "en") {
				if ((new LangMetadata()).guessScript(neccode) != 'Latn') {
					def += "<br><span style='padding-left:60px;'>Transliteration: </span><input type=text size=40 value='" + necdefs[i][1][l][1] + "' onKeyUp=necdefs[" + i + "][1][" + l + "][1]=this.value;fill_in() />";
				}
				def += "<br><span style='padding-left:60px;'>Translation: </span><input type=text size=40 value='" + necdefs[i][1][l][2] + "' onKeyUp=necdefs[" + i + "][1][" + l + "][2]=this.value;fill_in() />";
			}
		}
		for (var l = 0; l < necdefs[i][2].length; ++l) // Quotations
		{
			var x = ['Year', 'Author', 'Source title', 'Publisher', 'Page(s)'];
			var z = [4, 20, 20, 20, 5]; //sizes
			def += "<br><span style='padding-left:30px;'>";
			for (var y = 0; y < x.length; ++y) {
				def += x[y] + ": <input type=text size=" + z[y] + " value='" + necdefs[i][2][l][y] + "' onKeyUp=necdefs[" + i + "][2][" + l + "][" + y + "]=this.value;fill_in() /> "
			}
			def += "</span><br><span style='padding-left:30px;'>Quotation: <input type=text size=40 value='" + necdefs[i][2][l][5] + "' onKeyUp=necdefs[" + i + "][2][" + l + "][5]=this.value;fill_in() /><a href=javascript:necdefs[" + i + "][2].splice(" + l + ",1);necdefupdate();fill_in() title='Delete this quotation'>(–)</a>";
			if (neccode != "en") {
				def += "<br><span style='padding-left:60px;'>Translation: </span><input type=text size=40 value='" + necdefs[i][2][l][6] + "' onKeyUp=necdefs[" + i + "][2][" + l + "][6]=this.value;fill_in() />"
			}
		}
		def += "<br>";
	}
	document.getElementById('necdefs').innerHTML = def;
}


function necpostbox(q) {
	if (q != undefined) {
		if ((q > 5 && q <= 10) || q == 13 || q == 14 || q == 19) {
			necpost[q][necpost[q].length] = ['', '']
		} else if ((q > 10 && q < 13) || q > 15) {
			necpost[q][necpost[q].length] = ''
		} else {
			necpost[q] = ''
		}
	}
	var m = "";

	/* USAGE NOTES, INFLECTION TABLES */
	for (var o = 0; o <= 4; o++) {
		if (necpost[o] != undefined) {
			m += "<span style='padding-left:30px;'>" + necheadingorder[o] + ": <a href=javascript:necpost[" + o + "]=undefined;";
			if (!o) {
				m += "document.getElementById('necquotbutton').style.fontWeight='';";
			}
			m += "necpostbox();fill_in() title='Delete section'>(delete)</a></span><br><span style='padding-left:60px;'><textarea onKeyUp=necpost[" + o + "]=this.value;fill_in()>" + necpost[o] + "</textarea></span><br>";
		}
	}
	/* NYMS */
	for (o = 5; o < 14; o++) {
		if (necpost[o][0] != undefined) {
			m += "<span style='padding-left:30px;'>" + necheadingorder[o] + ": <a id=nec" + necheadingorder[o] + "button  href=javascript:necpost[" + o + "][necpost[" + o + "].length]=['',''];necpostbox();fill_in() title='add section'>(add section)</a></span><br>"
		} else if (o == 5) {
			document.getElementById('necSynonymsbutton').style.fontWeight = ''
		}

		for (var i = 0; i < necpost[o].length; ++i) {
			m += "<span style='padding-left:60px;'>Gloss: <input type=text value='" + necpost[o][i][0] + "' onKeyUp=necpost[" + o + "][" + i + "][0]=this.value;fill_in() /> " + necheadingorder[o] + ": ";
			for (var u = 0; u < necpost[o][i].length; ++u) {
				if (u != 0) {
					if (u != 1) {
						m += ", ";
					}
					m += "<input type=text size=5 value='" + necpost[o][i][u] + "' onKeyUp=necpost[" + o + "][" + i + "][" + u + "]=this.value;fill_in() />";
				}
			}
			m += "<a href=javascript:necpost[" + o + "][" + i + "].push('');necpostbox();fill_in() title='Add " + necheadingorder[o].substr(0, necheadingorder[o].length - 1).toLowerCase() + "'>(+)</a>";
			if (necpost[o][i].length > 2) {
				m += "<a href=javascript:necpost[" + o + "][" + i + "].splice(" + (necpost[o][i].length - 1) + ",1);necpostbox();fill_in() title='Delete " + necheadingorder[o].substr(0, necheadingorder[o].length - 1).toLowerCase() + "'>(–)</a>"
			}
			m += "<a href=javascript:necpost[" + o + "].splice(" + i + ",1);necpostbox();fill_in() title='Remove section'>(remove section)</a><br>";
		}
		if (o == 10) {
			o = 12
		}
	}

	/* DERIVED TERMS, RELATED TERMS, SEE ALSO, EXTERNAL LINKS */
	for (o = 11; o <= 17; o++) {
		if (necpost[o][0] != undefined) {
			m += "<span style='padding-left:30px;'>" + necheadingorder[o] + ": <a href=javascript:necpost[" + o + "].push('');necpostbox();fill_in()>(new)</a></span><br>";
		}

		for (var i = 0; i < necpost[o].length; ++i) {
			m += "<span style='padding-left:60px;'><input type=text value='" + necpost[o][i] + "' onKeyUp=necpost[" + o + "][" + i + "]=this.value;fill_in() /><a href=javascript:necpost[" + o + "].splice(" + i + ",1);necpostbox();fill_in() title='Delete'>(–)</a><br>"
		}
		if (o == 12) {
			o = 15
		}
	}

	/* DESCENDANTS */

	if (necpost[14][0] != undefined) {
		m += "<span style='padding-left:30px;'>" + necheadingorder[14] + ": <a href=javascript:necpost[14].push(['','']);necpostbox();fill_in() title='Add new descendant'>(new)</a></span><br>";
	}

	for (var i = 0; i < necpost[14].length; ++i) {
		m += "<span style='padding-left:60px;'>Language: <input type=text value='" + necpost[14][i][0] + "' onKeyUp=necpost[14][" + i + "][0]=this.value;fill_in() onblur=if (necCleanLangCode(this.value)){this.value=necCleanLangCode(this.value)};necpost[14][" + i + "][0]=this.value;fill_in() /> Word: <input type=text value='" + necpost[14][i][1] + "' onKeyUp=necpost[14][" + i + "][1]=this.value;fill_in() /><a href=javascript:necpost[14].splice(" + i + ",1);necpostbox();fill_in() title='Delete'>(–)</a><br>"
	}


	/* TRANSLATIONS */
	if (necpost[15][0] != undefined) {
		m += "<span style='padding-left:30px;'>Translations section: <a href=javascript:necpost[15].push('');necpostbox();fill_in() title='Add translations section'>(add section)</a></span><br>"
	} else {
		document.getElementById('nectransbutton').style.fontWeight = ''
	}
	for (var i = 0; i < necpost[15].length; ++i) {
		m += "<span style='padding-left:60px;'>Gloss: <input type=text value='" + necpost[15][i] + "' onKeyUp=necpost[15][" + i + "]=this.value;fill_in() /><a href=javascript:necpost[15].splice(" + i + ",1);necpostbox();fill_in() title='Delete'>(–)</a><br>"
	}

	if (necpost[18][0] != undefined) {
		for (var i = 0; i < necpost[18].length; ++i) {
			m += "<span style='padding-left:30px;'>Category:<input type=text value='" + necpost[18][i] + "' onKeyUp=necpost[18][" + i + "]=this.value;fill_in() /><a href=javascript:necpost[18].splice(" + i + ",1);necpostbox();fill_in() title='Remove category'>(–)</a>";
			if (i == 0) {
				m += "<a href=javascript:necpost[18].push('');necpostbox();fill_in() title='Add new category'>(+new category)</a>"
			}
			m += "</span><br>"
		}
	}

	if (necpost[19][0] != undefined) {
		for (var i = 0; i < necpost[19].length; ++i) {
			m += "<span style='padding-left:30px;'>File name:<input type=text value='" + necpost[19][i][0] + "' onKeyUp=necpost[19][" + i + "][0]=this.value;fill_in() />  Caption:<input type=text value='" + necpost[19][i][1] + "' onKeyUp=necpost[19][" + i + "][1]=this.value;fill_in() /><a href=javascript:necpost[19].splice(" + i + ",1);necpostbox();fill_in() title='Remove image'>(–)</a>";
			if (i == 0) {
				m += "<a href=javascript:necpost[19].push(['','']);necpostbox();fill_in() title='Add new image'>(+new image)</a>"
			}
			m += "</span><br>"
		}
	}

	document.getElementById('necpostbox').innerHTML = m;
}


function input_box_fix(cc, dd) {
	document.getElementById('necinput' + cc + necdata[cc]).style.fontWeight = '';
	necdata[cc] = document.getElementById(dd).value;
	document.getElementById(dd).parentNode.setAttribute('ID', 'necinput' + cc + document.getElementById(dd).value);
	document.getElementById('necinput' + cc + necdata[cc]).style.fontWeight = 'bold';
}


function necfunction7(qw, er) {
	var qwe = false;

	for (var ty in qw) {
		if (er == qw[ty][0]) {
			qwe = true;
		}
	}

	return qwe;
}

function wikilinkText() {
    var sel, range;
    if (window.getSelection) {
        sel = window.getSelection();
        var activeElement = document.activeElement;
        if (activeElement.nodeName == "TEXTAREA" ||
           (activeElement.nodeName == "INPUT" && activeElement.type.toLowerCase() == "text")) {
               var val = activeElement.value, start = activeElement.selectionStart, end = activeElement.selectionEnd;
               activeElement.value = val.slice(0, start) + '[[' + sel + ']]' + val.slice(end);
        }
	}
}

function label() {
    var sel, range;
    if (window.getSelection) {
        sel = window.getSelection();
        var activeElement = document.activeElement;
        if (activeElement.nodeName == "TEXTAREA" ||
           (activeElement.nodeName == "INPUT" && activeElement.type.toLowerCase() == "text")) {
               var val = activeElement.value
               activeElement.value = '{{lb|' + neccode + '|}} ' + val;
        }
	}
}

function form() {
	var necheadings = ['Usage notes', 'Inflection', 'Conjugation', 'Declension', 'Quotations', 'Synonyms', 'Antonyms', 'Hypernyms', 'Hyponyms', 'Meronyms', 'Holonyms', 'Derived terms', 'Related terms', 'Coordinate terms', 'Descendants', 'Translations', 'See also', 'External links', 'Categories', 'Images'];
	var necposlist = ['Noun', 'Verb', 'Adjective', 'Adverb', 'Pronoun', 'Conjunction', 'Interjection', 'Preposition', 'Proper noun', 'Article', 'Prepositional phrase', 'Contraction', 'Prefix', 'Suffix', 'Symbol', 'Letter', 'Idiom', 'Phrase'];
	var code = $('<p>').text('Language code: ').append(
		$('<input>').attr({
			type: 'text',
			value: 'da',
			id: 'lang',
	}))[0];
	
	// Generate new array by mapping over necposlist
	var pos_items= necposlist.map(function(value) {
		// Check the PoS from GET
		if (pos_cap === value) {
			return '<label class="nec-' + value + '">' +
					'<input type="radio" name="pos" value="' + value + '"' + 'checked="checked"' + '>' +
					value +
					'</label>'
		}
		// Check noun by default if no PoS set
		else if (pos_cap == null && value == 'Noun') {
			return '<label class="nec-' + value + '">' +
					'<input type="radio" name="pos" value="' + value + '"' + 'checked="checked"' + '>' +
					value +
					'</label>'
		}
		else {
			return '<label class="nec-' + value + '">' +
					'<input type="radio" name="pos" value="' + value + '">' +
					value +
					'</label>'
		}
	});
	var pos_joined = '<p class="nec-options">' + pos_items.join(' ') + '</p>';
	var pos = $('<p>').text('Part of speech: ').append(pos_joined)[0];
	var link_button = '<input class="unselectable" type="button" name="PasteOver" value="[[ + ]]" onmousedown="wikilinkText(); return false">';
	var label_button = '<input class="unselectable" type="button" name="label" value="Insert label" onmousedown="label(); return false">';
	var def2 = $('<p>').text('Definition: ').append(
				$('<input>').attr({
					type: 'text',
					value: '',
					id: 'def',
					size: 40
				})
	);
	// Generate the headings dynamically
	function slide(id){ 
		var id = id;
		console.info('slide clicked')
		$('.slidable#' + id).children().show();
	}
	// First generate the links
	var heading_links= necheadings.map(function(value) {
		return '<a onclick=slide(' + value + ')>' + value + ' </span>';
	});
	// Generate the headings
	var heading_items= necheadings.map(function(value) {
		var input = $('<p>').text(value).addClass('slidable').attr('id', value)
			.append(': ')
			.append(
				$('<input>').attr({
					type: 'text',
					value: '',
					id: 'input_' + value
				}));
		// Populate array
		return $(input).hide();
	});
	console.info(heading_items)
	var headings_links = $('<div>').attr({id:'headings_links'}).append(heading_links)
	var headings = $('<div>').attr({id:'headings'}).append(heading_items)
	var button = $('<input>').attr({
			type: 'submit',
			value: 'Generate',
	})[0];
	var form = $('<div>').append(
		code, pos, link_button, label_button, def2, headings_links, headings, button
	);
	// workaround bug related to the editform
	$('#editform').prepend($('#so9q-nec'), $('#editform').children().first())
	// Add the content
	$('#mw-content-text > div.mw-editintro').append(form);
	// Setup the slide
	//$('.slidable').click(slide());
}

jQuery(document).ready(function necload() {
	$.when( mw.loader.using('mediawiki.util'), $.ready ).then( function() {
		if (mw.config.get('wgPageName') === 'Special:Search') {
			mw.util.addPortletLink( mw.config.get('skin') === 'vector' ? 'p-views' : 'p-cactions', '/w/index.php?title=' + getUrlParams('search') + '&action=edit&editintro=User:So9q/usenec', 'nec', 'id', 'use the New Entry Creator to create a new entry', 'n', 'nextnode');
		}
		if (typeof variable === 'undefined' || getUrlParams('action') === 'undefined' || getUrlParams('action') === 'edit' && getUrlParams('redlink') === '1') {
			mw.util.addPortletLink( mw.config.get('skin') === 'vector' ? 'p-views' : 'p-cactions', '/w/index.php?title=' + mw.config.get('wgPageName') + '&action=edit&editintro=User:So9q/usenec', 'nec', 'id', 'use the New Entry Creator to create a new entry', 'm', 'nextnode');
		}
	} );
	if (document.getElementById('so9q-nec')) {
		form();
		/*create_id();
		necdefupdate();
		fill_in();
		call_infl();
		fill_in();*/
	}
});

function necCleanLangCode(lang) // taken from wt:edit 
{
	var key = lang.toLowerCase().replace(' ', '');

	var dict = {
		aar: "aa",
		afar: "aa",
		abk: "ab",
		abkhazian: "ab",
		afr: "af",
		afrikaans: "af",
		aka: "ak",
		akan: "ak",
		amh: "am",
		amharic: "am",
		ara: "ar",
		arabic: "ar",
		arg: "an",
		aragonese: "an",
		asm: "as",
		assamese: "as",
		ava: "av",
		avaric: "av",
		ave: "ae",
		avestan: "ae",
		aym: "ay",
		aymara: "ay",
		aze: "az",
		azerbaijani: "az",
		bak: "ba",
		bashkir: "ba",
		bam: "bm",
		bambara: "bm",
		bel: "be",
		belarusian: "be",
		ben: "bn",
		bengali: "bn",
		bis: "bi",
		bislama: "bi",
		bod: "bo",
		tibetan: "bo",
		bos: "bs",
		bosnian: "bs",
		bre: "br",
		breton: "br",
		bul: "bg",
		bulgarian: "bg",
		cat: "ca",
		catalan: "ca",
		ces: "cs",
		czech: "cs",
		cha: "ch",
		chamorro: "ch",
		che: "ce",
		chechen: "ce",
		chu: "cu",
		churchslavic: "cu",
		chv: "cv",
		chuvash: "cv",
		cor: "kw",
		cornish: "kw",
		cos: "co",
		corsican: "co",
		cre: "cr",
		cree: "cr",
		cym: "cy",
		welsh: "cy",
		dan: "da",
		danish: "da",
		deu: "de",
		german: "de",
		div: "dv",
		dhivehi: "dv",
		dzo: "dz",
		dzongkha: "dz",
		ell: "el",
		greek: "el",
		eng: "en",
		english: "en",
		epo: "eo",
		esperanto: "eo",
		est: "et",
		estonian: "et",
		eus: "eu",
		basque: "eu",
		ewe: "ee",
		fao: "fo",
		faroese: "fo",
		fas: "fa",
		persian: "fa",
		fij: "fj",
		fijian: "fj",
		fin: "fi",
		finnish: "fi",
		fra: "fr",
		french: "fr",
		fry: "fy",
		westernfrisian: "fy",
		ful: "ff",
		fulah: "ff",
		gla: "gd",
		scottishgaelic: "gd",
		gle: "ga",
		irish: "ga",
		glg: "gl",
		galician: "gl",
		glv: "gv",
		manx: "gv",
		grn: "gn",
		guarani: "gn",
		guj: "gu",
		gujarati: "gu",
		hat: "ht",
		haitian: "ht",
		hau: "ha",
		hausa: "ha",
		heb: "he",
		hebrew: "he",
		her: "hz",
		herero: "hz",
		hin: "hi",
		hindi: "hi",
		hmo: "ho",
		hirimotu: "ho",
		hrv: "hr",
		croatian: "hr",
		hun: "hu",
		hungarian: "hu",
		hye: "hy",
		armenian: "hy",
		ibo: "ig",
		igbo: "ig",
		ido: "io",
		iii: "ii",
		sichuanyi: "ii",
		iku: "iu",
		inuktitut: "iu",
		ile: "ie",
		interlingue: "ie",
		ina: "ia",
		interlingua: "ia",
		ind: "id",
		indonesian: "id",
		ipk: "ik",
		inupiaq: "ik",
		isl: "is",
		icelandic: "is",
		ita: "it",
		italian: "it",
		jav: "jv",
		javanese: "jv",
		jpn: "ja",
		japanese: "ja",
		kal: "kl",
		kalaallisut: "kl",
		kan: "kn",
		kannada: "kn",
		kas: "ks",
		kashmiri: "ks",
		kat: "ka",
		georgian: "ka",
		kau: "kr",
		kanuri: "kr",
		kaz: "kk",
		kazakh: "kk",
		khm: "km",
		centralkhmer: "km",
		kik: "ki",
		kikuyu: "ki",
		kin: "rw",
		kinyarwanda: "rw",
		kir: "ky",
		kirghiz: "ky",
		kom: "kv",
		komi: "kv",
		kon: "kg",
		kongo: "kg",
		kor: "ko",
		korean: "ko",
		kua: "kj",
		kuanyama: "kj",
		kur: "ku",
		kurdish: "ku",
		lao: "lo",
		lat: "la",
		latin: "la",
		lav: "lv",
		latvian: "lv",
		lim: "li",
		limburgan: "li",
		lin: "ln",
		lingala: "ln",
		lit: "lt",
		lithuanian: "lt",
		ltz: "lb",
		luxembourgish: "lb",
		lub: "lu",
		lubakatanga: "lu",
		lug: "lg",
		ganda: "lg",
		mah: "mh",
		marshallese: "mh",
		mal: "ml",
		malayalam: "ml",
		mar: "mr",
		marathi: "mr",
		mkd: "mk",
		macedonian: "mk",
		mlg: "mg",
		malagasy: "mg",
		mlt: "mt",
		maltese: "mt",
		mon: "mn",
		mongolian: "mn",
		mri: "mi",
		maori: "mi",
		msa: "ms",
		malay: "ms",
		mya: "my",
		burmese: "my",
		nau: "na",
		nauru: "na",
		nav: "nv",
		navajo: "nv",
		nbl: "nr",
		southndebele: "nr",
		nde: "nd",
		northndebele: "nd",
		ndo: "ng",
		ndonga: "ng",
		nep: "ne",
		nepali: "ne",
		nld: "nl",
		dutch: "nl",
		nno: "nn",
		norwegiannynorsk: "nn",
		nob: "nb",
		norwegianbokmal: "nb",
		nor: "no",
		norwegian: "no",
		nya: "ny",
		nyanja: "ny",
		oci: "oc",
		occitan: "oc",
		oji: "oj",
		ojibwa: "oj",
		ori: "or",
		oriya: "or",
		orm: "om",
		oromo: "om",
		oss: "os",
		ossetian: "os",
		pan: "pa",
		panjabi: "pa",
		pli: "pi",
		pali: "pi",
		pol: "pl",
		polish: "pl",
		por: "pt",
		portuguese: "pt",
		pus: "ps",
		pushto: "ps",
		que: "qu",
		quechua: "qu",
		roh: "rm",
		romansh: "rm",
		ron: "ro",
		romanian: "ro",
		run: "rn",
		rundi: "rn",
		rus: "ru",
		russian: "ru",
		sag: "sg",
		sango: "sg",
		san: "sa",
		sanskrit: "sa",
		sin: "si",
		sinhala: "si",
		slk: "sk",
		slovak: "sk",
		slv: "sl",
		slovenian: "sl",
		sme: "se",
		northernsami: "se",
		smo: "sm",
		samoan: "sm",
		sna: "sn",
		shona: "sn",
		snd: "sd",
		sindhi: "sd",
		som: "so",
		somali: "so",
		sot: "st",
		southernsotho: "st",
		spa: "es",
		spanish: "es",
		sqi: "sq",
		albanian: "sq",
		srd: "sc",
		sardinian: "sc",
		srp: "sr",
		serbian: "sr",
		ssw: "ss",
		swati: "ss",
		sun: "su",
		sundanese: "su",
		swa: "sw",
		swahili: "sw",
		swe: "sv",
		swedish: "sv",
		tah: "ty",
		tahitian: "ty",
		tam: "ta",
		tamil: "ta",
		tat: "tt",
		tatar: "tt",
		tel: "te",
		telugu: "te",
		tgk: "tg",
		tajik: "tg",
		tgl: "tl",
		tagalog: "tl",
		tha: "th",
		thai: "th",
		tir: "ti",
		tigrinya: "ti",
		ton: "to",
		tonga: "to",
		tsn: "tn",
		tswana: "tn",
		tso: "ts",
		tsonga: "ts",
		tuk: "tk",
		turkmen: "tk",
		tur: "tr",
		turkish: "tr",
		twi: "tw",
		uig: "ug",
		uighur: "ug",
		ukr: "uk",
		ukrainian: "uk",
		urd: "ur",
		urdu: "ur",
		uzb: "uz",
		uzbek: "uz",
		ven: "ve",
		venda: "ve",
		vie: "vi",
		vietnamese: "vi",
		vol: "vo",
		volapuk: "vo",
		wln: "wa",
		walloon: "wa",
		wol: "wo",
		wolof: "wo",
		xho: "xh",
		xhosa: "xh",
		yid: "yi",
		yiddish: "yi",
		yor: "yo",
		yoruba: "yo",
		zha: "za",
		zhuang: "za",
		zho: "zh",
		chinese: "zh",
		zul: "zu",
		zulu: "zu"
	};

	return dict[key];
}

// Data on inflection
var necinfls = {
	cmn: {
		noun: ['{{cmn-noun', '}}', ['Type', '', [
				['Simplified', '|s', "necinfls['cmn']['noun'][6][0]='Traditional';necinfls['cmn']['noun'][6][2][0][2]='|tra='"],
				['Traditional', '|t', "necinfls['cmn']['noun'][6][0]='Simplified';necinfls['cmn']['noun'][6][2][0][2]='|sim='"],
				['both', '|ts', "necinfls['cmn']['noun'][6][2][0][2]=''"]
			]],
			['Pinyin', '', [
				['input', ' ', '|pin=']
			]],
			['Pinyin (tone marks as numbers)', '', [
				['input', ' ', '|pint=']
			]],
			['Traditional', '', [
				['input', ' ', '|tra=']
			]]
		]
	},

	ca: {
		noun: ['{{ca-noun', '}}', ['Gender', '', [
				['Unknown', ''],
				['masculine', '|m'],
				['feminine', '|f']
			]],
			['Plural', '', [
				[title + 's', ''],
				['input', ' ', '|pl='],
				['(uncountable)', '|pl=-']
			]]
		],
		adjective: ['{{ca-adj', '}}'],
		adverb: ['{{ca-adv', '}}']
	},

	da: {
		noun: ['{{da-noun', '}}', 
			['Stem', '', [
				['(inherited)', ''],
				['input', 'Other: ', '|stem=']
			]],
			['Singular definite', '', [
				[title + 'en', '|en'],
				[title + 'et', '|et'],
				[title + 't', '|t'],
				[title + 'n', '|n'],
				['(no singular definite)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Plural', '', [
				[title + 'e', '|e'],
				[title + 'er', '|er'],
				[title + 'r', '|r'],
				[title + 's', '|s'],
				['(no plural)', '|-'],
				['input', 'Other: ', '|']
			]], ],
		verb: ['{{da-verb', '}}', 
			['Imperative', '', [
				['input', ': ', '|']
			]], 
			['Infinitive', '', [
				['input', 'Other: ', '|']
			]], 
			['Present', '', [
				[title + 'r', '|er'],
				[title + 'er', '|er'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Past', '', [
				[title + 'ede', '|ede'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Past participle', '', [
				['har ' + title + 'et', '|har|et'],
				['har ' + title + 't', '|har|t'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], ],
		adjective: ['{{da-adj', '}}', 
			['Neuter', '', [
				[title + 't', '|t'],
				['input', 'Other: ', '|']
			]], 
			['Plural or definite', '', [
				[title + 'e', '|e'],
				[title + 'er', '|er'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Comparative', '', [
				[title + 'ere', '|ere'],
				['mere ' + title, '|mere'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Superlative pred.', '', [
				[title + 'est', '|est'],
				[title + 'st', '|st'],
				['mest ' + title, '|mest'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Superlative attr.', '', [
				[title + 'este', '|este'],
				[title + 'ste', '|ste'],
				['mest ' + title + 'e', '|mest ' + title + 'e'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], ],
		adverb: ['{{da-adv', '}}'],
		propernoun: ['{{da-proper noun', '}}']
	},
	
	en: {
		noun: ['{{en-noun', '}}', ['Plural', '', [
			[title + 's', ''],
			[title + 'es', '|es'],
			['(uncountable)', '|-'],
			['input', 'Other: ', '|']
		]], ],
		verb: ['{{en-verb', '}}', ['Third-person singular present tense', '', [
				[title + 's', '|' + title + 's'],
				['input', 'Other: ', '|']
			]],
			['Present participle', '', [
				[title + 'ing', '|' + title + 'ing'],
				['input', 'Other: ', '|']
			]],
			['Past tense', '', [
				[title + 'ed', '|' + title + 'ed'],
				['input', 'Other: ', '|']
			]],
			['Past participle', '', [
				[title + 'ed', '|' + title + 'ed'],
				['input', 'Other: ', '|']
			]]
		],
		adjective: ['{{en-adj', '}}', ['Comparative', '', [
				['more ' + title, '', "necdata['en-adjective3']='most '+title"],
				[title + 'er', '|er', "necdata['en-adjective3']=title+'est'"],
				['(not comparable)', '|-', "necdata['en-adjective3']='(not comparable)'"],
				['input', 'Other: ', '|', '', 'input_box_fix("en-adjective3","en-adjective-3-3")']
			]],
			['Superlative', '', [
				['most ' + title, '', "necdata['en-adjective2']='more '+title"],
				[title + 'est', '', "necdata['en-adjective2']=title+'er'"],
				['(not comparable)', '', "necdata['en-adjective2']='(not comparable)'"],
				['input', 'Other: ', '|', '', 'input_box_fix("en-adjective2","en-adjective-2-3")']
			]]
		],
		adverb: ['{{en-adv', '}}', ['Comparative', '', [
				['more ' + title, '', "necdata['en-adverb3']='most '+title"],
				[title + 'er', '|er', "necdata['en-adverb3']=title+'est'"],
				['(not comparable)', '|-', "necdata['en-adverb3']='(not comparable)'"],
				['input', 'Other: ', '|', '', 'input_box_fix("en-adverb3","en-adverb-3-3")']
			]],
			['Superlative', '', [
				['most ' + title, '', "necdata['en-adverb2']='more '+title"],
				[title + 'est', '', "necdata['en-adverb2']=title+'er'"],
				['(not comparable)', '', "necdata['en-adverb2']='(not comparable)'"],
				['input', 'Other: ', '|', '', 'input_box_fix("en-adverb2","en-adverb-2-3")']
			]]
		],
		pronoun: ['{{en-pron', '}}'],
		conjunction: ['{{en-con', '}}'],
		interjection: ['{{en-interj', '}}'],
		preposition: ['{{en-prep', '}}'],
		propernoun: ['{{en-proper noun', '}}', ['Plural', '', [
			['None', ''],
			[title + 's', '|s'],
			['input', 'Other: ', '|']
		]]],
		contraction: ['{{en-cont', '}}'],
		prefix: ['{{en-prefix', '}}'],
		suffix: ['{{en-suffix', '}}']
	},

	eo: {
		noun: ['{{eo-noun', '}}'],
		verb: ['{{eo-verb', '}}'],
		adjective: ['{{eo-adj', '}}'],
		adverb: ['{{eo-adv', '}}'],
		propernoun: ['{{eo-proper noun', '}}']
	},

	es: {
		noun: ['{{es-noun', '}}'],
		adjective: ['{{es-adj', '}}'],
		adverb: ['{{es-adv', '}}'],
		propernoun: ['{{es-proper noun', '}}']
	},

	fr: {
		noun: ['{{fr-noun', '}}', ['Gender', '', [
				['Unknown', ''],
				['masculine', '|m'],
				['feminine', '|f']
			]],
			['Plural', '', [
				[title + 's', ''],
				['input', ' ', '|pl='],
				['(uncountable)', '|pl=-']
			]]
		],
		adjective: ['{{fr-adj', '}}'],
		verb: ['{{fr-verb', '}}'],
		adverb: ['{{fr-adv', '}}']
	},

	enm: {
		noun: ['{{enm-noun', '}}']
	},

	frm: {
		noun: ['{{frm-noun', '}}', ['Gender', '', [
				['Unknown', ''],
				['masculine', '|m'],
				['feminine', '|f']
			]],
			['Plural', '', [
				[title + 's', ''],
				['input', ' ', '|pl='],
				['(uncountable)', '|pl=-']
			]]
		],
		adjective: ['{{frm-adj', '}}']
	},

	fro: {
		noun: ['{{fro-noun', '}}', ['Gender', '', [
			['Unknown', ''],
			['masculine', '|m'],
			['feminine', '|f']
		]]]
	},

	he: {
		noun: ['{{he-noun', '}}', ['Transliteration', '', [
				['input', ' ', '|tr=']
			]],
			['With vowels', '', [
				['?', ''],
				['input', ' ', '|wv=']
			]],
			['Gender', '', [
				['?', ''],
				['Masculine', '|g=m'],
				['Feminine', '|g=f']
			]],
			['Plural', '', [
				['?', ''],
				[title + 'ים', '|pl=' + title + 'ים'],
				[title + 'ות', '|pl=' + title + 'ות'],
				['input', 'Other: ', '|pl='],
				['(uncountable)', '|pl=-']
			]],
			['Plural with vowels', '', [
				['?', ''],
				['input', ' ', '|plwv=']
			]],
			['Construct', '', [
				['?', ''],
				['input', ' ', '|cons='],
				['none', '|cons=-']
			]],
			['Construct with vowels', '', [
				['?', ''],
				['input', ' ', '|conswv=']
			]]
		],
		verb: ['{{he-verb', '}}', ['Transliteration', '', [
				['input', ' ', '|tr=']
			]],
			['With vowels', '', [
				['?', ''],
				['input', ' ', '|wv=']
			]],
			['Binyan', '', [
				['?', ''],
				['paal', '|pa'],
				['nifal', '|nif'],
				['piel', '|pi'],
				['pual', '|pu'],
				['hifil', '|hif'],
				['hufal', '|huf'],
				['hitpael', '|hit'],
				['hitpual', "|hitpu'al"]
			]]
		],
		adverb: ['{{he-adv', '}}', ['Transliteration', '', [
				['input', ' ', '|tr=']
			]],
			['With vowels', '', [
				['?', ''],
				['input', ' ', '|wv=']
			]]
		]
	},

	hi: {
		noun: ['{{hi-noun', '}}', ['Gender', '', [
				['unknown', ''],
				['masculine', '|g=m'],
				['feminine', '|g=f'],
				['neutral', '|g=mf'],
				['m. plural', '|g=mp'],
				['f. plural', '|g=fp'],
				['n. plural', '|g=p']
			]],
			['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		propernoun: ['{{hi-proper noun', '}}', ['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		adjective: ['{{hi-adj', '}}', ['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		verb: ['{{hi-verb', '}}', ['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		adverb: ['{{hi-adv', '}}', ['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		verbform: ['{{hi-verb-form', '}}', ['Gender', '', [
				['unknown', ''],
				['masculine', '|g=m'],
				['feminine', '|g=f'],
				['m. plural', '|g=m-p'],
				['f. plural', '|g=f-p']
			]],
			['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		pronoun: ['{{hi-pron', '}}', ['Gender', '', [
				['unknown', ''],
				['masculine', '|g=m'],
				['feminine', '|g=f']
			]],
			['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		interjection: ['{{hi-interj', '}}', ['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		preposition: ['{{hi-prep', '}}', ['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
		postposition: ['{{hi-post', '}}', ['Urdu form', '', [
				['none', ''],
				['input', ' ', '|ur=']
			]],
			['Transliteration', '', [
				['default', ''],
				['input', ' ', '|tr=']
			]]
		],
	},

	hil: {
		noun: ['{{hil-noun', '}}']
	},

	io: {
		noun: ['{{io-noun', '}}'],
		verb: ['{{io-verb', '}}'],
		adjective: ['{{io-adj', '}}'],
		adverb: ['{{io-adv', '}}']
	},

	nb: {
		noun: ['{{nb-noun', '}}', 
			['Stem', '', [
				['(inherited)', ''],
				['input', 'Other: ', '|stem=']
			]],
			['Singular definite', '', [
				[title + 'en', '|en'],
				[title + 'et', '|et'],
				[title + 't', '|t'],
				[title + 'n', '|n'],
				['(no singular definite)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Plural', '', [
				[title + 'e', '|e'],
				[title + 'er', '|er'],
				[title + 'r', '|r'],
				[title + 's', '|s'],
				['(no plural)', '|-'],
				['input', 'Other: ', '|']
			]], ],
		verb: ['{{nb-verb', '}}', 
			['Imperative', '', [
				['input', ': ', '|']
			]], 
			['Infinitive', '', [
				['input', 'Other: ', '|']
			]], 
			['Present', '', [
				[title + 'r', '|er'],
				[title + 'er', '|er'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Past', '', [
				[title + 'ede', '|ede'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Past participle', '', [
				['har ' + title + 'et', '|har|et'],
				['har ' + title + 't', '|har|t'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], ],
		adjective: ['{{nb-adj', '}}', 
			['Neuter', '', [
				[title + 't', '|t'],
				['input', 'Other: ', '|']
			]], 
			['Plural or definite', '', [
				[title + 'e', '|e'],
				[title + 'er', '|er'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Comparative', '', [
				[title + 'ere', '|ere'],
				['mere ' + title, '|mere'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Superlative pred.', '', [
				[title + 'est', '|est'],
				['mest ' + title, '|mest'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], 
			['Superlative attr.', '', [
				[title + 'este', '|este'],
				['mest ' + title + 'e', '|mest ' + title + 'e'],
				['(not used)', '|-'],
				['input', 'Other: ', '|']
			]], ],
		adverb: ['{{nb-adv', '}}'],
		propernoun: ['{{nb-proper noun', '}}']
	},
	
	lb: {
		noun: ['{{lb-noun', '}}', ['Gender', '', [
				['Unknown', ''],
				['masculine', '|m'],
				['feminine', '|f'],
				['neuter', '|n']
			]],
			['Plural', '', [
				[title + 's', ''],
				['input', ' ', '|pl='],
				['(uncountable)', '|pl=-']
			]]
		],
		adjective: ['{{lb-adj', '}}']
	},

	my: {
		noun: ['{{my-noun', '}}']
	},

	nmn: {
		noun: ['{{nmn-noun', '}}', ['Plural', '', [
				['input', ' ', '|pl=']
			]],
			['Diminutive', '', [
				['input', ' ', '|dim=']
			]],
			['Diminutive plural', '', [
				['input', ' ', '|dim_pl=']
			]],
			['Tone class', '', [
				['input', ' ', '|tone_class=']
			]],
			['Noun class', '', [
				['input', ' ', '|noun_class=']
			]]
		]
	},

	oc: {
		noun: ['{{oc-noun', '}}', ['Gender', '', [
				['Unknown', ''],
				['masculine', '|m'],
				['feminine', '|f']
			]],
			['Plural', '', [
				[title + 's', ''],
				['input', ' ', '|pl='],
				['(uncountable)', '|pl=-']
			]]
		],
		adjective: ['{{oc-adj', '}}'],
		verb: ['{{oc-verb', '}}']
	},

	pl: {
		noun: ['{{pl-noun', '}}', ['Gender', '', [
				['unknown', ''],
				['masculine', '|m'],
				['masculine personal', '|m-pr'],
				['masculine animate', '|m-an'],
				['masculine inanimate', '|m-in'],
				['feminine', '|f'],
				['neuter', '|n']
			]],
			['Diminutive', '', [
				['none', ''],
				['input', ' ', '|dim=']
			]],
			['Augmentative', '', [
				['none', ''],
				['input', ' ', '|aug=']
			]],
			['Female equivalent', '', [
				['none', ''],
				['input', ' ', '|f=']
			]],
			['Male equivalent', '', [
				['none', ''],
				['input', ' ', '|m=']
			]],
			['Abbreviation', '', [
				['none', ''],
				['input', ' ', '|abbr=']
			]]
		],
		propernoun: ['{{pl-proper noun', '}}', ['Gender', '', [
				['unknown', ''],
				['masculine', '|m'],
				['masculine personal', '|m-pr'],
				['masculine animate', '|m-an'],
				['masculine inanimate', '|m-in'],
				['feminine', '|f'],
				['neuter', '|n']
			]],
			['Female equivalent', '', [
				['none', ''],
				['input', ' ', '|f=']
			]],
			['Male equivalent', '', [
				['none', ''],
				['input', ' ', '|m=']
			]],
			['Abbreviation', '', [
				['none', ''],
				['input', ' ', '|abbr=']
			]]
		],
		adjective: ['{{pl-adj', '}}', ['Gender', '', [
				['unknown', '|?'],
				['masculine', '|m'],
				['feminine', '|f'],
				['neuter', '|n']
			]],
			['Comparative', '', [
				['(unknown)', ''],
				['bardziej ' + title, '|bardziej'],
				['(not comparable)', '|-'],
				['input', 'Other: ', '|', '']
			]]
		],
		adverb: ['{{pl-adv', '}}', ['Comparative', '', [
			['(unknown)', ''],
			[title + 'j', '|j'],
			['bardziej ' + title, '|bardziej'],
			['(not comparable)', '|-'],
			['input', 'Other: ', '|', '']
		]]],
		verb: ['{{pl-verb', '}}', ['Aspect', '', [
				['unknown', ''],
				['imperfective', '|a=impf'],
				['perfective', '|a=pf']
			]],
			['Imperfective counterpart', '', [
				['none', ''],
				['input', ' ', '|impf=']
			]],
			['Perfective counterpart', '', [
				['none', ''],
				['input', ' ', '|pf=']
			]]
		],
	},

	pro: {
		noun: ['{{pro-noun', '}}', ['Gender', '', [
				['Unknown', ''],
				['masculine', '|m'],
				['feminine', '|f']
			]],
			['Plural', '', [
				[title + 's', ''],
				['input', ' ', '|pl='],
				['(uncountable)', '|pl=-']
			]]
		],
		adjective: ['{{pro-adj', '}}']
	},

	pt: {
		noun: ['{{pt-noun', '}}', ['Gender', '', [
				['Unknown', ''],
				['masculine', '|m'],
				['feminine', '|f']
			]],
			['Plural', '', [
				[title + 's', ''],
				['input', ' ', '|pl='],
				['(uncountable)', '|pl=-']
			]]
		],
		adjective: ['{{pt-adj', '}}']
	},

	ru: {
		noun: ['{{ru-noun|', '}}', ['Gender', '', [
			['Unknown', '|?'],
			['masculine animate', '|m-an'],
			['masculine inanimate', '|m-in'],
			['feminine animate', '|f-an'],
			['feminine inanimate', '|f-in'],
			['neuter animate', '|n-an'],
			['neuter inanimate', '|n-in'],
			['masculine animate plural', '|m-an-p'],
			['masculine inanimate plural', '|m-in-p'],
			['feminine animate plural', '|f-an-p'],
			['feminine inanimate plural', '|f-in-p'],
			['neuter animate plural', '|n-an-p'],
			['neuter inanimate plural', '|n-in-p'],
			['plural', '|p']
		]]],
		propernoun: ['{{ru-proper noun', '}}', ['Gender', '', [
				['unknown', ''],
				['masculine', '|m'],
				['masculine animate', '|m-an'],
				['masculine inanimate', '|m-in'],
				['feminine', '|f'],
				['neuter', '|n']
			]],
			['Female equivalent', '', [
				['none', ''],
				['input', ' ', '|f=']
			]],
			['Male equivalent', '', [
				['none', ''],
				['input', ' ', '|m=']
			]]
		],
		adjective: ['{{ru-adj', '}}'],
		verb: ['{{ru-verb', '}}', ['Stress-marked form', '', [
				['input', '', '|']
			]],
			['Aspect', '', [
				['unknown', '|?'],
				['imperfective', '|impf'],
				['perfective', '|pf']
			]],
			['Imperfective counterpart', '', [
				['none', ''],
				['input', ' ', '|impf=']
			]],
			['Perfective counterpart', '', [
				['none', ''],
				['input', ' ', '|pf=']
			]]
		],
		adverb: ['{{ru-adv', '}}', ['Stress-marked form', '', [
				['input', '', '|']
			]],
			['Comparative', '', [
				['(unknown)', ''],
				['(not comparable)', '|-'],
				['input', 'Other: ', '|', '']
			]]
		],
	},

	wym: {
		noun: ['{{head|wym|noun', '}}', ['Gender', '', [
			['None', ''],
			['masculine', '|g=m'],
			['feminine', '|g=f']
		]]]
	}
};
// </nowiki>