diff options
author | Dan McGee <dan@archlinux.org> | 2011-01-14 14:38:23 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-01-14 14:38:23 -0600 |
commit | 9538d3492eb0efef144b78a50035ce4e4deaf8d1 (patch) | |
tree | 080c34f029ff005c0bbf3b82eab5d02b12028936 /media/archweb.js | |
parent | 6285c379bac3fa05ecb3ccaccbe981d3573e290a (diff) |
Fix JS null error when parsing non-matching date
We didn't escape early with some value, causing an invalid dereference.
While fixing this, also touch up the other functions and move a few more
thngs to parser dictionary attributes.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'media/archweb.js')
-rw-r--r-- | media/archweb.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/media/archweb.js b/media/archweb.js index bbbc48b2..cf8acd15 100644 --- a/media/archweb.js +++ b/media/archweb.js @@ -21,14 +21,13 @@ if (typeof $.tablesorter !== 'undefined') { $.tablesorter.addParser({ /* sorts numeric, but put '', 'unknown', and '∞' last. */ id: 'mostlydigit', + special: ['', 'unknown', '∞'], is: function(s, table) { - var special = ['', 'unknown', '∞']; var c = table.config; - return ($.inArray(s, special) > -1) || $.tablesorter.isDigit(s, c); + return ($.inArray(s, this.special) > -1) || $.tablesorter.isDigit(s, c); }, format: function(s) { - var special = ['', 'unknown', '∞']; - if ($.inArray(s, special) > -1) return Number.MAX_VALUE; + if ($.inArray(s, this.special) > -1) return Number.MAX_VALUE; return $.tablesorter.formatFloat(s); }, type: 'numeric' @@ -37,14 +36,14 @@ if (typeof $.tablesorter !== 'undefined') { /* sorts duration; put '', 'unknown', and '∞' last. */ id: 'duration', re: /^([0-9]+):([0-5][0-9])$/, + special: ['', 'unknown', '∞'], is: function(s) { - var special = ['', 'unknown', '∞']; - return ($.inArray(s, special) > -1) || this.re.test(s); + return ($.inArray(s, this.special) > -1) || this.re.test(s); }, format: function(s) { - var special = ['', 'unknown', '∞']; - if ($.inArray(s, special) > -1) return Number.MAX_VALUE; + if ($.inArray(s, this.special) > -1) return Number.MAX_VALUE; var matches = this.re.exec(s); + if (!matches) return Number.MAX_VALUE; return matches[1] * 60 + matches[2]; }, type: 'numeric' @@ -57,6 +56,7 @@ if (typeof $.tablesorter !== 'undefined') { }, format: function(s) { var matches = this.re.exec(s); + if (!matches) return 0; /* skip group 6, group 7 is optional seconds */ if (matches[7] == undefined) matches[7] = '0'; return $.tablesorter.formatFloat(new Date( |