From 229ac7838a12011f620a3ec7f0b82fc48a641647 Mon Sep 17 00:00:00 2001 From: Rafael Beckel Date: Sun, 3 Nov 2013 16:51:26 -0200 Subject: [PATCH] Change init method of Lawnchair-adapter to support 'db' argument, as stated in documentation --- Lawnchair-adapter/Lawnchair-sqlitePlugin.js | 12 ++++-------- Lawnchair-adapter/test-www/Lawnchair-sqlitePlugin.js | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Lawnchair-adapter/Lawnchair-sqlitePlugin.js b/Lawnchair-adapter/Lawnchair-sqlitePlugin.js index d30181817..e4ca0d580 100644 --- a/Lawnchair-adapter/Lawnchair-sqlitePlugin.js +++ b/Lawnchair-adapter/Lawnchair-sqlitePlugin.js @@ -21,25 +21,21 @@ Lawnchair.adapter('webkit-sqlite', (function () { // public methods return { - //valid: function() { return !!(window.openDatabase) }, - //valid: function() { return !!(window.my_openDatabase) }, valid: function() { return !!(sqlitePlugin.openDatabase) }, init: function (options, callback) { var that = this , cb = that.fn(that.name, callback) + , dbname = options.db || this.name + , bgType = options.bgType || 1 , create = "CREATE TABLE IF NOT EXISTS " + this.name + " (id NVARCHAR(32) UNIQUE PRIMARY KEY, value TEXT, timestamp REAL)" , win = function(){ return cb.call(that, that); } // 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 = sqlitePlugin.openDatabase(this.name, '1.0.0', this.name, 65536) - //this.db = sqlitePlugin.openDatabase("Database", "1.0", "PhoneGap Demo", 200000); + this.db = sqlitePlugin.openDatabase({name:dbname,bgType:bgType}) this.db.transaction(function (t) { t.executeSql(create, [], win, fail) }) - }, + }, keys: function (callback) { var cb = this.lambda(callback) diff --git a/Lawnchair-adapter/test-www/Lawnchair-sqlitePlugin.js b/Lawnchair-adapter/test-www/Lawnchair-sqlitePlugin.js index d30181817..e4ca0d580 100644 --- a/Lawnchair-adapter/test-www/Lawnchair-sqlitePlugin.js +++ b/Lawnchair-adapter/test-www/Lawnchair-sqlitePlugin.js @@ -21,25 +21,21 @@ Lawnchair.adapter('webkit-sqlite', (function () { // public methods return { - //valid: function() { return !!(window.openDatabase) }, - //valid: function() { return !!(window.my_openDatabase) }, valid: function() { return !!(sqlitePlugin.openDatabase) }, init: function (options, callback) { var that = this , cb = that.fn(that.name, callback) + , dbname = options.db || this.name + , bgType = options.bgType || 1 , create = "CREATE TABLE IF NOT EXISTS " + this.name + " (id NVARCHAR(32) UNIQUE PRIMARY KEY, value TEXT, timestamp REAL)" , win = function(){ return cb.call(that, that); } // 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 = sqlitePlugin.openDatabase(this.name, '1.0.0', this.name, 65536) - //this.db = sqlitePlugin.openDatabase("Database", "1.0", "PhoneGap Demo", 200000); + this.db = sqlitePlugin.openDatabase({name:dbname,bgType:bgType}) this.db.transaction(function (t) { t.executeSql(create, [], win, fail) }) - }, + }, keys: function (callback) { var cb = this.lambda(callback)