##// END OF EJS Templates
Associate persistence with URL
Jonathan Frederic -
Show More
@@ -103,10 +103,20 b' define(['
103 };
103 };
104
104
105 // Use local storage to persist widgets across page refresh by default.
105 // Use local storage to persist widgets across page refresh by default.
106 // LocalStorage is per domain, so we need to explicitly set the URL
107 // that the widgets are associated with so they don't show on other
108 // pages hosted by the noteboook server.
109 var url = [window.location.protocol, '//', window.location.host, window.location.pathname].join('');
106 WidgetManager.set_state_callbacks(function() {
110 WidgetManager.set_state_callbacks(function() {
107 return JSON.parse(localStorage.widgets || '{}');
111 if (localStorage.widgets && localStorage.widgets[url]) {
112 return JSON.parse(localStorage.widgets[url]);
113 }
114 return {};
108 }, function(state) {
115 }, function(state) {
109 localStorage.widgets = JSON.stringify(state);
116 if (localStorage.widgets === undefined) {
117 localStorage.widgets = {};
118 }
119 localStorage.widgets[url] = JSON.stringify(state);
110 });
120 });
111
121
112 //--------------------------------------------------------------------
122 //--------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now