]> code.delx.au - comingnext/blobdiff - comingNext/index.html
future improvements to italian translatios. Also updated credits.
[comingnext] / comingNext / index.html
index d66fd2917a992e14c4f05b49760e00b20ac8ea1c..0e80e7bf94c4a4cbe5764189495975d6c639f8a0 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
 \r
 <script>\r
-// valid types for the config object are 'Int', 'Bool', 'String', 'Enum', 'UID'\r
+// valid types for the config object are 'Int', 'Bool', 'String', 'Enum', 'UID', 'Array'\r
 var config = {\r
        monthRange: { Type: 'Int', Default: 2, Value: 2,},\r
        includeTodos: { Type: 'Bool', Default: true, Value: true,},\r
@@ -49,6 +55,8 @@ 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
+       excludedCalendars: { Type: 'Array', Default: '', Value: '',},\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 +68,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 +82,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.31";\r
 var versionURL = "http://comingnext.sourceforge.net/version.xml";\r
 var calendarService = null;\r
 var cacheEntriesHtml = [];\r
@@ -79,9 +93,11 @@ var mode = 0; // 0 = homescreen, 1 = fullscreen, 2 = settings, 3 = about, 4 = ch
 var reqV = null; \r
 var settingsCalEntryId = null;\r
 var settingsCache = null;\r
-var notificationRequest1;\r
-var notificationRequest2;\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
@@ -91,6 +107,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
@@ -298,13 +315,17 @@ function requestNotification()
 {\r
        var criteria = new Object();\r
        criteria.Type = "CalendarEntry";\r
-\r
-       try {\r
-               notificationRequest1 = calendarService.IDataSource.RequestNotification(criteria, callback);\r
-               if (notificationRequest1.ErrorCode)\r
-                       error('requestNotification failed with error code ' + notificationRequest1.ErrorCode);\r
-       } catch (e) {\r
-               error("requestNotification: " + e + ', line ' + e.line);\r
+       criteria.Filter = new Object();\r
+       for(var i=0; i < calendarList.length; i++) {\r
+               criteria.Filter.CalendarName = calendarList[i];\r
+               try {\r
+                       var notificationRequest = calendarService.IDataSource.RequestNotification(criteria, callback);\r
+                       if (notificationRequest.ErrorCode)\r
+                               error('requestNotification failed with error code ' + notificationRequest.ErrorCode);\r
+                       notificationRequests.push(notificationRequest);\r
+               } catch (e) {\r
+                       error("requestNotification: " + e + ', line ' + e.line);\r
+               }\r
        }\r
 \r
        var criteria2 = new Object();\r
@@ -312,16 +333,29 @@ function requestNotification()
        criteria2.Filter = new Object();\r
        criteria2.Filter.LocalIdList = new Array();\r
        criteria2.Filter.LocalIdList[0] = settingsCalEntryId;\r
-\r
        try {\r
-               notificationRequest2 = calendarService.IDataSource.RequestNotification(criteria2, settingsCallback);\r
-               if (notificationRequest2.ErrorCode)\r
-                       error('requestNotification failed with error code ' + notificationRequest2.ErrorCode);\r
+               var notificationRequest = calendarService.IDataSource.RequestNotification(criteria2, settingsCallback);\r
+               if (notificationRequest.ErrorCode)\r
+                       error('requestNotification failed with error code ' + notificationRequest.ErrorCode);\r
+               notificationRequests.push(notificationRequest);\r
        } catch (e) {\r
                error("requestNotification: " + e + ', line ' + e.line);\r
        }\r
 }\r
 \r
+function cancelNotification()\r
+{\r
+       for(var i=0; i < notificationRequests.length; i++) {\r
+               try {\r
+                       var result = calendarService.IDataSource.Cancel(notificationRequests[i]);\r
+                       if (result.ErrorCode)\r
+                               error('cancelNotification failed with error code ' + result.ErrorCode);\r
+               } catch (e) {\r
+                       error("cancelNotification: " + e + ', line ' + e.line);\r
+               }\r
+       }\r
+}\r
+\r
 function callback(transId, eventCode, result)\r
 {\r
        console.info("callback(): panelNum: %d  transId: %d  eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode);\r
@@ -480,6 +514,16 @@ function formatTime(date)
 function updateData()\r
 {\r
        console.info('updateData()');\r
+\r
+       // check if we got additional or less calendars since our last update\r
+       var newCalendarList = listCalendars();\r
+       if (newCalendarList.length != calendarList.length) {\r
+               calendarList = newCalendarList;\r
+               updateCalendarColors();\r
+               cancelNotification();\r
+               requestNotification();\r
+       }\r
+       \r
        try {\r
                // meetings have time\r
                // note: anniveraries have a start time of 12:00am. So since we want to include them, we have to query the whole day and check if events have passed later\r
@@ -487,6 +531,9 @@ function updateData()
                summertime = isSummertime(now); // cache summer time info for today\r
                var meetingList = [];\r
                for(var i=0; i < calendarList.length; i++) {\r
+                       // ignore excluded calendars\r
+                       if (config['excludedCalendars'].Value.indexOf(calendarList[i]) != -1)\r
+                               continue;\r
                        var meetingListFiltering = {\r
                                Type:'CalendarEntry',\r
                                Filter:{\r
@@ -499,7 +546,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
@@ -509,6 +556,9 @@ function updateData()
                if (config['includeTodos'].Value) {\r
                        var todayTodoList = [];\r
                        for(var i=0; i < calendarList.length; i++) {\r
+                               // ignore excluded calendars\r
+                               if (config['excludedCalendars'].Value.indexOf(calendarList[i]) != -1)\r
+                                       continue;\r
                                var todayTodoListFiltering = {\r
                                        Type:'CalendarEntry',\r
                                        Filter:{\r
@@ -520,7 +570,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
@@ -685,7 +735,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 - config['excludedCalendars'].Value.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
@@ -788,12 +842,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
@@ -804,10 +858,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
@@ -854,6 +924,16 @@ function showSettings()
                                if (config[key].ValidValues.indexOf(config[key].Value) == -1)\r
                                        config[key].Value = config[key].Default;\r
                        }\r
+                       else if (config[key].Type == 'Array') {\r
+                               if (key == 'excludedCalendars') {\r
+                                       config[key].Value = new Array();\r
+                                       for(var i=0; i < calendarList.length; i++) {\r
+                                               var element = document.forms[0].elements["settings." + key + "." + calendarList[i]];\r
+                                               if (element != null && element.checked == false)\r
+                                                       config[key].Value.push(calendarList[i]);\r
+                                       }\r
+                               }\r
+                       }\r
                }\r
                                \r
                updateCssClasses();\r
@@ -889,6 +969,18 @@ function showSettings()
                                settingsHtml += '<option value="' + config[key].ValidValues[i] + '"' + (config[key].Value == config[key].ValidValues[i] ? ' selected="selected"' : '') + '>' + getLocalizedText('settings.validValues.' + key + '.' + config[key].ValidValues[i]) + '</option>';\r
                        settingsHtml += '</select></div></td>' + printHintBox(getLocalizedText('settings.info.' + key)) + '<hr />';\r
                }\r
+               else if (config[key].Type == 'Array') {\r
+                       settingsHtml += '<table><tr><td>' + getLocalizedText('settings.name.' + key) + '<br />';\r
+                       if (key == 'excludedCalendars') {\r
+                               for(var i=0; i < calendarList.length; i++) {\r
+                                       var checked = 'checked="checked"';\r
+                                       if (config[key].Value.indexOf(calendarList[i]) != -1)\r
+                                               checked = '';\r
+                                       settingsHtml += '<input name="settings.' + key + '.' + calendarList[i] + '" type="checkbox" value="' + calendarList[i] + '" ' + checked + '/> ' + calendarList[i] + '<br />';\r
+                               }\r
+                       }\r
+                       settingsHtml += '</td>' + printHintBox(getLocalizedText('settings.info.' + key)) + '<hr />';\r
+               }\r
        }\r
        settingsHtml += '<input name="reset" type="button" value="' + getLocalizedText('settings.restoreDefaults') + '" onclick="javascript:restoreDefaultSettings();showSettings();" />';\r
        settingsHtml += '</form>';\r
@@ -1005,6 +1097,8 @@ function loadSettings()
                                        config[key].Value = value;\r
                                else if (config[key].Type == 'UID')\r
                                        config[key].Value = Number(value);\r
+                               else if (config[key].Type == 'Array')\r
+                                       config[key].Value = value.split("^");\r
                        }\r
                        settingsCache = entry.Summary;\r
                        updateCssClasses();\r
@@ -1038,6 +1132,8 @@ function saveSettings()
                        item.Summary += key + "=" + config[key].Value + "|";\r
                else if (config[key].Type == 'UID')\r
                        item.Summary += key + "=" + config[key].Value.toString() + "|";\r
+               else if (config[key].Type == 'Array')\r
+                       item.Summary += key + "=" + config[key].Value.join("^") + "|";\r
        }\r
        settingsCache = item.Summary;\r
        \r
@@ -1053,6 +1149,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
@@ -1251,7 +1350,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
@@ -1261,6 +1361,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
@@ -1334,6 +1438,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
@@ -1345,7 +1461,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
@@ -1380,8 +1496,10 @@ hr { color:#ffffff; background-color:#ffffff; height:1px; text-align:left; borde
                <p class="credits">Christophe Milsent (translation support & french translation)</p>\r
                <p class="credits">Flavio Nathan (portuguese-brazilian translation)</p>\r
                <p class="credits">Tokeda (russian translation)</p>\r
+               <p class="credits">Marcella Ferrari (italian translation)</p>\r
+               <p class="credits">Venos (italian 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