diff --git a/proj/batteries/index.html b/proj/batteries/index.html index 738f3a1..c9a1447 100644 --- a/proj/batteries/index.html +++ b/proj/batteries/index.html @@ -56,6 +56,7 @@ })(); + diff --git a/proj/index.html b/proj/index.html index b47da3d..9065661 100644 --- a/proj/index.html +++ b/proj/index.html @@ -27,6 +27,7 @@ })(); + diff --git a/proj/store.js b/proj/store.js new file mode 100644 index 0000000..c997e2c --- /dev/null +++ b/proj/store.js @@ -0,0 +1,22 @@ +(function() { + if (typeof localStorage === 'undefined') return + var global = this + global.ObjectStore = { + clear: function() { + localStorage.clear() + }, + get: function(key) { + var val = localStorage.getItem(key) + return typeof val === 'string' ? JSON.parse(val) : val + }, + key: function(n) { + return localStorage.key(n) + }, + set: function(key, val) { + localStorage.setItem(key, JSON.stringify(val)) + }, + remove: function(key) { + localStorage.remove(key) + } + } +}())