summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-04-22 03:06:14 +0200
committerDan McGee <dan@archlinux.org>2013-04-22 03:06:14 +0200
commitecf57207c0a5f90d51b6be551158ce7a0f82c9cb (patch)
tree2a8be71b4a5caeb9123166657e8ee31c5bd3a050
parentbb18fa3323a0494a2774ea61911572b089d04b6d (diff)
downloadarchweb-ecf57207c0a5f90d51b6be551158ce7a0f82c9cb.tar.gz
archweb-ecf57207c0a5f90d51b6be551158ce7a0f82c9cb.tar.xz
Fix sorting of file size values in jQuery tablesorter
The dumbass currency parser was matching values like '1.5 GB', causing the actual sorting to not work right since the magnitude values of GB values are obviously different than MB. Remove it fully from the parser list so our actual parser matches and we sort correctly. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--sitestatic/archweb.js16
-rw-r--r--templates/devel/packages.html2
2 files changed, 17 insertions, 1 deletions
diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js
index aa225f5..800c5ad 100644
--- a/sitestatic/archweb.js
+++ b/sitestatic/archweb.js
@@ -11,6 +11,7 @@ if (typeof $ !== 'undefined' && typeof $.tablesorter !== 'undefined') {
},
type: 'numeric'
});
+
$.tablesorter.addParser({
id: 'todostatus',
is: function(s) { return false; },
@@ -24,6 +25,7 @@ if (typeof $ !== 'undefined' && typeof $.tablesorter !== 'undefined') {
},
type: 'numeric'
});
+
$.tablesorter.addParser({
/* sorts numeric, but put '', 'unknown', and '∞' last. */
id: 'mostlydigit',
@@ -40,6 +42,7 @@ if (typeof $ !== 'undefined' && typeof $.tablesorter !== 'undefined') {
},
type: 'numeric'
});
+
$.tablesorter.addParser({
/* sorts duration; put '', 'unknown', and '∞' last. */
id: 'duration',
@@ -73,6 +76,7 @@ if (typeof $ !== 'undefined' && typeof $.tablesorter !== 'undefined') {
},
type: 'numeric'
});
+
$.tablesorter.addParser({
id: 'longDateTime',
re: /^(\d{4})-(\d{2})-(\d{2}) ([012]\d):([0-5]\d)(:([0-5]\d))?( (\w+))?$/,
@@ -96,6 +100,7 @@ if (typeof $ !== 'undefined' && typeof $.tablesorter !== 'undefined') {
},
type: 'numeric'
});
+
$.tablesorter.addParser({
id: 'filesize',
re: /^(\d+(?:\.\d+)?) (bytes?|[KMGTPEZY]i?B)$/,
@@ -141,6 +146,17 @@ if (typeof $ !== 'undefined' && typeof $.tablesorter !== 'undefined') {
},
type: 'numeric'
});
+
+ $.tablesorter.removeParser = function(id) {
+ $.tablesorter.parsers = $.grep($.tablesorter.parsers,
+ function(ele, i) {
+ return ele.id !== id;
+ });
+ };
+
+ // We don't use currency, and the parser is over-zealous at deciding it
+ // matches. Kill it from the parser selection.
+ $.tablesorter.removeParser('currency');
}
(function($) {
diff --git a/templates/devel/packages.html b/templates/devel/packages.html
index 0e6b175..d6aab49 100644
--- a/templates/devel/packages.html
+++ b/templates/devel/packages.html
@@ -86,7 +86,7 @@ $(document).ready(function() {
var filter_func = function() { filter_pkgs_list('#report_filter', '#dev-report-results tbody'); };
$('#report_filter input').change(filter_func);
$('#criteria_reset').click(function() { filter_pkgs_reset(filter_func); });
- // fire function on page load to ensure the current form selections take effect
+ // run on page load to ensure current form selections take effect
filter_func();
});
</script>