mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Global: Replace array push functions in main loops
This commit is contained in:
parent
61f38b81b1
commit
2f9fa35e55
@ -167,7 +167,7 @@
|
||||
c = table.config,
|
||||
namespace = c.namespace + 'pager',
|
||||
sz = parsePageSize( p, p.size, 'get' ); // don't allow dividing by zero
|
||||
if (p.countChildRows) { t.push(c.cssChildRow); }
|
||||
if (p.countChildRows) { t[ t.length ] = c.cssChildRow; }
|
||||
p.totalPages = Math.ceil( p.totalRows / sz ); // needed for "pageSize" method
|
||||
c.totalRows = p.totalRows;
|
||||
parsePageNumber( table, p );
|
||||
@ -254,10 +254,10 @@
|
||||
option_pages_start_page = (large_collection) ? skip_set_size : 1;
|
||||
|
||||
for ( i = option_pages_start_page; i <= pg; ) {
|
||||
option_pages.push(i);
|
||||
option_pages[ option_pages.length ] = i;
|
||||
i = i + ( large_collection ? skip_set_size : 1 );
|
||||
}
|
||||
option_pages.push(pg);
|
||||
option_pages[ option_pages.length ] = pg;
|
||||
if (large_collection) {
|
||||
focus_option_pages = [];
|
||||
// don't allow central focus size to be > 5 on either side of current page
|
||||
@ -269,7 +269,7 @@
|
||||
if (end_page > pg) { end_page = pg; }
|
||||
// construct an array to get a focus set around the current page
|
||||
for (i = start_page; i <= end_page ; i++) {
|
||||
focus_option_pages.push(i);
|
||||
focus_option_pages[ focus_option_pages.length ] = i;
|
||||
}
|
||||
|
||||
// keep unique values
|
||||
@ -349,7 +349,7 @@
|
||||
} else {
|
||||
rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
|
||||
if (last !== j && j >= s && j < e) {
|
||||
p.cacheIndex.push(i);
|
||||
p.cacheIndex[ p.cacheIndex.length ] = i;
|
||||
last = j;
|
||||
}
|
||||
// don't count child rows
|
||||
@ -565,7 +565,7 @@
|
||||
sortCol = sortCol[1];
|
||||
len = sortList.length;
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
arry.push(sortCol + '[' + sortList[indx][0] + ']=' + sortList[indx][1]);
|
||||
arry[ arry.length ] = sortCol + '[' + sortList[indx][0] + ']=' + sortList[indx][1];
|
||||
}
|
||||
// if the arry is empty, just add the col parameter... "&{sortList:col}" becomes "&col"
|
||||
url = url.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : sortCol );
|
||||
@ -576,7 +576,7 @@
|
||||
len = filterList.length;
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
if (filterList[indx]) {
|
||||
arry.push(filterCol + '[' + indx + ']=' + encodeURIComponent(filterList[indx]));
|
||||
arry[ arry.length ] = filterCol + '[' + indx + ']=' + encodeURIComponent( filterList[indx] );
|
||||
}
|
||||
}
|
||||
// if the arry is empty, just add the fcol parameter... "&{filterList:fcol}" becomes "&fcol"
|
||||
@ -634,7 +634,7 @@
|
||||
count++;
|
||||
if (count > s && added <= e) {
|
||||
added++;
|
||||
p.cacheIndex.push(index);
|
||||
p.cacheIndex[ p.cacheIndex.length ] = index;
|
||||
$tb.append(rows[index]);
|
||||
}
|
||||
}
|
||||
@ -695,7 +695,7 @@
|
||||
n = table.config.cache[0].normalized;
|
||||
p.totalRows = n.length;
|
||||
for (i = 0; i < p.totalRows; i++) {
|
||||
rows.push(n[i][c.columns].$row);
|
||||
rows[ rows.length ] = n[i][c.columns].$row;
|
||||
}
|
||||
c.rowsCopy = rows;
|
||||
moveToPage(table, p, true);
|
||||
|
@ -733,7 +733,7 @@
|
||||
}
|
||||
}
|
||||
if ( add ) {
|
||||
ts.parsers.push( parser );
|
||||
ts.parsers[ ts.parsers.length ] = parser;
|
||||
}
|
||||
},
|
||||
|
||||
@ -953,7 +953,7 @@
|
||||
}
|
||||
// ensure rowData is always in the same location (after the last column)
|
||||
cols[ c.columns ] = rowData;
|
||||
cache.normalized.push( cols );
|
||||
cache.normalized[ cache.normalized.length ] = cols;
|
||||
}
|
||||
cache.colMax = colMax;
|
||||
// total up rows, not including child rows
|
||||
@ -1022,9 +1022,9 @@
|
||||
});
|
||||
}
|
||||
if ( result !== false ) {
|
||||
data.parsed.push( parsed );
|
||||
data.raw.push( raw );
|
||||
data.$cell.push( $cell );
|
||||
data.parsed[ data.parsed.length ] = parsed;
|
||||
data.raw[ data.raw.length ] = raw;
|
||||
data.$cell[ data.$cell.length ] = $cell;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1213,7 +1213,7 @@
|
||||
}
|
||||
primary = indx === 0 ? dir : primary;
|
||||
group = [ col, parseInt( dir, 10 ) || 0 ];
|
||||
c.sortList.push( group );
|
||||
c.sortList[ c.sortList.length ] = group;
|
||||
dir = $.inArray( group[ 1 ], order ); // fixes issue #167
|
||||
c.sortVars[ col ].count = dir >= 0 ? dir : group[ 1 ] % ( c.sortReset ? 3 : 2 );
|
||||
}
|
||||
@ -1312,7 +1312,7 @@
|
||||
},
|
||||
|
||||
addRows : function( c, $row, resort, callback ) {
|
||||
var txt, val, tbodyIndex, rowIndex, rows, cellIndex, len,
|
||||
var txt, val, tbodyIndex, rowIndex, rows, cellIndex, len, order,
|
||||
cacheIndex, rowData, cells, cell, span,
|
||||
// allow passing a row string if only one non-info tbody exists in the table
|
||||
valid = typeof $row === 'string' && c.$tbodies.length === 1 && /<tr/.test( $row || '' ),
|
||||
@ -1347,12 +1347,13 @@
|
||||
for ( rowIndex = 0; rowIndex < rows; rowIndex++ ) {
|
||||
cacheIndex = 0;
|
||||
len = $row[ rowIndex ].cells.length;
|
||||
order = c.cache[ tbodyIndex ].normalized.length;
|
||||
cells = [];
|
||||
rowData = {
|
||||
child : [],
|
||||
raw : [],
|
||||
$row : $row.eq( rowIndex ),
|
||||
order : c.cache[ tbodyIndex ].normalized.length
|
||||
order : order
|
||||
};
|
||||
// add each cell
|
||||
for ( cellIndex = 0; cellIndex < len; cellIndex++ ) {
|
||||
@ -1375,7 +1376,7 @@
|
||||
// add the row data to the end
|
||||
cells[ c.columns ] = rowData;
|
||||
// update cache
|
||||
c.cache[ tbodyIndex ].normalized.push( cells );
|
||||
c.cache[ tbodyIndex ].normalized[ order ] = cells;
|
||||
}
|
||||
// resort using current settings
|
||||
ts.checkResort( c, resort, callback );
|
||||
@ -1417,7 +1418,7 @@
|
||||
parsed = cache[ tbodyIndex ].normalized;
|
||||
totalRows = parsed.length;
|
||||
for ( rowIndex = 0; rowIndex < totalRows; rowIndex++ ) {
|
||||
rows.push( parsed[ rowIndex ][ c.columns ].$row );
|
||||
rows[rows.length] = parsed[ rowIndex ][ c.columns ].$row;
|
||||
// removeRows used by the pager plugin; don't render if using ajax - fixes #411
|
||||
if ( !c.appender || ( c.pager && ( !c.pager.removeRows || !wo.pager_removeRows ) && !c.pager.ajax ) ) {
|
||||
$curTbody.append( parsed[ rowIndex ][ c.columns ].$row );
|
||||
@ -1499,18 +1500,18 @@
|
||||
arry = c.sortForce;
|
||||
for ( indx = 0; indx < arry.length; indx++ ) {
|
||||
if ( arry[ indx ][ 0 ] !== col ) {
|
||||
c.sortList.push( arry[ indx ] );
|
||||
c.sortList[ c.sortList.length ] = arry[ indx ];
|
||||
}
|
||||
}
|
||||
}
|
||||
// add column to sort list
|
||||
dir = order[ c.sortVars[ col ].count ];
|
||||
if ( dir < 2 ) {
|
||||
c.sortList.push( [ col, dir ] );
|
||||
c.sortList[ c.sortList.length ] = [ col, dir ];
|
||||
// add other columns if header spans across multiple
|
||||
if ( cell.colSpan > 1 ) {
|
||||
for ( indx = 1; indx < cell.colSpan; indx++ ) {
|
||||
c.sortList.push( [ col + indx, dir ] );
|
||||
c.sortList[ c.sortList.length ] = [ col + indx, dir ];
|
||||
// update count on columns in colSpan
|
||||
c.sortVars[ col + indx ].count = $.inArray( dir, order );
|
||||
}
|
||||
@ -1539,11 +1540,11 @@
|
||||
// add column to sort list array
|
||||
dir = order[ c.sortVars[ col ].count ];
|
||||
if ( dir < 2 ) {
|
||||
c.sortList.push( [ col, dir ] );
|
||||
c.sortList[ c.sortList.length ] = [ col, dir ];
|
||||
// add other columns if header spans across multiple
|
||||
if ( cell.colSpan > 1 ) {
|
||||
for ( indx = 1; indx < cell.colSpan; indx++ ) {
|
||||
c.sortList.push( [ col + indx, dir ] );
|
||||
c.sortList[ c.sortList.length ] = [ col + indx, dir ];
|
||||
// update count on columns in colSpan
|
||||
c.sortVars[ col + indx ].count = $.inArray( dir, order );
|
||||
}
|
||||
@ -1580,7 +1581,7 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
c.sortList.push( [ arry[ indx ][ 0 ], dir ] );
|
||||
c.sortList[ c.sortList.length ] = [ arry[ indx ][ 0 ], dir ];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1847,7 +1848,7 @@
|
||||
███████▀ ██ █████▀ ▀████▀ ██████ ██ █████▀
|
||||
*/
|
||||
addWidget : function( widget ) {
|
||||
ts.widgets.push( widget );
|
||||
ts.widgets[ ts.widgets.length ] = widget;
|
||||
},
|
||||
|
||||
hasWidget : function( $table, name ) {
|
||||
@ -1895,7 +1896,7 @@
|
||||
len = widgets.length;
|
||||
for ( indx = 0; indx < len; indx++ ) {
|
||||
if ( widgets[ indx ].match( widgetClass ) ) {
|
||||
c.widgets.push( widgets[ indx ].replace( widgetClass, '$1' ) );
|
||||
c.widgets[ c.widgets.length ] = widgets[ indx ].replace( widgetClass, '$1' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1912,7 +1913,7 @@
|
||||
applied = false;
|
||||
// add widget name to option list so it gets reapplied after sorting, filtering, etc
|
||||
if ( $.inArray( name, c.widgets ) < 0 ) {
|
||||
c.widgets.push( name );
|
||||
c.widgets[ c.widgets.length ] = name;
|
||||
}
|
||||
if ( c.debug ) { time = new Date(); }
|
||||
|
||||
@ -2022,7 +2023,7 @@
|
||||
for ( indx = 0; indx < len; indx++ ) {
|
||||
widget = ts.widgets[ indx ];
|
||||
if ( widget && widget.id ) {
|
||||
name.push( widget.id );
|
||||
name[ name.length ] = widget.id;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -2063,7 +2064,7 @@
|
||||
for ( indx = 0; indx < len; indx++ ) {
|
||||
widget = widgets[ indx ];
|
||||
if ( widget && widget.id && ( doAll || $.inArray( widget.id, curWidgets ) < 0 ) ) {
|
||||
list.push( widget.id );
|
||||
list[ list.length ] = widget.id;
|
||||
}
|
||||
}
|
||||
ts.removeWidget( table, list.join( ',' ), true );
|
||||
@ -2450,7 +2451,7 @@
|
||||
console = {};
|
||||
console.log = console.warn = console.error = console.table = function() {
|
||||
var arg = arguments.length > 1 ? arguments : arguments[0];
|
||||
ts.logs.push({ date: Date.now(), log: arg });
|
||||
ts.logs[ ts.logs.length ] = { date: Date.now(), log: arg };
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -971,7 +971,7 @@
|
||||
end = c.columns - 1;
|
||||
}
|
||||
for ( ; start <= end; start++ ) {
|
||||
columns.push( start );
|
||||
columns[ columns.length ] = start;
|
||||
}
|
||||
// remove processed range from val
|
||||
val = val.replace( ranges[ indx ], '' );
|
||||
@ -985,7 +985,7 @@
|
||||
if ( singles[ i ] !== '' ) {
|
||||
indx = parseInt( singles[ i ], 10 );
|
||||
if ( indx < c.columns ) {
|
||||
columns.push( indx );
|
||||
columns[ columns.length ] = indx;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -993,7 +993,7 @@
|
||||
// return all columns
|
||||
if ( !columns.length ) {
|
||||
for ( indx = 0; indx < c.columns; indx++ ) {
|
||||
columns.push( indx );
|
||||
columns[ columns.length ] = indx;
|
||||
}
|
||||
}
|
||||
return columns;
|
||||
@ -1491,13 +1491,13 @@
|
||||
// table cell to the parser format function
|
||||
if ( txt.text ) {
|
||||
txt.parsed = parsedTxt;
|
||||
parsed.push( txt );
|
||||
parsed[ parsed.length ] = txt;
|
||||
} else {
|
||||
parsed.push({
|
||||
parsed[ parsed.length ] = {
|
||||
text : txt,
|
||||
// check parser length - fixes #934
|
||||
parsed : parsedTxt
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
// sort parsed select options
|
||||
@ -1522,7 +1522,7 @@
|
||||
arry = [];
|
||||
len = parsed.length;
|
||||
for ( indx = 0; indx < len; indx++ ) {
|
||||
arry.push( parsed[indx] );
|
||||
arry[ arry.length ] = parsed[indx];
|
||||
}
|
||||
return arry;
|
||||
}
|
||||
@ -1551,23 +1551,23 @@
|
||||
if ( wo.filter_useParsedData ||
|
||||
c.parsers[column].parsed ||
|
||||
c.$headerIndexed[column].hasClass( 'filter-parsed' ) ) {
|
||||
arry.push( '' + cache.normalized[ rowIndex ][ column ] );
|
||||
arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ column ];
|
||||
// child row parsed data
|
||||
if ( wo.filter_childRows && wo.filter_childByColumn ) {
|
||||
childLen = cache.normalized[ rowIndex ][ c.columns ].$row.length - 1;
|
||||
for ( indx = 0; indx < childLen; indx++ ) {
|
||||
arry.push( '' + cache.normalized[ rowIndex ][ c.columns ].child[ indx ][ column ] );
|
||||
arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ c.columns ].child[ indx ][ column ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// get raw cached data instead of content directly from the cells
|
||||
arry.push( cache.normalized[ rowIndex ][ c.columns ].raw[ column ] );
|
||||
arry[ arry.length ] = cache.normalized[ rowIndex ][ c.columns ].raw[ column ];
|
||||
// child row unparsed data
|
||||
if ( wo.filter_childRows && wo.filter_childByColumn ) {
|
||||
childLen = cache.normalized[ rowIndex ][ c.columns ].$row.length;
|
||||
for ( indx = 1; indx < childLen; indx++ ) {
|
||||
child = cache.normalized[ rowIndex ][ c.columns ].$row.eq( indx ).children().eq( column );
|
||||
arry.push( '' + ts.getElementText( c, child, column ) );
|
||||
arry[ arry.length ] = '' + ts.getElementText( c, child, column );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -443,7 +443,7 @@
|
||||
p = c.pager,
|
||||
namespace = c.namespace + 'pager',
|
||||
sz = tsp.parsePageSize( c, p.size, 'get' ); // don't allow dividing by zero
|
||||
if ( wo.pager_countChildRows ) { t.push( c.cssChildRow ); }
|
||||
if ( wo.pager_countChildRows ) { t[ t.length ] = c.cssChildRow; }
|
||||
p.$size
|
||||
.add( p.$goto )
|
||||
.removeClass( wo.pager_css.disabled )
|
||||
@ -542,10 +542,10 @@
|
||||
optionPagesStartPage = largeCollection ? skipSetSize : 1;
|
||||
|
||||
for ( i = optionPagesStartPage; i <= pg; ) {
|
||||
optionPages.push( i );
|
||||
optionPages[ optionPages.length ] = i;
|
||||
i = i + ( largeCollection ? skipSetSize : 1 );
|
||||
}
|
||||
optionPages.push( pg );
|
||||
optionPages[ optionPages.length ] = pg;
|
||||
|
||||
if ( largeCollection ) {
|
||||
focusOptionPages = [];
|
||||
@ -558,7 +558,7 @@
|
||||
if ( endPage > pg ) { endPage = pg; }
|
||||
// construct an array to get a focus set around the current page
|
||||
for ( i = startPage; i <= endPage ; i++ ) {
|
||||
focusOptionPages.push( i );
|
||||
focusOptionPages[ focusOptionPages.length ] = i;
|
||||
}
|
||||
|
||||
// keep unique values
|
||||
@ -649,7 +649,7 @@
|
||||
} else {
|
||||
$rows[ rowIndex ].style.display = ( size >= start && size < end ) ? '' : 'none';
|
||||
if ( last !== size && size >= start && size < end ) {
|
||||
p.cacheIndex.push( rowIndex );
|
||||
p.cacheIndex[ p.cacheIndex.length ] = rowIndex;
|
||||
last = size;
|
||||
}
|
||||
// don't count child rows
|
||||
@ -875,7 +875,7 @@
|
||||
sortCol = sortCol[ 1 ];
|
||||
len = sortList.length;
|
||||
for ( indx = 0; indx < len; indx++ ) {
|
||||
arry.push( sortCol + '[' + sortList[ indx ][ 0 ] + ']=' + sortList[ indx ][ 1 ] );
|
||||
arry[ arry.length ] = sortCol + '[' + sortList[ indx ][ 0 ] + ']=' + sortList[ indx ][ 1 ];
|
||||
}
|
||||
// if the arry is empty, just add the col parameter... '&{sortList:col}' becomes '&col'
|
||||
url = url.replace( /\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join( '&' ) : sortCol );
|
||||
@ -886,7 +886,7 @@
|
||||
len = filterList.length;
|
||||
for ( indx = 0; indx < len; indx++ ) {
|
||||
if ( filterList[ indx ] ) {
|
||||
arry.push( filterCol + '[' + indx + ']=' + encodeURIComponent( filterList[ indx ] ) );
|
||||
arry[ arry.length ] = filterCol + '[' + indx + ']=' + encodeURIComponent( filterList[ indx ] );
|
||||
}
|
||||
}
|
||||
// if the arry is empty, just add the fcol parameter... '&{filterList:fcol}' becomes '&fcol'
|
||||
@ -945,7 +945,7 @@
|
||||
count++;
|
||||
if ( count > s && added <= e ) {
|
||||
added++;
|
||||
p.cacheIndex.push( index );
|
||||
p.cacheIndex[ p.cacheIndex.length ] = index;
|
||||
$tb.append( rows[ index ] );
|
||||
}
|
||||
}
|
||||
@ -1015,7 +1015,7 @@
|
||||
normalized = c.cache[ 0 ].normalized;
|
||||
p.totalRows = normalized.length;
|
||||
for ( index = 0; index < p.totalRows; index++ ) {
|
||||
rows.push( normalized[ index ][ c.columns ].$row );
|
||||
rows[ rows.length ] = normalized[ index ][ c.columns ].$row;
|
||||
}
|
||||
c.rowsCopy = rows;
|
||||
tsp.moveToPage( c, p, true );
|
||||
|
Loading…
Reference in New Issue
Block a user