mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Rename to Cordova
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("accelerometer")) {
|
||||
PhoneGap.addResource("accelerometer");
|
||||
if (!Cordova.hasResource("accelerometer")) {
|
||||
Cordova.addResource("accelerometer");
|
||||
|
||||
/** @constructor */
|
||||
var Acceleration = function(x, y, z) {
|
||||
@@ -69,7 +69,7 @@ Accelerometer.prototype.getCurrentAcceleration = function(successCallback, error
|
||||
}
|
||||
|
||||
// Get acceleration
|
||||
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
Cordova.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -98,18 +98,18 @@ Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallb
|
||||
}
|
||||
|
||||
// Make sure accelerometer timeout > frequency + 10 sec
|
||||
PhoneGap.exec(
|
||||
Cordova.exec(
|
||||
function(timeout) {
|
||||
if (timeout < (frequency + 10000)) {
|
||||
PhoneGap.exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
|
||||
Cordova.exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
|
||||
}
|
||||
},
|
||||
function(e) { }, "Accelerometer", "getTimeout", []);
|
||||
|
||||
// Start watch timer
|
||||
var id = PhoneGap.createUUID();
|
||||
var id = Cordova.createUUID();
|
||||
navigator.accelerometer.timers[id] = setInterval(function() {
|
||||
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
Cordova.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
}, (frequency ? frequency : 1));
|
||||
|
||||
return id;
|
||||
@@ -129,7 +129,7 @@ Accelerometer.prototype.clearWatch = function(id) {
|
||||
}
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if (typeof navigator.accelerometer === "undefined") {
|
||||
navigator.accelerometer = new Accelerometer();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("app")) {
|
||||
PhoneGap.addResource("app");
|
||||
if (!Cordova.hasResource("app")) {
|
||||
Cordova.addResource("app");
|
||||
(function() {
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ var App = function() {};
|
||||
* Clear the resource cache.
|
||||
*/
|
||||
App.prototype.clearCache = function() {
|
||||
PhoneGap.exec(null, null, "App", "clearCache", []);
|
||||
Cordova.exec(null, null, "App", "clearCache", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -49,14 +49,14 @@ App.prototype.clearCache = function() {
|
||||
* navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
|
||||
*/
|
||||
App.prototype.loadUrl = function(url, props) {
|
||||
PhoneGap.exec(null, null, "App", "loadUrl", [url, props]);
|
||||
Cordova.exec(null, null, "App", "loadUrl", [url, props]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel loadUrl that is waiting to be loaded.
|
||||
*/
|
||||
App.prototype.cancelLoadUrl = function() {
|
||||
PhoneGap.exec(null, null, "App", "cancelLoadUrl", []);
|
||||
Cordova.exec(null, null, "App", "cancelLoadUrl", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ App.prototype.cancelLoadUrl = function() {
|
||||
* Instead of BACK button loading the previous web page, it will exit the app.
|
||||
*/
|
||||
App.prototype.clearHistory = function() {
|
||||
PhoneGap.exec(null, null, "App", "clearHistory", []);
|
||||
Cordova.exec(null, null, "App", "clearHistory", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -72,17 +72,17 @@ App.prototype.clearHistory = function() {
|
||||
* This is the same as pressing the backbutton on Android device.
|
||||
*/
|
||||
App.prototype.backHistory = function() {
|
||||
PhoneGap.exec(null, null, "App", "backHistory", []);
|
||||
Cordova.exec(null, null, "App", "backHistory", []);
|
||||
};
|
||||
|
||||
/**
|
||||
* Exit and terminate the application.
|
||||
*/
|
||||
App.prototype.exitApp = function() {
|
||||
return PhoneGap.exec(null, null, "App", "exitApp", []);
|
||||
return Cordova.exec(null, null, "App", "exitApp", []);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
navigator.app = new App();
|
||||
});
|
||||
}());
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("battery")) {
|
||||
PhoneGap.addResource("battery");
|
||||
if (!Cordova.hasResource("battery")) {
|
||||
Cordova.addResource("battery");
|
||||
|
||||
/**
|
||||
* This class contains information about the current battery status.
|
||||
@@ -44,7 +44,7 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
|
||||
if (add) {
|
||||
// If there are no current registered event listeners start the battery listener on native side.
|
||||
if (me._batteryListener.length === 0 && me._lowListener.length === 0 && me._criticalListener.length === 0) {
|
||||
PhoneGap.exec(me._status, me._error, "Battery", "start", []);
|
||||
Cordova.exec(me._status, me._error, "Battery", "start", []);
|
||||
}
|
||||
|
||||
// Register the event listener in the proper array
|
||||
@@ -83,7 +83,7 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
|
||||
|
||||
// If there are no more registered event listeners stop the battery listener on native side.
|
||||
if (me._batteryListener.length === 0 && me._lowListener.length === 0 && me._criticalListener.length === 0) {
|
||||
PhoneGap.exec(null, null, "Battery", "stop", []);
|
||||
Cordova.exec(null, null, "Battery", "stop", []);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -99,15 +99,15 @@ Battery.prototype._status = function(info) {
|
||||
var level = info.level;
|
||||
if (me._level !== level || me._isPlugged !== info.isPlugged) {
|
||||
// Fire batterystatus event
|
||||
PhoneGap.fireWindowEvent("batterystatus", info);
|
||||
Cordova.fireWindowEvent("batterystatus", info);
|
||||
|
||||
// Fire low battery event
|
||||
if (level === 20 || level === 5) {
|
||||
if (level === 20) {
|
||||
PhoneGap.fireWindowEvent("batterylow", info);
|
||||
Cordova.fireWindowEvent("batterylow", info);
|
||||
}
|
||||
else {
|
||||
PhoneGap.fireWindowEvent("batterycritical", info);
|
||||
Cordova.fireWindowEvent("batterycritical", info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,12 +123,12 @@ Battery.prototype._error = function(e) {
|
||||
console.log("Error initializing Battery: " + e);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if (typeof navigator.battery === "undefined") {
|
||||
navigator.battery = new Battery();
|
||||
PhoneGap.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
|
||||
PhoneGap.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
|
||||
PhoneGap.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
|
||||
Cordova.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
|
||||
Cordova.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
|
||||
Cordova.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("camera")) {
|
||||
PhoneGap.addResource("camera");
|
||||
if (!Cordova.hasResource("camera")) {
|
||||
Cordova.addResource("camera");
|
||||
|
||||
/**
|
||||
* This class provides access to the device camera.
|
||||
@@ -157,10 +157,10 @@ Camera.prototype.getPicture = function(successCallback, errorCallback, options)
|
||||
}
|
||||
}
|
||||
|
||||
PhoneGap.exec(successCallback, errorCallback, "Camera", "takePicture", [options]);
|
||||
Cordova.exec(successCallback, errorCallback, "Camera", "takePicture", [options]);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if (typeof navigator.camera === "undefined") {
|
||||
navigator.camera = new Camera();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("capture")) {
|
||||
PhoneGap.addResource("capture");
|
||||
if (!Cordova.hasResource("capture")) {
|
||||
Cordova.addResource("capture");
|
||||
|
||||
/**
|
||||
* Represents a single file.
|
||||
@@ -44,7 +44,7 @@ var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
|
||||
* @param {Function} errorCB
|
||||
*/
|
||||
MediaFile.prototype.getFormatData = function(successCallback, errorCallback){
|
||||
PhoneGap.exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
|
||||
Cordova.exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,7 @@ var Capture = function(){
|
||||
* @param {CaptureAudioOptions} options
|
||||
*/
|
||||
Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
|
||||
PhoneGap.exec(successCallback, errorCallback, "Capture", "captureAudio", [options]);
|
||||
Cordova.exec(successCallback, errorCallback, "Capture", "captureAudio", [options]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ Capture.prototype.captureAudio = function(successCallback, errorCallback, option
|
||||
* @param {CaptureImageOptions} options
|
||||
*/
|
||||
Capture.prototype.captureImage = function(successCallback, errorCallback, options){
|
||||
PhoneGap.exec(successCallback, errorCallback, "Capture", "captureImage", [options]);
|
||||
Cordova.exec(successCallback, errorCallback, "Capture", "captureImage", [options]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ Capture.prototype._castMediaFile = function(pluginResult){
|
||||
* @param {CaptureVideoOptions} options
|
||||
*/
|
||||
Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
|
||||
PhoneGap.exec(successCallback, errorCallback, "Capture", "captureVideo", [options]);
|
||||
Cordova.exec(successCallback, errorCallback, "Capture", "captureVideo", [options]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -191,7 +191,7 @@ var CaptureAudioOptions = function(){
|
||||
this.mode = null;
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function(){
|
||||
Cordova.addConstructor(function(){
|
||||
if (typeof navigator.device.capture === "undefined") {
|
||||
navigator.device.capture = window.device.capture = new Capture();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("compass")) {
|
||||
PhoneGap.addResource("compass");
|
||||
if (!Cordova.hasResource("compass")) {
|
||||
Cordova.addResource("compass");
|
||||
|
||||
var CompassError = function(){
|
||||
this.code = null;
|
||||
@@ -75,7 +75,7 @@ Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, o
|
||||
}
|
||||
|
||||
// Get heading
|
||||
PhoneGap.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -104,19 +104,19 @@ Compass.prototype.watchHeading= function(successCallback, errorCallback, options
|
||||
}
|
||||
|
||||
// Make sure compass timeout > frequency + 10 sec
|
||||
PhoneGap.exec(
|
||||
Cordova.exec(
|
||||
function(timeout) {
|
||||
if (timeout < (frequency + 10000)) {
|
||||
PhoneGap.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
|
||||
Cordova.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
|
||||
}
|
||||
},
|
||||
function(e) { }, "Compass", "getTimeout", []);
|
||||
|
||||
// Start watch timer to get headings
|
||||
var id = PhoneGap.createUUID();
|
||||
var id = Cordova.createUUID();
|
||||
navigator.compass.timers[id] = setInterval(
|
||||
function() {
|
||||
PhoneGap.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
}, (frequency ? frequency : 1));
|
||||
|
||||
return id;
|
||||
@@ -145,7 +145,7 @@ Compass.prototype._castDate = function(pluginResult) {
|
||||
return pluginResult;
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if (typeof navigator.compass === "undefined") {
|
||||
navigator.compass = new Compass();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("contact")) {
|
||||
PhoneGap.addResource("contact");
|
||||
if (!Cordova.hasResource("contact")) {
|
||||
Cordova.addResource("contact");
|
||||
|
||||
/**
|
||||
* Contains information about a single contact.
|
||||
@@ -89,7 +89,7 @@ Contact.prototype.remove = function(successCB, errorCB) {
|
||||
errorCB(errorObj);
|
||||
}
|
||||
else {
|
||||
PhoneGap.exec(successCB, errorCB, "Contacts", "remove", [this.id]);
|
||||
Cordova.exec(successCB, errorCB, "Contacts", "remove", [this.id]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -99,7 +99,7 @@ Contact.prototype.remove = function(successCB, errorCB) {
|
||||
* @return copy of this Contact
|
||||
*/
|
||||
Contact.prototype.clone = function() {
|
||||
var clonedContact = PhoneGap.clone(this);
|
||||
var clonedContact = Cordova.clone(this);
|
||||
var i;
|
||||
clonedContact.id = null;
|
||||
clonedContact.rawId = null;
|
||||
@@ -153,7 +153,7 @@ Contact.prototype.clone = function() {
|
||||
* @param errorCB error callback
|
||||
*/
|
||||
Contact.prototype.save = function(successCB, errorCB) {
|
||||
PhoneGap.exec(successCB, errorCB, "Contacts", "save", [this]);
|
||||
Cordova.exec(successCB, errorCB, "Contacts", "save", [this]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -259,7 +259,7 @@ Contacts.prototype.find = function(fields, successCB, errorCB, options) {
|
||||
errorCB({"code": ContactError.INVALID_ARGUMENT_ERROR});
|
||||
}
|
||||
} else {
|
||||
PhoneGap.exec(successCB, errorCB, "Contacts", "search", [fields, options]);
|
||||
Cordova.exec(successCB, errorCB, "Contacts", "search", [fields, options]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -313,7 +313,7 @@ var ContactFindOptions = function(filter, multiple) {
|
||||
/**
|
||||
* Add the contact interface into the browser.
|
||||
*/
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if(typeof navigator.contacts === "undefined") {
|
||||
navigator.contacts = new Contacts();
|
||||
}
|
||||
|
||||
@@ -17,26 +17,24 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Version 1.2.0
|
||||
|
||||
if (typeof PhoneGap === "undefined") {
|
||||
if (typeof Cordova === "undefined") {
|
||||
|
||||
/**
|
||||
* The order of events during page load and PhoneGap startup is as follows:
|
||||
* The order of events during page load and Cordova startup is as follows:
|
||||
*
|
||||
* onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
|
||||
* window.onload Body onload event.
|
||||
* onNativeReady Internal event that indicates the PhoneGap native side is ready.
|
||||
* onPhoneGapInit Internal event that kicks off creation of all PhoneGap JavaScript objects (runs constructors).
|
||||
* onPhoneGapReady Internal event fired when all PhoneGap JavaScript objects have been created
|
||||
* onPhoneGapInfoReady Internal event fired when device properties are available
|
||||
* onDeviceReady User event fired to indicate that PhoneGap is ready
|
||||
* onNativeReady Internal event that indicates the Cordova native side is ready.
|
||||
* onCordovaInit Internal event that kicks off creation of all Cordova JavaScript objects (runs constructors).
|
||||
* onCordovaReady Internal event fired when all Cordova JavaScript objects have been created
|
||||
* onCordovaInfoReady Internal event fired when device properties are available
|
||||
* onDeviceReady User event fired to indicate that Cordova is ready
|
||||
* onResume User event fired to indicate a start/resume lifecycle event
|
||||
* onPause User event fired to indicate a pause lifecycle event
|
||||
* onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
|
||||
*
|
||||
* The only PhoneGap events that user code should register for are:
|
||||
* deviceready PhoneGap native code is initialized and PhoneGap APIs can be called from JavaScript
|
||||
* The only Cordova events that user code should register for are:
|
||||
* deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
|
||||
* pause App has moved to background
|
||||
* resume App has returned to foreground
|
||||
*
|
||||
@@ -51,45 +49,45 @@ if (typeof PhoneGap === "undefined") {
|
||||
*/
|
||||
|
||||
/**
|
||||
* This represents the PhoneGap API itself, and provides a global namespace for accessing
|
||||
* information about the state of PhoneGap.
|
||||
* This represents the Cordova API itself, and provides a global namespace for accessing
|
||||
* information about the state of Cordova.
|
||||
* @class
|
||||
*/
|
||||
var PhoneGap = {
|
||||
var Cordova = {
|
||||
documentEventHandler: {}, // Collection of custom document event handlers
|
||||
windowEventHandler: {} // Collection of custom window event handlers
|
||||
};
|
||||
|
||||
/**
|
||||
* List of resource files loaded by PhoneGap.
|
||||
* List of resource files loaded by Cordova.
|
||||
* This is used to ensure JS and other files are loaded only once.
|
||||
*/
|
||||
PhoneGap.resources = {base: true};
|
||||
Cordova.resources = {base: true};
|
||||
|
||||
/**
|
||||
* Determine if resource has been loaded by PhoneGap
|
||||
* Determine if resource has been loaded by Cordova
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
PhoneGap.hasResource = function(name) {
|
||||
return PhoneGap.resources[name];
|
||||
Cordova.hasResource = function(name) {
|
||||
return Cordova.resources[name];
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a resource to list of loaded resources by PhoneGap
|
||||
* Add a resource to list of loaded resources by Cordova
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
PhoneGap.addResource = function(name) {
|
||||
PhoneGap.resources[name] = true;
|
||||
Cordova.addResource = function(name) {
|
||||
Cordova.resources[name] = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom pub-sub channel that can have functions subscribed to it
|
||||
* @constructor
|
||||
*/
|
||||
PhoneGap.Channel = function (type)
|
||||
Cordova.Channel = function (type)
|
||||
{
|
||||
this.type = type;
|
||||
this.handlers = {};
|
||||
@@ -105,12 +103,12 @@ PhoneGap.Channel = function (type)
|
||||
* and a guid that can be used to stop subscribing to the channel.
|
||||
* Returns the guid.
|
||||
*/
|
||||
PhoneGap.Channel.prototype.subscribe = function(f, c, g) {
|
||||
Cordova.Channel.prototype.subscribe = function(f, c, g) {
|
||||
// need a function to call
|
||||
if (f === null) { return; }
|
||||
|
||||
var func = f;
|
||||
if (typeof c === "object" && typeof f === "function") { func = PhoneGap.close(c, f); }
|
||||
if (typeof c === "object" && typeof f === "function") { func = Cordova.close(c, f); }
|
||||
|
||||
g = g || func.observer_guid || f.observer_guid || this.guid++;
|
||||
func.observer_guid = g;
|
||||
@@ -123,7 +121,7 @@ PhoneGap.Channel.prototype.subscribe = function(f, c, g) {
|
||||
* Like subscribe but the function is only called once and then it
|
||||
* auto-unsubscribes itself.
|
||||
*/
|
||||
PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
|
||||
Cordova.Channel.prototype.subscribeOnce = function(f, c) {
|
||||
var g = null;
|
||||
var _this = this;
|
||||
var m = function() {
|
||||
@@ -131,7 +129,7 @@ PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
|
||||
_this.unsubscribe(g);
|
||||
};
|
||||
if (this.fired) {
|
||||
if (typeof c === "object" && typeof f === "function") { f = PhoneGap.close(c, f); }
|
||||
if (typeof c === "object" && typeof f === "function") { f = Cordova.close(c, f); }
|
||||
f.apply(this, this.fireArgs);
|
||||
} else {
|
||||
g = this.subscribe(m);
|
||||
@@ -142,7 +140,7 @@ PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
|
||||
/**
|
||||
* Unsubscribes the function with the given guid from the channel.
|
||||
*/
|
||||
PhoneGap.Channel.prototype.unsubscribe = function(g) {
|
||||
Cordova.Channel.prototype.unsubscribe = function(g) {
|
||||
if (typeof g === "function") { g = g.observer_guid; }
|
||||
this.handlers[g] = null;
|
||||
delete this.handlers[g];
|
||||
@@ -151,7 +149,7 @@ PhoneGap.Channel.prototype.unsubscribe = function(g) {
|
||||
/**
|
||||
* Calls all functions subscribed to this channel.
|
||||
*/
|
||||
PhoneGap.Channel.prototype.fire = function(e) {
|
||||
Cordova.Channel.prototype.fire = function(e) {
|
||||
if (this.enabled) {
|
||||
var fail = false;
|
||||
var item, handler, rv;
|
||||
@@ -175,7 +173,7 @@ PhoneGap.Channel.prototype.fire = function(e) {
|
||||
* Calls the provided function only after all of the channels specified
|
||||
* have been fired.
|
||||
*/
|
||||
PhoneGap.Channel.join = function(h, c) {
|
||||
Cordova.Channel.join = function(h, c) {
|
||||
var i = c.length;
|
||||
var f = function() {
|
||||
if (!(--i)) {
|
||||
@@ -199,11 +197,11 @@ PhoneGap.Channel.join = function(h, c) {
|
||||
|
||||
/**
|
||||
* Add an initialization function to a queue that ensures it will run and initialize
|
||||
* application constructors only once PhoneGap has been initialized.
|
||||
* @param {Function} func The function callback you want run once PhoneGap is initialized
|
||||
* application constructors only once Cordova has been initialized.
|
||||
* @param {Function} func The function callback you want run once Cordova is initialized
|
||||
*/
|
||||
PhoneGap.addConstructor = function(func) {
|
||||
PhoneGap.onPhoneGapInit.subscribeOnce(function() {
|
||||
Cordova.addConstructor = function(func) {
|
||||
Cordova.onCordovaInit.subscribeOnce(function() {
|
||||
try {
|
||||
func();
|
||||
} catch(e) {
|
||||
@@ -226,7 +224,7 @@ if (!window.plugins) {
|
||||
* @param name The plugin name
|
||||
* @param obj The plugin object
|
||||
*/
|
||||
PhoneGap.addPlugin = function(name, obj) {
|
||||
Cordova.addPlugin = function(name, obj) {
|
||||
if (!window.plugins[name]) {
|
||||
window.plugins[name] = obj;
|
||||
}
|
||||
@@ -239,78 +237,78 @@ PhoneGap.addPlugin = function(name, obj) {
|
||||
* onDOMContentLoaded channel is fired when the DOM content
|
||||
* of the page has been parsed.
|
||||
*/
|
||||
PhoneGap.onDOMContentLoaded = new PhoneGap.Channel('onDOMContentLoaded');
|
||||
Cordova.onDOMContentLoaded = new Cordova.Channel('onDOMContentLoaded');
|
||||
|
||||
/**
|
||||
* onNativeReady channel is fired when the PhoneGap native code
|
||||
* onNativeReady channel is fired when the Cordova native code
|
||||
* has been initialized.
|
||||
*/
|
||||
PhoneGap.onNativeReady = new PhoneGap.Channel('onNativeReady');
|
||||
Cordova.onNativeReady = new Cordova.Channel('onNativeReady');
|
||||
|
||||
/**
|
||||
* onPhoneGapInit channel is fired when the web page is fully loaded and
|
||||
* PhoneGap native code has been initialized.
|
||||
* onCordovaInit channel is fired when the web page is fully loaded and
|
||||
* Cordova native code has been initialized.
|
||||
*/
|
||||
PhoneGap.onPhoneGapInit = new PhoneGap.Channel('onPhoneGapInit');
|
||||
Cordova.onCordovaInit = new Cordova.Channel('onCordovaInit');
|
||||
|
||||
/**
|
||||
* onPhoneGapReady channel is fired when the JS PhoneGap objects have been created.
|
||||
* onCordovaReady channel is fired when the JS Cordova objects have been created.
|
||||
*/
|
||||
PhoneGap.onPhoneGapReady = new PhoneGap.Channel('onPhoneGapReady');
|
||||
Cordova.onCordovaReady = new Cordova.Channel('onCordovaReady');
|
||||
|
||||
/**
|
||||
* onPhoneGapInfoReady channel is fired when the PhoneGap device properties
|
||||
* onCordovaInfoReady channel is fired when the Cordova device properties
|
||||
* has been set.
|
||||
*/
|
||||
PhoneGap.onPhoneGapInfoReady = new PhoneGap.Channel('onPhoneGapInfoReady');
|
||||
Cordova.onCordovaInfoReady = new Cordova.Channel('onCordovaInfoReady');
|
||||
|
||||
/**
|
||||
* onPhoneGapConnectionReady channel is fired when the PhoneGap connection properties
|
||||
* onCordovaConnectionReady channel is fired when the Cordova connection properties
|
||||
* has been set.
|
||||
*/
|
||||
PhoneGap.onPhoneGapConnectionReady = new PhoneGap.Channel('onPhoneGapConnectionReady');
|
||||
Cordova.onCordovaConnectionReady = new Cordova.Channel('onCordovaConnectionReady');
|
||||
|
||||
/**
|
||||
* onDestroy channel is fired when the PhoneGap native code
|
||||
* onDestroy channel is fired when the Cordova native code
|
||||
* is destroyed. It is used internally.
|
||||
* Window.onunload should be used by the user.
|
||||
*/
|
||||
PhoneGap.onDestroy = new PhoneGap.Channel('onDestroy');
|
||||
PhoneGap.onDestroy.subscribeOnce(function() {
|
||||
PhoneGap.shuttingDown = true;
|
||||
Cordova.onDestroy = new Cordova.Channel('onDestroy');
|
||||
Cordova.onDestroy.subscribeOnce(function() {
|
||||
Cordova.shuttingDown = true;
|
||||
});
|
||||
PhoneGap.shuttingDown = false;
|
||||
Cordova.shuttingDown = false;
|
||||
|
||||
// _nativeReady is global variable that the native side can set
|
||||
// to signify that the native code is ready. It is a global since
|
||||
// it may be called before any PhoneGap JS is ready.
|
||||
if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
|
||||
// it may be called before any Cordova JS is ready.
|
||||
if (typeof _nativeReady !== 'undefined') { Cordova.onNativeReady.fire(); }
|
||||
|
||||
/**
|
||||
* onDeviceReady is fired only after all PhoneGap objects are created and
|
||||
* onDeviceReady is fired only after all Cordova objects are created and
|
||||
* the device properties are set.
|
||||
*/
|
||||
PhoneGap.onDeviceReady = new PhoneGap.Channel('onDeviceReady');
|
||||
Cordova.onDeviceReady = new Cordova.Channel('onDeviceReady');
|
||||
|
||||
|
||||
// Array of channels that must fire before "deviceready" is fired
|
||||
PhoneGap.deviceReadyChannelsArray = [ PhoneGap.onPhoneGapReady, PhoneGap.onPhoneGapInfoReady, PhoneGap.onPhoneGapConnectionReady];
|
||||
Cordova.deviceReadyChannelsArray = [ Cordova.onCordovaReady, Cordova.onCordovaInfoReady, Cordova.onCordovaConnectionReady];
|
||||
|
||||
// Hashtable of user defined channels that must also fire before "deviceready" is fired
|
||||
PhoneGap.deviceReadyChannelsMap = {};
|
||||
Cordova.deviceReadyChannelsMap = {};
|
||||
|
||||
/**
|
||||
* Indicate that a feature needs to be initialized before it is ready to be used.
|
||||
* This holds up PhoneGap's "deviceready" event until the feature has been initialized
|
||||
* and PhoneGap.initComplete(feature) is called.
|
||||
* This holds up Cordova's "deviceready" event until the feature has been initialized
|
||||
* and Cordova.initComplete(feature) is called.
|
||||
*
|
||||
* @param feature {String} The unique feature name
|
||||
*/
|
||||
PhoneGap.waitForInitialization = function(feature) {
|
||||
Cordova.waitForInitialization = function(feature) {
|
||||
if (feature) {
|
||||
var channel = new PhoneGap.Channel(feature);
|
||||
PhoneGap.deviceReadyChannelsMap[feature] = channel;
|
||||
PhoneGap.deviceReadyChannelsArray.push(channel);
|
||||
var channel = new Cordova.Channel(feature);
|
||||
Cordova.deviceReadyChannelsMap[feature] = channel;
|
||||
Cordova.deviceReadyChannelsArray.push(channel);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -319,64 +317,64 @@ PhoneGap.waitForInitialization = function(feature) {
|
||||
*
|
||||
* @param feature {String} The unique feature name
|
||||
*/
|
||||
PhoneGap.initializationComplete = function(feature) {
|
||||
var channel = PhoneGap.deviceReadyChannelsMap[feature];
|
||||
Cordova.initializationComplete = function(feature) {
|
||||
var channel = Cordova.deviceReadyChannelsMap[feature];
|
||||
if (channel) {
|
||||
channel.fire();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create all PhoneGap objects once page has fully loaded and native side is ready.
|
||||
* Create all Cordova objects once page has fully loaded and native side is ready.
|
||||
*/
|
||||
PhoneGap.Channel.join(function() {
|
||||
Cordova.Channel.join(function() {
|
||||
|
||||
// Start listening for XHR callbacks
|
||||
setTimeout(function() {
|
||||
if (PhoneGap.UsePolling) {
|
||||
PhoneGap.JSCallbackPolling();
|
||||
if (Cordova.UsePolling) {
|
||||
Cordova.JSCallbackPolling();
|
||||
}
|
||||
else {
|
||||
var polling = prompt("usePolling", "gap_callbackServer:");
|
||||
PhoneGap.UsePolling = polling;
|
||||
Cordova.UsePolling = polling;
|
||||
if (polling == "true") {
|
||||
PhoneGap.UsePolling = true;
|
||||
PhoneGap.JSCallbackPolling();
|
||||
Cordova.UsePolling = true;
|
||||
Cordova.JSCallbackPolling();
|
||||
}
|
||||
else {
|
||||
PhoneGap.UsePolling = false;
|
||||
PhoneGap.JSCallback();
|
||||
Cordova.UsePolling = false;
|
||||
Cordova.JSCallback();
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
|
||||
// Run PhoneGap constructors
|
||||
PhoneGap.onPhoneGapInit.fire();
|
||||
// Run Cordova constructors
|
||||
Cordova.onCordovaInit.fire();
|
||||
|
||||
// Fire event to notify that all objects are created
|
||||
PhoneGap.onPhoneGapReady.fire();
|
||||
Cordova.onCordovaReady.fire();
|
||||
|
||||
// Fire onDeviceReady event once all constructors have run and PhoneGap info has been
|
||||
// Fire onDeviceReady event once all constructors have run and Cordova info has been
|
||||
// received from native side, and any user defined initialization channels.
|
||||
PhoneGap.Channel.join(function() {
|
||||
Cordova.Channel.join(function() {
|
||||
// Let native code know we are inited on JS side
|
||||
prompt("", "gap_init:");
|
||||
|
||||
PhoneGap.onDeviceReady.fire();
|
||||
}, PhoneGap.deviceReadyChannelsArray);
|
||||
Cordova.onDeviceReady.fire();
|
||||
}, Cordova.deviceReadyChannelsArray);
|
||||
|
||||
}, [ PhoneGap.onDOMContentLoaded, PhoneGap.onNativeReady ]);
|
||||
}, [ Cordova.onDOMContentLoaded, Cordova.onNativeReady ]);
|
||||
|
||||
// Listen for DOMContentLoaded and notify our channel subscribers
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
PhoneGap.onDOMContentLoaded.fire();
|
||||
Cordova.onDOMContentLoaded.fire();
|
||||
}, false);
|
||||
|
||||
// Intercept calls to document.addEventListener and watch for deviceready
|
||||
PhoneGap.m_document_addEventListener = document.addEventListener;
|
||||
Cordova.m_document_addEventListener = document.addEventListener;
|
||||
|
||||
// Intercept calls to window.addEventListener
|
||||
PhoneGap.m_window_addEventListener = window.addEventListener;
|
||||
Cordova.m_window_addEventListener = window.addEventListener;
|
||||
|
||||
/**
|
||||
* Add a custom window event handler.
|
||||
@@ -384,8 +382,8 @@ PhoneGap.m_window_addEventListener = window.addEventListener;
|
||||
* @param {String} event The event name that callback handles
|
||||
* @param {Function} callback The event handler
|
||||
*/
|
||||
PhoneGap.addWindowEventHandler = function(event, callback) {
|
||||
PhoneGap.windowEventHandler[event] = callback;
|
||||
Cordova.addWindowEventHandler = function(event, callback) {
|
||||
Cordova.windowEventHandler[event] = callback;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -394,8 +392,8 @@ PhoneGap.addWindowEventHandler = function(event, callback) {
|
||||
* @param {String} event The event name that callback handles
|
||||
* @param {Function} callback The event handler
|
||||
*/
|
||||
PhoneGap.addDocumentEventHandler = function(event, callback) {
|
||||
PhoneGap.documentEventHandler[event] = callback;
|
||||
Cordova.addDocumentEventHandler = function(event, callback) {
|
||||
Cordova.documentEventHandler[event] = callback;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -408,22 +406,22 @@ PhoneGap.addDocumentEventHandler = function(event, callback) {
|
||||
document.addEventListener = function(evt, handler, capture) {
|
||||
var e = evt.toLowerCase();
|
||||
if (e === 'deviceready') {
|
||||
PhoneGap.onDeviceReady.subscribeOnce(handler);
|
||||
Cordova.onDeviceReady.subscribeOnce(handler);
|
||||
}
|
||||
else {
|
||||
// If subscribing to Android backbutton
|
||||
if (e === 'backbutton') {
|
||||
PhoneGap.exec(null, null, "App", "overrideBackbutton", [true]);
|
||||
Cordova.exec(null, null, "App", "overrideBackbutton", [true]);
|
||||
}
|
||||
|
||||
// If subscribing to an event that is handled by a plugin
|
||||
else if (typeof PhoneGap.documentEventHandler[e] !== "undefined") {
|
||||
if (PhoneGap.documentEventHandler[e](e, handler, true)) {
|
||||
else if (typeof Cordova.documentEventHandler[e] !== "undefined") {
|
||||
if (Cordova.documentEventHandler[e](e, handler, true)) {
|
||||
return; // Stop default behavior
|
||||
}
|
||||
}
|
||||
|
||||
PhoneGap.m_document_addEventListener.call(document, evt, handler, capture);
|
||||
Cordova.m_document_addEventListener.call(document, evt, handler, capture);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -438,21 +436,21 @@ window.addEventListener = function(evt, handler, capture) {
|
||||
var e = evt.toLowerCase();
|
||||
|
||||
// If subscribing to an event that is handled by a plugin
|
||||
if (typeof PhoneGap.windowEventHandler[e] !== "undefined") {
|
||||
if (PhoneGap.windowEventHandler[e](e, handler, true)) {
|
||||
if (typeof Cordova.windowEventHandler[e] !== "undefined") {
|
||||
if (Cordova.windowEventHandler[e](e, handler, true)) {
|
||||
return; // Stop default behavior
|
||||
}
|
||||
}
|
||||
|
||||
PhoneGap.m_window_addEventListener.call(window, evt, handler, capture);
|
||||
Cordova.m_window_addEventListener.call(window, evt, handler, capture);
|
||||
};
|
||||
|
||||
// Intercept calls to document.removeEventListener and watch for events that
|
||||
// are generated by PhoneGap native code
|
||||
PhoneGap.m_document_removeEventListener = document.removeEventListener;
|
||||
// are generated by Cordova native code
|
||||
Cordova.m_document_removeEventListener = document.removeEventListener;
|
||||
|
||||
// Intercept calls to window.removeEventListener
|
||||
PhoneGap.m_window_removeEventListener = window.removeEventListener;
|
||||
Cordova.m_window_removeEventListener = window.removeEventListener;
|
||||
|
||||
/**
|
||||
* Intercept removing document event listeners and handle our own
|
||||
@@ -466,17 +464,17 @@ document.removeEventListener = function(evt, handler, capture) {
|
||||
|
||||
// If unsubscribing to Android backbutton
|
||||
if (e === 'backbutton') {
|
||||
PhoneGap.exec(null, null, "App", "overrideBackbutton", [false]);
|
||||
Cordova.exec(null, null, "App", "overrideBackbutton", [false]);
|
||||
}
|
||||
|
||||
// If unsubcribing from an event that is handled by a plugin
|
||||
if (typeof PhoneGap.documentEventHandler[e] !== "undefined") {
|
||||
if (PhoneGap.documentEventHandler[e](e, handler, false)) {
|
||||
if (typeof Cordova.documentEventHandler[e] !== "undefined") {
|
||||
if (Cordova.documentEventHandler[e](e, handler, false)) {
|
||||
return; // Stop default behavior
|
||||
}
|
||||
}
|
||||
|
||||
PhoneGap.m_document_removeEventListener.call(document, evt, handler, capture);
|
||||
Cordova.m_document_removeEventListener.call(document, evt, handler, capture);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -490,13 +488,13 @@ window.removeEventListener = function(evt, handler, capture) {
|
||||
var e = evt.toLowerCase();
|
||||
|
||||
// If unsubcribing from an event that is handled by a plugin
|
||||
if (typeof PhoneGap.windowEventHandler[e] !== "undefined") {
|
||||
if (PhoneGap.windowEventHandler[e](e, handler, false)) {
|
||||
if (typeof Cordova.windowEventHandler[e] !== "undefined") {
|
||||
if (Cordova.windowEventHandler[e](e, handler, false)) {
|
||||
return; // Stop default behavior
|
||||
}
|
||||
}
|
||||
|
||||
PhoneGap.m_window_removeEventListener.call(window, evt, handler, capture);
|
||||
Cordova.m_window_removeEventListener.call(window, evt, handler, capture);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -505,7 +503,7 @@ window.removeEventListener = function(evt, handler, capture) {
|
||||
* @param {String} type The event type to fire
|
||||
* @param {Object} data Data to send with event
|
||||
*/
|
||||
PhoneGap.fireDocumentEvent = function(type, data) {
|
||||
Cordova.fireDocumentEvent = function(type, data) {
|
||||
var e = document.createEvent('Events');
|
||||
e.initEvent(type);
|
||||
if (data) {
|
||||
@@ -522,7 +520,7 @@ PhoneGap.fireDocumentEvent = function(type, data) {
|
||||
* @param {String} type The event type to fire
|
||||
* @param {Object} data Data to send with event
|
||||
*/
|
||||
PhoneGap.fireWindowEvent = function(type, data) {
|
||||
Cordova.fireWindowEvent = function(type, data) {
|
||||
var e = document.createEvent('Events');
|
||||
e.initEvent(type);
|
||||
if (data) {
|
||||
@@ -539,7 +537,7 @@ PhoneGap.fireWindowEvent = function(type, data) {
|
||||
* @param obj
|
||||
* @return {Object}
|
||||
*/
|
||||
PhoneGap.clone = function(obj) {
|
||||
Cordova.clone = function(obj) {
|
||||
var i, retVal;
|
||||
if(!obj) {
|
||||
return obj;
|
||||
@@ -548,7 +546,7 @@ PhoneGap.clone = function(obj) {
|
||||
if(obj instanceof Array){
|
||||
retVal = [];
|
||||
for(i = 0; i < obj.length; ++i){
|
||||
retVal.push(PhoneGap.clone(obj[i]));
|
||||
retVal.push(Cordova.clone(obj[i]));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
@@ -568,15 +566,15 @@ PhoneGap.clone = function(obj) {
|
||||
retVal = {};
|
||||
for(i in obj){
|
||||
if(!(i in retVal) || retVal[i] !== obj[i]) {
|
||||
retVal[i] = PhoneGap.clone(obj[i]);
|
||||
retVal[i] = Cordova.clone(obj[i]);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
};
|
||||
|
||||
PhoneGap.callbackId = 0;
|
||||
PhoneGap.callbacks = {};
|
||||
PhoneGap.callbackStatus = {
|
||||
Cordova.callbackId = 0;
|
||||
Cordova.callbacks = {};
|
||||
Cordova.callbackStatus = {
|
||||
NO_RESULT: 0,
|
||||
OK: 1,
|
||||
CLASS_NOT_FOUND_EXCEPTION: 2,
|
||||
@@ -591,24 +589,24 @@ PhoneGap.callbackStatus = {
|
||||
|
||||
|
||||
/**
|
||||
* Execute a PhoneGap command. It is up to the native side whether this action is synch or async.
|
||||
* Execute a Cordova command. It is up to the native side whether this action is synch or async.
|
||||
* The native side can return:
|
||||
* Synchronous: PluginResult object as a JSON string
|
||||
* Asynchrounous: Empty string ""
|
||||
* If async, the native side will PhoneGap.callbackSuccess or PhoneGap.callbackError,
|
||||
* If async, the native side will Cordova.callbackSuccess or Cordova.callbackError,
|
||||
* depending upon the result of the action.
|
||||
*
|
||||
* @param {Function} success The success callback
|
||||
* @param {Function} fail The fail callback
|
||||
* @param {String} service The name of the service to use
|
||||
* @param {String} action Action to be run in PhoneGap
|
||||
* @param {String} action Action to be run in Cordova
|
||||
* @param {Array.<String>} [args] Zero or more arguments to pass to the method
|
||||
*/
|
||||
PhoneGap.exec = function(success, fail, service, action, args) {
|
||||
Cordova.exec = function(success, fail, service, action, args) {
|
||||
try {
|
||||
var callbackId = service + PhoneGap.callbackId++;
|
||||
var callbackId = service + Cordova.callbackId++;
|
||||
if (success || fail) {
|
||||
PhoneGap.callbacks[callbackId] = {success:success, fail:fail};
|
||||
Cordova.callbacks[callbackId] = {success:success, fail:fail};
|
||||
}
|
||||
|
||||
var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
|
||||
@@ -618,7 +616,7 @@ PhoneGap.exec = function(success, fail, service, action, args) {
|
||||
eval("var v="+r+";");
|
||||
|
||||
// If status is OK, then return value back to caller
|
||||
if (v.status === PhoneGap.callbackStatus.OK) {
|
||||
if (v.status === Cordova.callbackStatus.OK) {
|
||||
|
||||
// If there is a success callback, then call it now with
|
||||
// returned value
|
||||
@@ -631,18 +629,18 @@ PhoneGap.exec = function(success, fail, service, action, args) {
|
||||
|
||||
// Clear callback if not expecting any more results
|
||||
if (!v.keepCallback) {
|
||||
delete PhoneGap.callbacks[callbackId];
|
||||
delete Cordova.callbacks[callbackId];
|
||||
}
|
||||
}
|
||||
return v.message;
|
||||
}
|
||||
|
||||
// If no result
|
||||
else if (v.status === PhoneGap.callbackStatus.NO_RESULT) {
|
||||
else if (v.status === Cordova.callbackStatus.NO_RESULT) {
|
||||
|
||||
// Clear callback if not expecting any more results
|
||||
if (!v.keepCallback) {
|
||||
delete PhoneGap.callbacks[callbackId];
|
||||
delete Cordova.callbacks[callbackId];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,7 +659,7 @@ PhoneGap.exec = function(success, fail, service, action, args) {
|
||||
|
||||
// Clear callback if not expecting any more results
|
||||
if (!v.keepCallback) {
|
||||
delete PhoneGap.callbacks[callbackId];
|
||||
delete Cordova.callbacks[callbackId];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -678,14 +676,14 @@ PhoneGap.exec = function(success, fail, service, action, args) {
|
||||
* @param callbackId
|
||||
* @param args
|
||||
*/
|
||||
PhoneGap.callbackSuccess = function(callbackId, args) {
|
||||
if (PhoneGap.callbacks[callbackId]) {
|
||||
Cordova.callbackSuccess = function(callbackId, args) {
|
||||
if (Cordova.callbacks[callbackId]) {
|
||||
|
||||
// If result is to be sent to callback
|
||||
if (args.status === PhoneGap.callbackStatus.OK) {
|
||||
if (args.status === Cordova.callbackStatus.OK) {
|
||||
try {
|
||||
if (PhoneGap.callbacks[callbackId].success) {
|
||||
PhoneGap.callbacks[callbackId].success(args.message);
|
||||
if (Cordova.callbacks[callbackId].success) {
|
||||
Cordova.callbacks[callbackId].success(args.message);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
@@ -695,7 +693,7 @@ PhoneGap.callbackSuccess = function(callbackId, args) {
|
||||
|
||||
// Clear callback if not expecting any more results
|
||||
if (!args.keepCallback) {
|
||||
delete PhoneGap.callbacks[callbackId];
|
||||
delete Cordova.callbacks[callbackId];
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -706,11 +704,11 @@ PhoneGap.callbackSuccess = function(callbackId, args) {
|
||||
* @param callbackId
|
||||
* @param args
|
||||
*/
|
||||
PhoneGap.callbackError = function(callbackId, args) {
|
||||
if (PhoneGap.callbacks[callbackId]) {
|
||||
Cordova.callbackError = function(callbackId, args) {
|
||||
if (Cordova.callbacks[callbackId]) {
|
||||
try {
|
||||
if (PhoneGap.callbacks[callbackId].fail) {
|
||||
PhoneGap.callbacks[callbackId].fail(args.message);
|
||||
if (Cordova.callbacks[callbackId].fail) {
|
||||
Cordova.callbacks[callbackId].fail(args.message);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
@@ -719,31 +717,31 @@ PhoneGap.callbackError = function(callbackId, args) {
|
||||
|
||||
// Clear callback if not expecting any more results
|
||||
if (!args.keepCallback) {
|
||||
delete PhoneGap.callbacks[callbackId];
|
||||
delete Cordova.callbacks[callbackId];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PhoneGap.JSCallbackPort = null;
|
||||
PhoneGap.JSCallbackToken = null;
|
||||
Cordova.JSCallbackPort = null;
|
||||
Cordova.JSCallbackToken = null;
|
||||
|
||||
/**
|
||||
* This is only for Android.
|
||||
*
|
||||
* Internal function that uses XHR to call into PhoneGap Java code and retrieve
|
||||
* Internal function that uses XHR to call into Cordova Java code and retrieve
|
||||
* any JavaScript code that needs to be run. This is used for callbacks from
|
||||
* Java to JavaScript.
|
||||
*/
|
||||
PhoneGap.JSCallback = function() {
|
||||
Cordova.JSCallback = function() {
|
||||
|
||||
// Exit if shutting down app
|
||||
if (PhoneGap.shuttingDown) {
|
||||
if (Cordova.shuttingDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If polling flag was changed, start using polling from now on
|
||||
if (PhoneGap.UsePolling) {
|
||||
PhoneGap.JSCallbackPolling();
|
||||
if (Cordova.UsePolling) {
|
||||
Cordova.JSCallbackPolling();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -754,7 +752,7 @@ PhoneGap.JSCallback = function() {
|
||||
if(xmlhttp.readyState === 4){
|
||||
|
||||
// Exit if shutting down app
|
||||
if (PhoneGap.shuttingDown) {
|
||||
if (Cordova.shuttingDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -773,12 +771,12 @@ PhoneGap.JSCallback = function() {
|
||||
console.log("JSCallback Error: "+e);
|
||||
}
|
||||
}, 1);
|
||||
setTimeout(PhoneGap.JSCallback, 1);
|
||||
setTimeout(Cordova.JSCallback, 1);
|
||||
}
|
||||
|
||||
// If callback ping (used to keep XHR request from timing out)
|
||||
else if (xmlhttp.status === 404) {
|
||||
setTimeout(PhoneGap.JSCallback, 10);
|
||||
setTimeout(Cordova.JSCallback, 10);
|
||||
}
|
||||
|
||||
// If security error
|
||||
@@ -799,19 +797,19 @@ PhoneGap.JSCallback = function() {
|
||||
// If error, revert to polling
|
||||
else {
|
||||
console.log("JSCallback Error: Request failed.");
|
||||
PhoneGap.UsePolling = true;
|
||||
PhoneGap.JSCallbackPolling();
|
||||
Cordova.UsePolling = true;
|
||||
Cordova.JSCallbackPolling();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (PhoneGap.JSCallbackPort === null) {
|
||||
PhoneGap.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
|
||||
if (Cordova.JSCallbackPort === null) {
|
||||
Cordova.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
|
||||
}
|
||||
if (PhoneGap.JSCallbackToken === null) {
|
||||
PhoneGap.JSCallbackToken = prompt("getToken", "gap_callbackServer:");
|
||||
if (Cordova.JSCallbackToken === null) {
|
||||
Cordova.JSCallbackToken = prompt("getToken", "gap_callbackServer:");
|
||||
}
|
||||
xmlhttp.open("GET", "http://127.0.0.1:"+PhoneGap.JSCallbackPort+"/"+PhoneGap.JSCallbackToken , true);
|
||||
xmlhttp.open("GET", "http://127.0.0.1:"+Cordova.JSCallbackPort+"/"+Cordova.JSCallbackToken , true);
|
||||
xmlhttp.send();
|
||||
};
|
||||
|
||||
@@ -819,30 +817,30 @@ PhoneGap.JSCallback = function() {
|
||||
* The polling period to use with JSCallbackPolling.
|
||||
* This can be changed by the application. The default is 50ms.
|
||||
*/
|
||||
PhoneGap.JSCallbackPollingPeriod = 50;
|
||||
Cordova.JSCallbackPollingPeriod = 50;
|
||||
|
||||
/**
|
||||
* Flag that can be set by the user to force polling to be used or force XHR to be used.
|
||||
*/
|
||||
PhoneGap.UsePolling = false; // T=use polling, F=use XHR
|
||||
Cordova.UsePolling = false; // T=use polling, F=use XHR
|
||||
|
||||
/**
|
||||
* This is only for Android.
|
||||
*
|
||||
* Internal function that uses polling to call into PhoneGap Java code and retrieve
|
||||
* Internal function that uses polling to call into Cordova Java code and retrieve
|
||||
* any JavaScript code that needs to be run. This is used for callbacks from
|
||||
* Java to JavaScript.
|
||||
*/
|
||||
PhoneGap.JSCallbackPolling = function() {
|
||||
Cordova.JSCallbackPolling = function() {
|
||||
|
||||
// Exit if shutting down app
|
||||
if (PhoneGap.shuttingDown) {
|
||||
if (Cordova.shuttingDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If polling flag was changed, stop using polling from now on
|
||||
if (!PhoneGap.UsePolling) {
|
||||
PhoneGap.JSCallback();
|
||||
if (!Cordova.UsePolling) {
|
||||
Cordova.JSCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -857,10 +855,10 @@ PhoneGap.JSCallbackPolling = function() {
|
||||
console.log("JSCallbackPolling Error: "+e);
|
||||
}
|
||||
}, 1);
|
||||
setTimeout(PhoneGap.JSCallbackPolling, 1);
|
||||
setTimeout(Cordova.JSCallbackPolling, 1);
|
||||
}
|
||||
else {
|
||||
setTimeout(PhoneGap.JSCallbackPolling, PhoneGap.JSCallbackPollingPeriod);
|
||||
setTimeout(Cordova.JSCallbackPolling, Cordova.JSCallbackPollingPeriod);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -869,15 +867,15 @@ PhoneGap.JSCallbackPolling = function() {
|
||||
*
|
||||
* @return {String}
|
||||
*/
|
||||
PhoneGap.createUUID = function() {
|
||||
return PhoneGap.UUIDcreatePart(4) + '-' +
|
||||
PhoneGap.UUIDcreatePart(2) + '-' +
|
||||
PhoneGap.UUIDcreatePart(2) + '-' +
|
||||
PhoneGap.UUIDcreatePart(2) + '-' +
|
||||
PhoneGap.UUIDcreatePart(6);
|
||||
Cordova.createUUID = function() {
|
||||
return Cordova.UUIDcreatePart(4) + '-' +
|
||||
Cordova.UUIDcreatePart(2) + '-' +
|
||||
Cordova.UUIDcreatePart(2) + '-' +
|
||||
Cordova.UUIDcreatePart(2) + '-' +
|
||||
Cordova.UUIDcreatePart(6);
|
||||
};
|
||||
|
||||
PhoneGap.UUIDcreatePart = function(length) {
|
||||
Cordova.UUIDcreatePart = function(length) {
|
||||
var uuidpart = "";
|
||||
var i, uuidchar;
|
||||
for (i=0; i<length; i++) {
|
||||
@@ -890,7 +888,7 @@ PhoneGap.UUIDcreatePart = function(length) {
|
||||
return uuidpart;
|
||||
};
|
||||
|
||||
PhoneGap.close = function(context, func, params) {
|
||||
Cordova.close = function(context, func, params) {
|
||||
if (typeof params === 'undefined') {
|
||||
return function() {
|
||||
return func.apply(context, arguments);
|
||||
@@ -908,7 +906,7 @@ PhoneGap.close = function(context, func, params) {
|
||||
* @param {String} jsfile The url of the JavaScript file to load.
|
||||
* @param {Function} successCallback The callback to call when the file has been loaded.
|
||||
*/
|
||||
PhoneGap.includeJavascript = function(jsfile, successCallback) {
|
||||
Cordova.includeJavascript = function(jsfile, successCallback) {
|
||||
var id = document.getElementsByTagName("head")[0];
|
||||
var el = document.createElement('script');
|
||||
el.type = 'text/javascript';
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
// TODO: Needs to be commented
|
||||
|
||||
if (!PhoneGap.hasResource("crypto")) {
|
||||
PhoneGap.addResource("crypto");
|
||||
if (!Cordova.hasResource("crypto")) {
|
||||
Cordova.addResource("crypto");
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -30,12 +30,12 @@ var Crypto = function() {
|
||||
|
||||
Crypto.prototype.encrypt = function(seed, string, callback) {
|
||||
this.encryptWin = callback;
|
||||
PhoneGap.exec(null, null, "Crypto", "encrypt", [seed, string]);
|
||||
Cordova.exec(null, null, "Crypto", "encrypt", [seed, string]);
|
||||
};
|
||||
|
||||
Crypto.prototype.decrypt = function(seed, string, callback) {
|
||||
this.decryptWin = callback;
|
||||
PhoneGap.exec(null, null, "Crypto", "decrypt", [seed, string]);
|
||||
Cordova.exec(null, null, "Crypto", "decrypt", [seed, string]);
|
||||
};
|
||||
|
||||
Crypto.prototype.gotCryptedString = function(string) {
|
||||
@@ -46,7 +46,7 @@ Crypto.prototype.getPlainString = function(string) {
|
||||
this.decryptWin(string);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if (typeof navigator.Crypto === "undefined") {
|
||||
navigator.Crypto = new Crypto();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("device")) {
|
||||
PhoneGap.addResource("device");
|
||||
if (!Cordova.hasResource("device")) {
|
||||
Cordova.addResource("device");
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
@@ -26,12 +26,12 @@ PhoneGap.addResource("device");
|
||||
* @constructor
|
||||
*/
|
||||
var Device = function() {
|
||||
this.available = PhoneGap.available;
|
||||
this.available = Cordova.available;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.name = null;
|
||||
this.uuid = null;
|
||||
this.phonegap = null;
|
||||
this.cordova = null;
|
||||
|
||||
var me = this;
|
||||
this.getInfo(
|
||||
@@ -41,13 +41,13 @@ var Device = function() {
|
||||
me.version = info.version;
|
||||
me.name = info.name;
|
||||
me.uuid = info.uuid;
|
||||
me.phonegap = info.phonegap;
|
||||
PhoneGap.onPhoneGapInfoReady.fire();
|
||||
me.cordova = info.cordova;
|
||||
Cordova.onCordovaInfoReady.fire();
|
||||
},
|
||||
function(e) {
|
||||
me.available = false;
|
||||
console.log("Error initializing PhoneGap: " + e);
|
||||
alert("Error initializing PhoneGap: "+e);
|
||||
console.log("Error initializing Cordova: " + e);
|
||||
alert("Error initializing Cordova: "+e);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -72,10 +72,10 @@ Device.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
}
|
||||
|
||||
// Get info
|
||||
PhoneGap.exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
Cordova.exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if (typeof navigator.device === "undefined") {
|
||||
navigator.device = window.device = new Device();
|
||||
}
|
||||
|
||||
+24
-24
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("file")) {
|
||||
PhoneGap.addResource("file");
|
||||
if (!Cordova.hasResource("file")) {
|
||||
Cordova.addResource("file");
|
||||
|
||||
/**
|
||||
* This class provides some useful information about a file.
|
||||
@@ -162,7 +162,7 @@ FileReader.prototype.readAsText = function(file, encoding) {
|
||||
var me = this;
|
||||
|
||||
// Read file
|
||||
PhoneGap.exec(
|
||||
Cordova.exec(
|
||||
// Success callback
|
||||
function(r) {
|
||||
var evt;
|
||||
@@ -241,7 +241,7 @@ FileReader.prototype.readAsDataURL = function(file) {
|
||||
var me = this;
|
||||
|
||||
// Read file
|
||||
PhoneGap.exec(
|
||||
Cordova.exec(
|
||||
// Success callback
|
||||
function(r) {
|
||||
var evt;
|
||||
@@ -412,7 +412,7 @@ FileWriter.prototype.write = function(text) {
|
||||
}
|
||||
|
||||
// Write file
|
||||
PhoneGap.exec(
|
||||
Cordova.exec(
|
||||
// Success callback
|
||||
function(r) {
|
||||
var evt;
|
||||
@@ -523,7 +523,7 @@ FileWriter.prototype.truncate = function(size) {
|
||||
}
|
||||
|
||||
// Write file
|
||||
PhoneGap.exec(
|
||||
Cordova.exec(
|
||||
// Success callback
|
||||
function(r) {
|
||||
var evt;
|
||||
@@ -624,7 +624,7 @@ var DirectoryReader = function(fullPath){
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "readEntries", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "readEntries", [this.fullPath]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -654,7 +654,7 @@ var DirectoryEntry = function() {
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -664,7 +664,7 @@ DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, err
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -674,7 +674,7 @@ DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback)
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -686,7 +686,7 @@ DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -696,7 +696,7 @@ DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, err
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.remove = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -725,7 +725,7 @@ DirectoryEntry.prototype.createReader = function(successCallback, errorCallback)
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "getDirectory", [this.fullPath, path, options]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "getDirectory", [this.fullPath, path, options]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -737,7 +737,7 @@ DirectoryEntry.prototype.getDirectory = function(path, options, successCallback,
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "getFile", [this.fullPath, path, options]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "getFile", [this.fullPath, path, options]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -747,7 +747,7 @@ DirectoryEntry.prototype.getFile = function(path, options, successCallback, erro
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "removeRecursively", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "removeRecursively", [this.fullPath]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -777,7 +777,7 @@ var FileEntry = function() {
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -787,7 +787,7 @@ FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCal
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -797,7 +797,7 @@ FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.getParent = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -809,7 +809,7 @@ FileEntry.prototype.getParent = function(successCallback, errorCallback) {
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -819,7 +819,7 @@ FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCal
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.remove = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -863,7 +863,7 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.file = function(successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
|
||||
};
|
||||
|
||||
/** @constructor */
|
||||
@@ -892,7 +892,7 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
|
||||
}
|
||||
}
|
||||
else {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "requestFileSystem", [type, size]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "requestFileSystem", [type, size]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -903,7 +903,7 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
LocalFileSystem.prototype.resolveLocalFileSystemURI = function(uri, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "resolveLocalFileSystemURI", [uri]);
|
||||
Cordova.exec(successCallback, errorCallback, "File", "resolveLocalFileSystemURI", [uri]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -986,7 +986,7 @@ LocalFileSystem.prototype._castDate = function(pluginResult) {
|
||||
/**
|
||||
* Add the FileSystem interface into the browser.
|
||||
*/
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
var pgLocalFileSystem = new LocalFileSystem();
|
||||
// Needed for cast methods
|
||||
if (typeof window.localFileSystem === "undefined") {
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("filetransfer")) {
|
||||
PhoneGap.addResource("filetransfer");
|
||||
if (!Cordova.hasResource("filetransfer")) {
|
||||
Cordova.addResource("filetransfer");
|
||||
|
||||
/**
|
||||
* FileTransfer uploads a file to a remote server.
|
||||
@@ -80,7 +80,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
|
||||
}
|
||||
}
|
||||
|
||||
PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
|
||||
Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
|
||||
* @param errorCallback {Function} Callback to be invoked upon error
|
||||
*/
|
||||
FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
|
||||
Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("geolocation")) {
|
||||
PhoneGap.addResource("geolocation");
|
||||
if (!Cordova.hasResource("geolocation")) {
|
||||
Cordova.addResource("geolocation");
|
||||
|
||||
/**
|
||||
* This class provides access to device GPS data.
|
||||
@@ -80,7 +80,7 @@ Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallba
|
||||
}
|
||||
}
|
||||
navigator._geo.listeners.global = {"success" : successCallback, "fail" : errorCallback };
|
||||
PhoneGap.exec(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
|
||||
Cordova.exec(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -110,9 +110,9 @@ Geolocation.prototype.watchPosition = function(successCallback, errorCallback, o
|
||||
timeout = options.timeout;
|
||||
}
|
||||
}
|
||||
var id = PhoneGap.createUUID();
|
||||
var id = Cordova.createUUID();
|
||||
navigator._geo.listeners[id] = {"success" : successCallback, "fail" : errorCallback };
|
||||
PhoneGap.exec(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
|
||||
Cordova.exec(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
|
||||
return id;
|
||||
};
|
||||
|
||||
@@ -173,19 +173,19 @@ Geolocation.prototype.fail = function(id, code, msg) {
|
||||
* @param {String} id The ID of the watch returned from #watchPosition
|
||||
*/
|
||||
Geolocation.prototype.clearWatch = function(id) {
|
||||
PhoneGap.exec(null, null, "Geolocation", "stop", [id]);
|
||||
Cordova.exec(null, null, "Geolocation", "stop", [id]);
|
||||
delete navigator._geo.listeners[id];
|
||||
};
|
||||
|
||||
/**
|
||||
* Force the PhoneGap geolocation to be used instead of built-in.
|
||||
* Force the Cordova geolocation to be used instead of built-in.
|
||||
*/
|
||||
Geolocation.usingPhoneGap = false;
|
||||
Geolocation.usePhoneGap = function() {
|
||||
if (Geolocation.usingPhoneGap) {
|
||||
Geolocation.usingCordova = false;
|
||||
Geolocation.useCordova = function() {
|
||||
if (Geolocation.usingCordova) {
|
||||
return;
|
||||
}
|
||||
Geolocation.usingPhoneGap = true;
|
||||
Geolocation.usingCordova = true;
|
||||
|
||||
// Set built-in geolocation methods to our own implementations
|
||||
// (Cannot replace entire geolocation, but can replace individual methods)
|
||||
@@ -197,13 +197,13 @@ Geolocation.usePhoneGap = function() {
|
||||
navigator.geolocation.stop = navigator._geo.stop;
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
navigator._geo = new Geolocation();
|
||||
|
||||
// No native geolocation object for Android 1.x, so use PhoneGap geolocation
|
||||
// No native geolocation object for Android 1.x, so use Cordova geolocation
|
||||
if (typeof navigator.geolocation === 'undefined') {
|
||||
navigator.geolocation = navigator._geo;
|
||||
Geolocation.usingPhoneGap = true;
|
||||
Geolocation.usingCordova = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("media")) {
|
||||
PhoneGap.addResource("media");
|
||||
if (!Cordova.hasResource("media")) {
|
||||
Cordova.addResource("media");
|
||||
|
||||
/**
|
||||
* This class provides access to the device media, interfaces to both sound and video
|
||||
@@ -60,8 +60,8 @@ var Media = function(src, successCallback, errorCallback, statusCallback, positi
|
||||
return;
|
||||
}
|
||||
|
||||
this.id = PhoneGap.createUUID();
|
||||
PhoneGap.mediaObjects[this.id] = this;
|
||||
this.id = Cordova.createUUID();
|
||||
Cordova.mediaObjects[this.id] = this;
|
||||
this.src = src;
|
||||
this.successCallback = successCallback;
|
||||
this.errorCallback = errorCallback;
|
||||
@@ -105,28 +105,28 @@ MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
|
||||
* Start or resume playing audio file.
|
||||
*/
|
||||
Media.prototype.play = function() {
|
||||
PhoneGap.exec(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
|
||||
Cordova.exec(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop playing audio file.
|
||||
*/
|
||||
Media.prototype.stop = function() {
|
||||
return PhoneGap.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
|
||||
return Cordova.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Seek or jump to a new time in the track..
|
||||
*/
|
||||
Media.prototype.seekTo = function(milliseconds) {
|
||||
PhoneGap.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]);
|
||||
Cordova.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Pause playing audio file.
|
||||
*/
|
||||
Media.prototype.pause = function() {
|
||||
PhoneGap.exec(null, null, "Media", "pausePlayingAudio", [this.id]);
|
||||
Cordova.exec(null, null, "Media", "pausePlayingAudio", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -143,49 +143,49 @@ Media.prototype.getDuration = function() {
|
||||
* Get position of audio.
|
||||
*/
|
||||
Media.prototype.getCurrentPosition = function(success, fail) {
|
||||
PhoneGap.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
|
||||
Cordova.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Start recording audio file.
|
||||
*/
|
||||
Media.prototype.startRecord = function() {
|
||||
PhoneGap.exec(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
|
||||
Cordova.exec(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop recording audio file.
|
||||
*/
|
||||
Media.prototype.stopRecord = function() {
|
||||
PhoneGap.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
|
||||
Cordova.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Release the resources.
|
||||
*/
|
||||
Media.prototype.release = function() {
|
||||
PhoneGap.exec(null, null, "Media", "release", [this.id]);
|
||||
Cordova.exec(null, null, "Media", "release", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adjust the volume.
|
||||
*/
|
||||
Media.prototype.setVolume = function(volume) {
|
||||
PhoneGap.exec(null, null, "Media", "setVolume", [this.id, volume]);
|
||||
Cordova.exec(null, null, "Media", "setVolume", [this.id, volume]);
|
||||
};
|
||||
|
||||
/**
|
||||
* List of media objects.
|
||||
* PRIVATE
|
||||
*/
|
||||
PhoneGap.mediaObjects = {};
|
||||
Cordova.mediaObjects = {};
|
||||
|
||||
/**
|
||||
* Object that receives native callbacks.
|
||||
* PRIVATE
|
||||
* @constructor
|
||||
*/
|
||||
PhoneGap.Media = function() {};
|
||||
Cordova.Media = function() {};
|
||||
|
||||
/**
|
||||
* Get the media object.
|
||||
@@ -193,8 +193,8 @@ PhoneGap.Media = function() {};
|
||||
*
|
||||
* @param id The media object id (string)
|
||||
*/
|
||||
PhoneGap.Media.getMediaObject = function(id) {
|
||||
return PhoneGap.mediaObjects[id];
|
||||
Cordova.Media.getMediaObject = function(id) {
|
||||
return Cordova.mediaObjects[id];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -205,8 +205,8 @@ PhoneGap.Media.getMediaObject = function(id) {
|
||||
* @param status The status code (int)
|
||||
* @param msg The status message (string)
|
||||
*/
|
||||
PhoneGap.Media.onStatus = function(id, msg, value) {
|
||||
var media = PhoneGap.mediaObjects[id];
|
||||
Cordova.Media.onStatus = function(id, msg, value) {
|
||||
var media = Cordova.mediaObjects[id];
|
||||
// If state update
|
||||
if (msg === Media.MEDIA_STATE) {
|
||||
if (value === Media.MEDIA_STOPPED) {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
*/
|
||||
|
||||
|
||||
if (!PhoneGap.hasResource("network")) {
|
||||
PhoneGap.addResource("network");
|
||||
if (!Cordova.hasResource("network")) {
|
||||
Cordova.addResource("network");
|
||||
|
||||
/**
|
||||
* This class contains information about the current network Connection.
|
||||
@@ -39,7 +39,7 @@ var Connection = function() {
|
||||
// set a timer if still offline at the end of timer send the offline event
|
||||
me._timer = setTimeout(function(){
|
||||
me.type = type;
|
||||
PhoneGap.fireDocumentEvent('offline');
|
||||
Cordova.fireDocumentEvent('offline');
|
||||
me._timer = null;
|
||||
}, me.timeout);
|
||||
} else {
|
||||
@@ -49,21 +49,21 @@ var Connection = function() {
|
||||
me._timer = null;
|
||||
}
|
||||
me.type = type;
|
||||
PhoneGap.fireDocumentEvent('online');
|
||||
Cordova.fireDocumentEvent('online');
|
||||
}
|
||||
|
||||
// should only fire this once
|
||||
if (me._firstRun) {
|
||||
me._firstRun = false;
|
||||
PhoneGap.onPhoneGapConnectionReady.fire();
|
||||
Cordova.onCordovaConnectionReady.fire();
|
||||
}
|
||||
},
|
||||
function(e) {
|
||||
// If we can't get the network info we should still tell PhoneGap
|
||||
// If we can't get the network info we should still tell Cordova
|
||||
// to fire the deviceready event.
|
||||
if (me._firstRun) {
|
||||
me._firstRun = false;
|
||||
PhoneGap.onPhoneGapConnectionReady.fire();
|
||||
Cordova.onCordovaConnectionReady.fire();
|
||||
}
|
||||
console.log("Error initializing Network Connection: " + e);
|
||||
});
|
||||
@@ -85,11 +85,11 @@ Connection.NONE = "none";
|
||||
*/
|
||||
Connection.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
// Get info
|
||||
PhoneGap.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
|
||||
Cordova.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
|
||||
};
|
||||
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if (typeof navigator.network === "undefined") {
|
||||
navigator.network = {};
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("notification")) {
|
||||
PhoneGap.addResource("notification");
|
||||
if (!Cordova.hasResource("notification")) {
|
||||
Cordova.addResource("notification");
|
||||
|
||||
/**
|
||||
* This class provides access to notifications on the device.
|
||||
@@ -38,7 +38,7 @@ var Notification = function() {
|
||||
Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) {
|
||||
var _title = (title || "Alert");
|
||||
var _buttonLabel = (buttonLabel || "OK");
|
||||
PhoneGap.exec(completeCallback, null, "Notification", "alert", [message,_title,_buttonLabel]);
|
||||
Cordova.exec(completeCallback, null, "Notification", "alert", [message,_title,_buttonLabel]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -53,21 +53,21 @@ Notification.prototype.alert = function(message, completeCallback, title, button
|
||||
Notification.prototype.confirm = function(message, resultCallback, title, buttonLabels) {
|
||||
var _title = (title || "Confirm");
|
||||
var _buttonLabels = (buttonLabels || "OK,Cancel");
|
||||
PhoneGap.exec(resultCallback, null, "Notification", "confirm", [message,_title,_buttonLabels]);
|
||||
Cordova.exec(resultCallback, null, "Notification", "confirm", [message,_title,_buttonLabels]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Start spinning the activity indicator on the statusbar
|
||||
*/
|
||||
Notification.prototype.activityStart = function() {
|
||||
PhoneGap.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
|
||||
Cordova.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop spinning the activity indicator on the statusbar, if it's currently spinning
|
||||
*/
|
||||
Notification.prototype.activityStop = function() {
|
||||
PhoneGap.exec(null, null, "Notification", "activityStop", []);
|
||||
Cordova.exec(null, null, "Notification", "activityStop", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ Notification.prototype.activityStop = function() {
|
||||
* @param {String} message Message to display in the dialog.
|
||||
*/
|
||||
Notification.prototype.progressStart = function(title, message) {
|
||||
PhoneGap.exec(null, null, "Notification", "progressStart", [title, message]);
|
||||
Cordova.exec(null, null, "Notification", "progressStart", [title, message]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -86,14 +86,14 @@ Notification.prototype.progressStart = function(title, message) {
|
||||
* @param {Number} value 0-100
|
||||
*/
|
||||
Notification.prototype.progressValue = function(value) {
|
||||
PhoneGap.exec(null, null, "Notification", "progressValue", [value]);
|
||||
Cordova.exec(null, null, "Notification", "progressValue", [value]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Close the progress dialog.
|
||||
*/
|
||||
Notification.prototype.progressStop = function() {
|
||||
PhoneGap.exec(null, null, "Notification", "progressStop", []);
|
||||
Cordova.exec(null, null, "Notification", "progressStop", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ Notification.prototype.blink = function(count, colour) {
|
||||
* @param {Integer} mills The number of milliseconds to vibrate for.
|
||||
*/
|
||||
Notification.prototype.vibrate = function(mills) {
|
||||
PhoneGap.exec(null, null, "Notification", "vibrate", [mills]);
|
||||
Cordova.exec(null, null, "Notification", "vibrate", [mills]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -122,10 +122,10 @@ Notification.prototype.vibrate = function(mills) {
|
||||
* @param {Integer} count The number of beeps.
|
||||
*/
|
||||
Notification.prototype.beep = function(count) {
|
||||
PhoneGap.exec(null, null, "Notification", "beep", [count]);
|
||||
Cordova.exec(null, null, "Notification", "beep", [count]);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
if (typeof navigator.notification === "undefined") {
|
||||
navigator.notification = new Notification();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("position")) {
|
||||
PhoneGap.addResource("position");
|
||||
if (!Cordova.hasResource("position")) {
|
||||
Cordova.addResource("position");
|
||||
|
||||
/**
|
||||
* This class contains position information.
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
* most manufacturers ship with Android 1.5 and do not do OTA Updates, this is required
|
||||
*/
|
||||
|
||||
if (!PhoneGap.hasResource("storage")) {
|
||||
PhoneGap.addResource("storage");
|
||||
if (!Cordova.hasResource("storage")) {
|
||||
Cordova.addResource("storage");
|
||||
|
||||
/**
|
||||
* SQL result set object
|
||||
@@ -153,7 +153,7 @@ DroidDB.prototype.fail = function(reason, id) {
|
||||
var DroidDB_Query = function(tx) {
|
||||
|
||||
// Set the id of the query
|
||||
this.id = PhoneGap.createUUID();
|
||||
this.id = Cordova.createUUID();
|
||||
|
||||
// Add this query to the queue
|
||||
droiddb.queryQueue[this.id] = this;
|
||||
@@ -181,7 +181,7 @@ var DroidDB_Query = function(tx) {
|
||||
var DroidDB_Tx = function() {
|
||||
|
||||
// Set the id of the transaction
|
||||
this.id = PhoneGap.createUUID();
|
||||
this.id = Cordova.createUUID();
|
||||
|
||||
// Callbacks
|
||||
this.successCallback = null;
|
||||
@@ -266,7 +266,7 @@ DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCa
|
||||
query.errorCallback = errorCallback;
|
||||
|
||||
// Call native code
|
||||
PhoneGap.exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
|
||||
Cordova.exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
|
||||
};
|
||||
|
||||
var DatabaseShell = function() {
|
||||
@@ -308,7 +308,7 @@ DatabaseShell.prototype.transaction = function(process, errorCallback, successCa
|
||||
* @return Database object
|
||||
*/
|
||||
var DroidDB_openDatabase = function(name, version, display_name, size) {
|
||||
PhoneGap.exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
|
||||
Cordova.exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
|
||||
var db = new DatabaseShell();
|
||||
return db;
|
||||
};
|
||||
@@ -340,7 +340,7 @@ var CupcakeLocalStorage = function() {
|
||||
storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
|
||||
}
|
||||
setLength(result.rows.length);
|
||||
PhoneGap.initializationComplete("cupcakeStorage");
|
||||
Cordova.initializationComplete("cupcakeStorage");
|
||||
});
|
||||
|
||||
},
|
||||
@@ -401,7 +401,7 @@ var CupcakeLocalStorage = function() {
|
||||
}
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
Cordova.addConstructor(function() {
|
||||
var setupDroidDB = function() {
|
||||
navigator.openDatabase = window.openDatabase = DroidDB_openDatabase;
|
||||
window.droiddb = new DroidDB();
|
||||
@@ -433,7 +433,7 @@ PhoneGap.addConstructor(function() {
|
||||
|
||||
if ((typeof window.localStorage == "undefined") || (window.localStorage == null)) {
|
||||
navigator.localStorage = window.localStorage = new CupcakeLocalStorage();
|
||||
PhoneGap.waitForInitialization("cupcakeStorage");
|
||||
Cordova.waitForInitialization("cupcakeStorage");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user