diff --git a/DroidGap/assets/www/SQLitePlugin.js b/DroidGap/assets/www/SQLitePlugin.js index 9c7f6e5..4ca0f06 100644 --- a/DroidGap/assets/www/SQLitePlugin.js +++ b/DroidGap/assets/www/SQLitePlugin.js @@ -13,6 +13,8 @@ */ +// XXX TODO: use function() { ... } () to encapsulate these declarations (except for Java callback) + /** * SQL result set object * PRIVATE METHOD @@ -331,8 +333,10 @@ var DDB_openDatabase = function(name, version, display_name, size) { * @constructor */ -window.my_openDatabase = function(name, version, desc, size){ +window.sqlitePlugin = { + openDatabase: function(name, version, desc, size) { window.dddb = new DDB(); return DDB_openDatabase(name, version, desc, size); } +}; diff --git a/DroidGap/assets/www/index.html b/DroidGap/assets/www/index.html index 555768d..6928c2a 100644 --- a/DroidGap/assets/www/index.html +++ b/DroidGap/assets/www/index.html @@ -5,7 +5,7 @@ PhoneGap - + @@ -23,7 +23,7 @@ function init1test() { // PhoneGap is ready // function onDeviceReady() { - var db = window.my_openDatabase("Database", "1.0", "PhoneGap Demo", 200000); + var db = window.sqlitePlugin.openDatabase("Database", "1.0", "PhoneGap Demo", 200000); db.transaction(function(tx) { diff --git a/DroidGap/lawnchair-adapter-test/www/SQLitePlugin.js b/DroidGap/lawnchair-adapter-test/www/SQLitePlugin.js index 068def9..4ca0f06 100644 --- a/DroidGap/lawnchair-adapter-test/www/SQLitePlugin.js +++ b/DroidGap/lawnchair-adapter-test/www/SQLitePlugin.js @@ -13,6 +13,8 @@ */ +// XXX TODO: use function() { ... } () to encapsulate these declarations (except for Java callback) + /** * SQL result set object * PRIVATE METHOD @@ -317,9 +319,7 @@ DatabaseShell.prototype.transaction = function(process, errorCallback, successCa * @return Database object */ var DDB_openDatabase = function(name, version, display_name, size) { -console.log("open database " + name + " ... typeof " + typeof(PhoneGap.exec)); PhoneGap.exec(null, null, "SQLitePlugin", "openDatabase", [name, version, display_name, size]); - //cordova.exec(null, null, "SQLitePlugin", "openDatabase", [name, version, display_name, size]); var db = new DatabaseShell(); return db; }; @@ -333,8 +333,10 @@ console.log("open database " + name + " ... typeof " + typeof(PhoneGap.exec)); * @constructor */ -window.my_openDatabase = function(name, version, desc, size){ +window.sqlitePlugin = { + openDatabase: function(name, version, desc, size) { window.dddb = new DDB(); return DDB_openDatabase(name, version, desc, size); } +}; diff --git a/DroidGap/lawnchair-adapter-test/www/webkit-sqlite.js b/DroidGap/lawnchair-adapter-test/www/webkit-sqlite.js index 6e1fadc..7fafb74 100644 --- a/DroidGap/lawnchair-adapter-test/www/webkit-sqlite.js +++ b/DroidGap/lawnchair-adapter-test/www/webkit-sqlite.js @@ -22,8 +22,8 @@ Lawnchair.adapter('webkit-sqlite', (function () { return { //valid: function() { return !!(window.openDatabase) }, - valid: function() { return !!(window.my_openDatabase) }, - //valid: function() { return !!(sqlitePlugin.openDatabase) }, + //valid: function() { return !!(window.my_openDatabase) }, + valid: function() { return !!(sqlitePlugin.openDatabase) }, init: function (options, callback) { var that = this @@ -33,8 +33,9 @@ Lawnchair.adapter('webkit-sqlite', (function () { // open a connection and create the db if it doesn't exist //this.db = openDatabase(this.name, '1.0.0', this.name, 65536) //this.db = my_openDatabase(this.name, '1.0.0', this.name, 65536) - this.db = window.my_openDatabase("Database", "1.0", "PhoneGap Demo", 200000); + //this.db = window.my_openDatabase("Database", "1.0", "PhoneGap Demo", 200000); //this.db = sqlitePlugin.openDatabase(this.name, '1.0.0', this.name, 65536) + this.db = sqlitePlugin.openDatabase("Database", "1.0", "PhoneGap Demo", 200000); this.db.transaction(function (t) { t.executeSql(create, [], win, fail) })