Skip to content

Commit

Permalink
add large file size support and remove whitespace before sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
xianzai committed Aug 24, 2015
1 parent 06611bf commit 0237135
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sorting/file-size.js
Expand Up @@ -19,7 +19,7 @@
*/

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;

if ( units === 'kb' ) {
Expand All @@ -31,6 +31,12 @@ jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
else if ( units === 'gb' ) {
multiplier = 1000000000;
}
else if ( units === 'tb' ) {
multiplier = 1000000000000;
}
else if ( units === 'pb' ) {
multiplier = 1000000000000000;
}

return parseFloat( data ) * multiplier;
};

0 comments on commit 0237135

Please sign in to comment.