public
Last active

  • Download Gist
webdatabase.sjs
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/**
@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;
}
};
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.