]> code.delx.au - comingnext/blobdiff - comingNext/index.html
Revert "added NaN validation check for settings with numbers"
[comingnext] / comingNext / index.html
index fa571f566300b77acc0f5dace834e0d67f55f5d6..7e774b94776fc97fb990360e248f64f20c02d9f6 100644 (file)
@@ -98,6 +98,8 @@ var calendarList = [];
 var calendarColors = [];\r
 var updateTimer = null;\r
 var screenRotationTimer = null;\r
+var lastUpdateTime = now;\r
+var errorOccured = false;\r
 \r
 // vars for daylight saving time\r
 var summertime = false; // true, if current date is in summer, false if in winter\r
@@ -192,6 +194,9 @@ function error(message)
 {\r
        console.info('Error: ' + message);\r
        document.getElementById("calendarList").innerHTML = 'Error: ' + message;\r
+       document.getElementById("fullscreenCalendarList").innerHTML = 'Error: ' + message;\r
+       errorOccured = true;\r
+       document.onclick = null;\r
 }\r
 \r
 function areDatesEqual(date1, date2)\r
@@ -514,6 +519,9 @@ function formatTime(date)
 function updateData()\r
 {\r
        console.info('updateData()');\r
+       if (errorOccured) {\r
+               return;\r
+       }\r
 \r
        // check if we got additional or less calendars since our last update\r
        var newCalendarList = listCalendars();\r
@@ -786,6 +794,8 @@ function updateData()
                                document.getElementById('fullscreenCalendarList').innerHTML = entriesHtml;\r
                        cacheEntriesHtml = entriesHtml;\r
                }\r
+               \r
+               lastUpdateTime = new Date();\r
        } catch(e) {\r
                error('displaying list:' + e + ', line ' + e.line);\r
                return;\r
@@ -811,6 +821,14 @@ function updateScreen()
                updateHomescreen();\r
        else if (mode == 1)\r
                updateFullscreen();\r
+       \r
+       var time = new Date();\r
+       if (time.getTime() - lastUpdateTime.getTime() > config['updateDataInterval'].Value * 60 * 1000) {\r
+               console.info('updateScreen(): force updateData() because last update was too long ago (' + (time.getTime() - lastUpdateTime.getTime()) / 1000 + 's)');\r
+               clearUpdateTimer();\r
+               updateData();\r
+               setUpdateTimer(); // reinitialize update timer\r
+       }\r
 }\r
 \r
 function launchCalendar()\r
@@ -836,8 +854,8 @@ function init()
                else\r
                        throw('device object does not exist');\r
        } catch(e) {\r
-               error('loading Calendar service: ' + e + ', line ' + e.line);\r
-               return;\r
+               error('loading Calendar service: ' + e + ', line ' + e.line + '<br /><a onclick="widget.openURL(\'http://comingnext.sf.net/help\'); return false;" href="http://comingnext.sf.net/help">' + getLocalizedText('menu.help') + '</a>');\r
+               //return;\r
        }\r
 \r
        calendarList = listCalendars();\r
@@ -885,15 +903,18 @@ function createMenu()
        var id = 0;\r
        var menuSettings = new MenuItem(getLocalizedText('menu.settings'), id++);\r
        var menuCallApp = new MenuItem(getLocalizedText('menu.openCalendarApp'), id++);\r
+       var menuHelp = new MenuItem(getLocalizedText('menu.help'), id++);\r
        var menuUpdate = new MenuItem(getLocalizedText('menu.update'), id++);\r
        var menuAbout = new MenuItem(getLocalizedText('menu.about'), id++);\r
        menuSettings.onSelect = showSettings;\r
        menuAbout.onSelect = showAbout;\r
        menuCallApp.onSelect = launchCalendar;\r
        menuUpdate.onSelect = showUpdate;\r
+       menuHelp.onSelect = showHelp;\r
        window.menu.clear();\r
        window.menu.append(menuCallApp);\r
        window.menu.append(menuSettings);\r
+       window.menu.append(menuHelp);\r
        window.menu.append(menuUpdate);\r
        window.menu.append(menuAbout);  \r
 }\r
@@ -1192,6 +1213,10 @@ function showAbout()
        document.getElementById("name").innerHTML = "Coming Next " + version;\r
 }\r
 \r
+function showHelp() {\r
+       widget.openURL('http://comingnext.sf.net/help');\r
+}\r
+\r
 function updateFullscreen()\r
 {\r
 }\r
@@ -1202,13 +1227,16 @@ function showFullscreen()
        hideViews();\r
        document.getElementById("fullscreenView").style.display = "block";\r
        document.getElementById('body').className = "backgroundFullscreen";\r
-       document.onclick = launchCalendar;\r
+       if (!errorOccured)\r
+               document.onclick = launchCalendar;\r
        createMenu();\r
        updateData();\r
 }\r
 \r
 function getBackgroundImage()\r
 {\r
+       if (errorOccured)\r
+               return '';\r
        var bgImage;\r
        if (config['backgroundImageLocation'].Value == config['backgroundImageLocation'].ValidValues[0]) // internal\r
                bgImage = 'background_' + orientation + '.png';\r
@@ -1484,6 +1512,7 @@ function updateCalendarColors()
 </script>\r
 \r
 <style type="text/css">\r
+a { color:#aaccff }\r
 table { margin:0px; padding:0px; border-spacing:0px; }\r
 td { padding:0px 5px 0px 0px; white-space:nowrap; overflow:hidden; }\r
 hr { color:#ffffff; background-color:#ffffff; height:1px; text-align:left; border-style:none; }\r
@@ -1530,7 +1559,7 @@ hr { color:#ffffff; background-color:#ffffff; height:1px; text-align:left; borde
                <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 <a onclick="widget.openURL('http://sourceforge.net/projects/comingnext'); return false;" href="http://sourceforge.net/projects/comingnext">sourceforge.net/projects/comingnext</a> for free updates.</p>\r
+       <p>Visit <a onclick="widget.openURL('http://comingnext.sf.net/'); return false;" href="http://comingnext.sf.net/">comingnext.sf.net</a> for free updates.</p>\r
        <hr />\r
 </div>\r
 <div id="updateView" style="display:none">\r