You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/04/28 02:03:25 UTC

js commit: adding compass support

Updated Branches:
  refs/heads/master f9f51d941 -> 2b811c261


adding compass support


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/2b811c26
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/2b811c26
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/2b811c26

Branch: refs/heads/master
Commit: 2b811c2613cf1546c858b8f7d931f96f353960cf
Parents: f9f51d9
Author: Anis Kadri <an...@gmail.com>
Authored: Fri Apr 27 17:03:16 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Fri Apr 27 17:03:16 2012 -0700

----------------------------------------------------------------------
 lib/bada/exec.js                |    3 ++-
 lib/bada/plugin/bada/Compass.js |   19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/2b811c26/lib/bada/exec.js
----------------------------------------------------------------------
diff --git a/lib/bada/exec.js b/lib/bada/exec.js
index d0ecf1c..d11505b 100644
--- a/lib/bada/exec.js
+++ b/lib/bada/exec.js
@@ -2,7 +2,8 @@ var plugins = {
     "Device": require('cordova/plugin/bada/device'),
     "NetworkStatus": require('cordova/plugin/bada/NetworkStatus'),
     "Accelerometer": require('cordova/plugin/bada/Accelerometer'),
-    "Notification": require('cordova/plugin/bada/Notification')
+    "Notification": require('cordova/plugin/bada/Notification'),
+    "Compass": require('cordova/plugin/bada/Compass')
 };
 
 module.exports = function(success, fail, service, action, args) {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/2b811c26/lib/bada/plugin/bada/Compass.js
----------------------------------------------------------------------
diff --git a/lib/bada/plugin/bada/Compass.js b/lib/bada/plugin/bada/Compass.js
new file mode 100644
index 0000000..ba8b983
--- /dev/null
+++ b/lib/bada/plugin/bada/Compass.js
@@ -0,0 +1,19 @@
+var CompassHeading = require('cordova/plugin/CompassHeading');
+
+module.exports = {
+        getHeading: function(compassSuccess, compassError, compassOptions) {
+            if(deviceapis.orientation === undefined) {
+                console.log("navigator.compass.getHeading", "Operation not supported!");
+                return -1;
+            }
+            var success = function(orientation) {
+                var heading = 360 - orientation.alpha;
+                var compassHeading = new CompassHeading(heading, heading, 0);
+                compassSuccess(compassHeading);
+            };
+            var error = function(error) {
+                compassError(error);
+            };
+            deviceapis.orientation.getCurrentOrientation(success, error);
+        }
+};