diff options
-rw-r--r-- | ogcp/static/js/ogcp.js | 19 | ||||
-rw-r--r-- | ogcp/templates/macros.html | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index 8a538ca..c6dbdf0 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -2,6 +2,25 @@ const Endpoint = '/scopes/status'; const Interval = 1000; let updateTimeoutId = null; +function keepScopesTreeState() { + const scopes_tree = $('#scopes .collapse') + + scopes_tree.on('hidden.bs.collapse', function (event) { + event.stopPropagation(); + localStorage.removeItem(this.id); + }); + scopes_tree.on('shown.bs.collapse', function (event) { + event.stopPropagation(); + localStorage.setItem(this.id, 'show'); + }); + + scopes_tree.each(function () { + if (localStorage.getItem(this.id) == 'show') { + $(this).collapse('show'); + } + }); +} + function updateScopeState() { if (updateTimeoutId) { clearTimeout(updateTimeoutId); diff --git a/ogcp/templates/macros.html b/ogcp/templates/macros.html index 4ae5982..dd26818 100644 --- a/ogcp/templates/macros.html +++ b/ogcp/templates/macros.html @@ -9,6 +9,7 @@ document.addEventListener('readystatechange', () => { if (document.readyState === 'complete') { updateScopeState(); + keepScopesTreeState(); } }); </script> |