2009/dap/system-info battery-status.html,1.59,1.60

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

Modified Files:
	battery-status.html 
Log Message:
change BatteryManager attributes based on Mozilla's feedback: change DOMString 'chargingState' to boolean 'charging', rename 'remaining' to 'remainingTime', add 'chargingTime'

Index: battery-status.html
===================================================================
RCS file: /sources/public/2009/dap/system-info/battery-status.html,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- battery-status.html	24 Oct 2011 10:32:32 -0000	1.59
+++ battery-status.html	25 Oct 2011 09:56:16 -0000	1.60
@@ -145,18 +145,18 @@
             
             var battery = navigator.battery;
             
-            battery.addEventListener('remainingchange', function () {
-              if (battery.chargingState === 'discharging' && battery.remaining < 60 * 30) {
+            battery.addEventListener('remainingtimechange', function () {
+              if (battery.remainingTime < 60 * 30) {
                 mail.setTimer(mail.INTERVAL_BATTERY_LOW);
                 console.log('30 minutes remaining, checking the server less frequently.');
-              } else if (battery.chargingState === 'discharging' && battery.remaining < 60 * 10) {
+              } else if (battery.remainingTime < 60 * 10) {
                 mail.setTimer(null);
                 console.log('10 minutes remaining, stop checking the server.');
               }
             }, false);
             
-            battery.addEventListener('chargingstatechange', function () {
-              if (battery.chargingState === 'charging') {
+            battery.addEventListener('chargingchange', function () {
+              if (battery.charging) {
                 mail.setTimer(mail.INTERVAL_DEFAULT);
                 console.log('Battery is charging, checking the server normally.');
               }
@@ -189,32 +189,36 @@
         </dd>
       </dl>
     </section>
+    
     <section>
       <h2><a>BatteryManager</a> Interface</h2>
       <dl title='[NoInterfaceObject]
                  interface BatteryManager : EventTarget'
           class='idl'>
-        <dt>readonly attribute DOMString chargingState</dt>
+        <dt>readonly attribute boolean charging</dt>
         <dd>
-          Represents the charging state of the battery. The attribute MUST be
-          set to the string <code>charging</code> if the battery is charging,
-          to the string <code>discharging</code>, if the battery is
-          discharging, to the string <code>full</code> if the battery is full,
-          or to the string <code>full</code> otherwise. The attribute MUST
-          be set to to the string <code>full</code> if the implementation is
-          unable to report the battery's level, or there is no battery
-          attached to the system.
+          Represents if the system's battery is charging. The attribute MUST be
+          set to true if the battery is charging, and set to false otherwise,
+          or if the implementation is unable to report the state, or there is
+          no battery attached to the system.
+        </dd>
+        <dt>readonly attribute double chargingTime</dt>
+        <dd>
+          Represents the time remaining in seconds until the system's battery
+          is fully charged. The attribute MUST be set to 0, if the battery is
+          full or not charging, or if the implementation is unable to report
+          the remaining charging time, or there is no battery attached to the
+          system.
         </dd>
         <dt>readonly attribute float level</dt>
         <dd>
-          Represents the current battery level scaled from <code>0</code> to
-          <code>1.0</code>. The attribute MUST be set to <code>0</code> if the
-          system's battery is depleted and the system is about to be suspended,
-          and to <code>1.0</code> if the battery is full, the implementation is
-          unable to report the battery's level, or there is no battery attached
-          to the system.
+          Represents the current battery level scaled from 0 to 1.0. The
+          attribute MUST be set to 0 if the system's battery is depleted and
+          the system is about to be suspended, and to 1.0 if the battery is
+          full, the implementation is unable to report the battery's level,
+          or there is no battery attached to the system.
         </dd>
-        <dt>readonly attribute double remaining</dt>
+        <dt>readonly attribute double remainingTime</dt>
         <dd>
           Represents the time remaining in seconds until the system's battery
           is depleted and the system is about to be suspended. The attribute
@@ -222,42 +226,42 @@
           unable to report the time remaining, or there is no battery attached
           to the system.
         </dd>
-        <dt>attribute Function? onchargingstatechange</dt>
+        <dt>attribute Function? onchargingchange</dt>
+        <dd>
+        </dd>
+        <dt>attribute Function? onchargingtimechange</dt>
         <dd>
         </dd>
         <dt>attribute Function? onlevelchange</dt>
         <dd>
         </dd>
-        <dt>attribute Function? onremainingchange</dt>
+        <dt>attribute Function? onremainingtimechange</dt>
         <dd>
         </dd>
       </dl>
       <p>
-        When a <code>Document</code> object is created,
-        <code>chargingState</code> MUST be set to the string <code>full</code>,
-        <code>level</code> to the value of <code>1.0</code> and
-        <code>remaining</code> to the value positive Infinity, if the implementation
-        is unable to report the battery's charging state, battery's level or
-        time remaining respectively.
+        When a <code>Document</code> object is created, <code>charging</code>
+        MUST be set to false, <code>chargingTime</code> to 0,
+        <code>level</code> to 1.0 and <code>remainingTime</code> to the value
+        positive Infinity, if the implementation is unable to report the
+        battery's charging state, charging time, level or remaining time
+        respectively.
       </p>
       <p>
-        When the value of <code>chargingState</code>, <code>level</code> or
-        <code>remaining</code> attribute changes, the
+        When the value of <code>charging</code>, <code>chargingTime</code>,
+        <code>level</code> or <code>remainingTime</code> attribute changes, the
         <a class="product-ua" href="#ua">user agent</a> MUST fire a simple
         event [[!HTML5]], which does not bubble and is not cancelable, named
-        <code>chargingstatechange</code>, <code>levelchange</code> or
-        <code>remainingchange</code> respectively at the <a>BatteryManager</a>
-        object.
+        <code>chargingchange</code>, <code>chargingtimechange</code>, 
+        <code>levelchange</code> or <code>remainingtimechange</code>
+        respectively at the <a>BatteryManager</a> object.
       </p>
       <div class="issue">
-        TODO: The <code>remainingchange</code> event should not be fired
-        too often, so it should be rate limited. For example, firing every
-        second is probably too often. Otherwise web developers will
-        need to resort to event throttling which is inefficient.
-      </div>
-      <div class="issue">
-        TODO: An alternative design which is being discussed is to replace
-        <code>chargingState</code> with <code>charging</code> of type boolean.
+        TODO: The <code>chargingtimechange</code> and
+        <code>remainingtimechange</code> events should not be fired too often,
+        so they should be rate limited. For example, firing every second is
+        probably too often. Otherwise web developers will need to resort to
+        event throttling which is inefficient.
       </div>
     </section>
 
@@ -298,23 +302,23 @@
             &lt;script&gt;
               var battery = navigator.battery;
               
-              battery.onchargingstatechange = function () {
-                document.querySelector('#chargingState').textContent = battery.chargingState;
+              battery.onchargingchange = function () {
+                document.querySelector('#charging').textContent = battery.charging ? 'charging' : 'not charging';
               };
 
               battery.onlevelchange = function () {
                 document.querySelector('#level').textContent = battery.level;
               };
 
-              battery.onremainingchange = function () {
-                document.querySelector('#remaining').textContent = battery.remaining / 60;
+              battery.onremainingtimechange = function () {
+                document.querySelector('#remainingTime').textContent = battery.remainingTime / 60;
               };
             &lt;/script&gt;
           &lt;/head&gt;
           &lt;body&gt;
-            &lt;div id="chargingState"&gt;(charging state unknown)&lt;/div&gt;
+            &lt;div id="charging"&gt;(charging state unknown)&lt;/div&gt;
             &lt;div id="level"&gt;(battery level unknown)&lt;/div&gt;
-            &lt;div id="remaining"&gt;(time remaining unknown)&lt;/div&gt;
+            &lt;div id="remainingTime"&gt;(remaining time unknown)&lt;/div&gt;
           &lt;/body&gt;
           &lt;/html&gt;
         </pre>

Received on Tuesday, 25 October 2011 09:56:21 UTC