W3C home > Mailing lists > Public > public-device-apis@w3.org > March 2011

Battery Status Event Spec

From: Anssi Kostiainen <anssi.kostiainen@nokia.com>
Date: Thu, 24 Mar 2011 16:48:35 +0200
Message-ID: <0400B95F-9EFB-45BA-9629-8D78EE48D3DC@nokia.com>
To: "public-device-apis@w3.org Group WG" <public-device-apis@w3.org>

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) {
}, true);

// ii) one-shot

function handler(event) {

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.


[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

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:53:48 UTC