User:PanSola/sortable mod.js/abstractions

/*

Abstractions
*/ /*

sortingTableRecord
*/ function sortingTableRecord_cons( rowStart, normalRowRecords, bottomRowRecords, numCols){ var initialDirections = new Array(numCols); for (var i = 0; i < numCols; i++) initialDirections[i]=0; return new Array(rowStart, normalRowRecords, bottomRowRecords, new Array(numCols), initialDirections); } sTR_cons = sortingTableRecord_cons;

function sortingTableRecord_getRowStart( sTR ){ return sTR[0]; } sTR_getRowStart = sortingTableRecord_getRowStart;

function sortingTableRecord_getNormalRowRecords(sTR){ return sTR[1]; } sTR_getNRR = sortingTableRecord_getNormalRowRecords;

function sortingTableRecord_getBottomRowRecords(sTR){ return sTR[2]; } sTR_getBRR = sortingTableRecord_getBottomRowRecords;

function sortingTableRecord_setSortFunction(sTR, sortFunction){ var sortFns = sTR[3]; if (SORT_COLUMN_INDEX < sortFns.length){ sTR[3][SORT_COLUMN_INDEX] = sortFunction; return sortFunction; }	return null; } sTR_setSFn = sortingTableRecord_setSortFunction;

function sortingTableRecord_getSortFunction(sTR){ var sortFns = sTR[3]; if (SORT_COLUMN_INDEX < sortFns.length){ return sortFns[SORT_COLUMN_INDEX]; }	return null; } sTR_getSFn = sortingTableRecord_getSortFunction;

function sortingTableRecord_getDir(sTR){ return sTR[4][SORT_COLUMN_INDEX]; } sTR_getDir = sortingTableRecord_getDir;

function sortingTableRecord_changeDir(sTR){ var newDir = 1 - sTR[4][SORT_COLUMN_INDEX]; sTR[4][SORT_COLUMN_INDEX] = newDir; return newDir; } sTR_changeDir = sortingTableRecord_changeDir; /*

rowRecords
*/ function rr_cons(row, numCols, j) { return new Array(row, new Array(numCols), j); }

function rr_appendRecordsToTable(rowRecords, table){ for (var i = 0; i < rowRecords.length; i++) { table.tBodies[0].appendChild(rowRecords[i][0]); } }

function rr_getCellText(rowRecord){ return ts_getInnerText(rowRecord[0].cells[SORT_COLUMN_INDEX]); }

function rr_setSortKey(rowRecord, sortKey){ rowRecord[1][SORT_COLUMN_INDEX] = sortKey; }

function rr_getSortKey(rowRecord){ return rowRecord[1][SORT_COLUMN_INDEX]; }