Added CupcakeLocalStorage.clear() method (in according to http://dev.w3.org/html5/webstorage/#the-storage-interface)

This commit is contained in:
Vadim Voituk 2011-01-20 18:23:07 +02:00 committed by Fil Maj
parent 691b093ccd
commit 5e858f8bc3

View File

@ -318,7 +318,7 @@ var CupcakeLocalStorage = function() {
}
);
this.setItem = function(key, val) {
console.log('set');
//console.log('set');
storage[key] = val;
this.db.transaction(
@ -343,6 +343,16 @@ var CupcakeLocalStorage = function() {
);
}
this.clear = function() {
storage = {};
this.db.transaction(
function (transaction) {
transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
transaction.executeSql('DELETE FROM storage', []);
}
);
}
} catch(e) {
alert("Database error "+e+".");