mw.loader.implement("jquery.tablesorter",function($,jQuery){(function($,mw){var ts,parsers=[];function getParserById(name){var i,len=parsers.length;for(i=0;i4)?5:rows.length;while(i=needed){return parsers[i];}}else{i++;rowIndex=0;concurrent=0;}}else{rowIndex++;if(rowIndex>rows.length){rowIndex=0;i++;}}}return parsers[0];}function buildParserCache(table,$headers){var rows=table.tBodies[0].rows,sortType,parsers=[];if(rows[0]){var cells=rows[0].cells,len=cells.length,i,parser;for(i=0;i tbody > tr');if(!$table.get(0).tHead){$thead=$('');$rows.each(function(){if($(this).children('td').length){return false;}$thead.append(this);});$table.find(' > tbody:first').before($thead);}if(!$table.get(0).tFoot){$tfoot=$('');len=$rows.length;for(i=len-1 ;i>=0;i--){if($($rows[i]).children('td').length){break;}$tfoot.prepend($($rows[i]));}$table.append($tfoot);}}function buildHeaders(table,msg){var maxSeen=0,colspanOffset=0,columns,i,$tableHeaders=$([]),$tableRows=$('thead:eq(0) > tr',table);if($tableRows.length<=1){$tableHeaders=$tableRows.children('th');}else{var rowspan,colspan,headerCount,longestTR,matrixRowIndex,matrixColumnIndex,exploded=[];$tableRows.each(function(rowIndex,row){$.each(row.cells,function(columnIndex,cell){rowspan=Number(cell.rowSpan);colspan=Number(cell.colSpan);while(exploded[rowIndex]&&exploded[rowIndex][columnIndex]!==undefined){++columnIndex;}for(matrixColumnIndex=columnIndex;matrixColumnIndex=maxSeen){maxSeen=headerCount;longestTR=index;}});$tableHeaders=$(uniqueElements(exploded[longestTR]));}table.headerToColumns=[];table.columnToHeader=[];$tableHeaders.each(function(headerIndex){columns=[];for(i=0;ib)?1:0));}function sortTextDesc(a,b){return((ba)?1:0));}function multisort(table,sortList,cache){var i,sortFn=[],len=sortList.length;for(i=0;i tbody > tr > [rowspan]').get();if(! rowspanCells.length){return;}$table.find('> tbody > tr').each(function(){var i,col=0,l=this.cells.length;for(i=0;i=spanningRealCellIndex;}function fixTdCellIndex(){this.realCellIndex+=colSpan;if(this.rowSpan>1){this.needResort=true;}}while(rowspanCells.length){if(rowspanCells[0].needResort){resortCells();}cell=rowspanCells.shift();rowSpan=cell.rowSpan;colSpan=cell.colSpan;spanningRealCellIndex=cell.realCellIndex;cell.rowSpan=1;$nextRows=$(cell).parent().nextAll();for(i=0;i tbody > tr.sortbottom');if($sortbottoms.length){var $tfoot=$table.children('tfoot');if($tfoot.length){$tfoot.eq(0).prepend($sortbottoms);}else{$table.append($('').append($sortbottoms));}}explodeRowspans($table);table.config.parsers=buildParserCache(table,$headers);}$headers.not('.'+table.config.unsortableClass).on('keypress click',function(e){if(e.type==='click'&&e.target.nodeName.toLowerCase()==='a'){return true;}if(e.type==='keypress'&&e.which!==13){return true;}if(firstTime){setupForFirstSort();}cache=buildCache(table);var totalRows=($table[0].tBodies[0]&&$table[0]. tBodies[0].rows.length)||0;if(!table.sortDisabled&&totalRows>0){this.order=this.count%2;this.count++;var cell,columns,newSortList,i;cell=this;columns=table.headerToColumns[this.headerIndex];newSortList=$.map(columns,function(c){return[[c,cell.order]];});i=columns[0];if(!e[config.sortMultiSortKey]){config.sortList=newSortList;}else{if(isValueInArray(i,config.sortList)){for(var j=0;j0){sortList=convertSortList(sortList);}setHeadersOrder($headers,sortList,table.headerToColumns);cache=buildCache(table);setHeadersCss(table,$headers,sortList,sortCSS,sortMsg,table.columnToHeader);appendToTable(table,multisort(table,sortList,cache));};if(config.sortList.length>0){setupForFirstSort();config.sortList=convertSortList(config.sortList);$table.data('tablesorter').sort();}});},addParser:function(parser){var l=parsers.length,a=true;for(var i=0;i