diff options
Diffstat (limited to 'share/www/script')
-rw-r--r-- | share/www/script/futon.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/share/www/script/futon.js b/share/www/script/futon.js index b15a5eec..200d6ec5 100644 --- a/share/www/script/futon.js +++ b/share/www/script/futon.js @@ -334,6 +334,14 @@ function $$(node) { return callback(decl); } + function windowName() { + try { + return JSON.parse(window.name || "{}"); + } catch (e) { + return {}; + } + } + // add suffix to cookie names to be able to separate between ports var cookiePrefix = location.port + "_"; @@ -366,15 +374,15 @@ function $$(node) { "window": { get: function(name) { - return JSON.parse(window.name || "{}")[name]; + return windowName()[name]; }, set: function(name, value) { - var obj = JSON.parse(window.name || "{}"); + var obj = windowName(); obj[name] = value || null; window.name = JSON.stringify(obj); }, del: function(name) { - var obj = JSON.parse(window.name || "{}"); + var obj = windowName(); delete obj[name]; window.name = JSON.stringify(obj); } |