Make tablesorter filesize sorter more flexible
Accept a few more prefixes, and also handle both 'MB' and 'MiB' style sizes. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
1f2466fffc
commit
c130414a47
@ -92,7 +92,7 @@ if (typeof $.tablesorter !== 'undefined') {
|
||||
});
|
||||
$.tablesorter.addParser({
|
||||
id: 'filesize',
|
||||
re: /^(\d+(?:\.\d+)?) (bytes?|KB|MB|GB|TB|PB)$/,
|
||||
re: /^(\d+(?:\.\d+)?) (bytes?|[KMGTPEZY]i?B)$/,
|
||||
is: function(s) {
|
||||
return this.re.test(s);
|
||||
},
|
||||
@ -106,15 +106,29 @@ if (typeof $.tablesorter !== 'undefined') {
|
||||
|
||||
switch(suffix) {
|
||||
/* intentional fall-through at each level */
|
||||
case 'YB':
|
||||
case 'YiB':
|
||||
size *= 1024;
|
||||
case 'ZB':
|
||||
case 'ZiB':
|
||||
size *= 1024;
|
||||
case 'EB':
|
||||
case 'EiB':
|
||||
size *= 1024;
|
||||
case 'PB':
|
||||
case 'PiB':
|
||||
size *= 1024;
|
||||
case 'TB':
|
||||
case 'TiB':
|
||||
size *= 1024;
|
||||
case 'GB':
|
||||
case 'GiB':
|
||||
size *= 1024;
|
||||
case 'MB':
|
||||
case 'MiB':
|
||||
size *= 1024;
|
||||
case 'KB':
|
||||
case 'KiB':
|
||||
size *= 1024;
|
||||
}
|
||||
return size;
|
||||
|
Loading…
Reference in New Issue
Block a user