- From: Anssi Kostiainen via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 09 Sep 2011 05:06:49 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/docs/battery-status In directory hutz:/tmp/cvs-serv6588 Modified Files: battery-status.js Log Message: do not fire batterystatus event if level=0 (isPlugged=false) and level=100 (isPlugged=true) Index: battery-status.js =================================================================== RCS file: /sources/public/2009/dap/docs/battery-status/battery-status.js,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- battery-status.js 8 Sep 2011 16:37:04 -0000 1.1 +++ battery-status.js 9 Sep 2011 05:06:46 -0000 1.2 @@ -28,7 +28,8 @@ onbatterylow: null, onbatterycritical: null, onbatteryok: null, - // we cheat a bit and do not implement event capture + // TODO: we cheat a bit and do not implement event capture + // or support for multiple event listeners of the same type addEventListener: function (type, listener, capture) { if (listener === null) { return; @@ -61,7 +62,7 @@ } function onLevelChange(level) { - _battery.e.level = level; + _battery.e.level = parseInt(level, '10'); $('levelmeter').innerHTML = level; if (!_battery.e.isPlugged) { @@ -89,8 +90,10 @@ var level = $('level'); try { level.stepUp(1); - } catch (ex) { } - onLevelChange(level.value); + onLevelChange(level.value); + } catch (ex) { + clearTimeout(_battery_charging); + } }, _BATTERY_CHARGING_INTERVAL); } else { // simulate depleting @@ -102,12 +105,13 @@ var level = $('level'); try { level.stepDown(1); - } catch (ex) { } - onLevelChange(level.value); + onLevelChange(level.value); + } catch (ex) { + clearTimeout(_battery_depleting); + } }, _BATTERY_DEPLETING_INTERVAL); } - fire('status'); } //---------------------------------------------------------------------------//
Received on Friday, 9 September 2011 05:06:51 UTC