summaryrefslogtreecommitdiff
path: root/media/archweb.js
diff options
context:
space:
mode:
Diffstat (limited to 'media/archweb.js')
-rw-r--r--media/archweb.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/media/archweb.js b/media/archweb.js
index 03358fa9..49f2a319 100644
--- a/media/archweb.js
+++ b/media/archweb.js
@@ -67,6 +67,36 @@ if (typeof $.tablesorter !== 'undefined') {
},
type: 'numeric'
});
+ $.tablesorter.addParser({
+ id: 'filesize',
+ re: /^(\d+(?:\.\d+)?) (bytes?|KB|MB|GB|TB|PB)$/,
+ is: function(s) {
+ return this.re.test(s);
+ },
+ format: function(s) {
+ var matches = this.re.exec(s);
+ if (!matches) return 0;
+ var size = parseFloat(matches[1]);
+ var suffix = matches[2];
+
+ switch(suffix) {
+ case 'byte':
+ case 'bytes':
+ return size;
+ case 'KB':
+ return size * 1024;
+ case 'MB':
+ return size * 1024 * 1024;
+ case 'GB':
+ return size * 1024 * 1024 * 1024;
+ case 'TB':
+ return size * 1024 * 1024 * 1024 * 1024;
+ case 'PB':
+ return size * 1024 * 1024 * 1024 * 1024 * 1024;
+ }
+ },
+ type: 'numeric'
+ });
}
/* news/add.html */