diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-06-19 20:49:57 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-06-19 20:49:57 +0200 |
commit | a8c2cada5206621f2eb2894258851d7d3a411e40 (patch) | |
tree | fe0173e942605db9ad0579a77cd19670121c265e /src/ws | |
parent | 804679db852b13664ca351e0ee302cc70e96bf67 (diff) |
Use localStorage instead of cookies to prevent libwebsockets from choking on the big amount of cookie data on server side when it isn't even needed in the first place...
Diffstat (limited to 'src/ws')
-rw-r--r-- | src/ws/node.js | 2 | ||||
-rw-r--r-- | src/ws/view.js | 35 |
2 files changed, 3 insertions, 34 deletions
diff --git a/src/ws/node.js b/src/ws/node.js index 4da3969..75fe1ec 100644 --- a/src/ws/node.js +++ b/src/ws/node.js @@ -225,7 +225,7 @@ Node.prototype.create = function() node.id = createId(this.subscribeid, this.id); { - var collapsed = getCookie(node.id+"_collapsed") == "true"; + var collapsed = localStorage.getItem(node.id+"_collapsed") == "true"; if(collapsed) { this.element.classList.add('collapsed'); diff --git a/src/ws/view.js b/src/ws/view.js index 8ed5184..7fc69bb 100644 --- a/src/ws/view.js +++ b/src/ws/view.js @@ -14,37 +14,6 @@ function createNode() } */ -var cookies = null; -function initCookie(cookie, index) -{ - const name = cookie.split('=')[0].trim(); - const value = cookie.split('=')[1]; - cookies[name] = value; -} -function initCookies() -{ - cookies = new Object(); - document.cookie.split(';').forEach(initCookie); -} -function setCookie(name, value) -{ - if(cookies == null) - { - initCookies(); - } - cookies[name] = value; - document.cookie = name + "=" + value+"; expires=Fri, 31 Dec 9999 23:59:59 GMT"; -} - -function getCookie(name) -{ - if(cookies == null) - { - initCookies(); - } - return cookies[name]; -} - function getNode(subscribeid, id) { } @@ -383,9 +352,9 @@ function collapse(e) return; // no node } - var collapsed = getCookie(id+"_collapsed") == "true"; + var collapsed = localStorage.getItem(id+"_collapsed") == "true"; collapsed = !collapsed; - setCookie(id+"_collapsed", collapsed?"true":"false"); + localStorage.setItem(id+"_collapsed", collapsed?"true":"false"); e.stopPropagation(); if(collapsed) |