You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/07/21 00:56:18 UTC

[7/11] js commit: stubbing File API

stubbing File API


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

Branch: refs/heads/master
Commit: dd9b970c53bf93c1fea503c287f026df838056e3
Parents: ef2e569
Author: Jesse <pu...@gmail.com>
Authored: Thu Jul 19 03:56:09 2012 -0700
Committer: Jesse <pu...@gmail.com>
Committed: Thu Jul 19 03:56:09 2012 -0700

----------------------------------------------------------------------
 lib/win8metro/exec.js |  102 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 93 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd9b970c/lib/win8metro/exec.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/exec.js b/lib/win8metro/exec.js
index 8af0c29..fb21454 100644
--- a/lib/win8metro/exec.js
+++ b/lib/win8metro/exec.js
@@ -36,7 +36,7 @@ var NativeProxy = {
             }
             else {
                 var self = this;
-                accel.reportInterval = Math.max(12,accel.minimumReportInterval);
+                accel.reportInterval = Math.max(16,accel.minimumReportInterval);
 
                 // store our bound function
                 this.onDataChanged = function(e) {
@@ -56,6 +56,7 @@ var NativeProxy = {
                 accel.removeEventListener("readingchanged",this.onDataChanged);
                 this.onDataChanged = null;
                 accel.reportInterval = 0; // back to the default
+                win();
             }
         }
     },
@@ -136,24 +137,37 @@ var NativeProxy = {
 
     },
     "Compass":{
-        //compass = Windows.Devices.Sensors.Compass.getDefault();
-        //
+        onReadingChanged:null,
         getHeading:function(win,lose) {
-            var comp = Windows.Devices.Sensors.Compass.getDefault();
-            if(!comp) {
+            var deviceCompass = Windows.Devices.Sensors.Compass.getDefault();
+            if(!deviceCompass) {
                 setTimeout(function(){lose("Compass not available");},0);
             }
             else {
-                var onResult = function(e) {
-                    comp.removeEventListener("readingchanged",onResult);
+
+                deviceCompass.reportInterval = Math.max(16,deviceCompass.minimumReportInterval);
+
+                this.onReadingChanged = function(e) {
                     var reading = e.reading;
-                    //result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp
+                    var heading = new CompassHeading(reading.headingMagneticNorth, reading.headingTrueNorth);
+                    win(heading);
                 };
-                comp.addEventListener("readingchanged",onResult);
+                deviceCompass.addEventListener("readingchanged",this.onReadingChanged);
             }
 
         },
         stopHeading:function(win,lose) {
+            var deviceCompass = Windows.Devices.Sensors.Compass.getDefault();
+            if(!deviceCompass) {
+                setTimeout(function(){lose("Compass not available");},0);
+            }
+            else {
+
+                deviceCompass.removeEventListener("readingchanged",this.onReadingChanged);
+                this.onReadingChanged = null;
+                deviceCompass.reportInterval = 0;
+                win();
+            }
 
         }
     },
@@ -165,6 +179,76 @@ var NativeProxy = {
             },0);
         }
     },
+    "File": {
+
+        getFileMetaData:function(win,fail,args) { // ["fullPath"]
+            var fullPath = args[0];
+        },
+        getMetadata:function(win,fail,args) { // ["fullPath"]
+            var fullPath = args[0];
+        },
+        getParent:function(win,fail,args) { // ["fullPath"]
+            var fullPath = args[0];
+        },
+        readAsText:function(win,fail,args) { // ["fileName","encoding"]
+            var fileName = args[0];
+            var encoding = args[1];
+        },
+        readAsDataURL:function(win,fail,args) { // ["fileName"]
+            var fileName = args[0];
+        },
+        getDirectory:function(win,fail,args) { // ["fullPath","path","options"]
+            var fullPath = args[0];
+            var path = args[1];
+            var options = args[2];
+        },
+        remove:function(win,fail,args) { // ["fullPath"]
+            var fullPath = args[0];
+        },
+        removeRecursively:function(win,fail,args) { // ["fullPath"]
+            var fullPath = args[0];
+        },
+        getFile:function(win,fail,args) { // ["fullPath","path","options"]
+            var fullPath = args[0];
+            var path = args[1];
+            var options = args[2];
+        },      
+        readEntries:function(win,fail,args) { // ["fullPath"]
+            var fullPath = args[0];
+        },
+        write:function(win,fail,args) { // ["fileName","data","position"]
+            var fileName = args[0];
+            var data = args[1];
+            var position = args[2];
+        },
+        truncate:function(win,fail,args) { // ["fileName","size"]
+            var fileName = args[0];
+            var size = args[1];
+        },
+        copyTo:function(win,fail,args) { // ["fullPath","parent", "newName"]
+            var fullPath = args[0];
+            var parent = args[1];
+            var newName = args[2];
+        },
+        moveTo:function(win,fail,args) { // ["fullPath","parent", "newName"]
+            var fullPath = args[0];
+            var parent = args[1];
+            var newName = args[2];
+        },
+        tempFileSystem:null,
+        persistentFileSystem:null,
+        requestFileSystem:function(win,fail,args) { // ["type","size"]
+
+            var type = args[0];
+            var size = args[1];
+
+
+        },         
+        resolveLocalFileSystemURI:function(win,fail,args) { // ["uri"]
+            var uri = args[0];
+        }           
+
+    },
     "NetworkStatus": { 
         getConnectionInfo:function(win,fail,args)
         {