incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [5/11] js commit: moved accel code to own module/file
Date Fri, 20 Jul 2012 22:56:18 GMT
moved accel code to own module/file


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

Branch: refs/heads/master
Commit: 9ec2de6c5fffb023285801204bc29771a0e921a7
Parents: 0a3d577
Author: Jesse <purplecabbage@gmail.com>
Authored: Fri Jul 20 11:43:33 2012 -0700
Committer: Jesse <purplecabbage@gmail.com>
Committed: Fri Jul 20 11:43:33 2012 -0700

----------------------------------------------------------------------
 lib/win8metro/exec.js                              |   38 +-------------
 .../plugin/win8metro/AccelerometerProxy.js         |   39 +++++++++++++++
 2 files changed, 42 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/9ec2de6c/lib/win8metro/exec.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/exec.js b/lib/win8metro/exec.js
index fb21454..2c82a45 100644
--- a/lib/win8metro/exec.js
+++ b/lib/win8metro/exec.js
@@ -25,41 +25,9 @@ var cordova = require('cordova');
 
 
 
-var NativeProxy = {
-    "Accelerometer": { 
-        onDataChanged:null,       
-        start:function(win,lose){
-
-            var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
-            if(!accel) {
-                lose("No accelerometer found");
-            }
-            else {
-                var self = this;
-                accel.reportInterval = Math.max(16,accel.minimumReportInterval);
-
-                // store our bound function
-                this.onDataChanged = function(e) {
-                    var a = e.reading;
-                    win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ));
-                }
-                accel.addEventListener("readingchanged",this.onDataChanged);
-            }
-        },
-        stop:function(win,lose){
-            console.log("Accelerometer.stop");
-            var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
-            if(!accel) {
-                lose("No accelerometer found");
-            }
-            else {
-                accel.removeEventListener("readingchanged",this.onDataChanged);
-                this.onDataChanged = null;
-                accel.reportInterval = 0; // back to the default
-                win();
-            }
-        }
-    },
+var CommandProxy  = {
+    
+    "Accelerometer": require('cordova/plugin/win8metro/AccelerometerProxy'),
     "Camera":{
         // args will contain ...  it is an array, so be careful
         // 0 quality:50, 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/9ec2de6c/lib/win8metro/plugin/win8metro/AccelerometerProxy.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/plugin/win8metro/AccelerometerProxy.js b/lib/win8metro/plugin/win8metro/AccelerometerProxy.js
new file mode 100644
index 0000000..37fd590
--- /dev/null
+++ b/lib/win8metro/plugin/win8metro/AccelerometerProxy.js
@@ -0,0 +1,39 @@
+var cordova = require('cordova');
+
+/* This is the actual implementation part that returns the result on Win8Metro
+*/
+
+module.exports = { 
+    onDataChanged:null,       
+    start:function(win,lose){
+
+        var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
+        if(!accel) {
+            lose("No accelerometer found");
+        }
+        else {
+            var self = this;
+            accel.reportInterval = Math.max(16,accel.minimumReportInterval);
+
+            // store our bound function
+            this.onDataChanged = function(e) {
+                var a = e.reading;
+                win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ));
+            }
+            accel.addEventListener("readingchanged",this.onDataChanged);
+        }
+    },
+    stop:function(win,lose){
+        console.log("Accelerometer.stop");
+        var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
+        if(!accel) {
+            lose("No accelerometer found");
+        }
+        else {
+            accel.removeEventListener("readingchanged",this.onDataChanged);
+            this.onDataChanged = null;
+            accel.reportInterval = 0; // back to the default
+            win();
+        }
+    }
+};
\ No newline at end of file


Mime
View raw message