From 9e3e5cfca7e5bedecb54b8b1063458f246bad38c Mon Sep 17 00:00:00 2001 From: Min RK Date: Sun, 4 Jan 2015 11:56:16 -0800 Subject: [PATCH] store widget state in single key rather than in a dict, which doesn't work without reserializing *all* stored widget states (of all notebooks), since localStorage only supports storing strings. --- IPython/html/static/widgets/js/manager.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/IPython/html/static/widgets/js/manager.js b/IPython/html/static/widgets/js/manager.js index 1b982daf3..5696f03f9 100644 --- a/IPython/html/static/widgets/js/manager.js +++ b/IPython/html/static/widgets/js/manager.js @@ -107,16 +107,14 @@ define([ // that the widgets are associated with so they don't show on other // pages hosted by the noteboook server. var url = [window.location.protocol, '//', window.location.host, window.location.pathname].join(''); + var key = 'widgets:' + url; WidgetManager.set_state_callbacks(function() { - if (localStorage.widgets && localStorage.widgets[url]) { - return JSON.parse(localStorage.widgets[url]); + if (localStorage[key]) { + return JSON.parse(localStorage[key]); } return {}; }, function(state) { - if (localStorage.widgets === undefined) { - localStorage.widgets = {}; - } - localStorage.widgets[url] = JSON.stringify(state); + localStorage[key] = JSON.stringify(state); }); //--------------------------------------------------------------------