Add check to only init and run JS code once - even if included multiple times.

This commit is contained in:
Bryce Curtis
2011-03-30 13:29:24 -05:00
parent b850d225f4
commit 908485751b
16 changed files with 139 additions and 59 deletions
+12 -8
View File
@@ -6,6 +6,9 @@
* Copyright (c) 2010, IBM Corporation
*/
if (!PhoneGap.hasResource("position")) {
PhoneGap.addResource("position");
/**
* This class contains position information.
* @param {Object} lat
@@ -17,12 +20,12 @@
* @param {Object} vel
* @constructor
*/
function Position(coords, timestamp) {
Position = function(coords, timestamp) {
this.coords = coords;
this.timestamp = (timestamp !== 'undefined') ? timestamp : new Date().getTime();
}
};
function Coordinates(lat, lng, alt, acc, head, vel, altacc) {
Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
/**
* The latitude of the position.
*/
@@ -51,13 +54,13 @@ function Coordinates(lat, lng, alt, acc, head, vel, altacc) {
* The altitude accuracy of the position.
*/
this.altitudeAccuracy = (altacc !== 'undefined') ? altacc : null;
}
};
/**
* This class specifies the options for requesting position data.
* @constructor
*/
function PositionOptions() {
PositionOptions = function() {
/**
* Specifies the desired position accuracy.
*/
@@ -67,18 +70,19 @@ function PositionOptions() {
* is called.
*/
this.timeout = 10000;
}
};
/**
* This class contains information about any GSP errors.
* @constructor
*/
function PositionError() {
PositionError = function() {
this.code = null;
this.message = "";
}
};
PositionError.UNKNOWN_ERROR = 0;
PositionError.PERMISSION_DENIED = 1;
PositionError.POSITION_UNAVAILABLE = 2;
PositionError.TIMEOUT = 3;
};