diff options
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js')
| -rw-r--r-- | StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js index f1f64456..c6c57884 100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/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]); } } }; |
