From a8c2cada5206621f2eb2894258851d7d3a411e40 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 19 Jun 2020 20:49:57 +0200 Subject: 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... --- src/ws/node.js | 2 +- src/ws/view.js | 35 ++--------------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) (limited to 'src/ws') 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) -- cgit v1.2.3