Skip to content

Instantly share code, notes, and snippets.

@tomger
Created October 6, 2010 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tomger/613526 to your computer and use it in GitHub Desktop.
Save tomger/613526 to your computer and use it in GitHub Desktop.
/**
@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