From 4312a6ddf160a284e7bc5b3e1f27bd7a38f08816 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 13 Aug 2014 15:03:30 +0200 Subject: Simplify sorting of history table Signed-off-by: Florian Pritz --- data/js/script.js | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'data/js/script.js') diff --git a/data/js/script.js b/data/js/script.js index ea9bac814..9e535643c 100644 --- a/data/js/script.js +++ b/data/js/script.js @@ -185,30 +185,19 @@ function fixedEncodeURIComponent (str) { }, type: 'numeric' }); - $.tablesorter.addParser({ - // set a unique id - id: 'mydate', - re: /t=([0-9]+)$/, - is: function(s) { - // return false so this parser is not auto detected - return false; - }, - format: function(s) { - var matches = this.re.exec(s); - if (!matches) { - return 0; + + $(".tablesorter").tablesorter({ + textExtraction: function(node) { + var attr = $(node).attr('data-sort-value'); + if (typeof attr !== 'undefined' && attr !== false) { + var intAttr = parseInt(attr); + if (!isNaN(intAttr)) { + return intAttr; + } + return attr; } - //console.log(s, matches); - return matches[1]; - }, - type: 'numeric' - }); - $("#upload_history:has(tbody tr)").tablesorter({ - headers: { - 0: {sorter: false}, - 4: {sorter: "mydate"}, - }, - sortList: [[4,1]], + return $(node).text(); + } }); } -- cgit v1.2.3-24-g4f1b