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
+8 -5
View File
@@ -6,14 +6,17 @@
* Copyright (c) 2010, IBM Corporation
*/
if (!PhoneGap.hasResource("network")) {
PhoneGap.addResource("network");
/**
* This class contains information about any NetworkStatus.
* @constructor
*/
function NetworkStatus() {
NetworkStatus = function() {
//this.code = null;
//this.message = "";
}
};
NetworkStatus.NOT_REACHABLE = 0;
NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK = 1;
@@ -23,14 +26,14 @@ NetworkStatus.REACHABLE_VIA_WIFI_NETWORK = 2;
* This class provides access to device Network data (reachability).
* @constructor
*/
function Network() {
Network = function() {
/**
* The last known Network status.
* { hostName: string, ipAddress: string,
remoteHostStatus: int(0/1/2), internetConnectionStatus: int(0/1/2), localWiFiConnectionStatus: int (0/2) }
*/
this.lastReachability = null;
}
};
/**
* Called by the geolocation framework when the reachability status has changed.
@@ -61,4 +64,4 @@ PhoneGap.addConstructor(function() {
navigator.network = new Network();
}
});
};