|
|
@ -2,28 +2,23 @@ class @CookieStore
|
|
|
|
INT = /^\d+$/
|
|
|
|
INT = /^\d+$/
|
|
|
|
|
|
|
|
|
|
|
|
get: (key) ->
|
|
|
|
get: (key) ->
|
|
|
|
try
|
|
|
|
|
|
|
|
value = Cookies.get(key)
|
|
|
|
value = Cookies.get(key)
|
|
|
|
value = parseInt(value, 10) if value? and INT.test(value)
|
|
|
|
value = parseInt(value, 10) if value? and INT.test(value)
|
|
|
|
value
|
|
|
|
value
|
|
|
|
catch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set: (key, value) ->
|
|
|
|
set: (key, value) ->
|
|
|
|
if value == false
|
|
|
|
if value == false
|
|
|
|
return @del(key)
|
|
|
|
@del(key)
|
|
|
|
else if value == true
|
|
|
|
return
|
|
|
|
value = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
value = 1 if value == true
|
|
|
|
Cookies.set(key, '' + value, path: '/', expires: 1e8)
|
|
|
|
Cookies.set(key, '' + value, path: '/', expires: 1e8)
|
|
|
|
true
|
|
|
|
throw new Error("Failed to set cookie '#{key}'") unless @get(key) == value
|
|
|
|
catch
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
del: (key) ->
|
|
|
|
del: (key) ->
|
|
|
|
try
|
|
|
|
|
|
|
|
Cookies.expire(key)
|
|
|
|
Cookies.expire(key)
|
|
|
|
true
|
|
|
|
return
|
|
|
|
catch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reset: ->
|
|
|
|
reset: ->
|
|
|
|
try
|
|
|
|
try
|
|
|
|