]> code.delx.au - comingnext/commitdiff
added more debug output to help fixing future sorting problems
authorMichael Prager <michael@pragers.de>
Wed, 13 Oct 2010 00:37:42 +0000 (02:37 +0200)
committerMichael Prager <michael@pragers.de>
Wed, 13 Oct 2010 00:37:42 +0000 (02:37 +0200)
also added some minor code cleanups

comingNext/index.html

index ce1215309905221e83fc8b9ee13cd31ba5e287d0..9b4b815a4b2524c8a1acaaee5b912cc1ce681d98 100644 (file)
@@ -488,6 +488,7 @@ function updateData()
                        var list = meetingResult.ReturnValue;\r
                        meetingList = meetingList.concat(listToArray(list));\r
                }\r
+               console.info("updateData(): meetingList.sort()");\r
                meetingList.sort(sortCalendarEntries);\r
 \r
                // todos don't, they start on 00:00 hrs., but should be visible anyway\r
@@ -508,6 +509,7 @@ function updateData()
                                var list = todayTodoResult.ReturnValue;\r
                                todayTodoList = todayTodoList.concat(listToArray(list));\r
                        }\r
+                       console.info("updateData(): todayTodoList.sort()");\r
                        todayTodoList.sort(sortCalendarEntries);\r
                        var entryLists = [todayTodoList, meetingList];\r
                } else {\r
@@ -548,6 +550,17 @@ function updateData()
                else\r
                        max = 30; // we can display a lot more events in fullscreen mode\r
 \r
+               var listinfo = "";\r
+               for (var i=0; i < entryLists.length; i++) {\r
+                       listinfo = listinfo + " " + entryLists[i].length;\r
+                       var entrieslist = "";\r
+                       for (var j=0; j < entryLists[i].length; j++) {\r
+                               entrieslist += entryLists[i][j].Summary + ", ";\r
+                       }\r
+                       console.info("updateData(): entrieslist: " + entrieslist);\r
+               }\r
+               console.info("updateData(): inner loop, " + entryLists.length + " lists, [" + listinfo + "] entries");\r
+               \r
                // the first outer loop iteration is for passed ToDos, the second loop is for all upcomming events (may also include ToDos)\r
                for (var i=0; counter < max && i < entryLists.length; i++) {\r
                        for (var j=0; (counter < max) && (j < entryLists[i].length); j++) {\r
@@ -555,17 +568,13 @@ function updateData()
                                counter++;\r
 \r
                                // output event info for debugging\r
-                               console.info(\r
-                                       'event: Id=' + entry.id + \r
-                                       ',Type=' + entry.Type + \r
-                                       ',Summary=' + entry.Summary + \r
-                                       ',Location=' + entry.Location + \r
-                                       ',Status=' + entry.Status + \r
-                                       ',StartTime=' + entry.StartTime +\r
-                                       ',EndTime=' + entry.EndTime +\r
-                                       ',InstanceStartTime=' + entry.InstanceStartTime +\r
-                                       ',InstanceEndTime=' + entry.InstanceEndTime\r
-                               );\r
+                               var entryInfo = "event: ";\r
+                               for(var k=0; k < entryFields.length; ++k) {\r
+                                       if (entry[entryFields[k]] != undefined) {\r
+                                               entryInfo += entryFields[k] + "=" + entry[entryFields[k]] + ",";\r
+                                       }\r
+                               }\r
+                               console.info(entryInfo);\r
 \r
                                // we don't want ToDos when includeTodos == false or when they are completed\r
                                if (entry.Type == 'ToDo' && (entry.Status == "TodoCompleted" || !config['includeTodos'].Value)) {\r
@@ -778,10 +787,12 @@ function init()
        else {\r
                mode = 1;\r
        }\r
+       console.info("init(): updateScreen()");\r
        updateScreen();\r
        if (config['useBackgroundImage'].Value)\r
                // check for screen rotation every 1 secs\r
                window.setInterval('updateScreen()', 1000 * 1);\r
+       console.info("init(): finished...");\r
 }\r
 \r
 function createMenu()\r
@@ -959,6 +970,7 @@ function loadSettings()
        }\r
        var entry = result.ReturnValue.getNext();\r
        if (entry != undefined) {\r
+               console.info("Loading Settings...");\r
                // only reload settings if they chanced since the last reload\r
                if (settingsCache != entry.Summary)\r
                {\r
@@ -984,6 +996,9 @@ function loadSettings()
                        settingsCache = entry.Summary;\r
                        updateCssClasses();\r
                }\r
+               else {\r
+                       console.info("Settings already cached and did not change");\r
+               }\r
        }\r
        else {\r
                error("Failed to load settings, calendar entry could not be found");\r
@@ -1067,6 +1082,7 @@ function updateFullscreen()
 \r
 function showFullscreen()\r
 {\r
+       console.info("showFullscreen()");\r
        hideViews();\r
        document.getElementById("fullscreenView").style.display = "block";\r
        document.getElementById('body').className = "backgroundFullscreen";\r
@@ -1111,6 +1127,7 @@ function updateHomescreen()
 \r
 function showHomescreen()\r
 {\r
+       console.info("showHomescreen()");\r
        hideViews();\r
        document.getElementById("homescreenView").style.display = "block";\r
        document.getElementById('body').className = "background";\r
@@ -1241,31 +1258,32 @@ function listToArray(list)
 function sortCalendarEntries(a, b)\r
 {\r
        var atime, btime;\r
+       console.info("sortCalendarEntries(" + a.Summary + "," + b.Summary + ")");\r
        \r
-       if (a['InstanceStartTime'] != null) {\r
-               atime = a['InstanceStartTime'];\r
+       if (a.InstanceStartTime != null) {\r
+               atime = a.InstanceStartTime;\r
        }\r
-       else if (a['StartTime'] != null) {\r
-               atime = a['StartTime'];\r
+       else if (a.StartTime != null) {\r
+               atime = a.StartTime;\r
        }\r
-       else if (a['InstanceEndTime'] != null) {\r
-               atime = a['InstanceEndTime'];\r
+       else if (a.InstanceEndTime != null) {\r
+               atime = a.InstanceEndTime;\r
        }\r
-       else if (a['EndTime'] != null) {\r
-               atime = a['EndTime'];\r
+       else if (a.EndTime != null) {\r
+               atime = a.EndTime;\r
        }\r
        \r
-       if (b['InstanceStartTime'] != null) {\r
-               btime = b['InstanceStartTime'];\r
+       if (b.InstanceStartTime != null) {\r
+               btime = b.InstanceStartTime;\r
        }\r
-       else if (b['StartTime'] != null) {\r
-               btime = b['StartTime'];\r
+       else if (b.StartTime != null) {\r
+               btime = b.StartTime;\r
        }\r
-       else if (b['InstanceEndTime'] != null) {\r
-               btime = b['InstanceEndTime'];\r
+       else if (b.InstanceEndTime != null) {\r
+               btime = b.InstanceEndTime;\r
        }\r
-       else if (b['EndTime'] != null) {\r
-               btime = b['EndTime'];\r
+       else if (b.EndTime != null) {\r
+               btime = b.EndTime;\r
        }\r
        \r
        if (atime && btime) {\r
@@ -1281,23 +1299,23 @@ function sortCalendarEntries(a, b)
                        return 1;\r
                }\r
                // sort by type\r
-               else if (a['Type'] != b['Type']) {\r
-                       if (a['Type'] < b['Type']) {\r
+               else if (a.Type != b.Type) {\r
+                       if (a.Type < b.Type) {\r
                                return -1;\r
                        }\r
-                       else if (a['Type'] > b['Type']) {\r
+                       else if (a.Type > b.Type) {\r
                                return 1;\r
                        }\r
                }\r
                // sort by description\r
-               else if (a['Summary'] && b['Summary'] && a['Summary'] != b['Summary']) {\r
-                       if (a['Summary'] < b['Summary']) {\r
+               else if (a.Summary && b.Summary && a.Summary != b.Summary) {\r
+                       if (a.Summary < b.Summary) {\r
                                return -1;\r
                        }\r
-                       else if (a['Summary'] > b['Summary']) {\r
+                       else if (a.Summary > b.Summary) {\r
                                return 1;\r
                        }\r
-               }               \r
+               }\r
        }\r
 \r
        return 0;\r