From c130414a478080519219872ebd842d139d1f139e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 4 Aug 2012 14:43:21 -0500 Subject: 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 --- sitestatic/archweb.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sitestatic') diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index 9e9bddf..1ddf4eb 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -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; -- cgit v1.2.3-24-g4f1b