WebAPI/BatteryAPI: Difference between revisions

Jump to navigation Jump to search
→‎Proposed API: Update the proposed api to match what we actually did
(→‎Proposed API: Update the proposed api to match what we actually did)
Line 22: Line 22:
     readonly attribute boolean  charging;
     readonly attribute boolean  charging;
     readonly attribute float    level;
     readonly attribute float    level;
    readonly attribute DOMString status;
    
    
             attribute Function? onchargingchange;
             attribute Function? onchargingchange;
             attribute Function? onlevelchange;
             attribute Function? onlevelchange;
            attribute Function? onstatuschange;
   }
   }


window.navigator.mozBattery will return ''null'' if the device has no battery.
The charging attribute will return true if the device is currently charging and false otherwise. True if there is no battery or if this information is not available.<br>
 
The level attribute will return the current battery level of the device from 0.0 to 1.0. 1.0 if there is no battery or if this information is not available.<br>
The charging attribute will return true if the device is currently charging and false otherwise.<br>
The level attribute will return the current battery level of the device from 0.0 to 100.0.<br>
The status attribute will return whether "critical", "low" or "ok" depending on the battery level.<br>


The following events can be sent to the mozBattery object:
The following events can be sent to the mozBattery object:
   ''chargingchange'': when the charging state changes;
   ''chargingchange'': when the charging state changes;
   ''levelchange'': when the level value changes of at least 1.0;
   ''levelchange'': when the level value changes of at least 0.01;
  ''statuschange'': when the status changes.


== Considered changes ==
== Considered changes ==
Confirmed users
368

edits

Navigation menu