]> code.delx.au - comingnext/blobdiff - comingNext/index.html
added info for T7-00 support (tested on Nokia RDA service). First working Anna device...
[comingnext] / comingNext / index.html
index 13745ef3f7e0007cfde8b0a3cb7b17af88735d63..518c31d5331c6053932d55d13c9dcd24e0a862f8 100644 (file)
@@ -83,7 +83,7 @@ var config = {
 // Nothing of interest from here on...\r
 //-------------------------------------------------------\r
 var panelNum = 0; // use 1 for second panel\r
-var version = "1.32";\r
+var version = "1.33";\r
 var versionURL = "http://comingnext.sourceforge.net/version.xml";\r
 var calendarService = null;\r
 var cacheEntriesHtml = [];\r
@@ -104,6 +104,7 @@ var lastReloadTime = null; // last time we fetched calendar data
 var reloadInterval = 6 * 60 * 60 * 1000; // = 6 hours; time interval for reloading calendar data\r
 var errorOccured = false;\r
 var entryLists = null; // stores all fetched calendar entries until data is refreshed\r
+var statupSuccessful = false; // indicates if everything started up wihtout errors. If we detect an error after that, it might just be a temporary problem e.g. by a backup process.\r
 \r
 // vars for daylight saving time\r
 var summertime = false; // true, if current date is in summer, false if in winter\r
@@ -240,7 +241,7 @@ function collectLocales()
                try {\r
                        var result = calendarService.IDataSource.Add(criteria);\r
                        if (result.ErrorCode)\r
-                               error(result.ErrorMessage);\r
+                               throw(result.ErrorMessage);\r
                } catch (e) {\r
                        error("collectLocales: " + e + ', line ' + e.line);\r
                }\r
@@ -258,13 +259,11 @@ function collectLocales()
                        }\r
                }\r
                var result = calendarService.IDataSource.GetList(listFiltering);\r
-               if (result.ErrorCode) {\r
-                       error(result.ErrorMessage);\r
-                       return;\r
-               }\r
+               if (result.ErrorCode)\r
+                       throw(result.ErrorMessage);\r
                var list = result.ReturnValue;\r
        } catch(e) {\r
-               error(e + ', line ' + e.line);\r
+               error("collectLocales: " + e + ', line ' + e.line);\r
                return;\r
        }\r
        var ids = new Array();\r
@@ -274,7 +273,7 @@ function collectLocales()
                var dateArr = [];\r
 \r
                while (list && (entry = list.getNext()) != undefined) {\r
-                       dateArr = entry.StartTime.replace(/,/g,'').replace(/\./g,':').replace(/  /g,' ').split(' ');\r
+                       dateArr = (entry.StartTime + '').replace(/,/g,'').replace(/\./g,':').replace(/  /g,' ').split(' ');\r
                        var day = dateArr[1];\r
                        var month = dateArr[2];\r
                        var year = dateArr[3];\r
@@ -296,7 +295,7 @@ function collectLocales()
                        counter++;\r
                }\r
        } catch(e) {\r
-               error(e + ', line ' + e.line);\r
+               error("collectLocales: " + e + ', line ' + e.line);\r
                return;\r
        }\r
        log(ids);\r
@@ -309,7 +308,7 @@ function collectLocales()
 \r
                var result = calendarService.IDataSource.Delete(criteria);\r
                if (result.ErrorCode)\r
-                       error(result.ErrorMessage);\r
+                       throw(result.ErrorMessage);\r
        } catch(e) {\r
                error('deleting temp calendar entries:' + e + ', line ' + e.line);\r
                return;\r
@@ -385,49 +384,58 @@ function parseDate(dateString)
        Wednesday,  2009 August, 28 8.00.00 pm\r
        Wednesday,  2009 August, 28 08:00:00 PM\r
        */\r
+       var result = null;\r
 \r
-       if (dateString == "" || dateString == null)\r
-               return null;\r
-       var dateArr = dateString.replace(/,/g,'').replace(/\./g,':').replace(/  /g,' ').split(' ');\r
-       if (dateArr.length != 5 && dateArr.length != 6)\r
-               return null;\r
-\r
-       // parse date\r
-       var weekDay = dateArr[0];\r
-       var day = dateArr[1];\r
-       var month = dateArr[2];\r
-       var year = dateArr[3];\r
-       // make sure month is set properly\r
-       if (isNaN(parseInt(day))) {\r
-               var tmp = day;\r
-               day = month;\r
-               month = tmp;\r
-       } else if (isNaN(parseInt(year))) {\r
-               var tmp = year;\r
-               year = month;\r
-               month = tmp;\r
+       if (dateString == "" || dateString == null || dateString == undefined)\r
+               return result;\r
+       if (dateString instanceof Date) {\r
+               // we already have a date object, no need to parse string here\r
+               result = dateString;\r
        }\r
-       // make sure day and year are set properly\r
-       if (Number(day) > Number(year)) {\r
-               var tmp = year;\r
-               year = day;\r
-               day = tmp;\r
+       else {\r
+               var dateArr = (dateString + '').replace(/,/g, '').replace(/\./g, ':').replace(/  /g, ' ').split(' ');\r
+               if (dateArr.length != 5 && dateArr.length != 6) \r
+                       return null;\r
+               \r
+               // parse date\r
+               var weekDay = dateArr[0];\r
+               var day = dateArr[1];\r
+               var month = dateArr[2];\r
+               var year = dateArr[3];\r
+               // make sure month is set properly\r
+               if (isNaN(parseInt(day))) {\r
+                       var tmp = day;\r
+                       day = month;\r
+                       month = tmp;\r
+               }\r
+               else \r
+                       if (isNaN(parseInt(year))) {\r
+                               var tmp = year;\r
+                               year = month;\r
+                               month = tmp;\r
+                       }\r
+               // make sure day and year are set properly\r
+               if (Number(day) > Number(year)) {\r
+                       var tmp = year;\r
+                       year = day;\r
+                       day = tmp;\r
+               }\r
+               month = months_translated[month];\r
+               \r
+               // parse time\r
+               var timeArr = dateArr[4].split(':');\r
+               if (timeArr.length != 3) \r
+                       return null;\r
+               var hours = Number(timeArr[0]);\r
+               var minutes = Number(timeArr[1]);\r
+               var seconds = Number(timeArr[2]);\r
+               if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'pm' && hours < 12) \r
+                       hours += 12;\r
+               if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'am' && hours == 12) \r
+                       hours = 0;\r
+               \r
+               result = new Date(year, month - 1, day, hours, minutes, seconds);\r
        }\r
-       month = months_translated[month];\r
-\r
-       // parse time\r
-       var timeArr = dateArr[4].split(':');\r
-       if (timeArr.length != 3)\r
-               return null;\r
-       var hours = Number(timeArr[0]);\r
-       var minutes = Number(timeArr[1]);\r
-       var seconds = Number(timeArr[2]);\r
-       if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'pm' && hours < 12)\r
-               hours += 12;\r
-       if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'am' && hours == 12)\r
-               hours = 0;\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
@@ -462,6 +470,13 @@ function formatDate(date, format)
        if (config['showTodayAsText'].Value && isTomorrow(date))\r
                return '<span class="tomorrow">' + config['tomorrowText'].Value + '</span>';\r
 \r
+       if (format instanceof Date) {\r
+               // we don't know how to format this\r
+               if (config['dateFormat'].Value == 'auto' || config['dateFormat'].Value == 'DDMM')\r
+                       return day + config['dateSeparator'].Value + month;\r
+               else\r
+                       return month + config['dateSeparator'].Value + day;\r
+       }\r
        var dateArr = format.replace(/,/g,'').replace(/\./g,':').replace(/  /g,' ').split(' ');\r
        if (dateArr.length != 5 && dateArr.length != 6) {\r
                // we don't know how to format this\r
@@ -526,6 +541,16 @@ function updateData()
 \r
        // check if we got additional or less calendars since our last update\r
        var newCalendarList = listCalendars();\r
+       if (newCalendarList == null) {\r
+               // Something went wrong fetching the calendars list.\r
+               // This usually happens when a backup is being made.\r
+               // Retry the next time updateData() is called by \r
+               // resetting errorOccured\r
+               log('updateData(): listCalendars() failed, trying again laster...');\r
+               cacheEntriesHtml = ''; // make sure we replace the currently shown error message on the next update\r
+               errorOccured = false;\r
+               return;\r
+       }\r
        if (newCalendarList.length != calendarList.length) {\r
                calendarList = newCalendarList;\r
                updateCalendarColors();\r
@@ -900,6 +925,8 @@ function init()
        window.widget.onshow = handleOnShow;\r
 \r
        log("init(): finished...");\r
+       if (!errorOccured)\r
+               statupSuccessful = true;\r
 }\r
 \r
 function checkOrientation()\r
@@ -1072,9 +1099,14 @@ function getSettingsCalEntryId()
                                Type: 'DayEvent'\r
                        }\r
                }\r
-               var result = calendarService.IDataSource.GetList(listFiltering);\r
-               if (result.ErrorCode) {\r
-                       error(result.ErrorMessage);\r
+               var result = null;\r
+               try {\r
+                       result = calendarService.IDataSource.GetList(listFiltering);\r
+                       if (result.ErrorCode)\r
+                               throw(result.ErrorMessage);\r
+               }\r
+               catch (e) {\r
+                       error("getSettingsCalEntryId: GetList() failed: " + e + ', line ' + e.line);\r
                        return;\r
                }\r
                var list = result.ReturnValue;\r
@@ -1096,7 +1128,7 @@ function getSettingsCalEntryId()
                        try {\r
                                var result = calendarService.IDataSource.Add(criteria);\r
                                if (result.ErrorCode)\r
-                                       error(result.ErrorMessage);\r
+                                       throw(result.ErrorMessage);\r
                        } catch (e) {\r
                                error("getSettingsCalEntryId: " + e + ', line ' + e.line);\r
                        }\r
@@ -1121,9 +1153,14 @@ function loadSettings()
                        LocalId: settingsCalEntryId\r
                }\r
        }\r
-       var result = calendarService.IDataSource.GetList(listFiltering);\r
-       if (result.ErrorCode) {\r
-               error(result.ErrorMessage);\r
+       var result = null;\r
+       try     {\r
+               result = calendarService.IDataSource.GetList(listFiltering);\r
+               if (result.ErrorCode)\r
+                       throw(result.ErrorMessage);\r
+       }\r
+       catch (e) {\r
+               error("loadSettings: GetList() failed: " + e + ', line ' + e.line);\r
                return;\r
        }\r
        var entry = result.ReturnValue.getNext();\r
@@ -1212,7 +1249,7 @@ function saveSettings()
        try {\r
                var result = calendarService.IDataSource.Add(criteria);\r
                if (result.ErrorCode)\r
-                       error(result.ErrorMessage);\r
+                       throw(result.ErrorMessage);\r
        } catch (e) {\r
                error("saveSettings: " + e + ', line ' + e.line);\r
        }\r
@@ -1291,14 +1328,22 @@ function getBackgroundImage()
 function updateHomescreen()\r
 {\r
        if (config['useBackgroundImage'].Value) {\r
+               // check if we have a completely unknown screen resolution\r
+               var screenHeight = screen.height;\r
+               var screenWidth = screen.width;\r
+               if (screenHeight != 640 && screenHeight != 480 && screenHeight != 360)\r
+                       screenHeight = 360; // we can only assume we're in portrait mode, so we set the screen dims as needed for the following code\r
+               if (screenWidth != 640 && screenWidth != 480 && screenWidth != 360)\r
+                       screenWidth = 640; // we can only assume we're in portrait mode, so we set the screen dims as needed for the following code\r
+               \r
                // check for screen rotation\r
-               if (orientation != 'portrait' && screen.width == 360 && screen.height == 640) {\r
+               if (orientation != 'portrait' && ((screenWidth == 360 && screenHeight == 640) || (screenWidth == 640 && screenHeight == 480))) {\r
                        window.widget.prepareForTransition("fade");\r
                        orientation = 'portrait';\r
                        document.getElementById('body').style.backgroundImage = 'url(' + getBackgroundImage() + ')';\r
                        document.getElementById('body').style.backgroundColor = 'none';\r
                        window.widget.performTransition();\r
-               } else if (orientation != 'landscape' && screen.width == 640 && screen.height == 360) {\r
+               } else if (orientation != 'landscape' && ((screenWidth == 640 && screenHeight == 360) || (screenWidth == 480 && screenHeight == 640))) {\r
                        window.widget.prepareForTransition("fade");\r
                        orientation = 'landscape';\r
                        document.getElementById('body').style.backgroundImage = 'url(' + getBackgroundImage() + ')';\r
@@ -1556,7 +1601,8 @@ function updateCalendarColors()
        }\r
 }\r
 \r
-function log(message) {\r
+function log(message)\r
+{\r
        if (config['enableLogging'].Value) {\r
                console.info(message);\r
        }\r