Merge pull request #211 from xianzai/master

Fix - file size sorting: Add large file size support and remove whitespace before sorting
pull/212/head
Allan Jardine 9 years ago
commit ccbbd84c0f

@ -19,7 +19,7 @@
*/ */
jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) { jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
var units = data.replace( /[\d\.]/g, '' ).toLowerCase(); var units = data.replace( /[\d\.\s]/g, '' ).toLowerCase();
var multiplier = 1; var multiplier = 1;
if ( units === 'kb' ) { if ( units === 'kb' ) {
@ -31,6 +31,12 @@ jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
else if ( units === 'gb' ) { else if ( units === 'gb' ) {
multiplier = 1000000000; multiplier = 1000000000;
} }
else if ( units === 'tb' ) {
multiplier = 1000000000000;
}
else if ( units === 'pb' ) {
multiplier = 1000000000000000;
}
return parseFloat( data ) * multiplier; return parseFloat( data ) * multiplier;
}; };

Loading…
Cancel
Save