]> code.delx.au - comingnext/blobdiff - comingNext/index.html
fixed update timer not being updated when changing update interval in settings
[comingnext] / comingNext / index.html
index 1afd1a098a56967225bcdbf48defdc94378c7c71..f098716ed7d9b87159b2cc9ff3fdb910a6b70bed 100644 (file)
 .description { }\r
 .icon { }\r
 .overdue {}\r
+.calendar1 {}\r
+.calendar2 {}\r
+.calendar3 {}\r
+.calendar4 {}\r
+.calendar5 {}\r
+.calendar6 {}\r
 </style>\r
 \r
 <script type="text/javascript" src="localizedTextStrings.js" charset="utf-8" />\r
@@ -49,6 +55,7 @@ var config = {
        enableDaylightSaving: { Type: 'Bool', Default: true, Value: true,},\r
        daylightSavingOffset: { Type: 'Int', Default: 1, Value: 1,},\r
        hideWidgetOnCalendarOpen: { Type: 'Bool', Default: false, Value: false,},\r
+       showCalendarIndicator: { Type: 'Bool', Default: true, Value: true,},\r
        cssStyle_background: { Type: 'String', Default: 'color:#ffffff; background-color:#000000', Value: 'color:#ffffff; background-color:#000000',},\r
        cssStyle_backgroundFullscreen: { Type: 'String', Default: 'color:#ffffff; background-color:#000000', Value: 'color:#ffffff; background-color:#000000',},\r
        cssStyle_weekDay: { Type: 'String', Default: '', Value: '',},\r
@@ -60,6 +67,12 @@ var config = {
        cssStyle_description: { Type: 'String', Default: '', Value: '',},\r
        cssStyle_icon: { Type: 'String', Default: 'width:15px; height:15px', Value: 'width:15px; height:15px',},\r
        cssStyle_overdue: { Type: 'String', Default: 'color:#ffff00', Value: 'color:#ffff00',},\r
+       cssStyle_calendar1: { Type: 'String', Default: 'background-color:#0757cf', Value: 'background-color:#0757cf',},\r
+       cssStyle_calendar2: { Type: 'String', Default: 'background-color:#579f37', Value: 'background-color:#579f37',},\r
+       cssStyle_calendar3: { Type: 'String', Default: 'background-color:#ff9f07', Value: 'background-color:#ff9f07',},\r
+       cssStyle_calendar4: { Type: 'String', Default: 'background-color:#af8fef', Value: 'background-color:#af8fef',},\r
+       cssStyle_calendar5: { Type: 'String', Default: 'background-color:#57afbf', Value: 'background-color:#57afbf',},\r
+       cssStyle_calendar6: { Type: 'String', Default: 'background-color:#9fdf57', Value: 'background-color:#9fdf57',},\r
 }\r
 \r
 \r
@@ -68,7 +81,7 @@ var config = {
 // Nothing of interest from here on...\r
 //-------------------------------------------------------\r
 var panelNum = 0; // use 1 for second panel\r
-var version = "1.29";\r
+var version = "1.30";\r
 var versionURL = "http://comingnext.sourceforge.net/version.xml";\r
 var calendarService = null;\r
 var cacheEntriesHtml = [];\r
@@ -81,6 +94,9 @@ var settingsCalEntryId = null;
 var settingsCache = null;\r
 var notificationRequests = new Array();\r
 var calendarList = [];\r
+var calendarColors = [];\r
+var updateTimer = null;\r
+var screenRotationTimer = null;\r
 \r
 // vars for daylight saving time\r
 var summertime = false; // true, if current date is in summer, false if in winter\r
@@ -90,6 +106,7 @@ var daylightSavingDates = new Object(); // caches calculated DST winter and summ
 var entryFields = [\r
        "id",\r
        "Type",\r
+       "CalendarName",\r
        "Summary",\r
        "Location",\r
        "Status",\r
@@ -331,9 +348,9 @@ function cancelNotification()
                try {\r
                        var result = calendarService.IDataSource.Cancel(notificationRequests[i]);\r
                        if (result.ErrorCode)\r
-                               error('requestNotification failed with error code ' + result.ErrorCode);\r
+                               error('cancelNotification failed with error code ' + result.ErrorCode);\r
                } catch (e) {\r
-                       error("requestNotification: " + e + ', line ' + e.line);\r
+                       error("cancelNotification: " + e + ', line ' + e.line);\r
                }\r
        }\r
 }\r
@@ -501,6 +518,7 @@ function updateData()
        var newCalendarList = listCalendars();\r
        if (newCalendarList.length != calendarList.length) {\r
                calendarList = newCalendarList;\r
+               updateCalendarColors();\r
                cancelNotification();\r
                requestNotification();\r
        }\r
@@ -524,7 +542,7 @@ function updateData()
                        if (meetingResult.ErrorCode != 0)\r
                                throw("Error fetching calendar data: " + meetingResult.ErrorCode + ': ' + meetingResult.ErrorMessage);\r
                        var list = meetingResult.ReturnValue;\r
-                       meetingList = meetingList.concat(listToArray(list));\r
+                       meetingList = meetingList.concat(listToArray(list, calendarList[i]));\r
                }\r
                console.info("updateData(): meetingList.sort()");\r
                meetingList.sort(sortCalendarEntries);\r
@@ -545,7 +563,7 @@ function updateData()
                                }\r
                                var todayTodoResult = calendarService.IDataSource.GetList(todayTodoListFiltering);\r
                                var list = todayTodoResult.ReturnValue;\r
-                               todayTodoList = todayTodoList.concat(listToArray(list));\r
+                               todayTodoList = todayTodoList.concat(listToArray(list, calendarList[i]));\r
                        }\r
                        console.info("updateData(): todayTodoList.sort()");\r
                        todayTodoList.sort(sortCalendarEntries);\r
@@ -710,7 +728,11 @@ function updateData()
                                }\r
 \r
                                // generate html output\r
-                               entriesHtml += '<tr><td><img class="icon" src="' + entry.Type + '.png" /></td>';\r
+                               entriesHtml += '<tr>';\r
+                               if (config['showCalendarIndicator'].Value && calendarList.length > 1) {\r
+                                       entriesHtml += '<td><span class="calendar' + calendarColors[entry.CalendarName] + '">&nbsp;</span></td>';\r
+                               }\r
+                               entriesHtml += '<td><img class="icon" src="' + entry.Type + '.png" /></td>';\r
                                if(date == null) {\r
                                        // some languages have very strange locale date formats, can't parse all those. Also some todos don't have dates at all.\r
                                        entriesHtml += '<td colspan="4"><span class="date">' + entryDate + '</span> ';\r
@@ -813,12 +835,12 @@ function init()
 \r
        calendarList = listCalendars();\r
        loadSettings();\r
+       updateCalendarColors();\r
        collectLocales();\r
        //updateData();\r
        requestNotification();\r
-       window.setInterval('updateData()', 1000 * 60 * config['updateDataInterval'].Value);\r
        document.getElementById("settingsTitle").innerHTML = getLocalizedText('menu.settings');\r
-\r
+       setUpdateTimer();\r
        if (window.innerHeight > 91) {\r
                mode = 0; // we're starting fullscreen, we set mode to homescreen in order to let updateScreen() do all the work for us\r
        }\r
@@ -829,10 +851,26 @@ function init()
        updateScreen();\r
        if (config['useBackgroundImage'].Value)\r
                // check for screen rotation every 1 secs\r
-               window.setInterval('updateScreen()', 1000 * 1);\r
+               screenRotationTimer = window.setInterval('updateScreen()', 1000 * 1);\r
        console.info("init(): finished...");\r
 }\r
 \r
+function setUpdateTimer()\r
+{\r
+       updateTimer = window.setInterval('updateTimerCallback()', 1000 * 60 * config['updateDataInterval'].Value);\r
+}\r
+\r
+function clearUpdateTimer() \r
+{\r
+       window.clearInterval(updateTimer);\r
+}\r
+\r
+function updateTimerCallback()\r
+{\r
+       console.info("updateTimerCallback()");\r
+       updateData();\r
+}\r
+\r
 function createMenu()\r
 {\r
        window.menu.setLeftSoftkeyLabel("",null);\r
@@ -1078,6 +1116,9 @@ function saveSettings()
        } catch (e) {\r
                error("saveSettings: " + e + ', line ' + e.line);\r
        }\r
+       \r
+       clearUpdateTimer();\r
+       setUpdateTimer();\r
 }\r
 \r
 function toggleVisibility(elementId)\r
@@ -1276,7 +1317,8 @@ function listCalendars()
 }\r
 \r
 // Copies all objects and their properties to an array. Data is copied so nothing gets lost when the reference is removed\r
-function listToArray(list)\r
+// Note: this will also set the "CalendarName" property of every entry to the name specified by the calendarName parameter if it has not been defined already\r
+function listToArray(list, calendarName)\r
 {\r
        var array = new Array();\r
        var item;\r
@@ -1286,6 +1328,10 @@ function listToArray(list)
                for(var i=0; i < entryFields.length; i++) {\r
                        itemCopy[entryFields[i]] = item[entryFields[i]];\r
                }\r
+               // for some reason, the CalendarName property is never correctly queried, so we assign it manually here\r
+               if (!itemCopy['CalendarName']) {\r
+                       itemCopy['CalendarName'] = calendarName;\r
+               }\r
                array.push(itemCopy);\r
                txt += array[array.length - 1].Summary + ", ";\r
        }\r
@@ -1359,6 +1405,18 @@ function sortCalendarEntries(a, b)
        return 0;\r
 }\r
 \r
+function updateCalendarColors()\r
+{\r
+       var maxColors = 6;\r
+       calendarColors = [];\r
+       if (calendarList.length > maxColors) {\r
+               console.info("updateCalendarColors(): Warning: more calendars than available indicator colors");\r
+       }\r
+       for(var i=0; i < calendarList.length; i++) {\r
+               calendarColors[calendarList[i]] = (i % maxColors) + 1;\r
+       }\r
+}\r
+\r
 </script>\r
 \r
 <style type="text/css">\r
@@ -1370,7 +1428,7 @@ hr { color:#ffffff; background-color:#ffffff; height:1px; text-align:left; borde
 .textInput { width:90%; }\r
 .credits { margin-left:40px; text-indent: -20px; margin-bottom:0px; }\r
 #homescreenView { width: 315px; height:91px; overflow:hidden; }\r
-#calendarList { position:absolute; left:10px; top:4px; width:295px; height:75px; overflow:hidden; }\r
+#calendarList { position:absolute; left:5px; top:4px; width:295px; height:75px; overflow:hidden; }\r
 #name { text-align:center; }\r
 #appicon { display: block; margin-left: auto; margin-right: auto; margin-top: 10px; }\r
 #smallappicon { width:22px; height:22px; margin-right:10px; float:left; }\r
@@ -1406,7 +1464,7 @@ hr { color:#ffffff; background-color:#ffffff; height:1px; text-align:left; borde
                <p class="credits">Flavio Nathan (portuguese-brazilian translation)</p>\r
                <p class="credits">Tokeda (russian translation)</p>\r
        <p>This software is open source and licensed under the GPLv3.</p>\r
-       <p>Visit sourceforge.net/projects/comingnext for free updates.</p>\r
+       <p>Visit <a href="http://sourceforge.net/projects/comingnext">sourceforge.net/projects/comingnext</a> for free updates.</p>\r
        <hr />\r
 </div>\r
 <div id="updateView" style="display:none">\r