summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-15 22:18:13 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-16 13:30:35 +0200
commit51186355ea168dfc6fb1363ace5c57b178f0331e (patch)
treeb65053816adef90df729013baaa99e06d4de2cd6 /modules/luci-base/htdocs
parentadeb0f3aa6bb9080066f79d0411e8e334b8b498f (diff)
luci-base: ui.js: use session data api to persist tab selection state
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/ui.js28
1 files changed, 11 insertions, 17 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js
index 2e4e4ad1c..235f62a98 100644
--- a/modules/luci-base/htdocs/luci-static/resources/ui.js
+++ b/modules/luci-base/htdocs/luci-static/resources/ui.js
@@ -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;
-
- window.sessionStorage.setItem('tab', JSON.stringify(state));
- }
- catch (e) { return false; }
+ state.paths[path] = tabIndex;
- return true;
+ return session.setLocalData('tab', state);
},
/** @private */