מדיה ויקי:Common.js: הבדלים בין גרסאות בדף

מתוך ויקיפועל
קפיצה לניווט קפיצה לחיפוש
אין תקציר עריכה
אין תקציר עריכה
שורה 10: שורה 10:
  */
  */


var ts_image_path = stylepath+"/common/images/";
var ts_image_path = stylepath+"/common/images/";
var ts_image_up = "sort_up.gif";
var ts_image_up = "sort_up.gif";
var ts_image_down = "sort_down.gif";
var ts_image_down = "sort_down.gif";
var ts_image_none = "sort_none.gif";
var ts_image_none = "sort_none.gif";
var ts_europeandate = wgContentLanguage != "en"; // The non-American-inclined can change to "true"
var ts_europeandate = wgContentLanguage != "en"; // The non-American-inclined can change to "true"


var ts_alternate_row_colors = false;
var ts_alternate_row_colors = false;
שורה 23: שורה 23:
var idnum = 0;
var idnum = 0;
// Find all tables with class sortable and make them sortable
// Find all tables with class sortable and make them sortable
var tables = getElementsByClassName(document, "table", "sortable");
var tables = getElementsByClassName(document, "table", "sortable");
for (var ti = 0; ti < tables.length ; ti++) {
for (var ti = 0; ti < tables.length ; ti++) {
if (!tables[ti].id) {
if (!tables[ti].id) {
tables[ti].setAttribute('id','sortable_table_id_'+idnum);
tables[ti].setAttribute('id','sortable_table_id_'+idnum);
שורה 35: שורה 35:
function ts_makeSortable(table) {
function ts_makeSortable(table) {
var firstRow;
var firstRow;
if (table.rows &amp;&amp; table.rows.length &gt; 0) {
if (table.rows && table.rows.length > 0) {
if (table.tHead &amp;&amp; table.tHead.rows.length &gt; 0) {
if (table.tHead && table.tHead.rows.length > 0) {
firstRow = table.tHead.rows[table.tHead.rows.length-1];
firstRow = table.tHead.rows[table.tHead.rows.length-1];
} else {
} else {
שורה 45: שורה 45:


// We have a first row: assume it's the header, and make its contents clickable links
// We have a first row: assume it's the header, and make its contents clickable links
for (var i = 0; i &lt; firstRow.cells.length; i++) {
for (var i = 0; i < firstRow.cells.length; i++) {
var cell = firstRow.cells[i];
var cell = firstRow.cells[i];
if ((&quot; &quot;+cell.className+&quot; &quot;).indexOf(&quot; unsortable &quot;) == -1) {
if ((" "+cell.className+" ").indexOf(" unsortable ") == -1) {
cell.innerHTML += '&lt;a href=&quot;#&quot; class=&quot;sortheader&quot; '
cell.innerHTML += '<a href="#" class="sortheader" '
+ 'onclick=&quot;ts_resortTable(this);return false;&quot;&gt;'
+ 'onclick="ts_resortTable(this);return false;">'
+ '&lt;span class=&quot;sortarrow&quot;&gt;'
+ '<span class="sortarrow">'
+ '&lt;img src=&quot;'
+ '<img src="'
+ ts_image_path
+ ts_image_path
+ ts_image_none
+ ts_image_none
+ '&quot; alt=&quot;&amp;darr;&quot;/&gt;&lt;/span&gt;&lt;/a&gt;';
+ '" alt="&darr;"/></span></a>';
}
}
}
}
שורה 75: שורה 75:


var table = tr.parentNode;
var table = tr.parentNode;
while (table &amp;&amp; !(table.tagName &amp;&amp; table.tagName.toLowerCase() == 'table'))
while (table && !(table.tagName && table.tagName.toLowerCase() == 'table'))
table = table.parentNode;
table = table.parentNode;
if (!table) return;
if (!table) return;


if (table.rows.length &lt;= 1) return;
if (table.rows.length <= 1) return;


// Generate the number transform table if it's not done already
// Generate the number transform table if it's not done already
שורה 88: שורה 88:
// Work out a type for the column
// Work out a type for the column
// Skip the first row if that's where the headings are
// Skip the first row if that's where the headings are
var rowStart = (table.tHead &amp;&amp; table.tHead.rows.length &gt; 0 ? 0 : 1);
var rowStart = (table.tHead && table.tHead.rows.length > 0 ? 0 : 1);


var itm = &quot;&quot;;
var itm = "";
for (var i = rowStart; i &lt; table.rows.length; i++) {
for (var i = rowStart; i < table.rows.length; i++) {
if (table.rows[i].cells.length &gt; column) {
if (table.rows[i].cells.length > column) {
itm = ts_getInnerText(table.rows[i].cells[column]);
itm = ts_getInnerText(table.rows[i].cells[column]);
itm = itm.replace(/^[\s\xa0]+/, &quot;&quot;).replace(/[\s\xa0]+$/, &quot;&quot;);
itm = itm.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "");
if (itm != &quot;&quot;) break;
if (itm != "") break;
}
}
}
}
שורה 115: שורה 115:
}
}


var reverse = (span.getAttribute(&quot;sortdir&quot;) == 'down');
var reverse = (span.getAttribute("sortdir") == 'down');


var newRows = new Array();
var newRows = new Array();
var staticRows = new Array();
var staticRows = new Array();
for (var j = rowStart; j &lt; table.rows.length; j++) {
for (var j = rowStart; j < table.rows.length; j++) {
var row = table.rows[j];
var row = table.rows[j];
if((&quot; &quot;+row.className+&quot; &quot;).indexOf(&quot; unsortable &quot;) &lt; 0) {
if((" "+row.className+" ").indexOf(" unsortable ") < 0) {
var keyText = ts_getInnerText(row.cells[column]);
var keyText = ts_getInnerText(row.cells[column]);
if(keyText == undefined) {
if(keyText == undefined) {
keyText = &quot;&quot;;  
keyText = "";  
}
}
var oldIndex = (reverse ? -j : j);
var oldIndex = (reverse ? -j : j);
var preprocessed = preprocessor( keyText.replace(/^[\s\xa0]+/, &quot;&quot;).replace(/[\s\xa0]+$/, &quot;&quot;) );
var preprocessed = preprocessor( keyText.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "") );


newRows[newRows.length] = new Array(row, preprocessed, oldIndex);
newRows[newRows.length] = new Array(row, preprocessed, oldIndex);
שורה 137: שורה 137:
var arrowHTML;
var arrowHTML;
if (reverse) {
if (reverse) {
arrowHTML = '&lt;img src=&quot;'+ ts_image_path + ts_image_down + '&quot; alt=&quot;&amp;darr;&quot;/&gt;';
arrowHTML = '<img src="'+ ts_image_path + ts_image_down + '" alt="&darr;"/>';
newRows.reverse();
newRows.reverse();
span.setAttribute('sortdir','up');
span.setAttribute('sortdir','up');
} else {
} else {
arrowHTML = '&lt;img src=&quot;'+ ts_image_path + ts_image_up + '&quot; alt=&quot;&amp;uarr;&quot;/&gt;';
arrowHTML = '<img src="'+ ts_image_path + ts_image_up + '" alt="&uarr;"/>';
span.setAttribute('sortdir','down');
span.setAttribute('sortdir','down');
}
}


for (var i = 0; i &lt; staticRows.length; i++) {
for (var i = 0; i < staticRows.length; i++) {
var row = staticRows[i];
var row = staticRows[i];
newRows.splice(row[2], 0, row);
newRows.splice(row[2], 0, row);
שורה 152: שורה 152:
// We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
// We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
// don't do sortbottom rows
// don't do sortbottom rows
for (var i = 0; i &lt; newRows.length; i++) {
for (var i = 0; i < newRows.length; i++) {
if ((&quot; &quot;+newRows[i][0].className+&quot; &quot;).indexOf(&quot; sortbottom &quot;) == -1)
if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") == -1)
table.tBodies[0].appendChild(newRows[i][0]);
table.tBodies[0].appendChild(newRows[i][0]);
}
}
// do sortbottom rows only
// do sortbottom rows only
for (var i = 0; i &lt; newRows.length; i++) {
for (var i = 0; i < newRows.length; i++) {
if ((&quot; &quot;+newRows[i][0].className+&quot; &quot;).indexOf(&quot; sortbottom &quot;) != -1)
if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") != -1)
table.tBodies[0].appendChild(newRows[i][0]);
table.tBodies[0].appendChild(newRows[i][0]);
}
}


// Delete any other arrows there may be showing
// Delete any other arrows there may be showing
var spans = getElementsByClassName(tr, &quot;span&quot;, &quot;sortarrow&quot;);
var spans = getElementsByClassName(tr, "span", "sortarrow");
for (var i = 0; i &lt; spans.length; i++) {
for (var i = 0; i < spans.length; i++) {
spans[i].innerHTML = '&lt;img src=&quot;'+ ts_image_path + ts_image_none + '&quot; alt=&quot;&amp;darr;&quot;/&gt;';
spans[i].innerHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/>';
}
}
span.innerHTML = arrowHTML;
span.innerHTML = arrowHTML;
שורה 175: שורה 175:


function ts_initTransformTable() {
function ts_initTransformTable() {
if ( typeof wgSeparatorTransformTable == &quot;undefined&quot;
if ( typeof wgSeparatorTransformTable == "undefined"


|| ( wgSeparatorTransformTable[0] == '' &amp;&amp; wgDigitTransformTable[2] == '' ) )
|| ( wgSeparatorTransformTable[0] == '' && wgDigitTransformTable[2] == '' ) )
{
{
digitClass = &quot;[0-9,.]&quot;;
digitClass = "[0-9,.]";
ts_number_transform_table = false;
ts_number_transform_table = false;
} else {
} else {
שורה 185: שורה 185:
// Unpack the transform table
// Unpack the transform table
// Separators
// Separators
ascii = wgSeparatorTransformTable[0].split(&quot;\t&quot;);
ascii = wgSeparatorTransformTable[0].split("\t");
localised = wgSeparatorTransformTable[1].split(&quot;\t&quot;);
localised = wgSeparatorTransformTable[1].split("\t");
for ( var i = 0; i &lt; ascii.length; i++ ) {
for ( var i = 0; i < ascii.length; i++ ) {
ts_number_transform_table[localised[i]] = ascii[i];
ts_number_transform_table[localised[i]] = ascii[i];
}
}
// Digits
// Digits
ascii = wgDigitTransformTable[0].split(&quot;\t&quot;);
ascii = wgDigitTransformTable[0].split("\t");
localised = wgDigitTransformTable[1].split(&quot;\t&quot;);
localised = wgDigitTransformTable[1].split("\t");
for ( var i = 0; i &lt; ascii.length; i++ ) {
for ( var i = 0; i < ascii.length; i++ ) {
ts_number_transform_table[localised[i]] = ascii[i];
ts_number_transform_table[localised[i]] = ascii[i];
}
}
שורה 206: שורה 206:
function( s ) { return '\\' + s; } )
function( s ) { return '\\' + s; } )
);
);
if (digit.length &gt; maxDigitLength) {
if (digit.length > maxDigitLength) {
maxDigitLength = digit.length;
maxDigitLength = digit.length;
}
}
}
}
if ( maxDigitLength &gt; 1 ) {
if ( maxDigitLength > 1 ) {
digitClass = '[' + digits.join( '', digits ) + ']';
digitClass = '[' + digits.join( '', digits ) + ']';
} else {
} else {
שורה 220: שורה 220:
// if percents and regular numbers aren't being mixed.
// if percents and regular numbers aren't being mixed.
ts_number_regex = new RegExp(
ts_number_regex = new RegExp(
&quot;^(&quot; +
"^(" +
&quot;[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?&quot; + // Fortran-style scientific
"[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific
&quot;|&quot; +
"|" +
&quot;[-+\u2212]?&quot; + digitClass + &quot;+%?&quot; + // Generic localised
"[-+\u2212]?" + digitClass + "+%?" + // Generic localised
&quot;)$&quot;, &quot;i&quot;
")$", "i"


);
);
שורה 237: שורה 237:
if (date.length == 11) {
if (date.length == 11) {
switch (date.substr(3,3).toLowerCase()) {
switch (date.substr(3,3).toLowerCase()) {
case &quot;jan&quot;: var month = &quot;01&quot;; break;
case "jan": var month = "01"; break;
case &quot;feb&quot;: var month = &quot;02&quot;; break;
case "feb": var month = "02"; break;
case &quot;mar&quot;: var month = &quot;03&quot;; break;
case "mar": var month = "03"; break;
case &quot;apr&quot;: var month = &quot;04&quot;; break;
case "apr": var month = "04"; break;
case &quot;may&quot;: var month = &quot;05&quot;; break;
case "may": var month = "05"; break;
case &quot;jun&quot;: var month = &quot;06&quot;; break;
case "jun": var month = "06"; break;
case &quot;jul&quot;: var month = &quot;07&quot;; break;
case "jul": var month = "07"; break;
case &quot;aug&quot;: var month = &quot;08&quot;; break;
case "aug": var month = "08"; break;
case &quot;sep&quot;: var month = &quot;09&quot;; break;
case "sep": var month = "09"; break;
case &quot;oct&quot;: var month = &quot;10&quot;; break;
case "oct": var month = "10"; break;
case &quot;nov&quot;: var month = &quot;11&quot;; break;
case "nov": var month = "11"; break;
case &quot;dec&quot;: var month = &quot;12&quot;; break;
case "dec": var month = "12"; break;
// default: var month = &quot;00&quot;;
// default: var month = "00";
}
}
return date.substr(7,4)+month+date.substr(0,2);
return date.substr(7,4)+month+date.substr(0,2);
שורה 260: שורה 260:
} else if (date.length == 8) {
} else if (date.length == 8) {
yr = date.substr(6,2);
yr = date.substr(6,2);
if (parseInt(yr) &lt; 50) {
if (parseInt(yr) < 50) {
yr = '20'+yr;
yr = '20'+yr;
} else {
} else {
שורה 271: שורה 271:
}
}
}
}
return &quot;00000000&quot;;
return "00000000";
}
}


שורה 281: שורה 281:
var newNum = '', c;
var newNum = '', c;


for ( var p = 0; p &lt; s.length; p++ ) {
for ( var p = 0; p < s.length; p++ ) {
c = s.charAt( p );
c = s.charAt( p );
if (c in ts_number_transform_table) {
if (c in ts_number_transform_table) {
שורה 291: שורה 291:
s = newNum;
s = newNum;
}
}
num = parseFloat(s.replace(/[, ]/g, &quot;&quot;).replace(&quot;\u2212&quot;, &quot;-&quot;));
num = parseFloat(s.replace(/[, ]/g, "").replace("\u2212", "-"));
return (isNaN(num) ? -Infinity : num);
return (isNaN(num) ? -Infinity : num);
}
}
שורה 300: שורה 300:


function ts_sort_generic(a, b) {
function ts_sort_generic(a, b) {
return a[1] &lt; b[1] ? -1 : a[1] &gt; b[1] ? 1 : a[2] - b[2];
return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : a[2] - b[2];
}
}


function ts_alternate(table) {
function ts_alternate(table) {
// Take object table and get all it's tbodies.
// Take object table and get all it's tbodies.
var tableBodies = table.getElementsByTagName(&quot;tbody&quot;);
var tableBodies = table.getElementsByTagName("tbody");
// Loop through these tbodies
// Loop through these tbodies
for (var i = 0; i &lt; tableBodies.length; i++) {
for (var i = 0; i < tableBodies.length; i++) {
// Take the tbody, and get all it's rows
// Take the tbody, and get all it's rows
var tableRows = tableBodies[i].getElementsByTagName(&quot;tr&quot;);
var tableRows = tableBodies[i].getElementsByTagName("tr");
// Loop through these rows
// Loop through these rows
// Start at 1 because we want to leave the heading row untouched
// Start at 1 because we want to leave the heading row untouched
for (var j = 0; j &lt; tableRows.length; j++) {
for (var j = 0; j < tableRows.length; j++) {
// Check if j is even, and apply classes for both possible results
// Check if j is even, and apply classes for both possible results
var oldClasses = tableRows[j].className.split(&quot; &quot;);
var oldClasses = tableRows[j].className.split(" ");
var newClassName = &quot;&quot;;
var newClassName = "";
for (var k = 0; k &lt; oldClasses.length; k++) {
for (var k = 0; k < oldClasses.length; k++) {
if (oldClasses[k] != &quot;&quot; &amp;&amp; oldClasses[k] != &quot;even&quot; &amp;&amp; oldClasses[k] != &quot;odd&quot;)
if (oldClasses[k] != "" && oldClasses[k] != "even" && oldClasses[k] != "odd")
newClassName += oldClasses[k] + &quot; &quot;;
newClassName += oldClasses[k] + " ";
}
}
tableRows[j].className = newClassName + (j % 2 == 0 ? &quot;even&quot; : &quot;odd&quot;);
tableRows[j].className = newClassName + (j % 2 == 0 ? "even" : "odd");
}
}
}
}
שורה 328: שורה 328:
  * End of table sorting code
  * End of table sorting code
  */
  */
addOnloadHook(sortables_init);
addOnloadHook(sortables_init);
addOnloadHook(sortables_init);

גרסה מ־21:37, 8 בינואר 2010

/*
 * Table sorting script based on one (c) 1997-2006 Stuart Langridge and Joost
 * de Valk:
 * http://www.joostdevalk.nl/code/sortable-table/
 * http://www.kryogenix.org/code/browser/sorttable/
 *
 * @todo don't break on colspans/rowspans (bug 8028)
 * @todo language-specific digit grouping/decimals (bug 8063)
 * @todo support all accepted date formats (bug 8226)
 */

var ts_image_path = stylepath+"/common/images/";
var ts_image_up = "sort_up.gif";
var ts_image_down = "sort_down.gif";
var ts_image_none = "sort_none.gif";
var ts_europeandate = wgContentLanguage != "en"; // The non-American-inclined can change to "true"

var ts_alternate_row_colors = false;
var ts_number_transform_table = null;
var ts_number_regex = null;

function sortables_init() {
	var idnum = 0;
	// Find all tables with class sortable and make them sortable
	var tables = getElementsByClassName(document, "table", "sortable");
	for (var ti = 0; ti < tables.length ; ti++) {
		if (!tables[ti].id) {
			tables[ti].setAttribute('id','sortable_table_id_'+idnum);
			++idnum;
		}
		ts_makeSortable(tables[ti]);
	}
}

function ts_makeSortable(table) {
	var firstRow;
	if (table.rows && table.rows.length > 0) {
		if (table.tHead && table.tHead.rows.length > 0) {
			firstRow = table.tHead.rows[table.tHead.rows.length-1];
		} else {
			firstRow = table.rows[0];
		}
	}
	if (!firstRow) return;

	// We have a first row: assume it's the header, and make its contents clickable links
	for (var i = 0; i < firstRow.cells.length; i++) {
		var cell = firstRow.cells[i];
		if ((" "+cell.className+" ").indexOf(" unsortable ") == -1) {
			cell.innerHTML += '<a href="#" class="sortheader" '
				+ 'onclick="ts_resortTable(this);return false;">'
				+ '<span class="sortarrow">'
				+ '<img src="'
				+ ts_image_path
				+ ts_image_none
				+ '" alt="&darr;"/></span></a>';
		}
	}
	if (ts_alternate_row_colors) {
		ts_alternate(table);
	}
}

function ts_getInnerText(el) {
	return getInnerText( el );
}

function ts_resortTable(lnk) {
	// get the span
	var span = lnk.getElementsByTagName('span')[0];

	var td = lnk.parentNode;
	var tr = td.parentNode;
	var column = td.cellIndex;

	var table = tr.parentNode;
	while (table && !(table.tagName && table.tagName.toLowerCase() == 'table'))
		table = table.parentNode;
	if (!table) return;

	if (table.rows.length <= 1) return;

	// Generate the number transform table if it's not done already
	if (ts_number_transform_table == null) {
		ts_initTransformTable();
	}

	// Work out a type for the column
	// Skip the first row if that's where the headings are
	var rowStart = (table.tHead && table.tHead.rows.length > 0 ? 0 : 1);

	var itm = "";
	for (var i = rowStart; i < table.rows.length; i++) {
		if (table.rows[i].cells.length > column) {
			itm = ts_getInnerText(table.rows[i].cells[column]);
			itm = itm.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "");
			if (itm != "") break;
		}
	}

	// TODO: bug 8226, localised date formats
	var sortfn = ts_sort_generic;
	var preprocessor = ts_toLowerCase;
	if (/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/.test(itm)) {
		preprocessor = ts_dateToSortKey;
	} else if (/^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/.test(itm)) {
		preprocessor = ts_dateToSortKey;
	} else if (/^\d\d[\/.-]\d\d[\/.-]\d\d$/.test(itm)) {
		preprocessor = ts_dateToSortKey;
		// (minus sign)([pound dollar euro yen currency]|cents)
	} else if (/(^([-\u2212] *)?[\u00a3$\u20ac\u00a4\u00a5]|\u00a2$)/.test(itm)) {
		preprocessor = ts_currencyToSortKey;
	} else if (ts_number_regex.test(itm)) {
		preprocessor = ts_parseFloat;
	}

	var reverse = (span.getAttribute("sortdir") == 'down');

	var newRows = new Array();
	var staticRows = new Array();
	for (var j = rowStart; j < table.rows.length; j++) {
		var row = table.rows[j];
		if((" "+row.className+" ").indexOf(" unsortable ") < 0) {
			var keyText = ts_getInnerText(row.cells[column]);
			if(keyText == undefined) {
				keyText = ""; 
			}
			var oldIndex = (reverse ? -j : j);
			var preprocessed = preprocessor( keyText.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "") );

			newRows[newRows.length] = new Array(row, preprocessed, oldIndex);
		} else staticRows[staticRows.length] = new Array(row, false, j-rowStart);
	}

	newRows.sort(sortfn);

	var arrowHTML;
	if (reverse) {
		arrowHTML = '<img src="'+ ts_image_path + ts_image_down + '" alt="&darr;"/>';
		newRows.reverse();
		span.setAttribute('sortdir','up');
	} else {
		arrowHTML = '<img src="'+ ts_image_path + ts_image_up + '" alt="&uarr;"/>';
		span.setAttribute('sortdir','down');
	}

	for (var i = 0; i < staticRows.length; i++) {
		var row = staticRows[i];
		newRows.splice(row[2], 0, row);
	}

	// We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
	// don't do sortbottom rows
	for (var i = 0; i < newRows.length; i++) {
		if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") == -1)
			table.tBodies[0].appendChild(newRows[i][0]);
	}
	// do sortbottom rows only
	for (var i = 0; i < newRows.length; i++) {
		if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") != -1)
			table.tBodies[0].appendChild(newRows[i][0]);
	}

	// Delete any other arrows there may be showing
	var spans = getElementsByClassName(tr, "span", "sortarrow");
	for (var i = 0; i < spans.length; i++) {
		spans[i].innerHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/>';
	}
	span.innerHTML = arrowHTML;

	if (ts_alternate_row_colors) {
		ts_alternate(table);
	}
}

function ts_initTransformTable() {
	if ( typeof wgSeparatorTransformTable == "undefined"

			|| ( wgSeparatorTransformTable[0] == '' && wgDigitTransformTable[2] == '' ) )
	{
		digitClass = "[0-9,.]";
		ts_number_transform_table = false;
	} else {
		ts_number_transform_table = {};
		// Unpack the transform table
		// Separators
		ascii = wgSeparatorTransformTable[0].split("\t");
		localised = wgSeparatorTransformTable[1].split("\t");
		for ( var i = 0; i < ascii.length; i++ ) {
			ts_number_transform_table[localised[i]] = ascii[i];
		}
		// Digits
		ascii = wgDigitTransformTable[0].split("\t");
		localised = wgDigitTransformTable[1].split("\t");
		for ( var i = 0; i < ascii.length; i++ ) {
			ts_number_transform_table[localised[i]] = ascii[i];
		}

		// Construct regex for number identification
		digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ',', '\\.'];
		maxDigitLength = 1;
		for ( var digit in ts_number_transform_table ) {
			// Escape regex metacharacters
			digits.push(
				digit.replace( /[\\\\$\*\+\?\.\(\)\|\{\}\[\]\-]/,
					function( s ) { return '\\' + s; } )
			);
			if (digit.length > maxDigitLength) {
				maxDigitLength = digit.length;
			}
		}
		if ( maxDigitLength > 1 ) {
			digitClass = '[' + digits.join( '', digits ) + ']';
		} else {
			digitClass = '(' + digits.join( '|', digits ) + ')';
		}
	}

	// We allow a trailing percent sign, which we just strip.  This works fine
	// if percents and regular numbers aren't being mixed.
	ts_number_regex = new RegExp(
		"^(" +
			"[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific
			"|" +
			"[-+\u2212]?" + digitClass + "+%?" + // Generic localised
		")$", "i"

	);
}

function ts_toLowerCase( s ) {
	return s.toLowerCase();
}

function ts_dateToSortKey(date) {
	// y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
	if (date.length == 11) {
		switch (date.substr(3,3).toLowerCase()) {
			case "jan": var month = "01"; break;
			case "feb": var month = "02"; break;
			case "mar": var month = "03"; break;
			case "apr": var month = "04"; break;
			case "may": var month = "05"; break;
			case "jun": var month = "06"; break;
			case "jul": var month = "07"; break;
			case "aug": var month = "08"; break;
			case "sep": var month = "09"; break;
			case "oct": var month = "10"; break;
			case "nov": var month = "11"; break;
			case "dec": var month = "12"; break;
			// default: var month = "00";
		}
		return date.substr(7,4)+month+date.substr(0,2);
	} else if (date.length == 10) {
		if (ts_europeandate == false) {
			return date.substr(6,4)+date.substr(0,2)+date.substr(3,2);
		} else {
			return date.substr(6,4)+date.substr(3,2)+date.substr(0,2);
		}
	} else if (date.length == 8) {
		yr = date.substr(6,2);
		if (parseInt(yr) < 50) {
			yr = '20'+yr;
		} else {
			yr = '19'+yr;
		}
		if (ts_europeandate == true) {
			return yr+date.substr(3,2)+date.substr(0,2);
		} else {
			return yr+date.substr(0,2)+date.substr(3,2);
		}
	}
	return "00000000";
}

function ts_parseFloat( s ) {
	if ( !s ) {
		return 0;
	}
	if (ts_number_transform_table != false) {
		var newNum = '', c;

		for ( var p = 0; p < s.length; p++ ) {
			c = s.charAt( p );
			if (c in ts_number_transform_table) {
				newNum += ts_number_transform_table[c];
			} else {
				newNum += c;
			}
		}
		s = newNum;
	}
	num = parseFloat(s.replace(/[, ]/g, "").replace("\u2212", "-"));
	return (isNaN(num) ? -Infinity : num);
}

function ts_currencyToSortKey( s ) {
	return ts_parseFloat(s.replace(/[^-\u22120-9.,]/g,''));
}

function ts_sort_generic(a, b) {
	return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : a[2] - b[2];
}

function ts_alternate(table) {
	// Take object table and get all it's tbodies.
	var tableBodies = table.getElementsByTagName("tbody");
	// Loop through these tbodies
	for (var i = 0; i < tableBodies.length; i++) {
		// Take the tbody, and get all it's rows
		var tableRows = tableBodies[i].getElementsByTagName("tr");
		// Loop through these rows
		// Start at 1 because we want to leave the heading row untouched
		for (var j = 0; j < tableRows.length; j++) {
			// Check if j is even, and apply classes for both possible results
			var oldClasses = tableRows[j].className.split(" ");
			var newClassName = "";
			for (var k = 0; k < oldClasses.length; k++) {
				if (oldClasses[k] != "" && oldClasses[k] != "even" && oldClasses[k] != "odd")
					newClassName += oldClasses[k] + " ";
			}
			tableRows[j].className = newClassName + (j % 2 == 0 ? "even" : "odd");
		}
	}
}

/*
 * End of table sorting code
 */


addOnloadHook(sortables_init);

addOnloadHook(sortables_init);