- From: Anssi Kostiainen <anssi.kostiainen@nokia.com>
- Date: Thu, 24 Mar 2011 16:48:35 +0200
- To: "public-device-apis@w3.org Group WG" <public-device-apis@w3.org>
Hi,
As per my ACTION-358, here's the bare bones Battery Status Event Spec to start the discussion. It is modeled on the Device Orientation Event [1]. The properties are from the SysInfo's Power [2].
---+ Battery Status Event
* The BatteryStatusEvent fires on the window object.
* Registration for battery status events is achieved by calling window.addEventListener with event type "batterystatus".
* The initBatteryStatusEvent() method must initialize the event in a manner analogous to the similarly-named method in the DOM Events interfaces.
interface BatteryStatusEvent : Event {
readonly attribute float? level;
readonly attribute unsigned long? timeRemaining;
readonly attribute boolean isBattery;
readonly attribute boolean isCharging;
void initBatteryStatusEvent(in DOMString type,
in boolean bubbles,
in boolean cancelable,
in float level,
in unsigned long timeRemaining,
in boolean isBattery,
in boolean isCharging);
}
---+ Examples
// i) repeated
window.addEventListener('batterystatus', function (event) {
console.log(event.level);
}, true);
// ii) one-shot
function handler(event) {
console.log(event.level);
}
window.addEventListener('batterystatus', handler, true);
window.removeEventListener('batterystatus', handler, true);
As said, this is to get the ball rolling, so let me know what you thing. If there's rough consensus I'll ReSpec this.
-Anssi
[1] http://dev.w3.org/geo/api/spec-source-orientation.html
[2] http://dev.w3.org/2009/dap/system-info/#power
Received on Thursday, 24 March 2011 14:49:14 UTC