Moved from localStorage to sessionStorage for testing - issue#118.

This commit is contained in:
Martin Edenhofer 2014-01-21 22:37:26 +01:00
parent c771a8c57f
commit ec00c76ea6

View file

@ -33,7 +33,7 @@ class _storeSingleton
store: {} store: {}
constructor: -> constructor: ->
@support = true @support = true
if !window.localStorage if !window.sessionStorage
@support = false @support = false
# @support = false # @support = false
@ -47,7 +47,7 @@ class _storeSingleton
@store[key] = value @store[key] = value
return if !@support return if !@support
try try
localStorage.setItem( key, JSON.stringify( value ) ) sessionStorage.setItem( key, JSON.stringify( value ) )
catch e catch e
if e is QUOTA_EXCEEDED_ERR if e is QUOTA_EXCEEDED_ERR
# do something nice to notify your users # do something nice to notify your users
@ -56,7 +56,7 @@ class _storeSingleton
# get item # get item
get: (key) -> get: (key) ->
return @store[key] if !@support return @store[key] if !@support
value = localStorage.getItem( key ) value = sessionStorage.getItem( key )
return if !value return if !value
object = JSON.parse( value ) object = JSON.parse( value )
return object return object
@ -65,12 +65,12 @@ class _storeSingleton
delete: (key) -> delete: (key) ->
delete @store[key] delete @store[key]
return if !@support return if !@support
localStorage.removeItem( key ) sessionStorage.removeItem( key )
# clear local storage # clear local storage
clear: -> clear: ->
@store = {} @store = {}
localStorage.clear() sessionStorage.clear()
# return list of all keys # return list of all keys
list: -> list: ->
@ -80,11 +80,11 @@ class _storeSingleton
list.push key list.push key
return list return list
# logLength = localStorage.length-1; # logLength = sessionStorage.length-1;
# for count in [0..logLength] # for count in [0..logLength]
# key = localStorage.key( count ) # key = sessionStorage.key( count )
# if key # if key
# list.push key # list.push key
for key of window.localStorage for key of window.sessionStorage
list.push key list.push key
list list