You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by au...@apache.org on 2017/08/04 15:22:30 UTC

cordova-plugin-battery-status git commit: CB-12895 : added eslint and removed jshint

Repository: cordova-plugin-battery-status
Updated Branches:
  refs/heads/master 01c636f04 -> 835acc8d4


CB-12895 : added eslint and removed jshint


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/commit/835acc8d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/tree/835acc8d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/diff/835acc8d

Branch: refs/heads/master
Commit: 835acc8d4daf4693d21c4be086fb06d1bdf9fc81
Parents: 01c636f
Author: Audrey So <au...@apache.org>
Authored: Fri Jun 9 14:41:05 2017 -0700
Committer: Audrey So <au...@apache.org>
Committed: Wed Aug 2 11:40:09 2017 -0700

----------------------------------------------------------------------
 .eslintrc.yml                   |  10 ++
 .jshintrc                       |  17 --
 package.json                    |  11 +-
 src/blackberry10/index.js       |  48 +++---
 src/browser/BatteryProxy.js     |  20 +--
 src/firefoxos/BatteryProxy.js   |  22 +--
 src/tizen/BatteryStatusProxy.js |  12 +-
 src/windows/BatteryProxy.js     |  22 +--
 tests/tests.js                  | 307 +++++++++++++++++------------------
 www/battery.js                  |  49 +++---
 10 files changed, 257 insertions(+), 261 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/.eslintrc.yml b/.eslintrc.yml
new file mode 100644
index 0000000..0cccb8c
--- /dev/null
+++ b/.eslintrc.yml
@@ -0,0 +1,10 @@
+root: true
+extends: semistandard
+rules:
+  indent:
+    - error
+    - 4
+  camelcase: off
+  padded-blocks: off
+  operator-linebreak: off
+  no-throw-literal: off
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index df32482..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-    "browser": true
-  , "devel": true
-  , "bitwise": true
-  , "undef": true
-  , "trailing": true
-  , "quotmark": false
-  , "indent": 4
-  , "unused": "vars"
-  , "latedef": "nofunc"
-  , "globals": {
-        "module": false,
-        "exports": false,
-        "require": false,
-        "cordova": true
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 70caadd..e551a82 100644
--- a/package.json
+++ b/package.json
@@ -39,8 +39,8 @@
     "cordova-firefoxos"
   ],
   "scripts": {
-    "test": "npm run jshint",
-    "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
+    "test": "npm run eslint",
+    "eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"
   },
   "author": "Apache Software Foundation",
   "license": "Apache-2.0",
@@ -52,6 +52,13 @@
     }
   },
   "devDependencies": {
+    "eslint": "^3.19.0",
+    "eslint-config-semistandard": "^11.0.0",
+    "eslint-config-standard": "^10.2.1",
+    "eslint-plugin-import": "^2.3.0",
+    "eslint-plugin-node": "^5.0.0",
+    "eslint-plugin-promise": "^3.5.0",
+    "eslint-plugin-standard": "^3.0.1",
     "jshint": "^2.6.0"
   }
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index a105f60..995908d 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -21,32 +21,32 @@
 
 /* global PluginResult */
 
-var _clientListeners = {},
-    _webkitBattery = navigator.webkitBattery || navigator.battery;
+var _clientListeners = {};
+var _webkitBattery = navigator.webkitBattery || navigator.battery;
 
 module.exports = {
     start: function (success, fail, args, env) {
-        var result = new PluginResult(args, env),
-            listener = function (info) {
-                var resultInfo = {};
-                if (info) {
-                    if (info.srcElement) {
-                        //webkitBattery listeners store webkitBattery in srcElement object
-                        info = info.srcElement;
-                    }
-
-                    //put data from webkitBattery into a format cordova expects
-                    //webkitBattery seems to return level as a decimal pre 10.2
-                    resultInfo.level = info.level <= 1 ? info.level * 100 : info.level;
-                    resultInfo.isPlugged = info.charging;
+        var result = new PluginResult(args, env);
+        var listener = function (info) {
+            var resultInfo = {};
+            if (info) {
+                if (info.srcElement) {
+                    // webkitBattery listeners store webkitBattery in srcElement object
+                    info = info.srcElement;
                 }
 
-                result.callbackOk(resultInfo, true);
-            };
+                // put data from webkitBattery into a format cordova expects
+                // webkitBattery seems to return level as a decimal pre 10.2
+                resultInfo.level = info.level <= 1 ? info.level * 100 : info.level;
+                resultInfo.isPlugged = info.charging;
+            }
+
+            result.callbackOk(resultInfo, true);
+        };
 
         if (_clientListeners[env.webview.id]) {
-            //TODO: Change back to erroring out after reset is implemented
-            //result.error("Battery listener already running");
+            // TODO: Change back to erroring out after reset is implemented
+            // result.error("Battery listener already running");
             _webkitBattery.onchargingchange = null;
             _webkitBattery.onlevelchange = null;
         }
@@ -56,19 +56,19 @@ module.exports = {
         _webkitBattery.onchargingchange = listener;
         _webkitBattery.onlevelchange = listener;
 
-        setTimeout(function(){
-            //Call callback with webkitBattery data right away
+        setTimeout(function () {
+            // Call callback with webkitBattery data right away
             listener(_webkitBattery);
         });
 
         result.noResult(true);
     },
     stop: function (success, fail, args, env) {
-        var result = new PluginResult(args, env),
-            listener = _clientListeners[env.webview.id];
+        var result = new PluginResult(args, env);
+        var listener = _clientListeners[env.webview.id];
 
         if (!listener) {
-            result.error("Battery listener has not started");
+            result.error('Battery listener has not started');
         } else {
             _webkitBattery.onchargingchange = null;
             _webkitBattery.onlevelchange = null;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/src/browser/BatteryProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/BatteryProxy.js b/src/browser/BatteryProxy.js
index d36c567..878f356 100644
--- a/src/browser/BatteryProxy.js
+++ b/src/browser/BatteryProxy.js
@@ -22,14 +22,14 @@
 var w3cBattery;
 var winCallBack;
 
-function success() {
+function success () {
     winCallBack({ level: w3cBattery.level * 100, isPlugged: w3cBattery.charging });
 }
 
 var Battery = {
-    start: function(win, fail, args, env) {
+    start: function (win, fail, args, env) {
         try {
-            var subscribe = function(battery) {
+            var subscribe = function (battery) {
                 w3cBattery = battery;
                 winCallBack = win;
 
@@ -45,11 +45,11 @@ var Battery = {
             };
 
             if (typeof navigator.getBattery === 'function') {
-                navigator.getBattery().then(function(battery) { 
-                    subscribe(battery); 
+                navigator.getBattery().then(function (battery) {
+                    subscribe(battery);
                 });
             } else {
-                var origBattery = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.battery');
+                var origBattery = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.battery'); // eslint-disable-line no-undef
 
                 if (origBattery) {
                     subscribe(origBattery);
@@ -57,12 +57,12 @@ var Battery = {
                     fail('Not supported');
                 }
             }
-        } catch(e) {
+        } catch (e) {
             fail(e);
         }
     },
 
-    stop: function() {
+    stop: function () {
         try {
             if (typeof w3cBattery.removeEventListener === 'function') {
                 w3cBattery.removeEventListener('levelchange', success, false);
@@ -71,10 +71,10 @@ var Battery = {
                 w3cBattery.onlevelchange = null;
                 w3cBattery.onchargingchange = null;
             }
-        } catch(e) {
+        } catch (e) {
             console.warn('Error occured while trying to stop battery: ' + JSON.stringify(e));
         }
     }
 };
 
-require("cordova/exec/proxy").add("Battery", Battery);
+require('cordova/exec/proxy').add('Battery', Battery);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/src/firefoxos/BatteryProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/BatteryProxy.js b/src/firefoxos/BatteryProxy.js
index 46be5ed..98a76a1 100644
--- a/src/firefoxos/BatteryProxy.js
+++ b/src/firefoxos/BatteryProxy.js
@@ -19,10 +19,10 @@
  *
  */
 
-var mozBattery = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.battery') || navigator.mozBattery;
+var mozBattery = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.battery') || navigator.mozBattery; // eslint-disable-line no-undef
 
 var Battery = {
-    start: function(successCB, failCB, args, env) {
+    start: function (successCB, failCB, args, env) {
         if (mozBattery) {
             Battery.attachListeners(successCB);
         } else {
@@ -30,32 +30,32 @@ var Battery = {
         }
     },
 
-    stop: function() {
+    stop: function () {
         Battery.detachListeners();
     },
 
-    attachListeners: function(_callBack) {
+    attachListeners: function (_callBack) {
 
         Battery.updateBatteryStatus(_callBack); // send a battery status event
 
-        mozBattery.addEventListener("chargingchange", function(){
+        mozBattery.addEventListener('chargingchange', function () {
             _callBack({level: (mozBattery.level * 100), isPlugged: mozBattery.charging});
         });
 
-        mozBattery.addEventListener("levelchange", function(){
+        mozBattery.addEventListener('levelchange', function () {
             _callBack({level: (mozBattery.level * 100), isPlugged: mozBattery.charging});
         });
     },
 
-    detachListeners: function() {
+    detachListeners: function () {
 
-        mozBattery.removeEventListener("chargingchange", null);
-        mozBattery.removeEventListener("levelchange", null);
+        mozBattery.removeEventListener('chargingchange', null);
+        mozBattery.removeEventListener('levelchange', null);
     },
 
-    updateBatteryStatus: function(_callBack) {
+    updateBatteryStatus: function (_callBack) {
         _callBack({level: (mozBattery.level * 100), isPlugged: mozBattery.charging});
     }
 };
 
-require("cordova/exec/proxy").add("Battery", Battery);
+require('cordova/exec/proxy').add('Battery', Battery);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/src/tizen/BatteryStatusProxy.js
----------------------------------------------------------------------
diff --git a/src/tizen/BatteryStatusProxy.js b/src/tizen/BatteryStatusProxy.js
index 5149f54..56feabc 100644
--- a/src/tizen/BatteryStatusProxy.js
+++ b/src/tizen/BatteryStatusProxy.js
@@ -24,24 +24,24 @@
 var batteryListenerId = null;
 
 module.exports = {
-    start: function(successCallback, errorCallback) {
-        var batterySuccessCallback = function(power) {
+    start: function (successCallback, errorCallback) {
+        var batterySuccessCallback = function (power) {
             if (successCallback) {
                 successCallback({level: Math.round(power.level * 100), isPlugged: power.isCharging});
             }
         };
 
         if (batteryListenerId === null) {
-            batteryListenerId = tizen.systeminfo.addPropertyValueChangeListener("BATTERY", batterySuccessCallback);
+            batteryListenerId = tizen.systeminfo.addPropertyValueChangeListener('BATTERY', batterySuccessCallback);
         }
 
-        tizen.systeminfo.getPropertyValue("BATTERY", batterySuccessCallback, errorCallback);
+        tizen.systeminfo.getPropertyValue('BATTERY', batterySuccessCallback, errorCallback);
     },
 
-    stop: function(successCallback, errorCallback) {
+    stop: function (successCallback, errorCallback) {
         tizen.systeminfo.removePropertyValueChangeListener(batteryListenerId);
         batteryListenerId = null;
     }
 };
 
-require("cordova/tizen/commandProxy").add("Battery", module.exports);
+require('cordova/tizen/commandProxy').add('Battery', module.exports);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/src/windows/BatteryProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/BatteryProxy.js b/src/windows/BatteryProxy.js
index 52a5c2c..f83a8b1 100644
--- a/src/windows/BatteryProxy.js
+++ b/src/windows/BatteryProxy.js
@@ -56,16 +56,16 @@ if (PowerManager) {
         }
     };
 
-    require("cordova/exec/proxy").add("Battery", BatteryWin10);
+    require('cordova/exec/proxy').add('Battery', BatteryWin10);
 
 } else {
-    
+
     var stopped;
 
-    var handleResponse = function(successCb, errorCb, jsonResponse) {
+    var handleResponse = function (successCb, errorCb, jsonResponse) {
         var info = JSON.parse(jsonResponse);
 
-        if (info.hasOwnProperty("exceptionMessage")) {
+        if (info.hasOwnProperty('exceptionMessage')) {
             errorCb(info.exceptionMessage);
             return;
         }
@@ -75,11 +75,11 @@ if (PowerManager) {
 
     var Battery = {
         start: function (win, fail, args, env) {
-            function getBatteryStatus(success, error) {
+            function getBatteryStatus (success, error) {
                 handleResponse(success, error, BatteryStatus.BatteryStatus.start());
             }
 
-            function getBatteryStatusLevelChangeEvent(success, error) {
+            function getBatteryStatusLevelChangeEvent (success, error) {
                 return BatteryStatus.BatteryStatus.getBatteryStatusChangeEvent().done(function (result) {
                     if (stopped) {
                         return;
@@ -87,8 +87,8 @@ if (PowerManager) {
 
                     handleResponse(success, error, result);
 
-                    setTimeout(function() { getBatteryStatusLevelChangeEvent(success, error); }, 0);
-                }, function(err) {
+                    setTimeout(function () { getBatteryStatusLevelChangeEvent(success, error); }, 0);
+                }, function (err) {
                     fail(err);
                 });
             }
@@ -96,7 +96,7 @@ if (PowerManager) {
             // Battery API supported on Phone devices only so in case of
             // desktop/tablet the only one choice is to fail with appropriate message.
             if (!WinJS.Utilities.isPhone) {
-                fail("The operation is not supported on Windows Desktop devices.");
+                fail('The operation is not supported on Windows Desktop devices.');
                 return;
             }
 
@@ -104,7 +104,7 @@ if (PowerManager) {
             try {
                 getBatteryStatus(win, fail);
                 getBatteryStatusLevelChangeEvent(win, fail);
-            } catch(e) {
+            } catch (e) {
                 fail(e);
             }
         },
@@ -121,5 +121,5 @@ if (PowerManager) {
         }
     };
 
-    require("cordova/exec/proxy").add("Battery", Battery);
+    require('cordova/exec/proxy').add('Battery', Battery);
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 38571a0..c956f45 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -19,23 +19,23 @@
  *
  */
 
-/* jshint jasmine: true */
+/* eslint-env jasmine */
 /* global Windows, WinJS */
 
 exports.defineAutoTests = function () {
-    var hasPowerManagerAPI = cordova.platformId === "windows" &&
+    var hasPowerManagerAPI = cordova.platformId === 'windows' && // eslint-disable-line no-undef
         Windows && Windows.System && Windows.System.Power &&
         Windows.System.Power.PowerManager;
 
-    var batteryStatusUnsupported = cordova.platformId === "windows8" ||
+    var batteryStatusUnsupported = (cordova.platformId === 'windows8' || // eslint-disable-line no-undef
         // We don't test battery status on Windows when there is no corresponding APIs available
-        cordova.platformId === "windows" && !(hasPowerManagerAPI || WinJS.Utilities.isPhone);
+        cordova.platformId === 'windows') && !(hasPowerManagerAPI || WinJS.Utilities.isPhone); // eslint-disable-line no-undef
 
     var onEvent;
 
     describe('Battery (navigator.battery)', function () {
 
-        it("battery.spec.1 should exist", function () {
+        it('battery.spec.1 should exist', function () {
             if (batteryStatusUnsupported) {
                 pending('Battery status is not supported on windows store');
             }
@@ -46,28 +46,27 @@ exports.defineAutoTests = function () {
 
     describe('Battery Events', function () {
 
-        describe("batterystatus", function () {
+        describe('batterystatus', function () {
 
             afterEach(function () {
                 if (!batteryStatusUnsupported) {
                     try {
-                        window.removeEventListener("batterystatus", onEvent, false);
-                    }
-                    catch (e) {
+                        window.removeEventListener('batterystatus', onEvent, false);
+                    } catch (e) {
                         console.error('Error removing batterystatus event listener: ' + e);
                     }
                 }
             });
 
-            it("battery.spec.2 should fire batterystatus events", function (done) {
+            it('battery.spec.2 should fire batterystatus events', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryStatus");
+                onEvent = jasmine.createSpy('BatteryStatus');
 
                 // batterystatus -> 30
-                window.addEventListener("batterystatus", onEvent, false);
+                window.addEventListener('batterystatus', onEvent, false);
 
                 navigator.battery._status({
                     level: 30,
@@ -82,37 +81,36 @@ exports.defineAutoTests = function () {
             });
         });
 
-        describe("batterylow", function () {
+        describe('batterylow', function () {
 
             afterEach(function () {
                 if (!batteryStatusUnsupported) {
                     try {
-                        window.removeEventListener("batterylow", onEvent, false);
-                    }
-                    catch (e) {
+                        window.removeEventListener('batterylow', onEvent, false);
+                    } catch (e) {
                         console.error('Error removing batterylow event listener: ' + e);
                     }
                 }
             });
 
-            it("battery.spec.3 should fire batterylow event (30 -> 20)", function (done) {
+            it('battery.spec.3 should fire batterylow event (30 -> 20)', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryLow");
+                onEvent = jasmine.createSpy('BatteryLow');
 
                 // batterylow 30 -> 20
-                window.addEventListener("batterylow", onEvent, false);
+                window.addEventListener('batterylow', onEvent, false);
 
                 navigator.battery._status({
-                    level : 30,
-                    isPlugged : false
+                    level: 30,
+                    isPlugged: false
                 });
 
                 navigator.battery._status({
-                    level : 20,
-                    isPlugged : false
+                    level: 20,
+                    isPlugged: false
                 });
 
                 setTimeout(function () {
@@ -122,24 +120,24 @@ exports.defineAutoTests = function () {
 
             });
 
-            it("battery.spec.3.1 should fire batterylow event (30 -> 19)", function (done) {
+            it('battery.spec.3.1 should fire batterylow event (30 -> 19)', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryLow");
+                onEvent = jasmine.createSpy('BatteryLow');
 
                 // batterylow 30 -> 19
-                window.addEventListener("batterylow", onEvent, false);
+                window.addEventListener('batterylow', onEvent, false);
 
                 navigator.battery._status({
-                    level : 30,
-                    isPlugged : false
+                    level: 30,
+                    isPlugged: false
                 });
 
                 navigator.battery._status({
-                    level : 19,
-                    isPlugged : false
+                    level: 19,
+                    isPlugged: false
                 });
 
                 setTimeout(function () {
@@ -148,19 +146,19 @@ exports.defineAutoTests = function () {
                 }, 100);
             });
 
-            it("battery.spec.3.2 should not fire batterylow event (5 -> 20)", function (done) {
+            it('battery.spec.3.2 should not fire batterylow event (5 -> 20)', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryLow");
+                onEvent = jasmine.createSpy('BatteryLow');
 
                 // batterylow should not fire when level increases (5->20) ( CB-4519 )
-                window.addEventListener("batterylow", onEvent, false);
+                window.addEventListener('batterylow', onEvent, false);
 
                 navigator.battery._status({
-                    level : 5,
-                    isPlugged : false
+                    level: 5,
+                    isPlugged: false
                 });
 
                 navigator.battery._status({
@@ -174,24 +172,24 @@ exports.defineAutoTests = function () {
                 }, 100);
             });
 
-            it("battery.spec.3.3 batterylow event(21 -> 20) should not fire if charging", function (done) {
+            it('battery.spec.3.3 batterylow event(21 -> 20) should not fire if charging', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryLow");
+                onEvent = jasmine.createSpy('BatteryLow');
 
                 // batterylow should NOT fire if we are charging   ( CB-4520 )
-                window.addEventListener("batterylow", onEvent, false);
+                window.addEventListener('batterylow', onEvent, false);
 
                 navigator.battery._status({
-                    level : 21,
-                    isPlugged : true
+                    level: 21,
+                    isPlugged: true
                 });
 
                 navigator.battery._status({
-                    level : 20,
-                    isPlugged : true
+                    level: 20,
+                    isPlugged: true
                 });
 
                 setTimeout(function () {
@@ -201,28 +199,27 @@ exports.defineAutoTests = function () {
             });
         });
 
-        describe("batterycritical", function () {
+        describe('batterycritical', function () {
 
             afterEach(function () {
                 if (!batteryStatusUnsupported) {
                     try {
-                        window.removeEventListener("batterycritical", onEvent, false);
-                    }
-                    catch (e) {
+                        window.removeEventListener('batterycritical', onEvent, false);
+                    } catch (e) {
                         console.error('Error removing batterycritical event listener: ' + e);
                     }
                 }
             });
 
-            it("battery.spec.4 should fire batterycritical event (19 -> 5)", function (done) {
+            it('battery.spec.4 should fire batterycritical event (19 -> 5)', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryCritical");
+                onEvent = jasmine.createSpy('BatteryCritical');
 
                 // batterycritical 19->5
-                window.addEventListener("batterycritical", onEvent, false);
+                window.addEventListener('batterycritical', onEvent, false);
 
                 navigator.battery._status({
                     level: 19,
@@ -241,15 +238,15 @@ exports.defineAutoTests = function () {
 
             });
 
-            it("battery.spec.4.1 should fire batterycritical event (19 -> 4)", function (done) {
+            it('battery.spec.4.1 should fire batterycritical event (19 -> 4)', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryCritical");
+                onEvent = jasmine.createSpy('BatteryCritical');
 
                 // batterycritical 19->4
-                window.addEventListener("batterycritical", onEvent, false);
+                window.addEventListener('batterycritical', onEvent, false);
 
                 navigator.battery._status({
                     level: 19,
@@ -268,15 +265,15 @@ exports.defineAutoTests = function () {
 
             });
 
-            it("battery.spec.4.2 should fire batterycritical event (100 -> 4) when decreases", function (done) {
+            it('battery.spec.4.2 should fire batterycritical event (100 -> 4) when decreases', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryCritical");
+                onEvent = jasmine.createSpy('BatteryCritical');
 
                 // setup: batterycritical should fire when level decreases (100->4) ( CB-4519 )
-                window.addEventListener("batterycritical", onEvent, false);
+                window.addEventListener('batterycritical', onEvent, false);
 
                 navigator.battery._status({
                     level: 100,
@@ -294,14 +291,14 @@ exports.defineAutoTests = function () {
                 }, 100);
             });
 
-            it("battery.spec.4.3 should not fire batterycritical event (4 -> 5) when increasing", function (done) {
+            it('battery.spec.4.3 should not fire batterycritical event (4 -> 5) when increasing', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryCritical");
+                onEvent = jasmine.createSpy('BatteryCritical');
 
-                window.addEventListener("batterycritical", onEvent, false);
+                window.addEventListener('batterycritical', onEvent, false);
 
                 // batterycritical should not fire when level increases (4->5)( CB-4519 )
                 navigator.battery._status({
@@ -320,14 +317,14 @@ exports.defineAutoTests = function () {
                 }, 100);
             });
 
-            it("battery.spec.4.4 should not fire batterycritical event (6 -> 5) if charging", function (done) {
+            it('battery.spec.4.4 should not fire batterycritical event (6 -> 5) if charging', function (done) {
                 if (batteryStatusUnsupported) {
                     pending('Battery status is not supported on windows store');
                 }
 
-                onEvent = jasmine.createSpy("BatteryCritical");
+                onEvent = jasmine.createSpy('BatteryCritical');
 
-                window.addEventListener("batterycritical", onEvent, false);
+                window.addEventListener('batterycritical', onEvent, false);
 
                 // batterycritical should NOT fire if we are charging   ( CB-4520 )
                 navigator.battery._status({
@@ -349,175 +346,175 @@ exports.defineAutoTests = function () {
     });
 };
 
-//******************************************************************************************
-//***************************************Manual Tests***************************************
-//******************************************************************************************
+//* *****************************************************************************************
+//* **************************************Manual Tests***************************************
+//* *****************************************************************************************
 
 exports.defineManualTests = function (contentEl, createActionButton) {
 
     /* Battery */
-    function updateInfo(info) {
+    function updateInfo (info) {
         document.getElementById('levelValue').innerText = info.level;
         document.getElementById('pluggedValue').innerText = info.isPlugged;
         if (info.level > 5) {
-            document.getElementById('criticalValue').innerText = "false";
+            document.getElementById('criticalValue').innerText = 'false';
         }
         if (info.level > 20) {
-            document.getElementById('lowValue').innerText = "false";
+            document.getElementById('lowValue').innerText = 'false';
         }
     }
 
-    function batteryLow(info) {
-        document.getElementById('lowValue').innerText = "true";
+    function batteryLow (info) {
+        document.getElementById('lowValue').innerText = 'true';
     }
 
-    function batteryCritical(info) {
-        document.getElementById('criticalValue').innerText = "true";
+    function batteryCritical (info) {
+        document.getElementById('criticalValue').innerText = 'true';
     }
 
-    function addBattery() {
-        window.addEventListener("batterystatus", updateInfo, false);
+    function addBattery () {
+        window.addEventListener('batterystatus', updateInfo, false);
     }
 
-    function removeBattery() {
-        window.removeEventListener("batterystatus", updateInfo, false);
+    function removeBattery () {
+        window.removeEventListener('batterystatus', updateInfo, false);
     }
 
-    function addLow() {
-        window.addEventListener("batterylow", batteryLow, false);
+    function addLow () {
+        window.addEventListener('batterylow', batteryLow, false);
     }
 
-    function removeLow() {
-        window.removeEventListener("batterylow", batteryLow, false);
+    function removeLow () {
+        window.removeEventListener('batterylow', batteryLow, false);
     }
 
-    function addCritical() {
-        window.addEventListener("batterycritical", batteryCritical, false);
+    function addCritical () {
+        window.addEventListener('batterycritical', batteryCritical, false);
     }
 
-    function removeCritical() {
-        window.removeEventListener("batterycritical", batteryCritical, false);
+    function removeCritical () {
+        window.removeEventListener('batterycritical', batteryCritical, false);
     }
 
-    //Generate Dynamic Table
-    function generateTable(tableId, rows, cells, elements) {
+    // Generate Dynamic Table
+    function generateTable (tableId, rows, cells, elements) {
         var table = document.createElement('table');
         for (var r = 0; r < rows; r++) {
             var row = table.insertRow(r);
             for (var c = 0; c < cells; c++) {
                 var cell = row.insertCell(c);
-                cell.setAttribute("align", "center");
+                cell.setAttribute('align', 'center');
                 for (var e in elements) {
-                    if (elements[e].position.row == r && elements[e].position.cell == c) {
+                    if (elements[e].position.row === r && elements[e].position.cell === c) {
                         var htmlElement = document.createElement(elements[e].tag);
                         var content;
 
-                        if (elements[e].content !== "") {
+                        if (elements[e].content !== '') {
                             content = document.createTextNode(elements[e].content);
                             htmlElement.appendChild(content);
                         }
                         if (elements[e].type) {
                             htmlElement.type = elements[e].type;
                         }
-                        htmlElement.setAttribute("id", elements[e].id);
+                        htmlElement.setAttribute('id', elements[e].id);
                         cell.appendChild(htmlElement);
                     }
                 }
             }
         }
-        table.setAttribute("align", "center");
-        table.setAttribute("id", tableId);
+        table.setAttribute('align', 'center');
+        table.setAttribute('id', tableId);
         return table;
     }
     // Battery Elements
     var batteryElements =
         [{
-            id : "statusTag",
-            content : "Status:",
-            tag : "div",
-            position : {
-                row : 0,
-                cell : 0
+            id: 'statusTag',
+            content: 'Status:',
+            tag: 'div',
+            position: {
+                row: 0,
+                cell: 0
             }
         }, {
-            id : "statusValue",
-            content : "",
-            tag : "div",
-            position : {
-                row : 0,
-                cell : 1
+            id: 'statusValue',
+            content: '',
+            tag: 'div',
+            position: {
+                row: 0,
+                cell: 1
             }
         }, {
-            id : "levelTag",
-            content : "Level:",
-            tag : "div",
-            position : {
-                row : 1,
-                cell : 0
+            id: 'levelTag',
+            content: 'Level:',
+            tag: 'div',
+            position: {
+                row: 1,
+                cell: 0
             }
         }, {
-            id : "levelValue",
-            content : "",
-            tag : "div",
-            position : {
-                row : 1,
-                cell : 1
+            id: 'levelValue',
+            content: '',
+            tag: 'div',
+            position: {
+                row: 1,
+                cell: 1
             }
         }, {
-            id : "pluggedTag",
-            content : "Plugged:",
-            tag : "div",
-            position : {
-                row : 2,
-                cell : 0
+            id: 'pluggedTag',
+            content: 'Plugged:',
+            tag: 'div',
+            position: {
+                row: 2,
+                cell: 0
             }
         }, {
-            id : "pluggedValue",
-            content : "",
-            tag : "div",
-            position : {
-                row : 2,
-                cell : 1
+            id: 'pluggedValue',
+            content: '',
+            tag: 'div',
+            position: {
+                row: 2,
+                cell: 1
             }
         }, {
-            id : "lowTag",
-            content : "Low:",
-            tag : "div",
-            position : {
-                row : 3,
-                cell : 0
+            id: 'lowTag',
+            content: 'Low:',
+            tag: 'div',
+            position: {
+                row: 3,
+                cell: 0
             }
         }, {
-            id : "lowValue",
-            content : "",
-            tag : "div",
-            position : {
-                row : 3,
-                cell : 1
+            id: 'lowValue',
+            content: '',
+            tag: 'div',
+            position: {
+                row: 3,
+                cell: 1
             }
         }, {
-            id : "criticalTag",
-            content : "Critical:",
-            tag : "div",
-            position : {
-                row : 4,
-                cell : 0
+            id: 'criticalTag',
+            content: 'Critical:',
+            tag: 'div',
+            position: {
+                row: 4,
+                cell: 0
             }
         }, {
-            id : "criticalValue",
-            content : "",
-            tag : "div",
-            position : {
-                row : 4,
-                cell : 1
+            id: 'criticalValue',
+            content: '',
+            tag: 'div',
+            position: {
+                row: 4,
+                cell: 1
             }
         }
-    ];
+        ];
 
-    //Title audio results
+    // Title audio results
     var div = document.createElement('h2');
     div.appendChild(document.createTextNode('Battery Status'));
-    div.setAttribute("align", "center");
+    div.setAttribute('align', 'center');
     contentEl.appendChild(div);
 
     var batteryTable = generateTable('info', 5, 3, batteryElements);
@@ -525,7 +522,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
 
     div = document.createElement('h2');
     div.appendChild(document.createTextNode('Actions'));
-    div.setAttribute("align", "center");
+    div.setAttribute('align', 'center');
     contentEl.appendChild(div);
 
     contentEl.innerHTML += '<h3>Battery Status Tests</h3>' +

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/835acc8d/www/battery.js
----------------------------------------------------------------------
diff --git a/www/battery.js b/www/battery.js
index 242503d..e3a69ed 100644
--- a/www/battery.js
+++ b/www/battery.js
@@ -23,27 +23,27 @@
  * This class contains information about the current battery status.
  * @constructor
  */
-var cordova = require('cordova'),
-    exec = require('cordova/exec');
+var cordova = require('cordova');
+var exec = require('cordova/exec');
 
 var STATUS_CRITICAL = 5;
 var STATUS_LOW = 20;
 
-var Battery = function() {
+var Battery = function () {
     this._level = null;
     this._isPlugged = null;
     // Create new event handlers on the window (returns a channel instance)
     this.channels = {
-      batterystatus:cordova.addWindowEventHandler("batterystatus"),
-      batterylow:cordova.addWindowEventHandler("batterylow"),
-      batterycritical:cordova.addWindowEventHandler("batterycritical")
+        batterystatus: cordova.addWindowEventHandler('batterystatus'),
+        batterylow: cordova.addWindowEventHandler('batterylow'),
+        batterycritical: cordova.addWindowEventHandler('batterycritical')
     };
     for (var key in this.channels) {
         this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
     }
 };
 
-function handlers() {
+function handlers () {
     return battery.channels.batterystatus.numHandlers +
         battery.channels.batterylow.numHandlers +
         battery.channels.batterycritical.numHandlers;
@@ -54,13 +54,13 @@ function handlers() {
  * Keep track of how many handlers we have so we can start and stop the native battery listener
  * appropriately (and hopefully save on battery life!).
  */
-Battery.onHasSubscribersChange = function() {
+Battery.onHasSubscribersChange = function () {
   // If we just registered the first handler, make sure native listener is started.
-  if (this.numHandlers === 1 && handlers() === 1) {
-      exec(battery._status, battery._error, "Battery", "start", []);
-  } else if (handlers() === 0) {
-      exec(null, null, "Battery", "stop", []);
-  }
+    if (this.numHandlers === 1 && handlers() === 1) {
+        exec(battery._status, battery._error, 'Battery', 'start', []);
+    } else if (handlers() === 0) {
+        exec(null, null, 'Battery', 'stop', []);
+    }
 };
 
 /**
@@ -72,24 +72,23 @@ Battery.prototype._status = function (info) {
 
     if (info) {
         if (battery._level !== info.level || battery._isPlugged !== info.isPlugged) {
-            
-            if(info.level === null && battery._level !== null) {
+
+            if (info.level === null && battery._level !== null) {
                 return; // special case where callback is called because we stopped listening to the native side.
             }
-            
+
             // Something changed. Fire batterystatus event
-            cordova.fireWindowEvent("batterystatus", info);
+            cordova.fireWindowEvent('batterystatus', info);
 
             if (!info.isPlugged) { // do not fire low/critical if we are charging. issue: CB-4520
-                // note the following are NOT exact checks, as we want to catch a transition from 
+                // note the following are NOT exact checks, as we want to catch a transition from
                 // above the threshold to below. issue: CB-4519
-                if (battery._level > STATUS_CRITICAL && info.level <= STATUS_CRITICAL) { 
+                if (battery._level > STATUS_CRITICAL && info.level <= STATUS_CRITICAL) {
                     // Fire critical battery event
-                    cordova.fireWindowEvent("batterycritical", info);
-                }
-                else if (battery._level > STATUS_LOW && info.level <= STATUS_LOW) {
+                    cordova.fireWindowEvent('batterycritical', info);
+                } else if (battery._level > STATUS_LOW && info.level <= STATUS_LOW) {
                     // Fire low battery event
-                    cordova.fireWindowEvent("batterylow", info);
+                    cordova.fireWindowEvent('batterylow', info);
                 }
             }
             battery._level = info.level;
@@ -101,8 +100,8 @@ Battery.prototype._status = function (info) {
 /**
  * Error callback for battery start
  */
-Battery.prototype._error = function(e) {
-    console.log("Error initializing Battery: " + e);
+Battery.prototype._error = function (e) {
+    console.log('Error initializing Battery: ' + e);
 };
 
 var battery = new Battery(); // jshint ignore:line


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org