Battery Status Event Spec

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