mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Change to use Commands and CommandManager.
This commit is contained in:
@@ -1,89 +1,85 @@
|
||||
com.phonegap.StorageProxy = function() {
|
||||
this.className = "com.phonegap.Storage";
|
||||
};
|
||||
com.phonegap.StorageProxy.prototype.executeSql = function(query, params, id) {
|
||||
return PhoneGap.exec(this.className, "executeSql", [query, params, id]);
|
||||
};
|
||||
com.phonegap.StorageProxy.prototype.openDatabase = function(name, version, display_name, size) {
|
||||
return PhoneGap.exec(this.className, "openDatabase", [name, version, display_name, size]);
|
||||
};
|
||||
com.phonegap.Storage = new com.phonegap.StorageProxy();
|
||||
|
||||
/*
|
||||
* This is purely for the Android 1.5/1.6 HTML 5 Storage
|
||||
* I was hoping that Android 2.0 would deprecate this, but given the fact that
|
||||
* I was hoping that Android 2.0 would deprecate this, but given the fact that
|
||||
* most manufacturers ship with Android 1.5 and do not do OTA Updates, this is required
|
||||
*/
|
||||
|
||||
var DroidDB = function()
|
||||
{
|
||||
this.txQueue = [];
|
||||
}
|
||||
var DroidDB = function() {
|
||||
this.txQueue = [];
|
||||
};
|
||||
|
||||
DroidDB.prototype.addResult = function(rawdata, tx_id)
|
||||
{
|
||||
eval("var data = " + rawdata);
|
||||
var tx = this.txQueue[tx_id];
|
||||
tx.resultSet.push(data);
|
||||
}
|
||||
DroidDB.prototype.addResult = function(rawdata, tx_id) {
|
||||
eval("var data = " + rawdata);
|
||||
var tx = this.txQueue[tx_id];
|
||||
tx.resultSet.push(data);
|
||||
};
|
||||
|
||||
DroidDB.prototype.completeQuery = function(tx_id)
|
||||
{
|
||||
var tx = this.txQueue[tx_id];
|
||||
var r = new result();
|
||||
r.rows.resultSet = tx.resultSet;
|
||||
r.rows.length = tx.resultSet.length;
|
||||
tx.win(r);
|
||||
}
|
||||
DroidDB.prototype.completeQuery = function(tx_id) {
|
||||
var tx = this.txQueue[tx_id];
|
||||
var r = new result();
|
||||
r.rows.resultSet = tx.resultSet;
|
||||
r.rows.length = tx.resultSet.length;
|
||||
tx.win(r);
|
||||
};
|
||||
|
||||
DroidDB.prototype.fail = function(reason, tx_id)
|
||||
{
|
||||
var tx = this.txQueue[tx_id];
|
||||
tx.fail(reason);
|
||||
}
|
||||
DroidDB.prototype.fail = function(reason, tx_id) {
|
||||
var tx = this.txQueue[tx_id];
|
||||
tx.fail(reason);
|
||||
};
|
||||
|
||||
var DatabaseShell = function()
|
||||
{
|
||||
|
||||
}
|
||||
var DatabaseShell = function() {
|
||||
};
|
||||
|
||||
DatabaseShell.prototype.transaction = function(process)
|
||||
{
|
||||
tx = new Tx();
|
||||
process(tx);
|
||||
}
|
||||
DatabaseShell.prototype.transaction = function(process) {
|
||||
tx = new Tx();
|
||||
process(tx);
|
||||
};
|
||||
|
||||
var Tx = function()
|
||||
{
|
||||
droiddb.txQueue.push(this);
|
||||
this.id = droiddb.txQueue.length - 1;
|
||||
this.resultSet = [];
|
||||
}
|
||||
var Tx = function() {
|
||||
droiddb.txQueue.push(this);
|
||||
this.id = droiddb.txQueue.length - 1;
|
||||
this.resultSet = [];
|
||||
};
|
||||
|
||||
Tx.prototype.executeSql = function(query, params, win, fail)
|
||||
{
|
||||
droidStorage.executeSql(query, params, this.id);
|
||||
tx.win = win;
|
||||
tx.fail = fail;
|
||||
}
|
||||
Tx.prototype.executeSql = function(query, params, win, fail) {
|
||||
com.phonegap.Storage.executeSql(query, params, this.id);
|
||||
tx.win = win;
|
||||
tx.fail = fail;
|
||||
};
|
||||
|
||||
var result = function()
|
||||
{
|
||||
this.rows = new Rows();
|
||||
}
|
||||
var result = function() {
|
||||
this.rows = new Rows();
|
||||
};
|
||||
|
||||
var Rows = function()
|
||||
{
|
||||
this.resultSet = [];
|
||||
this.length = 0;
|
||||
}
|
||||
var Rows = function() {
|
||||
this.resultSet = [];
|
||||
this.length = 0;
|
||||
};
|
||||
|
||||
Rows.prototype.item = function(row_id)
|
||||
{
|
||||
return this.resultSet[id];
|
||||
}
|
||||
Rows.prototype.item = function(row_id) {
|
||||
return this.resultSet[id];
|
||||
};
|
||||
|
||||
var dbSetup = function(name, version, display_name, size)
|
||||
{
|
||||
droidStorage.openDatabase(name, version, display_name, size)
|
||||
var dbSetup = function(name, version, display_name, size) {
|
||||
com.phonegap.Storage.openDatabase(name, version, display_name, size)
|
||||
db_object = new DatabaseShell();
|
||||
return db_object;
|
||||
}
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
if (typeof window.openDatabase == "undefined")
|
||||
{
|
||||
navigator.openDatabase = window.openDatabase = dbSetup;
|
||||
window.droiddb = new DroidDB();
|
||||
}
|
||||
if (typeof window.openDatabase == "undefined") {
|
||||
navigator.openDatabase = window.openDatabase = dbSetup;
|
||||
window.droiddb = new DroidDB();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user