User:Erutuon/scripts/changeCaseOrder.js

Hello, you have come here looking for the meaning of the word User:Erutuon/scripts/changeCaseOrder.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Erutuon/scripts/changeCaseOrder.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Erutuon/scripts/changeCaseOrder.js in singular and plural. Everything you need to know about the word User:Erutuon/scripts/changeCaseOrder.js you have here. The definition of the word User:Erutuon/scripts/changeCaseOrder.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Erutuon/scripts/changeCaseOrder.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
// <nowiki>

/* jshint eqeqeq: true */
/* globals mw, $ */

'use strict';

$(function () {
	// Each object contains a canonical name, code, and an array of
	// row headers.
	// The array will be used to sort the table rows. List row headers in the order
	// that you want them to display.
	// If a row does not have its header listed in the array, it will appear
	// before all the headers in the array.
	// For Ancient Greek noun declension tables, this means that the "Case / #"
	// row will appear directly above the "Nominative" row.
	// Headers are converted to lowercase before this list is used.
	var languages = [
		{
			name: "Ancient Greek",
			code: "grc",
			headers: 
		},
		{
			name: "Latin",
			code: "la",
			headers: ,
		},
		{
			name: "German",
			code: "de",
			headers: ,
		},
	];
	
	function rearrange(language) {
		var languageName = language.name, languageCode = language.code, rowOrder = language.headers;
		
		var declensionTables = $(".inflection-table-" + languageCode + " tbody");
		
		// Get text of first header in row.
		var getCompareValue = function (row) {
			var headerText = $(row).children("th").first().text().trim().toLowerCase();
			return rowOrder.indexOf(headerText);
		};
		
		declensionTables.each(function () {
			$(this).replaceWith(function() {
				return $(this)
					.children()
					.sort(function (a, b) {
						return getCompareValue(a) - getCompareValue(b);
					});
			});
		});
	}
	
	languages.forEach(rearrange);
});

// </nowiki>