2009/dap/system-info battery-status.html,1.25,1.26

Update of /sources/public/2009/dap/system-info
In directory hutz:/tmp/cvs-serv16736

Modified Files:
	battery-status.html 
Log Message:
minor aesthetic tweaks; make the first example ten seconds which is a bit more realistic :)

Index: battery-status.html
===================================================================
RCS file: /sources/public/2009/dap/system-info/battery-status.html,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- battery-status.html	9 Jun 2011 11:55:38 -0000	1.25
+++ battery-status.html	10 Jun 2011 13:19:34 -0000	1.26
@@ -98,7 +98,7 @@
       </p>
       <p>
         The following example shows how a web-based email client could check
-        for new emails every second without knowledge of the battery status:
+        for new emails every ten seconds without knowledge of the battery status:
       </p>
       <pre class='example sh_javascript'>
         &lt;!DOCTYPE html&gt;
@@ -107,24 +107,19 @@
           &lt;title&gt;Email Client&lt;/title&gt;
           &lt;script&gt;
             var mail = {
-              INTERVAL_DEFAULT: 1000,
+              INTERVAL_DEFAULT: 10000,
               interval_current: null,
               timer: 0,
 
               check: function () {
-                console.log('Checking the server for new emails using ' +
-                  'an interval of ' + (mail.interval_current/1000) + ' s.');
+                console.log('Checking the server for new emails using an interval of ' + 
+                            (mail.interval_current/1000) + ' seconds.');
               }
             };
 
             window.onload = function () {
-              var interval = (!mail.interval_current) ?
-                mail.INTERVAL_DEFAULT : mail.interval_current;
-              
-              mail.timer = setInterval(function () {
-                mail.check();
-              }, interval);
-              
+              var interval = (!mail.interval_current) ? mail.INTERVAL_DEFAULT : mail.interval_current;
+              mail.timer = setInterval(function () { mail.check(); }, interval);
               mail.interval_current = interval;
             };
           &lt;/script&gt;
@@ -134,7 +129,7 @@
 
       </pre>
       <p>
-        The script will always check for emails every second, even if the
+        The script will always check for emails every ten seconds, even if the
         battery level is critically low and the device is not plugged in.
         This is an example of poor resource management.
       </p>
@@ -151,38 +146,29 @@
           &lt;script&gt;
             var mail = {
               INTERVAL_LOW_BATTERY: 1000 * 60 * 10,
-              INTERVAL_DEFAULT: 1000,
+              INTERVAL_DEFAULT: 10000,
               interval_current: null,
               timer: 0,
 
               check: function () {
-                console.log('Checking the server for new emails using ' +
-                  'an interval of ' + (mail.interval_current/1000) + ' s.');
+                console.log('Checking the server for new emails using an interval of ' + 
+                            (mail.interval_current/1000) + ' seconds.');
               }
             };
 
             window.onload = function () {
-              var interval = (!mail.interval_current) ?
-                mail.INTERVAL_DEFAULT : mail.interval_current;
-              
-              mail.timer = setInterval(function () {
-                mail.check();
-              }, interval);
-              
+              var interval = (!mail.interval_current) ? mail.INTERVAL_DEFAULT : mail.interval_current;
+              mail.timer = setInterval(function () { mail.check(); }, interval);
               mail.interval_current = interval;
             };
 
             window.onbatterystatus = function (battery) {
-              var interval = (!battery.isPlugged && battery.level &lt; 10) ?
-                mail.INTERVAL_LOW_BATTERY : mail.INTERVAL_DEFAULT;
+              var interval = (!battery.isPlugged &amp;&amp; battery.level &lt; 10) ? 
+                                                    mail.INTERVAL_LOW_BATTERY : mail.INTERVAL_DEFAULT;
 
               if (interval !== mail.interval_current) {
                 clearTimeout(mail.timer);
-
-                mail.timer = setInterval(function () {
-                  mail.check();
-                }, interval);
-
+                mail.timer = setInterval(function () { mail.check(); }, interval);
                 mail.interval_current = interval;
               }
             };

Received on Friday, 10 June 2011 13:19:41 UTC