cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject [09/47] git commit: proper implementation for firefoxos
Date Mon, 05 May 2014 16:13:06 GMT
proper implementation for firefoxos


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/b3209cb9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/b3209cb9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/b3209cb9

Branch: refs/heads/cdvtest
Commit: b3209cb92870a07528b5340e7e1845664858d6b3
Parents: 98b7283
Author: James Long <longster@gmail.com>
Authored: Mon Nov 4 13:50:38 2013 -0500
Committer: hermwong <herm.wong@gmail.com>
Committed: Wed Nov 6 13:42:30 2013 -0800

----------------------------------------------------------------------
 plugin.xml                        | 21 ++++++++++++---
 src/firefoxos/GeolocationProxy.js | 49 +++++++++++++++++++++-------------
 2 files changed, 48 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/b3209cb9/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 9a72f77..23307a6 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -132,18 +132,33 @@ xmlns:android="http://schemas.android.com/apk/res/android"
             <DeviceCapability Name="location" />
         </config-file>
     </platform>
-    
+
     <!-- firefoxos -->
     <platform name="firefoxos">
         <config-file target="config.xml" parent="/*">
             <feature name="Geolocation">
                 <param name="firefoxos-package" value="Geolocation" />
             </feature>
-        </config-file>                                         
+        </config-file>
+
         <js-module src="src/firefoxos/GeolocationProxy.js" name="GeolocationProxy">
             <runs />
         </js-module>
-    </platform>
 
+        <js-module src="www/Coordinates.js" name="Coordinates">
+            <clobbers target="Coordinates" />
+        </js-module>
 
+        <js-module src="www/PositionError.js" name="PositionError">
+            <clobbers target="PositionError" />
+        </js-module>
+
+        <js-module src="www/Position.js" name="Position">
+            <clobbers target="Position" />
+        </js-module>
+
+        <js-module src="www/geolocation.js" name="geolocation">
+            <clobbers target="navigator.geolocation" />
+        </js-module>
+    </platform>
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/b3209cb9/src/firefoxos/GeolocationProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/GeolocationProxy.js b/src/firefoxos/GeolocationProxy.js
index 0f05f02..c5803de 100644
--- a/src/firefoxos/GeolocationProxy.js
+++ b/src/firefoxos/GeolocationProxy.js
@@ -21,29 +21,40 @@
            
 // latest geolocation spec can be found here: http://www.w3.org/TR/geolocation-API/
 
+var idsMap = {};
+
 module.exports = {
+    getLocation: function(success, error, args) {
+        var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+        geo.getCurrentPosition(success, error, {
+            enableHighAccuracy: args[0],
+            maximumAge: args[1]
+        });
+    },
 
-    getCurrentPosition: function(win, geolocationError, args) {
-        win(position);
+    addWatch: function(success, error, args) {
+        var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
       
+        var id = args[0];
+        var nativeId = geo.watchPosition(success, error, {
+            enableHighAccuracy: args[1]
+        });
+
+        idsMap[id] = nativeId;
     },
-    
-    geolocationError(error) {
-        switch(error.code) {
-            case error.TIMEOUT:
-                console.log("geolocation timeout");
-                break;
-            case error.POSITION_UNAVAILABLE:
-                console.log("position unavailable");
-                break;
-            case error:.PERMISSION_DENIED:
-                console.log("permission denied");
-                break;
-            default:    
-                console.log("unknown error");
-                break;
+
+    clearWatch: function(success, error, args) {
+        var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+        var id = args[0];
+
+        if(id in idsMap) {
+            geo.clearWatch(idsMap[id]);
+            delete idsMap[id];
         }
-    }
 
+        if(success) {
+            success();
+        }
+    }
 };
 
-require("cordova/firefoxos/commandProxy").add("Geolocation", module.exports);
\ No newline at end of file
+require("cordova/firefoxos/commandProxy").add("Geolocation", module.exports);


Mime
View raw message