You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by au...@apache.org on 2017/08/09 18:43:05 UTC
cordova-plugin-geolocation git commit: CB-12895 : added eslint and
removed jshint
Repository: cordova-plugin-geolocation
Updated Branches:
refs/heads/master de69eb1b5 -> 69eb5ba5b
CB-12895 : added eslint and removed jshint
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/69eb5ba5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/69eb5ba5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/69eb5ba5
Branch: refs/heads/master
Commit: 69eb5ba5b5e801c55661dd277a2dd6997ff19c4d
Parents: de69eb1
Author: Audrey So <au...@apache.org>
Authored: Mon Jun 12 10:18:43 2017 -0700
Committer: Audrey So <au...@apache.org>
Committed: Thu Aug 3 07:57:04 2017 -0700
----------------------------------------------------------------------
.eslintrc.yml | 10 +++
.jshintrc | 17 ----
package.json | 12 ++-
src/firefoxos/GeolocationProxy.js | 30 +++----
src/windows/GeolocationProxy.js | 113 ++++++++++++++-------------
tests/tests.js | 126 +++++++++++++++---------------
www/Coordinates.js | 2 +-
www/Position.js | 2 +-
www/PositionError.js | 2 +-
www/android/geolocation.js | 34 ++++----
www/blackberry10/GeolocationProxy.js | 38 ++++-----
www/geolocation.js | 78 +++++++++---------
12 files changed, 231 insertions(+), 233 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/.eslintrc.yml b/.eslintrc.yml
new file mode 100644
index 0000000..0cccb8c
--- /dev/null
+++ b/.eslintrc.yml
@@ -0,0 +1,10 @@
+root: true
+extends: semistandard
+rules:
+ indent:
+ - error
+ - 4
+ camelcase: off
+ padded-blocks: off
+ operator-linebreak: off
+ no-throw-literal: off
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index df32482..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "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/69eb5ba5/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 4bc3ab2..5924167 100644
--- a/package.json
+++ b/package.json
@@ -40,8 +40,8 @@
"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"
+ "test": "npm run eslint",
+ "eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
@@ -53,6 +53,12 @@
}
},
"devDependencies": {
- "jshint": "^2.6.0"
+ "eslint": "^4.0.0",
+ "eslint-config-semistandard": "^11.0.0",
+ "eslint-config-standard": "^10.2.1",
+ "eslint-plugin-import": "^2.3.0",
+ "eslint-plugin-node": "^5.0.0",
+ "eslint-plugin-promise": "^3.5.0",
+ "eslint-plugin-standard": "^3.0.1"
}
}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/src/firefoxos/GeolocationProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/GeolocationProxy.js b/src/firefoxos/GeolocationProxy.js
index e4b4052..598f705 100644
--- a/src/firefoxos/GeolocationProxy.js
+++ b/src/firefoxos/GeolocationProxy.js
@@ -18,17 +18,17 @@
* under the License.
*
*/
-
+
// 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');
- function successCallback(position) {
- // Cordova is creating Position object using just coords
- success(position.coords);
+ getLocation: function (success, error, args) {
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef
+ function successCallback (position) {
+ // Cordova is creating Position object using just coords
+ success(position.coords);
}
geo.getCurrentPosition(successCallback, error, {
enableHighAccuracy: args[0],
@@ -36,11 +36,11 @@ module.exports = {
});
},
- addWatch: function(success, error, args) {
- var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+ addWatch: function (success, error, args) {
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef
var id = args[0];
- function successCallback(position) {
- success(position.coords);
+ function successCallback (position) {
+ success(position.coords);
}
var nativeId = geo.watchPosition(successCallback, error, {
enableHighAccuracy: args[1]
@@ -49,19 +49,19 @@ module.exports = {
idsMap[id] = nativeId;
},
- clearWatch: function(success, error, args) {
- var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+ clearWatch: function (success, error, args) {
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef
var id = args[0];
- if(id in idsMap) {
+ if (id in idsMap) {
geo.clearWatch(idsMap[id]);
delete idsMap[id];
}
- if(success) {
+ if (success) {
success();
}
}
};
-require("cordova/exec/proxy").add("Geolocation", module.exports);
+require('cordova/exec/proxy').add('Geolocation', module.exports);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/src/windows/GeolocationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/GeolocationProxy.js b/src/windows/GeolocationProxy.js
index 03ed495..f792b91 100644
--- a/src/windows/GeolocationProxy.js
+++ b/src/windows/GeolocationProxy.js
@@ -16,14 +16,14 @@
/* global Windows, WinJS */
-var PositionError = require('./PositionError');
-var callbacks = {};
-var locs = {};
+var PositionError = require('./PositionError');
+var callbacks = {};
+var locs = {};
// constants
var FALLBACK_EPSILON = 0.001;
-function ensureAndCreateLocator() {
+function ensureAndCreateLocator () {
var deferral;
var loc = new Windows.Devices.Geolocation.Geolocator();
@@ -46,30 +46,32 @@ function ensureAndCreateLocator() {
return deferral;
}
-function createErrorCode(loc) {
+function createErrorCode (loc) {
+ /* eslint-disable no-fallthrough */
switch (loc.locationStatus) {
- case Windows.Devices.Geolocation.PositionStatus.initializing:
- // This status indicates that a location device is still initializing
- case Windows.Devices.Geolocation.PositionStatus.noData:
- // No location data is currently available
- case Windows.Devices.Geolocation.PositionStatus.notInitialized:
- // This status indicates that the app has not yet requested
- // location data by calling GetGeolocationAsync() or
- // registering an event handler for the positionChanged event.
- case Windows.Devices.Geolocation.PositionStatus.notAvailable:
- // Location is not available on this version of Windows
- return PositionError.POSITION_UNAVAILABLE;
-
- case Windows.Devices.Geolocation.PositionStatus.disabled:
- // The app doesn't have permission to access location,
- // either because location has been turned off.
- return PositionError.PERMISSION_DENIED;
-
- default:
- break;
+ case Windows.Devices.Geolocation.PositionStatus.initializing:
+ // This status indicates that a location device is still initializing
+ case Windows.Devices.Geolocation.PositionStatus.noData:
+ // No location data is currently available
+ case Windows.Devices.Geolocation.PositionStatus.notInitialized:
+ // This status indicates that the app has not yet requested
+ // location data by calling GetGeolocationAsync() or
+ // registering an event handler for the positionChanged event.
+ case Windows.Devices.Geolocation.PositionStatus.notAvailable:
+ // Location is not available on this version of Windows
+ return PositionError.POSITION_UNAVAILABLE;
+
+ case Windows.Devices.Geolocation.PositionStatus.disabled:
+ // The app doesn't have permission to access location,
+ // either because location has been turned off.
+ return PositionError.PERMISSION_DENIED;
+
+ default:
+ break;
}
}
-function createResult(pos) {
+/* eslint-enable no-fallthrough */
+function createResult (pos) {
var res = {
accuracy: pos.coordinate.accuracy,
heading: pos.coordinate.heading,
@@ -95,14 +97,14 @@ module.exports = {
getLocation: function (success, fail, args, env) {
ensureAndCreateLocator().done(function (loc) {
if (loc) {
- var highAccuracy = args[0],
- maxAge = args[1];
+ var highAccuracy = args[0];
+ var maxAge = args[1];
loc.desiredAccuracy = highAccuracy ?
Windows.Devices.Geolocation.PositionAccuracy.high :
Windows.Devices.Geolocation.PositionAccuracy.default;
- loc.reportInterval = maxAge ? maxAge : 0;
+ loc.reportInterval = maxAge || 0;
loc.getGeopositionAsync().then(
function (pos) {
@@ -115,11 +117,10 @@ module.exports = {
});
}
);
- }
- else {
+ } else {
fail({
code: PositionError.POSITION_UNAVAILABLE,
- message: "You do not have the required location services present on your system."
+ message: 'You do not have the required location services present on your system.'
});
}
}, fail);
@@ -136,33 +137,33 @@ module.exports = {
var onStatusChanged = function (e) {
switch (e.status) {
- case Windows.Devices.Geolocation.PositionStatus.noData:
- case Windows.Devices.Geolocation.PositionStatus.notAvailable:
- fail({
- code: PositionError.POSITION_UNAVAILABLE,
- message: "Data from location services is currently unavailable or you do not have the required location services present on your system."
- });
- break;
-
- case Windows.Devices.Geolocation.PositionStatus.disabled:
- fail({
- code: PositionError.PERMISSION_DENIED,
- message: "Your location is currently turned off."
- });
- break;
+ case Windows.Devices.Geolocation.PositionStatus.noData:
+ case Windows.Devices.Geolocation.PositionStatus.notAvailable:
+ fail({
+ code: PositionError.POSITION_UNAVAILABLE,
+ message: 'Data from location services is currently unavailable or you do not have the required location services present on your system.'
+ });
+ break;
+
+ case Windows.Devices.Geolocation.PositionStatus.disabled:
+ fail({
+ code: PositionError.PERMISSION_DENIED,
+ message: 'Your location is currently turned off.'
+ });
+ break;
// case Windows.Devices.Geolocation.PositionStatus.initializing:
// case Windows.Devices.Geolocation.PositionStatus.ready:
- default:
- break;
+ default:
+ break;
}
};
loc.desiredAccuracy = highAccuracy ?
- Windows.Devices.Geolocation.PositionAccuracy.high :
- Windows.Devices.Geolocation.PositionAccuracy.default;
+ Windows.Devices.Geolocation.PositionAccuracy.high :
+ Windows.Devices.Geolocation.PositionAccuracy.default;
- if (cordova.platformId == 'windows') {
+ if (cordova.platformId === 'windows') { // eslint-disable-line no-undef
// 'positionchanged' event fails with error below if movementThreshold is not set
// JavaScript runtime error: Operation aborted
// You must set the MovementThreshold property or the ReportInterval property before adding event handlers.
@@ -174,8 +175,8 @@ module.exports = {
}
}
- loc.addEventListener("positionchanged", onPositionChanged);
- loc.addEventListener("statuschanged", onStatusChanged);
+ loc.addEventListener('positionchanged', onPositionChanged);
+ loc.addEventListener('statuschanged', onStatusChanged);
callbacks[clientId] = { pos: onPositionChanged, status: onStatusChanged };
locs[clientId] = loc;
@@ -185,11 +186,11 @@ 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);
- loc.removeEventListener("statuschanged", callback.status);
+ loc.removeEventListener('positionchanged', callback.pos);
+ loc.removeEventListener('statuschanged', callback.status);
delete callbacks[clientId];
delete locs[clientId];
@@ -199,4 +200,4 @@ module.exports = {
}
};
-require("cordova/exec/proxy").add("Geolocation", module.exports);
+require('cordova/exec/proxy').add('Geolocation', module.exports);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 50c5bfb..cf3a5ab 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -19,7 +19,7 @@
*
*/
-/* jshint jasmine: true */
+/* eslint-env jasmine */
/* global WinJS, device */
exports.defineAutoTests = function () {
@@ -42,7 +42,7 @@ exports.defineAutoTests = function () {
done();
});
};
-
+
var succeed = function (done, context) {
// prevents done() to be called several times
if (context) {
@@ -60,7 +60,7 @@ exports.defineAutoTests = function () {
};
// On Windows, some tests prompt user for permission to use geolocation and interrupt autotests run
- var isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone);
+ var isWindowsStore = (cordova.platformId === 'windows8') || (cordova.platformId === 'windows' && !WinJS.Utilities.isPhone); // eslint-disable-line no-undef
var majorDeviceVersion = null;
var versionRegex = /(\d)\..+/.exec(device.version);
if (versionRegex !== null) {
@@ -68,29 +68,28 @@ exports.defineAutoTests = function () {
}
// Starting from Android 6.0 there are confirmation dialog which prevents us from running auto tests in silent mode (user interaction needed)
// Also, Android emulator doesn't provide geo fix without manual interactions or mocks
- var skipAndroid = cordova.platformId == "android" && (device.isVirtual || majorDeviceVersion >= 6);
+ var skipAndroid = cordova.platformId === 'android' && (device.isVirtual || majorDeviceVersion >= 6); // eslint-disable-line no-undef
var isIOSSim = false; // if iOS simulator does not have a location set, it will fail.
-
describe('Geolocation (navigator.geolocation)', function () {
- it("geolocation.spec.1 should exist", function () {
+ it('geolocation.spec.1 should exist', function () {
expect(navigator.geolocation).toBeDefined();
});
- it("geolocation.spec.2 should contain a getCurrentPosition function", function () {
+ it('geolocation.spec.2 should contain a getCurrentPosition function', function () {
expect(typeof navigator.geolocation.getCurrentPosition).toBeDefined();
- expect(typeof navigator.geolocation.getCurrentPosition == 'function').toBe(true);
+ expect(typeof navigator.geolocation.getCurrentPosition === 'function').toBe(true);
});
- it("geolocation.spec.3 should contain a watchPosition function", function () {
+ it('geolocation.spec.3 should contain a watchPosition function', function () {
expect(typeof navigator.geolocation.watchPosition).toBeDefined();
- expect(typeof navigator.geolocation.watchPosition == 'function').toBe(true);
+ expect(typeof navigator.geolocation.watchPosition === 'function').toBe(true);
});
- it("geolocation.spec.4 should contain a clearWatch function", function () {
+ it('geolocation.spec.4 should contain a clearWatch function', function () {
expect(typeof navigator.geolocation.clearWatch).toBeDefined();
- expect(typeof navigator.geolocation.clearWatch == 'function').toBe(true);
+ expect(typeof navigator.geolocation.clearWatch === 'function').toBe(true);
});
});
@@ -99,7 +98,7 @@ exports.defineAutoTests = function () {
describe('error callback', function () {
- it("geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) {
+ it('geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number', function (done) {
if (isWindowsStore || skipAndroid) {
pending();
}
@@ -113,14 +112,14 @@ exports.defineAutoTests = function () {
});
});
- it("geolocation.spec.9 on failure should return PositionError object with error code constants", function (done) {
+ it('geolocation.spec.9 on failure should return PositionError object with error code constants', function (done) {
if (isWindowsStore || skipAndroid) {
pending();
}
navigator.geolocation.getCurrentPosition(
fail.bind(this, done),
- function(gpsError) {
+ function (gpsError) {
// W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface
expect(gpsError.PERMISSION_DENIED).toBe(1);
expect(gpsError.POSITION_UNAVAILABLE).toBe(2);
@@ -137,7 +136,7 @@ exports.defineAutoTests = function () {
describe('success callback', function () {
- it("geolocation.spec.6 should be called with a Position object", function (done) {
+ it('geolocation.spec.6 should be called with a Position object', function (done) {
if (isWindowsStore || skipAndroid) {
pending();
}
@@ -146,14 +145,13 @@ exports.defineAutoTests = function () {
expect(p.coords).toBeDefined();
expect(p.timestamp).toBeDefined();
done();
- }, function(err){
- if(err.message && err.message.indexOf('kCLErrorDomain') > -1){
- console.log("Error: Location not set in simulator, tests will fail.");
+ }, function (err) {
+ if (err.message && err.message.indexOf('kCLErrorDomain') > -1) {
+ console.log('Error: Location not set in simulator, tests will fail.');
expect(true).toBe(true);
isIOSSim = true;
done();
- }
- else {
+ } else {
fail(done);
}
},
@@ -167,10 +165,10 @@ exports.defineAutoTests = function () {
describe('watchPosition method', function () {
- beforeEach(function(done) {
+ beforeEach(function (done) {
// This timeout is set to lessen the load on platform's geolocation services
// which were causing occasional test failures
- setTimeout(function() {
+ setTimeout(function () {
done();
}, 100);
});
@@ -182,7 +180,7 @@ exports.defineAutoTests = function () {
navigator.geolocation.clearWatch(errorWatch);
});
- it("geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) {
+ it('geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number', function (done) {
if (isWindowsStore || skipAndroid) {
pending();
}
@@ -197,7 +195,7 @@ exports.defineAutoTests = function () {
});
});
- it("geolocation.spec.10 on failure should return PositionError object with error code constants", function (done) {
+ it('geolocation.spec.10 on failure should return PositionError object with error code constants', function (done) {
if (isWindowsStore || skipAndroid) {
pending();
}
@@ -205,7 +203,7 @@ exports.defineAutoTests = function () {
var context = this;
errorWatch = navigator.geolocation.watchPosition(
fail.bind(this, done, context, 'Unexpected win'),
- function(gpsError) {
+ function (gpsError) {
if (context.done) return;
context.done = true;
@@ -231,7 +229,7 @@ exports.defineAutoTests = function () {
navigator.geolocation.clearWatch(successWatch);
});
- it("geolocation.spec.8 should be called with a Position object", function (done) {
+ it('geolocation.spec.8 should be called with a Position object', function (done) {
if (isWindowsStore || skipAndroid || isIOSSim) {
pending();
}
@@ -245,7 +243,7 @@ exports.defineAutoTests = function () {
expect(p.coords).toBeDefined();
expect(p.timestamp).toBeDefined();
- // callback could be called sync so we invoke done async to make sure we know watcher id to .clear in afterEach
+ // callback could be called sync so we invoke done async to make sure we know watcher id to .clear in afterEach
setTimeout(function () {
done();
});
@@ -273,10 +271,10 @@ exports.defineManualTests = function (contentEl, createActionButton) {
/**
* Set location status
*/
- function setLocationStatus(status) {
+ function setLocationStatus (status) {
document.getElementById('location_status').innerHTML = status;
}
- function setLocationDetails(p) {
+ function setLocationDetails (p) {
var date = (new Date(p.timestamp));
document.getElementById('latitude').innerHTML = p.coords.latitude;
document.getElementById('longitude').innerHTML = p.coords.longitude;
@@ -285,19 +283,19 @@ exports.defineManualTests = function (contentEl, createActionButton) {
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();
+ document.getElementById('timestamp').innerHTML = date.toDateString() + ' ' + date.toTimeString();
}
/**
* Stop watching the location
*/
- function stopLocation() {
+ function stopLocation () {
var geo = navigator.geolocation;
if (!geo) {
- alert('navigator.geolocation object is missing.');
+ alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef
return;
}
- setLocationStatus("Stopped");
+ setLocationStatus('Stopped');
if (watchLocationId) {
geo.clearWatch(watchLocationId);
watchLocationId = null;
@@ -310,7 +308,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var watchLocation = function () {
var geo = navigator.geolocation;
if (!geo) {
- alert('navigator.geolocation object is missing.');
+ alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef
return;
}
@@ -321,13 +319,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
// Fail callback
var fail = function (e) {
- console.log("watchLocation fail callback with error code " + e);
+ console.log('watchLocation fail callback with error code ' + e);
stopLocation(geo);
};
// Get location
watchLocationId = geo.watchPosition(success, fail, { enableHighAccuracy: true });
- setLocationStatus("Running");
+ setLocationStatus('Running');
};
/**
@@ -336,7 +334,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var getLocation = function (opts) {
var geo = navigator.geolocation;
if (!geo) {
- alert('navigator.geolocation object is missing.');
+ alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef
return;
}
@@ -346,16 +344,16 @@ exports.defineManualTests = function (contentEl, createActionButton) {
// Success callback
var success = function (p) {
setLocationDetails(p);
- setLocationStatus("Done");
+ setLocationStatus('Done');
};
// Fail callback
var fail = function (e) {
- console.log("getLocation fail callback with error code " + e.code);
- setLocationStatus("Error: " + e.code);
+ console.log('getLocation fail callback with error code ' + e.code);
+ setLocationStatus('Error: ' + e.code);
};
- setLocationStatus("Retrieving location...");
+ setLocationStatus('Retrieving location...');
// Get location
geo.getCurrentPosition(success, fail, opts || { enableHighAccuracy: true }); //, {timeout: 10000});
@@ -366,54 +364,54 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var location_div = '<div id="info">' +
'<b>Status:</b> <span id="location_status">Stopped</span>' +
- '<table width="100%">',
- latitude = '<tr>' +
+ '<table width="100%">';
+ var latitude = '<tr>' +
'<td><b>Latitude:</b></td>' +
'<td id="latitude"> </td>' +
'<td>(decimal degrees) geographic coordinate [<a href="http://dev.w3.org/geo/api/spec-source.html#lat">#ref]</a></td>' +
- '</tr>',
- longitude = '<tr>' +
+ '</tr>';
+ var longitude = '<tr>' +
'<td><b>Longitude:</b></td>' +
'<td id="longitude"> </td>' +
'<td>(decimal degrees) geographic coordinate [<a href="http://dev.w3.org/geo/api/spec-source.html#lat">#ref]</a></td>' +
- '</tr>',
- altitude = '<tr>' +
+ '</tr>';
+ var altitude = '<tr>' +
'<td><b>Altitude:</b></td>' +
'<td id="altitude"> </td>' +
'<td>null if not supported;<br>' +
'(meters) height above the [<a href="http://dev.w3.org/geo/api/spec-source.html#ref-wgs">WGS84</a>] ellipsoid. [<a href="http://dev.w3.org/geo/api/spec-source.html#altitude">#ref]</a></td>' +
- '</tr>',
- accuracy = '<tr>' +
+ '</tr>';
+ var accuracy = '<tr>' +
'<td><b>Accuracy:</b></td>' +
'<td id="accuracy"> </td>' +
'<td>(meters; non-negative; 95% confidence level) the accuracy level of the latitude and longitude coordinates. [<a href="http://dev.w3.org/geo/api/spec-source.html#accuracy">#ref]</a></td>' +
- '</tr>',
- heading = '<tr>' +
+ '</tr>';
+ var heading = '<tr>' +
'<td><b>Heading:</b></td>' +
'<td id="heading"> </td>' +
'<td>null if not supported;<br>' +
'NaN if speed == 0;<br>' +
'(degrees; 0° ≤ heading < 360°) direction of travel of the hosting device- counting clockwise relative to the true north. [<a href="http://dev.w3.org/geo/api/spec-source.html#heading">#ref]</a></td>' +
- '</tr>',
- speed = '<tr>' +
+ '</tr>';
+ var speed = '<tr>' +
'<td><b>Speed:</b></td>' +
'<td id="speed"> </td>' +
'<td>null if not supported;<br>' +
'(meters per second; non-negative) magnitude of the horizontal component of the hosting device current velocity. [<a href="http://dev.w3.org/geo/api/spec-source.html#speed">#ref]</a></td>' +
- '</tr>',
- altitude_accuracy = '<tr>' +
+ '</tr>';
+ var altitude_accuracy = '<tr>' +
'<td><b>Altitude Accuracy:</b></td>' +
'<td id="altitude_accuracy"> </td>' +
'<td>null if not supported;<br>(meters; non-negative; 95% confidence level) the accuracy level of the altitude. [<a href="http://dev.w3.org/geo/api/spec-source.html#altitude-accuracy">#ref]</a></td>' +
- '</tr>',
- time = '<tr>' +
+ '</tr>';
+ var time = '<tr>' +
'<td><b>Time:</b></td>' +
'<td id="timestamp"> </td>' +
'<td>(DOMTimeStamp) when the position was acquired [<a href="http://dev.w3.org/geo/api/spec-source.html#timestamp">#ref]</a></td>' +
'</tr>' +
'</table>' +
- '</div>',
- actions =
+ '</div>';
+ var actions =
'<div id="cordova-getLocation"></div>' +
'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' +
'<p/> <div id="cordova-watchLocation"></div>' +
@@ -421,10 +419,10 @@ exports.defineManualTests = function (contentEl, createActionButton) {
'<p/> <div id="cordova-stopLocation"></div>' +
'Expected result: Will stop watching the location so values will not be updated. Status will read Stopped.' +
'<p/> <div id="cordova-getOld"></div>' +
- 'Expected result: Will update location values with a cached position that is up to 30 seconds old. Verify with time value. Status will read Done.',
- values_info =
- '<h3>Details about each value are listed below in the status box</h3>',
- note =
+ 'Expected result: Will update location values with a cached position that is up to 30 seconds old. Verify with time value. Status will read Done.';
+ var values_info =
+ '<h3>Details about each value are listed below in the status box</h3>';
+ var note =
'<h3>Allow use of current location, if prompted</h3>';
contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed +
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/www/Coordinates.js
----------------------------------------------------------------------
diff --git a/www/Coordinates.js b/www/Coordinates.js
index 84fdd5b..1d7e879 100644
--- a/www/Coordinates.js
+++ b/www/Coordinates.js
@@ -30,7 +30,7 @@
* @param {Object} altacc
* @constructor
*/
-var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
+var Coordinates = function (lat, lng, alt, acc, head, vel, altacc) {
/**
* The latitude of the position.
*/
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/www/Position.js
----------------------------------------------------------------------
diff --git a/www/Position.js b/www/Position.js
index d6b2c0c..b4f20e0 100644
--- a/www/Position.js
+++ b/www/Position.js
@@ -21,7 +21,7 @@
var Coordinates = require('./Coordinates');
-var Position = function(coords, timestamp) {
+var Position = function (coords, timestamp) {
if (coords) {
this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
} else {
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/www/PositionError.js
----------------------------------------------------------------------
diff --git a/www/PositionError.js b/www/PositionError.js
index 9456240..476b322 100644
--- a/www/PositionError.js
+++ b/www/PositionError.js
@@ -26,7 +26,7 @@
* @param code
* @param message
*/
-var PositionError = function(code, message) {
+var PositionError = function (code, message) {
this.code = code || null;
this.message = message || '';
};
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/www/android/geolocation.js
----------------------------------------------------------------------
diff --git a/www/android/geolocation.js b/www/android/geolocation.js
index 7265bec..5400554 100644
--- a/www/android/geolocation.js
+++ b/www/android/geolocation.js
@@ -19,7 +19,7 @@
*
*/
-var exec = cordova.require('cordova/exec');
+var exec = cordova.require('cordova/exec'); // eslint-disable-line no-undef
var utils = require('cordova/utils');
var PositionError = require('./PositionError');
@@ -28,44 +28,44 @@ var PositionError = require('./PositionError');
var pluginToNativeWatchMap = {};
module.exports = {
- getCurrentPosition: function(success, error, args) {
- var win = function() {
- var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
- geo.getCurrentPosition(success, error, args);
+ getCurrentPosition: function (success, error, args) {
+ var win = function () {
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef
+ geo.getCurrentPosition(success, error, args);
};
- var fail = function() {
+ var fail = function () {
if (error) {
- error(new PositionError (PositionError.PERMISSION_DENIED, 'Illegal Access'));
+ error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access'));
}
};
- exec(win, fail, "Geolocation", "getPermission", []);
+ exec(win, fail, 'Geolocation', 'getPermission', []);
},
- watchPosition: function(success, error, args) {
+ watchPosition: function (success, error, args) {
var pluginWatchId = utils.createUUID();
- var win = function() {
- var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+ var win = function () {
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef
pluginToNativeWatchMap[pluginWatchId] = geo.watchPosition(success, error, args);
};
- var fail = function() {
+ var fail = function () {
if (error) {
error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access'));
}
};
- exec(win, fail, "Geolocation", "getPermission", []);
+ exec(win, fail, 'Geolocation', 'getPermission', []);
return pluginWatchId;
},
- clearWatch: function(pluginWatchId) {
- var win = function() {
+ clearWatch: function (pluginWatchId) {
+ var win = function () {
var nativeWatchId = pluginToNativeWatchMap[pluginWatchId];
- var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef
geo.clearWatch(nativeWatchId);
};
- exec(win, null, "Geolocation", "getPermission", []);
+ exec(win, null, 'Geolocation', 'getPermission', []);
}
};
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/www/blackberry10/GeolocationProxy.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/GeolocationProxy.js b/www/blackberry10/GeolocationProxy.js
index 0bba226..476d84f 100644
--- a/www/blackberry10/GeolocationProxy.js
+++ b/www/blackberry10/GeolocationProxy.js
@@ -19,12 +19,12 @@
*
*/
-var idsMap = {},
- geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+var idsMap = {};
+var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef
module.exports = {
- getLocation: function(success, error, args) {
+ getLocation: function (success, error, args) {
var successCallback = function (result) {
var pos = result.coords;
pos.timestamp = result.timestamp;
@@ -38,32 +38,32 @@ module.exports = {
});
},
- addWatch: function(success, error, args) {
- var id = args[0],
- successCallback = function (result) {
- var pos = result.coords;
- pos.timestamp = result.timestamp;
- if (success) {
- success(pos);
- }
- },
- nativeId = geo.watchPosition(successCallback, error, {
- enableHighAccuracy: args[1]
- });
+ addWatch: function (success, error, args) {
+ var id = args[0];
+ var successCallback = function (result) {
+ var pos = result.coords;
+ pos.timestamp = result.timestamp;
+ if (success) {
+ success(pos);
+ }
+ };
+ var nativeId = geo.watchPosition(successCallback, error, {
+ enableHighAccuracy: args[1]
+ });
idsMap[id] = nativeId;
},
- clearWatch: function(success, error, args) {
+ clearWatch: function (success, error, args) {
var id = args[0];
- if(id in idsMap) {
+ if (id in idsMap) {
geo.clearWatch(idsMap[id]);
delete idsMap[id];
}
- if(success) {
+ if (success) {
success();
}
}
};
-require("cordova/exec/proxy").add("Geolocation", module.exports);
+require('cordova/exec/proxy').add('Geolocation', module.exports);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/69eb5ba5/www/geolocation.js
----------------------------------------------------------------------
diff --git a/www/geolocation.js b/www/geolocation.js
index f1f6445..c6c5788 100644
--- a/www/geolocation.js
+++ b/www/geolocation.js
@@ -19,16 +19,16 @@
*
*/
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- PositionError = require('./PositionError'),
- Position = require('./Position');
+var argscheck = require('cordova/argscheck');
+var utils = require('cordova/utils');
+var exec = require('cordova/exec');
+var PositionError = require('./PositionError');
+var Position = require('./Position');
-var timers = {}; // list of timers in use
+var timers = {}; // list of timers in use
// Returns default params, overrides if provided with values
-function parseParameters(options) {
+function parseParameters (options) {
var opt = {
maximumAge: 0,
enableHighAccuracy: false,
@@ -55,20 +55,20 @@ function parseParameters(options) {
}
// Returns a timeout failure, closed over a specified timeout value and error callback.
-function createTimeout(errorCallback, timeout) {
- var t = setTimeout(function() {
+function createTimeout (errorCallback, timeout) {
+ var t = setTimeout(function () {
clearTimeout(t);
t = null;
errorCallback({
- code:PositionError.TIMEOUT,
- message:"Position retrieval timed out."
+ code: PositionError.TIMEOUT,
+ message: 'Position retrieval timed out.'
});
}, timeout);
return t;
}
var geolocation = {
- lastPosition:null, // reference to last known (cached) position returned
+ lastPosition: null, // reference to last known (cached) position returned
/**
* Asynchronously acquires the current position.
*
@@ -76,15 +76,15 @@ var geolocation = {
* @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
* @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
*/
- getCurrentPosition:function(successCallback, errorCallback, options) {
+ getCurrentPosition: function (successCallback, errorCallback, options) {
argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
options = parseParameters(options);
// Timer var that will fire an error callback if no position is retrieved from native
// before the "timeout" param provided expires
- var timeoutTimer = {timer:null};
+ var timeoutTimer = {timer: null};
- var win = function(p) {
+ var win = function (p) {
clearTimeout(timeoutTimer.timer);
if (!(timeoutTimer.timer)) {
// Timeout already happened, or native fired error callback for
@@ -94,20 +94,20 @@ var geolocation = {
}
var pos = new Position(
{
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
+ latitude: p.latitude,
+ longitude: p.longitude,
+ altitude: p.altitude,
+ accuracy: p.accuracy,
+ heading: p.heading,
+ velocity: p.velocity,
+ altitudeAccuracy: p.altitudeAccuracy
},
p.timestamp
);
geolocation.lastPosition = pos;
successCallback(pos);
};
- var fail = function(e) {
+ var fail = function (e) {
clearTimeout(timeoutTimer.timer);
timeoutTimer.timer = null;
var err = new PositionError(e.code, e.message);
@@ -123,8 +123,8 @@ var geolocation = {
// If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object.
} else if (options.timeout === 0) {
fail({
- code:PositionError.TIMEOUT,
- message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter."
+ code: PositionError.TIMEOUT,
+ message: "timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter."
});
// Otherwise we have to call into native to retrieve a position.
} else {
@@ -139,7 +139,7 @@ var geolocation = {
// always truthy before we call into native
timeoutTimer.timer = true;
}
- exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
+ exec(win, fail, 'Geolocation', 'getLocation', [options.enableHighAccuracy, options.maximumAge]);
}
return timeoutTimer;
},
@@ -152,7 +152,7 @@ var geolocation = {
* @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
* @return String The watch id that must be passed to #clearWatch to stop watching.
*/
- watchPosition:function(successCallback, errorCallback, options) {
+ watchPosition: function (successCallback, errorCallback, options) {
argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
options = parseParameters(options);
@@ -161,7 +161,7 @@ var geolocation = {
// Tell device to get a position ASAP, and also retrieve a reference to the timeout timer generated in getCurrentPosition
timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
- var fail = function(e) {
+ var fail = function (e) {
clearTimeout(timers[id].timer);
var err = new PositionError(e.code, e.message);
if (errorCallback) {
@@ -169,20 +169,20 @@ var geolocation = {
}
};
- var win = function(p) {
+ var win = function (p) {
clearTimeout(timers[id].timer);
if (options.timeout !== Infinity) {
timers[id].timer = createTimeout(fail, options.timeout);
}
var pos = new Position(
{
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
+ latitude: p.latitude,
+ longitude: p.longitude,
+ altitude: p.altitude,
+ accuracy: p.accuracy,
+ heading: p.heading,
+ velocity: p.velocity,
+ altitudeAccuracy: p.altitudeAccuracy
},
p.timestamp
);
@@ -190,7 +190,7 @@ var geolocation = {
successCallback(pos);
};
- exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]);
+ exec(win, fail, 'Geolocation', 'addWatch', [id, options.enableHighAccuracy]);
return id;
},
@@ -199,11 +199,11 @@ var geolocation = {
*
* @param {String} id The ID of the watch returned from #watchPosition
*/
- clearWatch:function(id) {
+ clearWatch: function (id) {
if (id && timers[id] !== undefined) {
clearTimeout(timers[id].timer);
timers[id].timer = false;
- exec(null, null, "Geolocation", "clearWatch", [id]);
+ exec(null, null, 'Geolocation', 'clearWatch', [id]);
}
}
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org