From: Calin Crisan Date: Sat, 18 Jan 2014 17:54:33 +0000 (+0200) Subject: media list entries are now sorted descending by timestamp X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=cbcc71146e0cca1be4e33d614a72fa42b4b2217e;p=motioneye-debian media list entries are now sorted descending by timestamp --- diff --git a/static/js/main.js b/static/js/main.js index 1ad741d..2c74ce9 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -124,15 +124,15 @@ Array.prototype.map = function (func, thisArg) { return mapped; }; -Array.prototype.sortKey = function (keyFunc) { +Array.prototype.sortKey = function (keyFunc, reverse) { this.sort(function (e1, e2) { var k1 = keyFunc(e1); var k2 = keyFunc(e2); - if (k1 < k2) { + if ((k1 < k2 && !reverse) || (k1 > k2 && reverse)) { return -1; } - else if (k1 > k2) { + else if ((k1 > k2 && !reverse) || (k1 < k2 && reverse)) { return 1; } else { @@ -1601,7 +1601,7 @@ function runMediaDialog(cameraId, mediaType) { }); /* sort the entries by timestamp */ - entries.sortKey(function (e) {return e.timestamp || e.name;}); + entries.sortKey(function (e) {return e.timestamp || e.name;}, true); addEntries(); });