From b36fa4fbe4f5f62129d8025e0e9df6bc6489a156 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Mon, 18 Oct 2010 14:05:44 +0000 Subject: Avoid occasional stalling of Futon in Firefox. Closes COUCHDB-896. Patch by Dale Harvey. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1023807 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/futon.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'share/www/script') 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); } -- cgit v1.2.3