mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Associate persistence with URL
This commit is contained in:
parent
97e5c4cc4b
commit
8ad7cb3f4b
@ -103,10 +103,20 @@ define([
|
||||
};
|
||||
|
||||
// Use local storage to persist widgets across page refresh by default.
|
||||
// LocalStorage is per domain, so we need to explicitly set the URL
|
||||
// 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('');
|
||||
WidgetManager.set_state_callbacks(function() {
|
||||
return JSON.parse(localStorage.widgets || '{}');
|
||||
if (localStorage.widgets && localStorage.widgets[url]) {
|
||||
return JSON.parse(localStorage.widgets[url]);
|
||||
}
|
||||
return {};
|
||||
}, function(state) {
|
||||
localStorage.widgets = JSON.stringify(state);
|
||||
if (localStorage.widgets === undefined) {
|
||||
localStorage.widgets = {};
|
||||
}
|
||||
localStorage.widgets[url] = JSON.stringify(state);
|
||||
});
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user