Skip to content

Commit

Permalink
Change init method of Lawnchair-adapter to support 'db' argument, as …
Browse files Browse the repository at this point in the history
…stated in documentation
  • Loading branch information
rafaelbeckel committed Nov 3, 2013
1 parent bd9c243 commit 229ac78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 4 additions & 8 deletions Lawnchair-adapter/Lawnchair-sqlitePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 4 additions & 8 deletions Lawnchair-adapter/test-www/Lawnchair-sqlitePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 229ac78

Please sign in to comment.