summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-08-04 21:43:21 +0200
committerDan McGee <dan@archlinux.org>2012-08-04 22:11:27 +0200
commitc130414a478080519219872ebd842d139d1f139e (patch)
treeaa41d5a7c6652b9d976d10c4367b3f16c5592ffe
parent1f2466fffceafebfaca34e3ed2d34de6b622768b (diff)
downloadarchweb-c130414a478080519219872ebd842d139d1f139e.tar.gz
archweb-c130414a478080519219872ebd842d139d1f139e.tar.xz
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>
-rw-r--r--sitestatic/archweb.js16
1 files changed, 15 insertions, 1 deletions
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;