]> code.delx.au - comingnext/commitdiff
- improve startup performance by calling init() in <body> - improved battery life...
authorMichael Prager <michael@pragers.de>
Tue, 29 Mar 2011 15:33:44 +0000 (17:33 +0200)
committerMichael Prager <michael@pragers.de>
Thu, 12 May 2011 15:06:18 +0000 (17:06 +0200)
comingNext/index.html

index 145ac249f3390de212d7c2c3b16e2d849805c653..19789fd9776933c66543a04028fcc50ede80c0e9 100644 (file)
@@ -123,17 +123,13 @@ var entryFields = [
        "InstanceEndTime"\r
 ];\r
 \r
-window.onload = init;\r
-window.onresize = updateScreen;\r
-window.onshow = updateScreen;\r
-\r
 function isLeapYear( year ) {\r
        if (( year % 4 == 0 && year % 100 != 0 ) || year % 400 == 0 )\r
                return true;\r
        else\r
                return false;\r
 }\r
-         \r
+
 function calcLeapYear(year, days)\r
 {\r
        if (isLeapYear(year))\r
@@ -816,8 +812,11 @@ function updateData()
        }\r
 }\r
 \r
+// called by handleOnShow() and onResize events
 function updateScreen()\r
 {\r
+       log('updateScreen()');
+
        // check if opening fullscreen\r
        if( window.innerHeight > 91 && mode == 0) {\r
                mode = 1;\r
@@ -832,10 +831,15 @@ function updateScreen()
        }\r
        \r
        if (mode == 0)\r
-               updateHomescreen();\r
+               updateHomescreen(); // check for screen rotation
        else if (mode == 1)\r
                updateFullscreen();\r
-       \r
+}
+
+function handleOnShow()
+{
+       updateScreen();
+
        var time = new Date();\r
        if (time.getTime() - lastUpdateTime.getTime() > config['updateDataInterval'].Value * 60 * 1000) {\r
                log('updateScreen(): force updateData() because last update was too long ago (' + (time.getTime() - lastUpdateTime.getTime()) / 1000 + 's)');
@@ -890,10 +894,21 @@ function init()
        updateScreen();\r
        if (config['useBackgroundImage'].Value)\r
                // check for screen rotation every 1 secs\r
-               screenRotationTimer = window.setInterval('updateScreen()', 1000 * 1);\r
+               screenRotationTimer = window.setInterval('checkOrientation()', 1000 * 1);
+       
+       // call updateScreen() when widget changes from background to forground
+       window.widget.onshow = handleOnShow;
+
        log("init(): finished...");
 }\r
 \r
+function checkOrientation()
+{
+       //updateScreen();
+       if (mode == 0)
+               updateHomescreen(); // check for screen rotation
+}
+
 function setUpdateTimer()\r
 {\r
        updateTimer = window.setInterval('updateTimerCallback()', 1000 * 60 * config['updateDataInterval'].Value);\r
@@ -1550,7 +1565,7 @@ hr { color:#ffffff; background-color:#ffffff; height:1px; text-align:left; borde
 \r
 </head>\r
 \r
-<body id="body" class="background">\r
+<body onload="javascript:init()" onresize="javascript:updateScreen()" id="body" class="background">
 <div id="homescreenView">\r
        <div id="calendarList"></div>\r
 </div>\r