forked from github/cordova-android
Update JS snapshot to version 3.2.0-dev (via coho)
This commit is contained in:
parent
2c6285d4b3
commit
95edd970bc
822
framework/assets/www/cordova.js
vendored
822
framework/assets/www/cordova.js
vendored
@ -1,5 +1,5 @@
|
||||
// Platform: android
|
||||
// 3.0.0rc1-1-g1965a39
|
||||
// 3.2.0-dev-8e5a2e7
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
@ -19,7 +19,7 @@
|
||||
under the License.
|
||||
*/
|
||||
;(function() {
|
||||
var CORDOVA_JS_BUILD_LABEL = '3.0.0rc1-1-g1965a39';
|
||||
var CORDOVA_JS_BUILD_LABEL = '3.2.0-dev-8e5a2e7';
|
||||
// file: lib/scripts/require.js
|
||||
|
||||
var require,
|
||||
@ -100,16 +100,7 @@ define("cordova", function(require, exports, module) {
|
||||
|
||||
|
||||
var channel = require('cordova/channel');
|
||||
|
||||
/**
|
||||
* Listen for DOMContentLoaded and notify our channel subscribers.
|
||||
*/
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
channel.onDOMContentLoaded.fire();
|
||||
}, false);
|
||||
if (document.readyState == 'complete' || document.readyState == 'interactive') {
|
||||
channel.onDOMContentLoaded.fire();
|
||||
}
|
||||
var platform = require('cordova/platform');
|
||||
|
||||
/**
|
||||
* Intercept calls to addEventListener + removeEventListener and handle deviceready,
|
||||
@ -177,21 +168,12 @@ function createEvent(type, data) {
|
||||
return event;
|
||||
}
|
||||
|
||||
if(typeof window.console === "undefined") {
|
||||
window.console = {
|
||||
log:function(){}
|
||||
};
|
||||
}
|
||||
// there are places in the framework where we call `warn` also, so we should make sure it exists
|
||||
if(typeof window.console.warn === "undefined") {
|
||||
window.console.warn = function(msg) {
|
||||
this.log("warn: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
var cordova = {
|
||||
define:define,
|
||||
require:require,
|
||||
version:CORDOVA_JS_BUILD_LABEL,
|
||||
platformId:platform.id,
|
||||
/**
|
||||
* Methods to add/remove your own addEventListener hijacking on document + window.
|
||||
*/
|
||||
@ -326,15 +308,56 @@ var cordova = {
|
||||
}
|
||||
};
|
||||
|
||||
// Register pause, resume and deviceready channels as events on document.
|
||||
channel.onPause = cordova.addDocumentEventHandler('pause');
|
||||
channel.onResume = cordova.addDocumentEventHandler('resume');
|
||||
channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
|
||||
|
||||
module.exports = cordova;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/android/android/nativeapiprovider.js
|
||||
define("cordova/android/nativeapiprovider", function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Exports the ExposedJsApi.java object if available, otherwise exports the PromptBasedNativeApi.
|
||||
*/
|
||||
|
||||
var nativeApi = this._cordovaNative || require('cordova/android/promptbasednativeapi');
|
||||
var currentApi = nativeApi;
|
||||
|
||||
module.exports = {
|
||||
get: function() { return currentApi; },
|
||||
setPreferPrompt: function(value) {
|
||||
currentApi = value ? require('cordova/android/promptbasednativeapi') : nativeApi;
|
||||
},
|
||||
// Used only by tests.
|
||||
set: function(value) {
|
||||
currentApi = value;
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
// file: lib/android/android/promptbasednativeapi.js
|
||||
define("cordova/android/promptbasednativeapi", function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Implements the API of ExposedJsApi.java, but uses prompt() to communicate.
|
||||
* This is used only on the 2.3 simulator, where addJavascriptInterface() is broken.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
exec: function(service, action, callbackId, argsJson) {
|
||||
return prompt(argsJson, 'gap:'+JSON.stringify([service, action, callbackId]));
|
||||
},
|
||||
setNativeToJsBridgeMode: function(value) {
|
||||
prompt(value, 'gap_bridge_mode:');
|
||||
},
|
||||
retrieveJsMessages: function(fromOnlineEvent) {
|
||||
return prompt(+fromOnlineEvent, 'gap_poll:');
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/argscheck.js
|
||||
define("cordova/argscheck", function(require, exports, module) {
|
||||
|
||||
@ -430,7 +453,7 @@ var b64_12bitTable = function() {
|
||||
}
|
||||
b64_12bitTable = function() { return b64_12bit; };
|
||||
return b64_12bit;
|
||||
}
|
||||
};
|
||||
|
||||
function uint8ToBase64(rawData) {
|
||||
var numBytes = rawData.byteLength;
|
||||
@ -811,36 +834,6 @@ module.exports = channel;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/commandProxy.js
|
||||
define("cordova/commandProxy", function(require, exports, module) {
|
||||
|
||||
|
||||
// internal map of proxy function
|
||||
var CommandProxyMap = {};
|
||||
|
||||
module.exports = {
|
||||
|
||||
// example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
|
||||
add:function(id,proxyObj) {
|
||||
console.log("adding proxy for " + id);
|
||||
CommandProxyMap[id] = proxyObj;
|
||||
return proxyObj;
|
||||
},
|
||||
|
||||
// cordova.commandProxy.remove("Accelerometer");
|
||||
remove:function(id) {
|
||||
var proxy = CommandProxyMap[id];
|
||||
delete CommandProxyMap[id];
|
||||
CommandProxyMap[id] = null;
|
||||
return proxy;
|
||||
},
|
||||
|
||||
get:function(service,action) {
|
||||
return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null );
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// file: lib/android/exec.js
|
||||
define("cordova/exec", function(require, exports, module) {
|
||||
|
||||
@ -859,7 +852,7 @@ define("cordova/exec", function(require, exports, module) {
|
||||
* @param {String[]} [args] Zero or more arguments to pass to the method
|
||||
*/
|
||||
var cordova = require('cordova'),
|
||||
nativeApiProvider = require('cordova/plugin/android/nativeapiprovider'),
|
||||
nativeApiProvider = require('cordova/android/nativeapiprovider'),
|
||||
utils = require('cordova/utils'),
|
||||
base64 = require('cordova/base64'),
|
||||
jsToNativeModes = {
|
||||
@ -928,8 +921,12 @@ function androidExec(success, fail, service, action, args) {
|
||||
}
|
||||
}
|
||||
|
||||
function pollOnce() {
|
||||
var msg = nativeApiProvider.get().retrieveJsMessages();
|
||||
function pollOnceFromOnlineEvent() {
|
||||
pollOnce(true);
|
||||
}
|
||||
|
||||
function pollOnce(opt_fromOnlineEvent) {
|
||||
var msg = nativeApiProvider.get().retrieveJsMessages(!!opt_fromOnlineEvent);
|
||||
androidExec.processMessages(msg);
|
||||
}
|
||||
|
||||
@ -948,8 +945,8 @@ function hookOnlineApis() {
|
||||
// It currently fires them only on document though, so we bridge them
|
||||
// to window here (while first listening for exec()-releated online/offline
|
||||
// events).
|
||||
window.addEventListener('online', pollOnce, false);
|
||||
window.addEventListener('offline', pollOnce, false);
|
||||
window.addEventListener('online', pollOnceFromOnlineEvent, false);
|
||||
window.addEventListener('offline', pollOnceFromOnlineEvent, false);
|
||||
cordova.addWindowEventHandler('online');
|
||||
cordova.addWindowEventHandler('offline');
|
||||
document.addEventListener('online', proxyEvent, false);
|
||||
@ -1072,6 +1069,120 @@ androidExec.processMessages = function(messages) {
|
||||
|
||||
module.exports = androidExec;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/init.js
|
||||
define("cordova/init", function(require, exports, module) {
|
||||
|
||||
var channel = require('cordova/channel');
|
||||
var cordova = require('cordova');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var platform = require('cordova/platform');
|
||||
var pluginloader = require('cordova/pluginloader');
|
||||
|
||||
var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
|
||||
|
||||
function logUnfiredChannels(arr) {
|
||||
for (var i = 0; i < arr.length; ++i) {
|
||||
if (arr[i].state != 2) {
|
||||
console.log('Channel not fired: ' + arr[i].type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.setTimeout(function() {
|
||||
if (channel.onDeviceReady.state != 2) {
|
||||
console.log('deviceready has not fired after 5 seconds.');
|
||||
logUnfiredChannels(platformInitChannelsArray);
|
||||
logUnfiredChannels(channel.deviceReadyChannelsArray);
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
// Replace navigator before any modules are required(), to ensure it happens as soon as possible.
|
||||
// We replace it so that properties that can't be clobbered can instead be overridden.
|
||||
function replaceNavigator(origNavigator) {
|
||||
var CordovaNavigator = function() {};
|
||||
CordovaNavigator.prototype = origNavigator;
|
||||
var newNavigator = new CordovaNavigator();
|
||||
// This work-around really only applies to new APIs that are newer than Function.bind.
|
||||
// Without it, APIs such as getGamepads() break.
|
||||
if (CordovaNavigator.bind) {
|
||||
for (var key in origNavigator) {
|
||||
if (typeof origNavigator[key] == 'function') {
|
||||
newNavigator[key] = origNavigator[key].bind(origNavigator);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newNavigator;
|
||||
}
|
||||
if (window.navigator) {
|
||||
window.navigator = replaceNavigator(window.navigator);
|
||||
}
|
||||
|
||||
if (!window.console) {
|
||||
window.console = {
|
||||
log: function(){}
|
||||
};
|
||||
}
|
||||
if (!window.console.warn) {
|
||||
window.console.warn = function(msg) {
|
||||
this.log("warn: " + msg);
|
||||
};
|
||||
}
|
||||
|
||||
// Register pause, resume and deviceready channels as events on document.
|
||||
channel.onPause = cordova.addDocumentEventHandler('pause');
|
||||
channel.onResume = cordova.addDocumentEventHandler('resume');
|
||||
channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
|
||||
|
||||
// Listen for DOMContentLoaded and notify our channel subscribers.
|
||||
if (document.readyState == 'complete' || document.readyState == 'interactive') {
|
||||
channel.onDOMContentLoaded.fire();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
channel.onDOMContentLoaded.fire();
|
||||
}, 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 cordova JS is ready.
|
||||
if (window._nativeReady) {
|
||||
channel.onNativeReady.fire();
|
||||
}
|
||||
|
||||
modulemapper.clobbers('cordova', 'cordova');
|
||||
modulemapper.clobbers('cordova/exec', 'cordova.exec');
|
||||
modulemapper.clobbers('cordova/exec', 'Cordova.exec');
|
||||
|
||||
// Call the platform-specific initialization.
|
||||
platform.bootstrap && platform.bootstrap();
|
||||
|
||||
pluginloader.load(function() {
|
||||
channel.onPluginsReady.fire();
|
||||
});
|
||||
|
||||
/**
|
||||
* Create all cordova objects once native side is ready.
|
||||
*/
|
||||
channel.join(function() {
|
||||
modulemapper.mapModules(window);
|
||||
|
||||
platform.initialize && platform.initialize();
|
||||
|
||||
// Fire event to notify that all objects are created
|
||||
channel.onCordovaReady.fire();
|
||||
|
||||
// Fire onDeviceReady event once page has fully loaded, all
|
||||
// constructors have run and cordova info has been received from native
|
||||
// side.
|
||||
channel.join(function() {
|
||||
require('cordova').fireDocumentEvent('deviceready');
|
||||
}, channel.deviceReadyChannelsArray);
|
||||
|
||||
}, platformInitChannelsArray);
|
||||
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/modulemapper.js
|
||||
@ -1170,14 +1281,6 @@ exports.getOriginalSymbol = function(context, symbolPath) {
|
||||
return obj;
|
||||
};
|
||||
|
||||
exports.loadMatchingModules = function(matchingRegExp) {
|
||||
for (var k in moduleMap) {
|
||||
if (matchingRegExp.exec(k)) {
|
||||
require(k);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.reset();
|
||||
|
||||
|
||||
@ -1187,17 +1290,20 @@ exports.reset();
|
||||
define("cordova/platform", function(require, exports, module) {
|
||||
|
||||
module.exports = {
|
||||
id: "android",
|
||||
initialize:function() {
|
||||
var channel = require("cordova/channel"),
|
||||
id: 'android',
|
||||
bootstrap: function() {
|
||||
var channel = require('cordova/channel'),
|
||||
cordova = require('cordova'),
|
||||
exec = require('cordova/exec'),
|
||||
modulemapper = require('cordova/modulemapper');
|
||||
|
||||
modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
|
||||
modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
|
||||
// Tell the native code that a page change has occurred.
|
||||
exec(null, null, 'PluginManager', 'startup', []);
|
||||
// Tell the JS that the native side is ready.
|
||||
channel.onNativeReady.fire();
|
||||
|
||||
modulemapper.mapModules(window);
|
||||
// TODO: Extract this as a proper plugin.
|
||||
modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
|
||||
|
||||
// Inject a listener for the backbutton on the document.
|
||||
var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
|
||||
@ -1213,9 +1319,9 @@ module.exports = {
|
||||
|
||||
// Let native code know we are all done on the JS side.
|
||||
// Native code will then un-hide the WebView.
|
||||
channel.join(function() {
|
||||
channel.onCordovaReady.subscribe(function() {
|
||||
exec(null, null, "App", "show", []);
|
||||
}, [channel.onCordovaReady]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -1296,435 +1402,11 @@ module.exports = {
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
// file: lib/android/plugin/android/nativeapiprovider.js
|
||||
define("cordova/plugin/android/nativeapiprovider", function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Exports the ExposedJsApi.java object if available, otherwise exports the PromptBasedNativeApi.
|
||||
*/
|
||||
|
||||
var nativeApi = this._cordovaNative || require('cordova/plugin/android/promptbasednativeapi');
|
||||
var currentApi = nativeApi;
|
||||
|
||||
module.exports = {
|
||||
get: function() { return currentApi; },
|
||||
setPreferPrompt: function(value) {
|
||||
currentApi = value ? require('cordova/plugin/android/promptbasednativeapi') : nativeApi;
|
||||
},
|
||||
// Used only by tests.
|
||||
set: function(value) {
|
||||
currentApi = value;
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
// file: lib/android/plugin/android/promptbasednativeapi.js
|
||||
define("cordova/plugin/android/promptbasednativeapi", function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Implements the API of ExposedJsApi.java, but uses prompt() to communicate.
|
||||
* This is used only on the 2.3 simulator, where addJavascriptInterface() is broken.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
exec: function(service, action, callbackId, argsJson) {
|
||||
return prompt(argsJson, 'gap:'+JSON.stringify([service, action, callbackId]));
|
||||
},
|
||||
setNativeToJsBridgeMode: function(value) {
|
||||
prompt(value, 'gap_bridge_mode:');
|
||||
},
|
||||
retrieveJsMessages: function() {
|
||||
return prompt('', 'gap_poll:');
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
// file: lib/android/plugin/android/storage.js
|
||||
define("cordova/plugin/android/storage", function(require, exports, module) {
|
||||
|
||||
var utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec'),
|
||||
channel = require('cordova/channel');
|
||||
|
||||
var queryQueue = {};
|
||||
|
||||
/**
|
||||
* SQL result set object
|
||||
* PRIVATE METHOD
|
||||
* @constructor
|
||||
*/
|
||||
var DroidDB_Rows = function() {
|
||||
this.resultSet = []; // results array
|
||||
this.length = 0; // number of rows
|
||||
};
|
||||
|
||||
/**
|
||||
* Get item from SQL result set
|
||||
*
|
||||
* @param row The row number to return
|
||||
* @return The row object
|
||||
*/
|
||||
DroidDB_Rows.prototype.item = function(row) {
|
||||
return this.resultSet[row];
|
||||
};
|
||||
|
||||
/**
|
||||
* SQL result set that is returned to user.
|
||||
* PRIVATE METHOD
|
||||
* @constructor
|
||||
*/
|
||||
var DroidDB_Result = function() {
|
||||
this.rows = new DroidDB_Rows();
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback from native code when query is complete.
|
||||
* PRIVATE METHOD
|
||||
*
|
||||
* @param id Query id
|
||||
*/
|
||||
function completeQuery(id, data) {
|
||||
var query = queryQueue[id];
|
||||
if (query) {
|
||||
try {
|
||||
delete queryQueue[id];
|
||||
|
||||
// Get transaction
|
||||
var tx = query.tx;
|
||||
|
||||
// If transaction hasn't failed
|
||||
// Note: We ignore all query results if previous query
|
||||
// in the same transaction failed.
|
||||
if (tx && tx.queryList[id]) {
|
||||
|
||||
// Save query results
|
||||
var r = new DroidDB_Result();
|
||||
r.rows.resultSet = data;
|
||||
r.rows.length = data.length;
|
||||
try {
|
||||
if (typeof query.successCallback === 'function') {
|
||||
query.successCallback(query.tx, r);
|
||||
}
|
||||
} catch (ex) {
|
||||
console.log("executeSql error calling user success callback: "+ex);
|
||||
}
|
||||
|
||||
tx.queryComplete(id);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("executeSql error: "+e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback from native code when query fails
|
||||
* PRIVATE METHOD
|
||||
*
|
||||
* @param reason Error message
|
||||
* @param id Query id
|
||||
*/
|
||||
function failQuery(reason, id) {
|
||||
var query = queryQueue[id];
|
||||
if (query) {
|
||||
try {
|
||||
delete queryQueue[id];
|
||||
|
||||
// Get transaction
|
||||
var tx = query.tx;
|
||||
|
||||
// If transaction hasn't failed
|
||||
// Note: We ignore all query results if previous query
|
||||
// in the same transaction failed.
|
||||
if (tx && tx.queryList[id]) {
|
||||
tx.queryList = {};
|
||||
|
||||
try {
|
||||
if (typeof query.errorCallback === 'function') {
|
||||
query.errorCallback(query.tx, reason);
|
||||
}
|
||||
} catch (ex) {
|
||||
console.log("executeSql error calling user error callback: "+ex);
|
||||
}
|
||||
|
||||
tx.queryFailed(id, reason);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.log("executeSql error: "+e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL query object
|
||||
* PRIVATE METHOD
|
||||
*
|
||||
* @constructor
|
||||
* @param tx The transaction object that this query belongs to
|
||||
*/
|
||||
var DroidDB_Query = function(tx) {
|
||||
|
||||
// Set the id of the query
|
||||
this.id = utils.createUUID();
|
||||
|
||||
// Add this query to the queue
|
||||
queryQueue[this.id] = this;
|
||||
|
||||
// Init result
|
||||
this.resultSet = [];
|
||||
|
||||
// Set transaction that this query belongs to
|
||||
this.tx = tx;
|
||||
|
||||
// Add this query to transaction list
|
||||
this.tx.queryList[this.id] = this;
|
||||
|
||||
// Callbacks
|
||||
this.successCallback = null;
|
||||
this.errorCallback = null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Transaction object
|
||||
* PRIVATE METHOD
|
||||
* @constructor
|
||||
*/
|
||||
var DroidDB_Tx = function() {
|
||||
|
||||
// Set the id of the transaction
|
||||
this.id = utils.createUUID();
|
||||
|
||||
// Callbacks
|
||||
this.successCallback = null;
|
||||
this.errorCallback = null;
|
||||
|
||||
// Query list
|
||||
this.queryList = {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Mark query in transaction as complete.
|
||||
* If all queries are complete, call the user's transaction success callback.
|
||||
*
|
||||
* @param id Query id
|
||||
*/
|
||||
DroidDB_Tx.prototype.queryComplete = function(id) {
|
||||
delete this.queryList[id];
|
||||
|
||||
// If no more outstanding queries, then fire transaction success
|
||||
if (this.successCallback) {
|
||||
var count = 0;
|
||||
var i;
|
||||
for (i in this.queryList) {
|
||||
if (this.queryList.hasOwnProperty(i)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count === 0) {
|
||||
try {
|
||||
this.successCallback();
|
||||
} catch(e) {
|
||||
console.log("Transaction error calling user success callback: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Mark query in transaction as failed.
|
||||
*
|
||||
* @param id Query id
|
||||
* @param reason Error message
|
||||
*/
|
||||
DroidDB_Tx.prototype.queryFailed = function(id, reason) {
|
||||
|
||||
// The sql queries in this transaction have already been run, since
|
||||
// we really don't have a real transaction implemented in native code.
|
||||
// However, the user callbacks for the remaining sql queries in transaction
|
||||
// will not be called.
|
||||
this.queryList = {};
|
||||
|
||||
if (this.errorCallback) {
|
||||
try {
|
||||
this.errorCallback(reason);
|
||||
} catch(e) {
|
||||
console.log("Transaction error calling user error callback: " + e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Execute SQL statement
|
||||
*
|
||||
* @param sql SQL statement to execute
|
||||
* @param params Statement parameters
|
||||
* @param successCallback Success callback
|
||||
* @param errorCallback Error callback
|
||||
*/
|
||||
DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCallback) {
|
||||
|
||||
// Init params array
|
||||
if (typeof params === 'undefined') {
|
||||
params = [];
|
||||
}
|
||||
|
||||
// Create query and add to queue
|
||||
var query = new DroidDB_Query(this);
|
||||
queryQueue[query.id] = query;
|
||||
|
||||
// Save callbacks
|
||||
query.successCallback = successCallback;
|
||||
query.errorCallback = errorCallback;
|
||||
|
||||
// Call native code
|
||||
exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
|
||||
};
|
||||
|
||||
var DatabaseShell = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Start a transaction.
|
||||
* Does not support rollback in event of failure.
|
||||
*
|
||||
* @param process {Function} The transaction function
|
||||
* @param successCallback {Function}
|
||||
* @param errorCallback {Function}
|
||||
*/
|
||||
DatabaseShell.prototype.transaction = function(process, errorCallback, successCallback) {
|
||||
var tx = new DroidDB_Tx();
|
||||
tx.successCallback = successCallback;
|
||||
tx.errorCallback = errorCallback;
|
||||
try {
|
||||
process(tx);
|
||||
} catch (e) {
|
||||
console.log("Transaction error: "+e);
|
||||
if (tx.errorCallback) {
|
||||
try {
|
||||
tx.errorCallback(e);
|
||||
} catch (ex) {
|
||||
console.log("Transaction error calling user error callback: "+e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Open database
|
||||
*
|
||||
* @param name Database name
|
||||
* @param version Database version
|
||||
* @param display_name Database display name
|
||||
* @param size Database size in bytes
|
||||
* @return Database object
|
||||
*/
|
||||
var DroidDB_openDatabase = function(name, version, display_name, size) {
|
||||
exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
|
||||
var db = new DatabaseShell();
|
||||
return db;
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
openDatabase:DroidDB_openDatabase,
|
||||
failQuery:failQuery,
|
||||
completeQuery:completeQuery
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
// file: lib/android/plugin/android/storage/openDatabase.js
|
||||
define("cordova/plugin/android/storage/openDatabase", function(require, exports, module) {
|
||||
|
||||
|
||||
var modulemapper = require('cordova/modulemapper'),
|
||||
storage = require('cordova/plugin/android/storage');
|
||||
|
||||
var originalOpenDatabase = modulemapper.getOriginalSymbol(window, 'openDatabase');
|
||||
|
||||
module.exports = function(name, version, desc, size) {
|
||||
// First patch WebSQL if necessary
|
||||
if (!originalOpenDatabase) {
|
||||
// Not defined, create an openDatabase function for all to use!
|
||||
return storage.openDatabase.apply(this, arguments);
|
||||
}
|
||||
|
||||
// Defined, but some Android devices will throw a SECURITY_ERR -
|
||||
// so we wrap the whole thing in a try-catch and shim in our own
|
||||
// if the device has Android bug 16175.
|
||||
try {
|
||||
return originalOpenDatabase(name, version, desc, size);
|
||||
} catch (ex) {
|
||||
if (ex.code !== 18) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return storage.openDatabase(name, version, desc, size);
|
||||
};
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
// file: lib/android/plugin/android/storage/symbols.js
|
||||
define("cordova/plugin/android/storage/symbols", function(require, exports, module) {
|
||||
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
modulemapper.clobbers('cordova/plugin/android/storage/openDatabase', 'openDatabase');
|
||||
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/echo.js
|
||||
define("cordova/plugin/echo", function(require, exports, module) {
|
||||
|
||||
var exec = require('cordova/exec'),
|
||||
utils = require('cordova/utils');
|
||||
|
||||
/**
|
||||
* Sends the given message through exec() to the Echo plugin, which sends it back to the successCallback.
|
||||
* @param successCallback invoked with a FileSystem object
|
||||
* @param errorCallback invoked if error occurs retrieving file system
|
||||
* @param message The string to be echoed.
|
||||
* @param forceAsync Whether to force an async return value (for testing native->js bridge).
|
||||
*/
|
||||
module.exports = function(successCallback, errorCallback, message, forceAsync) {
|
||||
var action = 'echo';
|
||||
var messageIsMultipart = (utils.typeName(message) == "Array");
|
||||
var args = messageIsMultipart ? message : [message];
|
||||
|
||||
if (utils.typeName(message) == 'ArrayBuffer') {
|
||||
if (forceAsync) {
|
||||
console.warn('Cannot echo ArrayBuffer with forced async, falling back to sync.');
|
||||
}
|
||||
action += 'ArrayBuffer';
|
||||
} else if (messageIsMultipart) {
|
||||
if (forceAsync) {
|
||||
console.warn('Cannot echo MultiPart Array with forced async, falling back to sync.');
|
||||
}
|
||||
action += 'MultiPart';
|
||||
} else if (forceAsync) {
|
||||
action += 'Async';
|
||||
}
|
||||
|
||||
exec(successCallback, errorCallback, "Echo", action, args);
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/pluginloader.js
|
||||
define("cordova/pluginloader", function(require, exports, module) {
|
||||
|
||||
var channel = require('cordova/channel');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
// Helper function to inject a <script> tag.
|
||||
@ -1737,7 +1419,7 @@ function injectScript(url, onload, onerror) {
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
function onScriptLoadingComplete(moduleList) {
|
||||
function onScriptLoadingComplete(moduleList, finishPluginLoading) {
|
||||
// Loop through all the plugins and then through their clobbers and merges.
|
||||
for (var i = 0, module; module = moduleList[i]; i++) {
|
||||
if (module) {
|
||||
@ -1770,28 +1452,21 @@ function onScriptLoadingComplete(moduleList) {
|
||||
finishPluginLoading();
|
||||
}
|
||||
|
||||
// Called when:
|
||||
// * There are plugins defined and all plugins are finished loading.
|
||||
// * There are no plugins to load.
|
||||
function finishPluginLoading() {
|
||||
channel.onPluginsReady.fire();
|
||||
}
|
||||
|
||||
// Handler for the cordova_plugins.js content.
|
||||
// See plugman's plugin_loader.js for the details of this object.
|
||||
// This function is only called if the really is a plugins array that isn't empty.
|
||||
// Otherwise the onerror response handler will just call finishPluginLoading().
|
||||
function handlePluginsObject(path, moduleList) {
|
||||
function handlePluginsObject(path, moduleList, finishPluginLoading) {
|
||||
// Now inject the scripts.
|
||||
var scriptCounter = moduleList.length;
|
||||
|
||||
if (!scriptCounter) {
|
||||
onScriptLoadingComplete();
|
||||
finishPluginLoading();
|
||||
return;
|
||||
}
|
||||
function scriptLoadedCallback() {
|
||||
if (!--scriptCounter) {
|
||||
onScriptLoadingComplete(moduleList);
|
||||
onScriptLoadingComplete(moduleList, finishPluginLoading);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1800,17 +1475,17 @@ function handlePluginsObject(path, moduleList) {
|
||||
}
|
||||
}
|
||||
|
||||
function injectPluginScript(pathPrefix) {
|
||||
function injectPluginScript(pathPrefix, finishPluginLoading) {
|
||||
injectScript(pathPrefix + 'cordova_plugins.js', function(){
|
||||
try {
|
||||
var moduleList = require("cordova/plugin_list");
|
||||
handlePluginsObject(pathPrefix, moduleList);
|
||||
handlePluginsObject(pathPrefix, moduleList, finishPluginLoading);
|
||||
} catch (e) {
|
||||
// Error loading cordova_plugins.js, file not found or something
|
||||
// this is an acceptable error, pre-3.0.0, so we just move on.
|
||||
finishPluginLoading();
|
||||
}
|
||||
},finishPluginLoading); // also, add script load error handler for file not found
|
||||
}, finishPluginLoading); // also, add script load error handler for file not found
|
||||
}
|
||||
|
||||
function findCordovaPath() {
|
||||
@ -1830,28 +1505,32 @@ function findCordovaPath() {
|
||||
// Tries to load all plugins' js-modules.
|
||||
// This is an async process, but onDeviceReady is blocked on onPluginsReady.
|
||||
// onPluginsReady is fired when there are no plugins to load, or they are all done.
|
||||
exports.load = function() {
|
||||
exports.load = function(callback) {
|
||||
var pathPrefix = findCordovaPath();
|
||||
if (pathPrefix === null) {
|
||||
console.log('Could not find cordova.js script tag. Plugin loading may fail.');
|
||||
pathPrefix = '';
|
||||
}
|
||||
injectPluginScript(pathPrefix);
|
||||
injectPluginScript(pathPrefix, callback);
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/symbols.js
|
||||
define("cordova/symbols", function(require, exports, module) {
|
||||
// file: lib/common/urlutil.js
|
||||
define("cordova/urlutil", function(require, exports, module) {
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var urlutil = exports;
|
||||
var anchorEl = document.createElement('a');
|
||||
|
||||
// Use merges here in case others symbols files depend on this running first,
|
||||
// but fail to declare the dependency with a require().
|
||||
modulemapper.merges('cordova', 'cordova');
|
||||
modulemapper.clobbers('cordova/exec', 'cordova.exec');
|
||||
modulemapper.clobbers('cordova/exec', 'Cordova.exec');
|
||||
/**
|
||||
* For already absolute URLs, returns what is passed in.
|
||||
* For relative URLs, converts them to absolute ones.
|
||||
*/
|
||||
urlutil.makeAbsolute = function(url) {
|
||||
anchorEl.href = url;
|
||||
return anchorEl.href;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
@ -2028,93 +1707,6 @@ function UUIDcreatePart(length) {
|
||||
window.cordova = require('cordova');
|
||||
// file: lib/scripts/bootstrap.js
|
||||
|
||||
(function (context) {
|
||||
if (context._cordovaJsLoaded) {
|
||||
throw new Error('cordova.js included multiple times.');
|
||||
}
|
||||
context._cordovaJsLoaded = true;
|
||||
|
||||
var channel = require('cordova/channel');
|
||||
var pluginloader = require('cordova/pluginloader');
|
||||
|
||||
var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
|
||||
|
||||
function logUnfiredChannels(arr) {
|
||||
for (var i = 0; i < arr.length; ++i) {
|
||||
if (arr[i].state != 2) {
|
||||
console.log('Channel not fired: ' + arr[i].type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.setTimeout(function() {
|
||||
if (channel.onDeviceReady.state != 2) {
|
||||
console.log('deviceready has not fired after 5 seconds.');
|
||||
logUnfiredChannels(platformInitChannelsArray);
|
||||
logUnfiredChannels(channel.deviceReadyChannelsArray);
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
// Replace navigator before any modules are required(), to ensure it happens as soon as possible.
|
||||
// We replace it so that properties that can't be clobbered can instead be overridden.
|
||||
function replaceNavigator(origNavigator) {
|
||||
var CordovaNavigator = function() {};
|
||||
CordovaNavigator.prototype = origNavigator;
|
||||
var newNavigator = new CordovaNavigator();
|
||||
// This work-around really only applies to new APIs that are newer than Function.bind.
|
||||
// Without it, APIs such as getGamepads() break.
|
||||
if (CordovaNavigator.bind) {
|
||||
for (var key in origNavigator) {
|
||||
if (typeof origNavigator[key] == 'function') {
|
||||
newNavigator[key] = origNavigator[key].bind(origNavigator);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newNavigator;
|
||||
}
|
||||
if (context.navigator) {
|
||||
context.navigator = replaceNavigator(context.navigator);
|
||||
}
|
||||
|
||||
// _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 cordova JS is ready.
|
||||
if (window._nativeReady) {
|
||||
channel.onNativeReady.fire();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create all cordova objects once native side is ready.
|
||||
*/
|
||||
channel.join(function() {
|
||||
// Call the platform-specific initialization
|
||||
require('cordova/platform').initialize();
|
||||
|
||||
// Fire event to notify that all objects are created
|
||||
channel.onCordovaReady.fire();
|
||||
|
||||
// Fire onDeviceReady event once page has fully loaded, all
|
||||
// constructors have run and cordova info has been received from native
|
||||
// side.
|
||||
// This join call is deliberately made after platform.initialize() in
|
||||
// order that plugins may manipulate channel.deviceReadyChannelsArray
|
||||
// if necessary.
|
||||
channel.join(function() {
|
||||
require('cordova').fireDocumentEvent('deviceready');
|
||||
}, channel.deviceReadyChannelsArray);
|
||||
|
||||
}, platformInitChannelsArray);
|
||||
|
||||
// Don't attempt to load when running unit tests.
|
||||
if (typeof XMLHttpRequest != 'undefined') {
|
||||
pluginloader.load();
|
||||
}
|
||||
}(window));
|
||||
|
||||
// file: lib/scripts/bootstrap-android.js
|
||||
|
||||
// Tell the native code that a page change has occurred.
|
||||
require('cordova/exec')(null, null, 'PluginManager', 'startup', []);
|
||||
require('cordova/channel').onNativeReady.fire();
|
||||
require('cordova/init');
|
||||
|
||||
})();
|
Loading…
Reference in New Issue
Block a user