Created
October 6, 2010 15:28
-
-
Save tomger/613526 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
@module webdatabase | |
@desc A simple stratified wrapper over the asynchronous webdatabase api (webkit) */ | |
*/ | |
/** | |
@function openDatabase | |
*/ | |
exports.openDatabase = function (name, version, desc, size) { | |
var db = openDatabase(name, version, desc, size); | |
return { | |
executeSql: function (sql, params) { | |
var rv; | |
this.transaction(function(tx){ | |
rv = tx.executeSql(sql, params); | |
}); | |
return rv; | |
}, | |
transaction: function (cb) { | |
var error; | |
waitfor() { | |
db.transaction(function(t) { | |
var tx = { | |
executeSql: function (sql, params) { | |
waitfor(var dummytx, rv) { | |
t.executeSql(sql, params, resume); | |
} | |
return rv; | |
} | |
} | |
cb(tx); | |
resume(); | |
}, function (f) { | |
error = f; | |
resume(); | |
}); | |
} | |
if (error) throw error; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment