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.
Min RK 11 years ago
parent ffaa09492a
commit 9e3e5cfca7

@ -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);
});
//--------------------------------------------------------------------

Loading…
Cancel
Save