]> www.vanbest.org Git - motioneye-debian/commitdiff
media list entries are now sorted descending by timestamp
authorCalin Crisan <ccrisan@gmail.com>
Sat, 18 Jan 2014 17:54:33 +0000 (19:54 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 18 Jan 2014 17:54:33 +0000 (19:54 +0200)
static/js/main.js

index 1ad741d9013412a6af197e77e1b86fd861667cef..2c74ce91407ac699e50eb8f4bec64fed49196220 100644 (file)
@@ -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();
             });