From 3cddebe08a84cd50cd38b13a2d2d195ecc311d45 Mon Sep 17 00:00:00 2001 From: Georgy Khatuncev Date: Tue, 18 May 2021 10:19:03 +0500 Subject: [PATCH] Release 0.9 --- Diagram-Canvas/index.html | 6 ++++++ Diagram-Canvas/index.js | 41 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Diagram-Canvas/index.html b/Diagram-Canvas/index.html index 6c20b41..e182ae6 100644 --- a/Diagram-Canvas/index.html +++ b/Diagram-Canvas/index.html @@ -54,6 +54,12 @@ + diff --git a/Diagram-Canvas/index.js b/Diagram-Canvas/index.js index 541ee90..e867f16 100644 --- a/Diagram-Canvas/index.js +++ b/Diagram-Canvas/index.js @@ -87,7 +87,7 @@ PrintCycle(); //Update Status \/ \/ \/ function UpdateStatus() { var xhr = new XMLHttpRequest(); - xhr.open('POST', 'https://test1.mbucb.ru/api/currcycles', true); + xhr.open('POST', 'api/currcycles', true); xhr.send(); xhr.onreadystatechange = function () { if (xhr.readyState != 4) return; @@ -101,7 +101,7 @@ function UpdateStatus() { $("#Error_Border").hide(); var data = JSON.parse(xhr.responseText); if (data.currTime === undefined) { - htmlErrMSG.innerHTML = "Ошибка в полученных данных"; + htmlErrMSG.innerHTML = "Ошибка в полученных данных: отсутствует время сервера"; $("#Error_Border").show(); $("#Update_Button").show(); return; @@ -109,6 +109,41 @@ function UpdateStatus() { updateDateSynch(new Date()); updateDateServer(new Date(data.currTime)); + if (data.data === undefined || !Array.isArray(data.data)) { + htmlErrMSG.innerHTML = "Ошибка в полученных данных: отстутствует массив днных"; + $("#Error_Border").show(); + $("#Update_Button").show(); + return; + } + + var p = data.data; + for (var i = 0; i < p.length; i++) { + var idx = p[i].vdp - 1; + var s = -1; + var b = -1; + switch (p[i].cycle) { + case 0: s = 0; b = -1; break; + case 1: s = 0; b = 1; break; + case 2: s = 1; b = 0; break; + case 5: s = 2; b = 0; break; + case 6: s = 3; b = 0; break; + case 7: s = 4; b = 0; break; + case 8: s = 5; b = 3; break; + case 9: s = 6; b = 3; break; + case 10: s = 7; b = 3; break; + case 11: s = 8; b = 3; break; + case 12: s = 9; b = 3; break; + case 14: s = 1; b = 1; break; + case 15: s = 2; b = 1; break; + case 16: s = 3; b = 1; break; + default: s = -1; b = -1; + } + diagram.ChangeStatProc(idx, s, 0); + diagram.ChangeStatBlink(idx, b); + diagram.StartDate(idx, new Date(p[i].factStart)); + diagram.EndDate(idx, new Date(p[i].thinkEnd)); + } + diagram.Cycle(true); /* ctx.clearRect(0, 0, canvas.width, canvas.height); @@ -134,7 +169,7 @@ function UpdateStatus() { else $("#Error_Border").hide(); */ - diagram.Print(); + diagram.Print(ctx); setTimeout(UpdateStatus, 60 * 1000); } }