luci-base: ui.js: use session data api to persist tab selection state
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
adeb0f3aa6
commit
51186355ea
1 changed files with 11 additions and 17 deletions
|
@ -2,6 +2,7 @@
|
|||
'require validation';
|
||||
'require baseclass';
|
||||
'require request';
|
||||
'require session';
|
||||
'require poll';
|
||||
'require dom';
|
||||
'require rpc';
|
||||
|
@ -3463,16 +3464,14 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
|
|||
|
||||
/** @private */
|
||||
getActiveTabState: function() {
|
||||
var page = document.body.getAttribute('data-page');
|
||||
var page = document.body.getAttribute('data-page'),
|
||||
state = session.getLocalData('tab');
|
||||
|
||||
try {
|
||||
var val = JSON.parse(window.sessionStorage.getItem('tab'));
|
||||
if (val.page === page && L.isObject(val.paths))
|
||||
return val;
|
||||
}
|
||||
catch(e) {}
|
||||
if (L.isObject(state) && state.page === page && L.isObject(state.paths))
|
||||
return state;
|
||||
|
||||
session.setLocalData('tab', null);
|
||||
|
||||
window.sessionStorage.removeItem('tab');
|
||||
return { page: page, paths: {} };
|
||||
},
|
||||
|
||||
|
@ -3484,17 +3483,12 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
|
|||
|
||||
/** @private */
|
||||
setActiveTabId: function(pane, tabIndex) {
|
||||
var path = this.getPathForPane(pane);
|
||||
var path = this.getPathForPane(pane),
|
||||
state = this.getActiveTabState();
|
||||
|
||||
try {
|
||||
var state = this.getActiveTabState();
|
||||
state.paths[path] = tabIndex;
|
||||
state.paths[path] = tabIndex;
|
||||
|
||||
window.sessionStorage.setItem('tab', JSON.stringify(state));
|
||||
}
|
||||
catch (e) { return false; }
|
||||
|
||||
return true;
|
||||
return session.setLocalData('tab', state);
|
||||
},
|
||||
|
||||
/** @private */
|
||||
|
|
Loading…
Reference in a new issue