first stab at sorting events before building day view
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 14 Nov 2010 23:56:45 +0000 (18:56 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 14 Nov 2010 23:56:45 +0000 (18:56 -0500)
kronolith/js/kronolithmobile.js

index d54b436..3d02747 100644 (file)
         }
     },
 
+    sortEvents: function(events)
+    {
+        return  events.sort(function(a, b) {
+           sortA = a.e.s;
+           sortB = b.e.s;
+           return (sortA < sortB) ? -1 : (sortA > sortB) ? 1 : 0;
+         });
+    },
+
     /**
      * Callback for the listEvents AJAX request.
      */
@@ -60,8 +69,9 @@
             });
         }
         if (KronolithMobile.loadedCalendars.length == KronolithMobile.calendars.length) {
+            var events = KronolithMobile.sortEvents(KronolithMobile.events);
             list = $('<ul>').attr({'data-role': 'listview'});
-            $.each(KronolithMobile.events, function(index, event) {
+            $.each(events, function(index, event) {
                 list.append(KronolithMobile.buildDayEvent(event.cal, event.e, event.id));
             });
             if (!list.children().length) {