You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by za...@apache.org on 2014/05/19 23:57:08 UTC
[1/3] git commit: CB-5611 firefoxos: battery-status plugin
Repository: cordova-plugin-battery-status
Updated Branches:
refs/heads/master 9821813a4 -> dbdcbebaa
CB-5611 firefoxos: battery-status plugin
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/7d9f58d1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/tree/7d9f58d1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/diff/7d9f58d1
Branch: refs/heads/master
Commit: 7d9f58d195709d6220c7ac1358a3b45848f95a31
Parents: d38f0ab
Author: Richard Sentino <ri...@mingdinative.com>
Authored: Sat Mar 1 01:13:55 2014 +1300
Committer: Rodrigo Silveira <ro...@outlook.com>
Committed: Thu May 1 11:50:39 2014 -0700
----------------------------------------------------------------------
plugin.xml | 7 +++++
src/firefoxos/BatteryProxy.js | 61 ++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/7d9f58d1/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index f29babb..5dde753 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -107,4 +107,11 @@
<runs/>
</js-module>
</platform>
+
+ <!-- firefoxos -->
+ <platform name="firefoxos">
+ <js-module src="src/firefoxos/BatteryProxy.js" name="Battery">
+ <runs />
+ </js-module>
+ </platform>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/7d9f58d1/src/firefoxos/BatteryProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/BatteryProxy.js b/src/firefoxos/BatteryProxy.js
new file mode 100644
index 0000000..6b592ae
--- /dev/null
+++ b/src/firefoxos/BatteryProxy.js
@@ -0,0 +1,61 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+var mozBattery = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.battery');
+
+var Battery = {
+ start: function(successCB, failCB, args, env) {
+ if (mozBattery) {
+ Battery.attachListeners(successCB);
+ } else {
+ failCB('Could not get window.navigator.battery');
+ }
+ },
+
+ stop: function() {
+ Battery.detachListeners();
+ },
+
+ attachListeners: function(_callBack) {
+
+ Battery.updateBatteryStatus(_callBack); // send a battery status event
+
+ mozBattery.addEventListener("chargingchange", function(){
+ _callBack({level: (mozBattery.level * 100), isPlugged: mozBattery.charging});
+ });
+
+ mozBattery.addEventListener("levelchange", function(){
+ _callBack({level: (mozBattery.level * 100), isPlugged: mozBattery.charging});
+ });
+ },
+
+ detachListeners: function() {
+
+ mozBattery.removeEventListener("chargingchange", null);
+ mozBattery.removeEventListener("levelchange", null);
+ },
+
+ updateBatteryStatus: function(_callBack) {
+ _callBack({level: (mozBattery.level * 100), isPlugged: mozBattery.charging});
+ }
+};
+
+require("cordova/exec/proxy").add("Battery", Battery);
[3/3] git commit: Merge branch 'initial' of
github.com:mozilla-cordova/cordova-plugin-battery-status
Posted by za...@apache.org.
Merge branch 'initial' of github.com:mozilla-cordova/cordova-plugin-battery-status
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/dbdcbeba
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/tree/dbdcbeba
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/diff/dbdcbeba
Branch: refs/heads/master
Commit: dbdcbebaa9a524f9dcef7816345ffa4b82109f21
Parents: 9821813 7222959
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Mon May 19 23:52:46 2014 +0200
Committer: Piotr Zalewa <pi...@zalewa.info>
Committed: Mon May 19 23:52:46 2014 +0200
----------------------------------------------------------------------
doc/index.md | 3 ++
plugin.xml | 7 +++++
src/firefoxos/BatteryProxy.js | 61 ++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+)
----------------------------------------------------------------------
[2/3] git commit: Updated documentation. Added support for mozBattery.
Posted by za...@apache.org.
Updated documentation. Added support for mozBattery.
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/7222959f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/tree/7222959f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/diff/7222959f
Branch: refs/heads/master
Commit: 7222959f2741cc54401c84c4506413001684e799
Parents: 7d9f58d
Author: Rodrigo Silveira <ro...@outlook.com>
Authored: Thu May 1 14:52:38 2014 -0700
Committer: Rodrigo Silveira <ro...@outlook.com>
Committed: Thu May 1 14:52:38 2014 -0700
----------------------------------------------------------------------
doc/index.md | 3 +++
src/firefoxos/BatteryProxy.js | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/7222959f/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 9d946f9..3bb43ab 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -54,6 +54,7 @@ attach an event listener once the `deviceready` event fires. e.g.:
- BlackBerry 10
- Windows Phone 7 and 8
- Tizen
+- Firefox OS
### Windows Phone 7 and 8 Quirks
@@ -92,6 +93,7 @@ an event listener once the `deviceready` event fires.
- Android
- BlackBerry 10
- Tizen
+- Firefox OS
### Example
@@ -124,6 +126,7 @@ attach an event listener once the `deviceready` event fires.
- Android
- BlackBerry 10
- Tizen
+- Firefox OS
### Example
http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/7222959f/src/firefoxos/BatteryProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/BatteryProxy.js b/src/firefoxos/BatteryProxy.js
index 6b592ae..46be5ed 100644
--- a/src/firefoxos/BatteryProxy.js
+++ b/src/firefoxos/BatteryProxy.js
@@ -19,7 +19,7 @@
*
*/
-var mozBattery = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.battery');
+var mozBattery = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.battery') || navigator.mozBattery;
var Battery = {
start: function(successCB, failCB, args, env) {