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
+6 -2
View File
@@ -6,12 +6,15 @@
* Copyright (c) 2010-2011, IBM Corporation
*/
if (!PhoneGap.hasResource("device")) {
PhoneGap.addResource("device");
/**
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
* phone, etc.
* @constructor
*/
function Device() {
Device = function() {
this.available = PhoneGap.available;
this.platform = null;
this.version = null;
@@ -35,7 +38,7 @@ function Device() {
console.log("Error initializing PhoneGap: " + e);
alert("Error initializing PhoneGap: "+e);
});
}
};
/**
* Get device info
@@ -97,3 +100,4 @@ Device.prototype.exitApp = function() {
PhoneGap.addConstructor(function() {
navigator.device = window.device = new Device();
});
};