You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2013/09/23 16:34:48 UTC

[3/4] git commit: added Geolocation for FirefoxOS

added Geolocation 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/8840c938
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/8840c938
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/8840c938

Branch: refs/heads/master
Commit: 8840c938ea7909e7e74dd3a8e7ef61a96629b7d9
Parents: be1c752
Author: hermwong <he...@gmail.com>
Authored: Tue Sep 17 14:45:12 2013 -0700
Committer: hermwong <he...@gmail.com>
Committed: Tue Sep 17 14:45:12 2013 -0700

----------------------------------------------------------------------
 plugin.xml                        | 13 +++++++++
 src/firefoxos/GeolocationProxy.js | 49 ++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/8840c938/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 5a764f4..0572a4f 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -134,5 +134,18 @@ 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>                                         
+        <js-module src="src/firefoxos/GeolocationProxy.js" name="GeolocationProxy">
+            <runs />
+        </js-module>
+    </platform>
+
 
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/8840c938/src/firefoxos/GeolocationProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/GeolocationProxy.js b/src/firefoxos/GeolocationProxy.js
new file mode 100644
index 0000000..0f05f02
--- /dev/null
+++ b/src/firefoxos/GeolocationProxy.js
@@ -0,0 +1,49 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+           
+// latest geolocation spec can be found here: http://www.w3.org/TR/geolocation-API/
+
+module.exports = {
+
+    getCurrentPosition: function(win, geolocationError, args) {
+        win(position);
+    },
+    
+    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;
+        }
+    }
+
+};
+
+require("cordova/firefoxos/commandProxy").add("Geolocation", module.exports);
\ No newline at end of file