mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
Add error checking for PhoneGap.addPlugin().
This commit is contained in:
parent
4f1bc1401f
commit
1428ac5ed5
@ -167,16 +167,23 @@ PhoneGap.addConstructor = function(func) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a plugin object to window.plugins
|
||||
* Adds a plugin object to window.plugins.
|
||||
* The plugin is accessed using window.plugins.<name>
|
||||
*
|
||||
* @param name The plugin name
|
||||
* @param obj The plugin object
|
||||
*/
|
||||
PhoneGap.addPlugin = function(name, obj) {
|
||||
if ( !window.plugins ) {
|
||||
window.plugins = {};
|
||||
}
|
||||
if (!window.plugins) {
|
||||
window.plugins = {};
|
||||
}
|
||||
|
||||
if ( !window.plugins[name] ) {
|
||||
window.plugins[name] = obj;
|
||||
}
|
||||
if (!window.plugins[name]) {
|
||||
window.plugins[name] = obj;
|
||||
}
|
||||
else {
|
||||
console.log("Error: Plugin "+name+" already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -737,4 +744,4 @@ PhoneGap.includeJavascript = function(jsfile, successCallback) {
|
||||
}
|
||||
el.src = jsfile;
|
||||
id.appendChild(el);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user