From 257bfd00575181e237447a06047da470d5689810 Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <49808844+DmitryBorisenko33@users.noreply.github.com> Date: Fri, 23 Sep 2022 14:12:50 +0200 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20=D1=81=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=20=D0=B1=D0=B8=D0=BD=D0=B0=D1=80=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.svelte | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/App.svelte b/src/App.svelte index cc899df..6b06897 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -203,6 +203,49 @@ sortingLayout(); }); + class blobToJson { + constructor(data, st, end) { + this.data = data; + this.st = st; + this.end = end; + this.flag = true; + this.blob = new MyBlobBuilder(); + } + + stEvent() { + if (this.data === st) { + this.flag = true; + } + } + + endEvent() { + if (this.data === end) { + this.flag = false; + var bb = blob.getBlob(); + let reader = new FileReader(); + reader.readAsText(bb); + reader.onload = () => { + let result = reader.result; + if (IsJsonParse(result)) { + let out = JSON.parse(result); + if (debug) console.log("✔", "chartJson parced", out); + //дергаем функцию из класса + } + }; + this.blob.clear(); + } + } + + //сборщик данных + append(data) { + if (this.flag) this.blob.append(data); + } + } + + // Использование: + //let chartJson = new blobToJson(); + //user.sayHi(); + //****************************************************web sockets section******************************************************/ function connectToAllDevices() { //closeAllConnection(); @@ -452,6 +495,7 @@ itemsJsonBlob.clear(); } } + //прием от всех учтройств //сборщик layoutJson пакетов if (data === "/st/layout.json") { layoutReceivingCompleted = false; @@ -520,9 +564,9 @@ if (widgetsJsonFlag) widgetsJsonBlob.append(event.data); if (itemsJsonFlag) itemsJsonBlob.append(event.data); if (scenarioJsonFlag) scenarioTxtBlob.append(event.data); - if (chartJsonFlag) chartJsonBlob.append(event.data); } //принимаем данные от всех устройств + if (chartJsonFlag) chartJsonBlob.append(event.data); if (!layoutJsonArray[ws]) layoutJsonArray[ws] = new MyBlobBuilder(); layoutJsonArray[ws].append(event.data); }