]> code.delx.au - comingnext/blobdiff - comingNext/index.html
bumped version number for 1.30 release
[comingnext] / comingNext / index.html
index 9b4b815a4b2524c8a1acaaee5b912cc1ce681d98..383f8e158b4d3a7dbb1a848feb90412f799c8b1a 100644 (file)
@@ -47,7 +47,9 @@ var config = {
        showNothingText: { Type: 'Bool', Default: true, Value: true,},\r
        nothingText: { Type: 'String', Default: getLocalizedText('settings.default.nothingText'), Value: getLocalizedText('settings.default.nothingText'),},\r
        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
@@ -59,6 +61,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:#800000', Value: 'background-color:#800000',},\r
+       cssStyle_calendar2: { Type: 'String', Default: 'background-color:#ff0000', Value: 'background-color:#ff0000',},\r
+       cssStyle_calendar3: { Type: 'String', Default: 'background-color:#808000', Value: 'background-color:#808000',},\r
+       cssStyle_calendar4: { Type: 'String', Default: 'background-color:#ffff00', Value: 'background-color:#ffff00',},\r
+       cssStyle_calendar5: { Type: 'String', Default: 'background-color:#008000', Value: 'background-color:#008000',},\r
+       cssStyle_calendar6: { Type: 'String', Default: 'background-color:#008080', Value: 'background-color:#008080',},\r
 }\r
 \r
 \r
@@ -67,7 +75,7 @@ var config = {
 // Nothing of interest from here on...\r
 //-------------------------------------------------------\r
 var panelNum = 0; // use 1 for second panel\r
-var version = "1.28";\r
+var version = "1.30";\r
 var versionURL = "http://comingnext.sourceforge.net/version.xml";\r
 var calendarService = null;\r
 var cacheEntriesHtml = [];\r
@@ -78,19 +86,19 @@ 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
 \r
 // vars for daylight saving time\r
-var daylightsavingWinter = 0;\r
-var daylightsavingSummer = 0;\r
-var summertime = false;\r
+var summertime = false; // true, if current date is in summer, false if in winter\r
+var daylightSavingDates = new Object(); // caches calculated DST winter and summer time shift dates\r
 \r
 // this is a list of data fields a calendar event can have\r
 var entryFields = [\r
        "id",\r
        "Type",\r
+       "CalendarName",\r
        "Summary",\r
        "Location",\r
        "Status",\r
@@ -127,43 +135,48 @@ function subToSunday(myDate, year, days, prevMonthDays)
        days = isLeapYear(year) ? --days : days;\r
        return days;\r
 }\r
-       \r
-function calcDaylightSaving()\r
+\r
+function isSummertime(curDate)\r
 {\r
-       var thisYearS = new Date(now.getFullYear(),  3, 0, 0, 0, 0 );\r
-       var thisYearW = new Date(now.getFullYear(), 10, 0, 0, 0, 0 );\r
-       var nextYearS = new Date(now.getFullYear() + 1,  3, 0, 0, 0, 0 );\r
-       var nextYearW = new Date(now.getFullYear() + 1, 10, 0, 0, 0, 0 );\r
        var summer = false;\r
        var winter = false;\r
-       \r
-       thisYearSDays = nextYearSDays = 90;\r
-       thisYearWDays = nextYearWDays = 304;\r
-       \r
-       thisYearSDays = calcLeapYear(now.getFullYear(), thisYearSDays);\r
-       thisYearWDays = calcLeapYear(now.getFullYear(), thisYearWDays);\r
-       nextYearSDays = calcLeapYear(now.getFullYear() + 1, nextYearSDays);\r
-       nextYearWDays = calcLeapYear(now.getFullYear() + 1, nextYearWDays);\r
-       \r
-       thisYearSDays = subToSunday(thisYearS, now.getFullYear(), thisYearSDays, 59);\r
-       thisYearWDays = subToSunday(thisYearW, now.getFullYear(), thisYearWDays, 273);\r
-       nextYearSDays = subToSunday(nextYearS, now.getFullYear() + 1, nextYearSDays, 59);\r
-       nextYearWDays = subToSunday(nextYearW, now.getFullYear() + 1, nextYearWDays, 273);\r
-       \r
-       daylightsavingSummer = new Date (now.getFullYear(), 03-1, thisYearSDays, 2, 0, 0);\r
-       daylightsavingWinter = new Date (now.getFullYear(), 10-1, thisYearWDays, 2, 0, 0);\r
-       if (daylightsavingSummer < now) {\r
-               daylightsavingSummer = new Date (now.getFullYear()+1, 03-1, nextYearSDays, 2, 0, 0);\r
-               var summer = true;\r
-       }\r
-       if (daylightsavingWinter < now) {\r
-               daylightsavingWinter = new Date (now.getFullYear()+1, 10-1, nextYearWDays, 2, 0, 0);\r
-               var winter = true;\r
+\r
+       // if we already calculated DST summer and winter time dates for this year, use cached values\r
+       var dst = daylightSavingDates[curDate.getFullYear()];\r
+       if (!dst) {\r
+               var thisYearS = new Date(curDate.getFullYear(),  3, 0, 0, 0, 0 );\r
+               var thisYearW = new Date(curDate.getFullYear(), 10, 0, 0, 0, 0 );\r
+               var nextYearS = new Date(curDate.getFullYear() + 1,  3, 0, 0, 0, 0 );\r
+               var nextYearW = new Date(curDate.getFullYear() + 1, 10, 0, 0, 0, 0 );\r
+               \r
+               thisYearSDays = nextYearSDays = 90;\r
+               thisYearWDays = nextYearWDays = 304;\r
+               \r
+               thisYearSDays = calcLeapYear(curDate.getFullYear(), thisYearSDays);\r
+               thisYearWDays = calcLeapYear(curDate.getFullYear(), thisYearWDays);\r
+               nextYearSDays = calcLeapYear(curDate.getFullYear() + 1, nextYearSDays);\r
+               nextYearWDays = calcLeapYear(curDate.getFullYear() + 1, nextYearWDays);\r
+               \r
+               thisYearSDays = subToSunday(thisYearS, curDate.getFullYear(), thisYearSDays, 59);\r
+               thisYearWDays = subToSunday(thisYearW, curDate.getFullYear(), thisYearWDays, 273);\r
+               nextYearSDays = subToSunday(nextYearS, curDate.getFullYear() + 1, nextYearSDays, 59);\r
+               nextYearWDays = subToSunday(nextYearW, curDate.getFullYear() + 1, nextYearWDays, 273);\r
+               \r
+               dst = {\r
+                       Summer: new Date (curDate.getFullYear(), 03-1, thisYearSDays, 2, 0, 0),\r
+                       Winter: new Date (curDate.getFullYear(), 10-1, thisYearWDays, 2, 0, 0),\r
+               }\r
+               daylightSavingDates[curDate.getFullYear()] = dst;\r
        }\r
+\r
+       if (dst.Summer < curDate)\r
+               summer = true;\r
+       if (dst.Winter < curDate)\r
+               winter = true;\r
        if (summer && !winter)\r
-               summertime = true;\r
+               return true;\r
        else\r
-               summertime = false;\r
+               return false;\r
 }\r
 \r
 function error(message)\r
@@ -293,13 +306,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
@@ -307,16 +324,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
@@ -382,18 +412,26 @@ function parseDate(dateString)
        if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'am' && hours == 12)\r
                hours = 0;\r
 \r
-       console.info('year=' + year + ' month=' + month + ' day=' + day + ' hours=' + hours + ' minutes=' + minutes+ ' seconds=' + seconds);\r
-\r
+       var result = new Date(year, month - 1, day, hours, minutes, seconds);\r
+       \r
        // take care of daylight saving time\r
        if (config['enableDaylightSaving'].Value) {\r
-               var date = new Date(year, month - 1, day, hours, minutes, seconds);\r
-               if (summertime && date > daylightsavingWinter && date < daylightsavingSummer)\r
-                       hours -= 1;\r
-               else if (!summertime && date > daylightsavingSummer && date < daylightsavingWinter)\r
-                       hours += 1;\r
+               \r
+               // determine if date is in summer or winter time\r
+               var dateSummerTime = isSummertime(result);\r
+\r
+               // work around bug in Nokias calendar api resulting in dates within a different DST to be off by 1 hour\r
+               if (summertime && !dateSummerTime) {\r
+                       result = new Date(result.getTime() - 1000 * 60 * 60 * config['daylightSavingOffset'].Value); // -1 hour\r
+                       console.info('parseDate(): fixing time -1h: ' + result);\r
+               }\r
+               else if (!summertime && dateSummerTime) {\r
+                       result = new Date(result.getTime() + 1000 * 60 * 60 * config['daylightSavingOffset'].Value); // +1 hour\r
+                       console.info('parseDate(): fixing time +1h: ' + result);\r
+               }\r
        }\r
 \r
-       return new Date(year, month - 1, day, hours, minutes, seconds);\r
+       return result;\r
 }\r
 \r
 // returns a short date as string ("31.12" or "12.31") based on the format string which should look like "Wednesday,  26 August, 2009 12:00:00 am"\r
@@ -467,11 +505,21 @@ function formatTime(date)
 function updateData()\r
 {\r
        console.info('updateData()');\r
-       calcDaylightSaving();\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
                now = new Date();\r
+               summertime = isSummertime(now); // cache summer time info for today\r
                var meetingList = [];\r
                for(var i=0; i < calendarList.length; i++) {\r
                        var meetingListFiltering = {\r
@@ -672,7 +720,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 class="calendar' + calendarColors[entry.CalendarName] + '">&nbsp;</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
@@ -775,6 +827,7 @@ function init()
 \r
        calendarList = listCalendars();\r
        loadSettings();\r
+       updateCalendarColors();\r
        collectLocales();\r
        //updateData();\r
        requestNotification();\r
@@ -1320,6 +1373,18 @@ function sortCalendarEntries(a, b)
 \r
        return 0;\r
 }\r
+\r
+function updateCalendarColors()\r
+{\r
+       calendarColors = [];\r
+       if (calendarList.length > 6) {\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 % 6) + 1;\r
+       }\r
+}\r
+\r
 </script>\r
 \r
 <style type="text/css">\r
@@ -1367,7 +1432,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