summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-08 18:41:23 -0600
committerDan McGee <dan@archlinux.org>2011-01-08 18:41:23 -0600
commit2cc75b6939b43162a9c60f7d12159c7a1c9a707e (patch)
treecef0d3d0b40ade08f82b9347cecf8c9c733a3697 /media
parent09bccb50e7c1bcbe15ca4f0e26c2f82cd816accb (diff)
Add a long datetime parser to table sorting code
This comes into play on our new developer clocks page, where the last column was not sorting at all as expected. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'media')
-rw-r--r--media/archweb.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/media/archweb.js b/media/archweb.js
index c5025ded..1c80ab64 100644
--- a/media/archweb.js
+++ b/media/archweb.js
@@ -36,18 +36,34 @@ if(typeof $.tablesorter !== "undefined") {
$.tablesorter.addParser({
/* sorts duration; put '', 'unknown', and '∞' last. */
id: 'duration',
- is: function(s,table) {
+ re: /^([0-9]+):([0-5][0-9])$/,
+ is: function(s) {
var special = ['', 'unknown', '∞'];
- return ($.inArray(s, special) > -1) || /^[0-9]+:[0-5][0-9]$/.test(s);
+ return ($.inArray(s, special) > -1) || this.re.test(s);
},
format: function(s) {
var special = ['', 'unknown', '∞'];
if($.inArray(s, special) > -1) return Number.MAX_VALUE;
- matches = /^([0-9]+):([0-5][0-9])$/.exec(s);
+ var matches = this.re.exec(s);
return matches[1] * 60 + matches[2];
},
type: 'numeric'
});
+ $.tablesorter.addParser({
+ id: 'longDateTime',
+ re: /^(\d{4})-(\d{2})-(\d{2}) ([012]\d):([0-5]\d)(:([0-5]\d))?( (\w+))?$/,
+ is: function (s) {
+ return this.re.test(s);
+ },
+ format: function (s) {
+ var matches = this.re.exec(s);
+ /* skip group 6, group 7 is optional seconds */
+ if(matches[7] == undefined) matches[7] = "0";
+ return $.tablesorter.formatFloat(new Date(
+ matches[1],matches[2],matches[3],matches[4],matches[5],matches[7]).getTime());
+ },
+ type: "numeric"
+ });
}
/* news/add.html */