You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2020/07/02 10:12:36 UTC
[cordova-plugin-geolocation] branch master updated:
refactor(eslint): use cordova-eslint /w fix (#200)
This is an automated email from the ASF dual-hosted git repository.
timbru31 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-geolocation.git
The following commit(s) were added to refs/heads/master by this push:
new d6d5a34 refactor(eslint): use cordova-eslint /w fix (#200)
d6d5a34 is described below
commit d6d5a34ed670945b57dd8786fd05a13e478fd368
Author: Tim Brust <gi...@timbrust.de>
AuthorDate: Thu Jul 2 10:12:21 2020 +0000
refactor(eslint): use cordova-eslint /w fix (#200)
---
.eslintrc.yml | 31 +++--
package.json | 12 +-
src/windows/GeolocationProxy.js | 33 ++---
tests/tests.js | 271 +++++++++++++++++++++-------------------
www/Coordinates.js | 10 +-
www/Position.js | 14 ++-
www/PositionError.js | 2 +-
www/android/geolocation.js | 2 +-
www/geolocation.js | 31 +++--
9 files changed, 224 insertions(+), 182 deletions(-)
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 0cccb8c..17277f7 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -1,10 +1,23 @@
+# 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.
+
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
+extends: '@cordova/eslint-config/browser'
+
+overrides:
+ - files: [tests/**/*.js]
+ extends: '@cordova/eslint-config/node-tests'
diff --git a/package.json b/package.json
index dc65236..20dadbe 100644
--- a/package.json
+++ b/package.json
@@ -21,8 +21,8 @@
"cordova-windows"
],
"scripts": {
- "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"
+ "test": "npm run lint",
+ "lint": "eslint ."
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
@@ -37,12 +37,6 @@
}
},
"devDependencies": {
- "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"
+ "@cordova/eslint-config": "^3.0.0"
}
}
diff --git a/src/windows/GeolocationProxy.js b/src/windows/GeolocationProxy.js
index f792b91..e60d058 100644
--- a/src/windows/GeolocationProxy.js
+++ b/src/windows/GeolocationProxy.js
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-/* global Windows, WinJS */
+/* global cordova, Windows, WinJS */
var PositionError = require('./PositionError');
var callbacks = {};
@@ -50,13 +50,13 @@ 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
+ // This status indicates that a location device is still initializing
case Windows.Devices.Geolocation.PositionStatus.noData:
- // No location data is currently available
+ // 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.
+ // 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;
@@ -84,7 +84,8 @@ function createResult (pos) {
res.latitude = pos.coordinate.point.position.latitude;
res.longitude = pos.coordinate.point.position.longitude;
res.altitude = pos.coordinate.point.position.altitude;
- } else { // compatibility with old windows8.0 api
+ } else {
+ // compatibility with old windows8.0 api
res.latitude = pos.coordinate.latitude;
res.longitude = pos.coordinate.longitude;
res.altitude = pos.coordinate.altitude;
@@ -100,9 +101,9 @@ module.exports = {
var highAccuracy = args[0];
var maxAge = args[1];
- loc.desiredAccuracy = highAccuracy ?
- Windows.Devices.Geolocation.PositionAccuracy.high :
- Windows.Devices.Geolocation.PositionAccuracy.default;
+ loc.desiredAccuracy = highAccuracy
+ ? Windows.Devices.Geolocation.PositionAccuracy.high
+ : Windows.Devices.Geolocation.PositionAccuracy.default;
loc.reportInterval = maxAge || 0;
@@ -141,7 +142,8 @@ module.exports = {
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.'
+ message:
+ 'Data from location services is currently unavailable or you do not have the required location services present on your system.'
});
break;
@@ -159,11 +161,12 @@ module.exports = {
}
};
- loc.desiredAccuracy = highAccuracy ?
- Windows.Devices.Geolocation.PositionAccuracy.high :
- Windows.Devices.Geolocation.PositionAccuracy.default;
+ loc.desiredAccuracy = highAccuracy
+ ? Windows.Devices.Geolocation.PositionAccuracy.high
+ : Windows.Devices.Geolocation.PositionAccuracy.default;
- if (cordova.platformId === 'windows') { // eslint-disable-line no-undef
+ 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.
diff --git a/tests/tests.js b/tests/tests.js
index cf3a5ab..f6d1250 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -17,9 +17,8 @@
* specific language governing permissions and limitations
* under the License.
*
-*/
+ */
-/* eslint-env jasmine */
/* global WinJS, device */
exports.defineAutoTests = function () {
@@ -60,7 +59,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); // eslint-disable-line no-undef
+ 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) {
@@ -72,7 +71,6 @@ exports.defineAutoTests = function () {
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 () {
expect(navigator.geolocation).toBeDefined();
});
@@ -91,25 +89,19 @@ exports.defineAutoTests = function () {
expect(typeof navigator.geolocation.clearWatch).toBeDefined();
expect(typeof navigator.geolocation.clearWatch === 'function').toBe(true);
});
-
});
describe('getCurrentPosition method', 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) {
if (isWindowsStore || skipAndroid) {
pending();
}
- navigator.geolocation.getCurrentPosition(
- fail.bind(null, done),
- succeed.bind(null, done),
- {
- maximumAge: 0,
- timeout: 0
- });
+ navigator.geolocation.getCurrentPosition(fail.bind(null, done), succeed.bind(null, done), {
+ maximumAge: 0,
+ timeout: 0
+ });
});
it('geolocation.spec.9 on failure should return PositionError object with error code constants', function (done) {
@@ -129,42 +121,42 @@ exports.defineAutoTests = function () {
{
maximumAge: 0,
timeout: 0
- });
+ }
+ );
});
-
});
describe('success callback', function () {
-
it('geolocation.spec.6 should be called with a Position object', function (done) {
if (isWindowsStore || skipAndroid) {
pending();
}
- navigator.geolocation.getCurrentPosition(function (p) {
- 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.');
- expect(true).toBe(true);
- isIOSSim = true;
+ navigator.geolocation.getCurrentPosition(
+ function (p) {
+ expect(p.coords).toBeDefined();
+ expect(p.timestamp).toBeDefined();
done();
- } else {
- fail(done);
+ },
+ 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 {
+ fail(done);
+ }
+ },
+ {
+ maximumAge: 5 * 60 * 1000 // 5 minutes maximum age of cached position
}
- },
- {
- maximumAge: (5 * 60 * 1000) // 5 minutes maximum age of cached position
- });
+ );
}, 25000); // first geolocation call can take several seconds on some devices
});
-
});
describe('watchPosition method', function () {
-
beforeEach(function (done) {
// This timeout is set to lessen the load on platform's geolocation services
// which were causing occasional test failures
@@ -174,7 +166,6 @@ exports.defineAutoTests = function () {
});
describe('error callback', function () {
-
var errorWatch = null;
afterEach(function () {
navigator.geolocation.clearWatch(errorWatch);
@@ -192,7 +183,8 @@ exports.defineAutoTests = function () {
{
maximumAge: 0,
timeout: 0
- });
+ }
+ );
});
it('geolocation.spec.10 on failure should return PositionError object with error code constants', function (done) {
@@ -217,13 +209,12 @@ exports.defineAutoTests = function () {
{
maximumAge: 0,
timeout: 0
- });
+ }
+ );
});
-
});
describe('success callback', function () {
-
var successWatch = null;
afterEach(function () {
navigator.geolocation.clearWatch(successWatch);
@@ -250,15 +241,13 @@ exports.defineAutoTests = function () {
},
fail.bind(null, done, context, 'Unexpected fail callback'),
{
- maximumAge: (5 * 60 * 1000) // 5 minutes maximum age of cached position
- });
+ maximumAge: 5 * 60 * 1000 // 5 minutes maximum age of cached position
+ }
+ );
expect(successWatch).toBeDefined();
});
-
});
-
});
-
};
/******************************************************************************/
@@ -275,7 +264,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
document.getElementById('location_status').innerHTML = status;
}
function setLocationDetails (p) {
- var date = (new Date(p.timestamp));
+ 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;
@@ -357,90 +346,120 @@ exports.defineManualTests = function (contentEl, createActionButton) {
// Get location
geo.getCurrentPosition(success, fail, opts || { enableHighAccuracy: true }); //, {timeout: 10000});
-
};
/******************************************************************************/
- var location_div = '<div id="info">' +
- '<b>Status:</b> <span id="location_status">Stopped</span>' +
- '<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>';
- 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>';
- 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>';
- 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>';
- 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>';
- 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>';
- 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>';
- 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>';
+ var location_div = '<div id="info">' + '<b>Status:</b> <span id="location_status">Stopped</span>' + '<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>';
+ 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>';
+ 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>';
+ 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>';
+ 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>';
+ 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>';
+ 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>';
+ 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>';
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>' +
- 'Expected result: Will update all applicable values in status box for current location and update as location changes. Status will read Running.' +
- '<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.';
- 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 +
- altitude_accuracy + time + note + actions;
-
- createActionButton('Get Location', function () {
- getLocation();
- }, 'cordova-getLocation');
-
- createActionButton('Start Watching Location', function () {
- watchLocation();
- }, 'cordova-watchLocation');
-
- createActionButton('Stop Watching Location', function () {
- stopLocation();
- }, 'cordova-stopLocation');
-
- createActionButton('Get Location Up to 30 Sec Old', function () {
- getLocation({ maximumAge: 30000 });
- }, 'cordova-getOld');
+ '<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>' +
+ 'Expected result: Will update all applicable values in status box for current location and update as location changes. Status will read Running.' +
+ '<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.';
+ 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 +
+ altitude_accuracy +
+ time +
+ note +
+ actions;
+
+ createActionButton(
+ 'Get Location',
+ function () {
+ getLocation();
+ },
+ 'cordova-getLocation'
+ );
+
+ createActionButton(
+ 'Start Watching Location',
+ function () {
+ watchLocation();
+ },
+ 'cordova-watchLocation'
+ );
+
+ createActionButton(
+ 'Stop Watching Location',
+ function () {
+ stopLocation();
+ },
+ 'cordova-stopLocation'
+ );
+
+ createActionButton(
+ 'Get Location Up to 30 Sec Old',
+ function () {
+ getLocation({ maximumAge: 30000 });
+ },
+ 'cordova-getOld'
+ );
};
diff --git a/www/Coordinates.js b/www/Coordinates.js
index 1d7e879..c98a069 100644
--- a/www/Coordinates.js
+++ b/www/Coordinates.js
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*
-*/
+ */
/**
* This class contains position information.
@@ -46,15 +46,15 @@ var Coordinates = function (lat, lng, alt, acc, head, vel, altacc) {
/**
* The altitude of the position.
*/
- this.altitude = (alt !== undefined ? alt : null);
+ this.altitude = alt !== undefined ? alt : null;
/**
* The direction the device is moving at the position.
*/
- this.heading = (head !== undefined ? head : null);
+ this.heading = head !== undefined ? head : null;
/**
* The velocity with which the device is moving at the position.
*/
- this.speed = (vel !== undefined ? vel : null);
+ this.speed = vel !== undefined ? vel : null;
if (this.speed === 0 || this.speed === null) {
this.heading = NaN;
@@ -63,7 +63,7 @@ var Coordinates = function (lat, lng, alt, acc, head, vel, altacc) {
/**
* The altitude accuracy of the position.
*/
- this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
+ this.altitudeAccuracy = altacc !== undefined ? altacc : null;
};
module.exports = Coordinates;
diff --git a/www/Position.js b/www/Position.js
index b4f20e0..2015f59 100644
--- a/www/Position.js
+++ b/www/Position.js
@@ -17,17 +17,25 @@
* specific language governing permissions and limitations
* under the License.
*
-*/
+ */
var Coordinates = require('./Coordinates');
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);
+ this.coords = new Coordinates(
+ coords.latitude,
+ coords.longitude,
+ coords.altitude,
+ coords.accuracy,
+ coords.heading,
+ coords.velocity,
+ coords.altitudeAccuracy
+ );
} else {
this.coords = new Coordinates();
}
- this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime();
+ this.timestamp = timestamp !== undefined ? timestamp : new Date().getTime();
};
module.exports = Position;
diff --git a/www/PositionError.js b/www/PositionError.js
index 476b322..d7b7081 100644
--- a/www/PositionError.js
+++ b/www/PositionError.js
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*
-*/
+ */
/**
* Position error object
diff --git a/www/android/geolocation.js b/www/android/geolocation.js
index 5400554..c02940b 100644
--- a/www/android/geolocation.js
+++ b/www/android/geolocation.js
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*
-*/
+ */
var exec = cordova.require('cordova/exec'); // eslint-disable-line no-undef
var utils = require('cordova/utils');
diff --git a/www/geolocation.js b/www/geolocation.js
index c6c5788..ef4579c 100644
--- a/www/geolocation.js
+++ b/www/geolocation.js
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*
-*/
+ */
var argscheck = require('cordova/argscheck');
var utils = require('cordova/utils');
@@ -70,23 +70,23 @@ function createTimeout (errorCallback, timeout) {
var geolocation = {
lastPosition: null, // reference to last known (cached) position returned
/**
- * Asynchronously acquires the current position.
- *
- * @param {Function} successCallback The function to call when the position data is available
- * @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)
- */
+ * Asynchronously acquires the current position.
+ *
+ * @param {Function} successCallback The function to call when the position data is available
+ * @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) {
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) {
clearTimeout(timeoutTimer.timer);
- if (!(timeoutTimer.timer)) {
+ if (!timeoutTimer.timer) {
// Timeout already happened, or native fired error callback for
// this geo request.
// Don't continue with success callback.
@@ -118,15 +118,20 @@ var geolocation = {
// Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just
// fire the success callback with the cached position.
- if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp) <= options.maximumAge)) {
+ if (
+ geolocation.lastPosition &&
+ options.maximumAge &&
+ new Date().getTime() - geolocation.lastPosition.timestamp <= options.maximumAge
+ ) {
successCallback(geolocation.lastPosition);
- // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object.
+ // 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."
+ 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.
+ // Otherwise we have to call into native to retrieve a position.
} else {
if (options.timeout !== Infinity) {
// If the timeout value was not set to Infinity (default), then
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org