I would have done something a little more Object-Oriented:
function DB( dbNativeObject ) {
this._native = dbNativeObject;
}
jQuery.extend( DB.prototype, {
exec: function( sql ) {
return jQuery.Deferred(function( defer ) {
this._native.transaction(function( transaction ) {
transaction.executeSql( sql, [],
function( transaction, result ) {
defer.resolveWith( transaction, [ result ] );
},
function( transaction, error ) {
defer.rejectWith( transaction, [ error, sql ] );
}
)
})
}).promise();
}
} );
function MyDB( dbNativeObject ) {
DB.call( this, dbNativeObject );
}
jQuery.extend( MyDB.prototype, DB.prototype, {
loadSummary: function() {
return this.exec( "SELECT * FROM tbl_summary" );
}
} );
var myDB = new MyDB( g_oDeviceDB );
myDB.loadSummary().done(function( resultSet ) {
data = resultSet.rows.item( 0 );
jQuery.each( data, function( key, value ) {
jQuery( "#summary_" + key ).text( value );
});
});
Just add all you app-specific methods into the MyDB prototype in the extend and you get quite an elegant solution imo.