You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2016/02/29 08:29:01 UTC
cordova-plugin-geolocation git commit: CB-10636 Add JSHint for plugins
Repository: cordova-plugin-geolocation
Updated Branches:
refs/heads/master aa69e1bf1 -> d56ab5b08
CB-10636 Add JSHint for plugins
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/d56ab5b0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/d56ab5b0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/d56ab5b0
Branch: refs/heads/master
Commit: d56ab5b08ac855f73025a657521c79dcb93ef617
Parents: aa69e1b
Author: daserge <v-...@microsoft.com>
Authored: Fri Feb 26 20:34:43 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Fri Feb 26 20:58:55 2016 +0300
----------------------------------------------------------------------
.gitignore | 2 +-
.jshintrc | 17 ++++++++
.travis.yml | 4 ++
README.md | 2 +
package.json | 9 ++++-
src/windows/GeolocationProxy.js | 10 +++--
tests/tests.js | 76 +++++++++++++++++++-----------------
www/android/geolocation.js | 10 ++---
8 files changed, 82 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/d56ab5b0/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 52b558e..6964ea0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,7 @@ Thumbs.db
*.swp
*.user
-
+node_modules
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/d56ab5b0/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..df32482
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,17 @@
+{
+ "browser": true
+ , "devel": true
+ , "bitwise": true
+ , "undef": true
+ , "trailing": true
+ , "quotmark": false
+ , "indent": 4
+ , "unused": "vars"
+ , "latedef": "nofunc"
+ , "globals": {
+ "module": false,
+ "exports": false,
+ "require": false,
+ "cordova": true
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/d56ab5b0/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b9af4c5
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+sudo: false
+node_js:
+ - "4.2"
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/d56ab5b0/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 74695ea..28b67a8 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,8 @@
# under the License.
-->
+[](https://travis-ci.org/apache/cordova-plugin-geolocation)
+
# cordova-plugin-geolocation
This plugin provides information about the device's location, such as
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/d56ab5b0/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 83e4c1f..984899d 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,13 @@
"cordova-windows",
"cordova-firefoxos"
],
+ "scripts": {
+ "test": "npm run jshint",
+ "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
+ },
"author": "Apache Software Foundation",
- "license": "Apache-2.0"
+ "license": "Apache-2.0",
+ "devDependencies": {
+ "jshint": "^2.6.0"
+ }
}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/d56ab5b0/src/windows/GeolocationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/GeolocationProxy.js b/src/windows/GeolocationProxy.js
index 3f1a42d..03ed495 100644
--- a/src/windows/GeolocationProxy.js
+++ b/src/windows/GeolocationProxy.js
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+/* global Windows, WinJS */
+
var PositionError = require('./PositionError');
var callbacks = {};
var locs = {};
@@ -128,11 +130,11 @@ module.exports = {
var clientId = args[0];
var highAccuracy = args[1];
- onPositionChanged = function (e) {
+ var onPositionChanged = function (e) {
success(createResult(e.position), { keepCallback: true });
- },
+ };
- onStatusChanged = function (e) {
+ var onStatusChanged = function (e) {
switch (e.status) {
case Windows.Devices.Geolocation.PositionStatus.noData:
case Windows.Devices.Geolocation.PositionStatus.notAvailable:
@@ -183,7 +185,7 @@ module.exports = {
clearWatch: function (success, fail, args, env) {
var clientId = args[0];
var callback = callbacks[clientId];
- var loc = locs[clientId]
+ var loc = locs[clientId];
if (callback && loc) {
loc.removeEventListener("positionchanged", callback.pos);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/d56ab5b0/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 65a9c69..50c5bfb 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -18,6 +18,10 @@
* under the License.
*
*/
+
+/* jshint jasmine: true */
+/* global WinJS, device */
+
exports.defineAutoTests = function () {
var fail = function (done, context, message) {
// prevents done() to be called several times
@@ -267,6 +271,40 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var watchLocationId = null;
/**
+ * Set location status
+ */
+ function setLocationStatus(status) {
+ document.getElementById('location_status').innerHTML = status;
+ }
+ function setLocationDetails(p) {
+ var date = (new Date(p.timestamp));
+ document.getElementById('latitude').innerHTML = p.coords.latitude;
+ document.getElementById('longitude').innerHTML = p.coords.longitude;
+ document.getElementById('altitude').innerHTML = p.coords.altitude;
+ document.getElementById('accuracy').innerHTML = p.coords.accuracy;
+ document.getElementById('heading').innerHTML = p.coords.heading;
+ document.getElementById('speed').innerHTML = p.coords.speed;
+ document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy;
+ document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString();
+ }
+
+ /**
+ * Stop watching the location
+ */
+ function stopLocation() {
+ var geo = navigator.geolocation;
+ if (!geo) {
+ alert('navigator.geolocation object is missing.');
+ return;
+ }
+ setLocationStatus("Stopped");
+ if (watchLocationId) {
+ geo.clearWatch(watchLocationId);
+ watchLocationId = null;
+ }
+ }
+
+ /**
* Start watching location
*/
var watchLocation = function () {
@@ -293,22 +331,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
};
/**
- * Stop watching the location
- */
- var stopLocation = function () {
- var geo = navigator.geolocation;
- if (!geo) {
- alert('navigator.geolocation object is missing.');
- return;
- }
- setLocationStatus("Stopped");
- if (watchLocationId) {
- geo.clearWatch(watchLocationId);
- watchLocationId = null;
- }
- };
-
- /**
* Get current location
*/
var getLocation = function (opts) {
@@ -340,24 +362,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
};
- /**
- * Set location status
- */
- var setLocationStatus = function (status) {
- document.getElementById('location_status').innerHTML = status;
- };
- var setLocationDetails = function (p) {
- var date = (new Date(p.timestamp));
- document.getElementById('latitude').innerHTML = p.coords.latitude;
- document.getElementById('longitude').innerHTML = p.coords.longitude;
- document.getElementById('altitude').innerHTML = p.coords.altitude;
- document.getElementById('accuracy').innerHTML = p.coords.accuracy;
- document.getElementById('heading').innerHTML = p.coords.heading;
- document.getElementById('speed').innerHTML = p.coords.speed;
- document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy;
- document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString();
- };
-
/******************************************************************************/
var location_div = '<div id="info">' +
@@ -423,8 +427,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
note =
'<h3>Allow use of current location, if prompted</h3>';
- contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed
- + altitude_accuracy + time + note + actions;
+ contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed +
+ altitude_accuracy + time + note + actions;
createActionButton('Get Location', function () {
getLocation();
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/d56ab5b0/www/android/geolocation.js
----------------------------------------------------------------------
diff --git a/www/android/geolocation.js b/www/android/geolocation.js
index 57b8122..7265bec 100644
--- a/www/android/geolocation.js
+++ b/www/android/geolocation.js
@@ -19,13 +19,15 @@
*
*/
-
var exec = cordova.require('cordova/exec');
var utils = require('cordova/utils');
var PositionError = require('./PositionError');
-module.exports = {
+// Native watchPosition method is called async after permissions prompt.
+// So we use additional map and own ids to return watch id synchronously.
+var pluginToNativeWatchMap = {};
+module.exports = {
getCurrentPosition: function(success, error, args) {
var win = function() {
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
@@ -67,7 +69,3 @@ module.exports = {
exec(win, null, "Geolocation", "getPermission", []);
}
};
-
-// Native watchPosition method is called async after permissions prompt.
-// So we use additional map and own ids to return watch id synchronously.
-var pluginToNativeWatchMap = {};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org