From 5e858f8bc3fabaec55db532511659fdf39621a4b Mon Sep 17 00:00:00 2001 From: Vadim Voituk <vadim.voituk@gmail.com> Date: Thu, 20 Jan 2011 18:23:07 +0200 Subject: [PATCH] Added CupcakeLocalStorage.clear() method (in according to http://dev.w3.org/html5/webstorage/#the-storage-interface) --- framework/assets/js/storage.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/framework/assets/js/storage.js b/framework/assets/js/storage.js index 9c1f8593..c677d9d0 100755 --- a/framework/assets/js/storage.js +++ b/framework/assets/js/storage.js @@ -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+".");