incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [3/3] git commit: updating / polishing compass implementation
Date Wed, 07 Mar 2012 00:08:09 GMT
updating / polishing compass implementation


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/d5998934
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/d5998934
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/d5998934

Branch: refs/heads/master
Commit: d59989345294b7ff01bcd18458a4d8f76deae709
Parents: 2400a6f
Author: Fil Maj <maj.fil@gmail.com>
Authored: Mon Mar 5 16:45:45 2012 -0800
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Tue Mar 6 16:07:14 2012 -0800

----------------------------------------------------------------------
 lib/plugin/CompassError.js   |    6 +-----
 lib/plugin/CompassHeading.js |    8 ++++----
 lib/plugin/compass.js        |   12 ++----------
 3 files changed, 7 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5998934/lib/plugin/CompassError.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CompassError.js b/lib/plugin/CompassError.js
index 60067d2..baba76d 100644
--- a/lib/plugin/CompassError.js
+++ b/lib/plugin/CompassError.js
@@ -4,14 +4,10 @@
  * @constructor
  */
 var CompassError = function(err) {
-    this.code = (typeof err != 'undefined' ? err : null);
+    this.code = (err !== undefined ? err : null);
 };
 
-/**
- * Error codes
- */
 CompassError.COMPASS_INTERNAL_ERR = 0;
 CompassError.COMPASS_NOT_SUPPORTED = 20;
 
 module.exports = CompassError;
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5998934/lib/plugin/CompassHeading.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CompassHeading.js b/lib/plugin/CompassHeading.js
index c1ab1a3..2336beb 100644
--- a/lib/plugin/CompassHeading.js
+++ b/lib/plugin/CompassHeading.js
@@ -1,8 +1,8 @@
 var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
-  this.magneticHeading = magneticHeading !== undefined ? magneticHeading :  null;
-  this.trueHeading = trueHeading !== undefined ? trueHeading : null;
-  this.headingAccuracy = headingAccuracy !== undefined ? headingAccuracy : null;
-  this.timestamp = timestamp !== undefined ? new Date(timestamp) : new Date();
+  this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
+  this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
+  this.headingAccuracy = (headingAccuracy !== undefined ? headingAccuracy : null);
+  this.timestamp = (timestamp !== undefined ? new Date(timestamp) : new Date());
 };
 
 module.exports = CompassHeading;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5998934/lib/plugin/compass.js
----------------------------------------------------------------------
diff --git a/lib/plugin/compass.js b/lib/plugin/compass.js
index 3e6049c..1685f2d 100644
--- a/lib/plugin/compass.js
+++ b/lib/plugin/compass.js
@@ -12,7 +12,7 @@ var exec = require('cordova/exec'),
          * getting the heading data.
          * @param {CompassOptions} options The options for getting the heading data (not
used).
          */
-        getCurrentHeading:function(successCallback, errorCallback, options) {
+        getCurrentHeading:function(successCallback, errorCallback) {
             // successCallback required
             if (typeof successCallback !== "function") {
               console.log("Compass Error: successCallback is not a function");
@@ -65,17 +65,9 @@ var exec = require('cordova/exec'),
 
             // Start watch timer to get headings
             var id = utils.createUUID();
-            var win = function(result) {
-                var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy,
result.timestamp);
-                successCallback(ch);
-            };
-            var fail = function(code) {
-                var ce = new CompassError(code);
-                errorCallback(ce);
-            };
 
             timers[id] = window.setInterval(function() {
-                 exec(win, fail, "Compass", "getHeading", []);
+                compass.getCurrentHeading(successCallback, errorCallback);
             }, frequency);
 
             return id;


Mime
View raw message