a[n]&&(t=s[n],s[n]=a[n],a[n]=t)}}
\ No newline at end of file
+function Rectangle(n, i, e, r) { function o(t) { t = parseFloat(t); return isNaN(t) || t < 0 ? 0 : t } this.X = function (t) { if (void 0 === t) return n; n = o(t) }, this.Y = function (t) { if (void 0 === t) return i; i = o(t) }, this.W = function (t) { if (void 0 === t) return e; e = o(t) }, this.H = function (t) { if (void 0 === t) return r; r = o(t) }, this.RectParam = function (t, n, i, e) { this.X(t), this.Y(n), this.W(i), this.H(e) }, this.Rect = function (t) { if (void 0 === t) return this; this.RectParam(t.X(), t.Y(), t.W(), t.H()) }, void 0 === n ? n = 0 : this.X(n), void 0 === i ? i = 0 : this.Y(i), void 0 === e ? e = 0 : this.W(e), void 0 === r ? r = 0 : this.H(r) } function PercentColumn(t, n, i, e) { var r = new Rectangle(t, n, i, e), o = new Rectangle, s = !1, a = 0, l = "#000"; this.X = function (t) { if (void 0 === t) return r.X(); r.X(t) }, this.Y = function (t) { if (void 0 === t) return r.Y(); r.Y(t) }, this.W = function (t) { if (void 0 === t) return r.W(); r.W(t) }, this.H = function (t) { if (void 0 === t) return r.H(); r.H(t) }, this.Percent = function (t) { if (void 0 === t) return a; t = parseFloat(t), t = isNaN(t) || t < 0 ? 0 : 100 < t ? 100 : t; a = t }, this.Color = function (t) { if (void 0 === t) return l; t = t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i); l = null === t ? "#000000" : t[0] }, this.RectParam = function (t, n, i, e) { r.RectParam(t, n, i, e) }, this.Rect = function (t) { if (void 0 === t) return r; r.Rect(t) }, this.Rotate = function (t) { if (void 0 === t) return s; s = "boolean" == typeof t && t }, this.Print = function (t) { var n; n = (s ? r.W() : r.H()) * a / 100, o.RectParam(r.X(), s ? r.Y() : r.Y() + r.H() - n, s ? n : r.W(), s ? r.H() : n), t.fillStyle = l, t.strokeStyle = l, t.fillRect(o.X(), o.Y(), o.W(), o.H()), t.strokeRect(r.X(), r.Y(), r.W(), r.H()) }, this.PrintText = function (t) { t.save(), t.translate(r.X() + r.W() / 2, r.Y() + r.H() / 2), s || t.rotate(3 * Math.PI / 2), t.fillStyle = "#888", t.textAlign = "center", t.textBaseline = "middle", t.font = s ? (r.H() - 10 < 0 ? 0 : r.H() - 10) + "px Arial" : (r.W() - 10 < 0 ? 0 : r.W() - 10) + "px Arial", t.fillText(Math.floor(100 * a) / 100 + "%", 0, 0), t.restore() } } function ProcessColumn(t, n, i, e) { var s = new Rectangle(t, n, i, e), a = [], l = [], r = 0, o = -1, f = !1; function u(t, n) { var i = parseInt(t), n = parseFloat(n); if (!isNaN(i)) { for (; i >= l.length;)l.push(1); l[i] = isNaN(n) || n <= 0 ? 1 : n } } function c() { for (var t = 0, n = 0; n < l.length; n++)t += l[n]; return t } function h() { var t = (t = (f ? s.W() : s.H()) - (1 + a.length)) < 0 ? 0 : t; return c() <= 0 ? 0 : t / c() } function d() { for (var t = 0; t < a.length; t++)a[t].Percent(t < o ? 100 : t == o ? r : 0) } function p() { for (var t = s.X() + 1, n = s.Y() + 1, i = 0; i < a.length; i++) { var e = f ? i : a.length - (i + 1), r = f ? l[e] * h() : s.W() - 2, o = f ? s.H() - 2 : l[e] * h(); a[e].RectParam(t, n, r, o), t = f ? t + 1 + r : t, n = f ? n : n + 1 + o } } this.X = function (t) { if (void 0 === t) return s().X(); s().X(t) }, this.Y = function (t) { if (void 0 === t) return s().Y(); s().Y(t) }, this.W = function (t) { if (void 0 === t) return s().W(); s().W(t) }, this.H = function (t) { if (void 0 === t) return s().H(); s().H(t) }, this.Percent = function (t) { if (void 0 === t) return r; t = parseFloat(t); r = isNaN(t) || t < 0 ? 0 : 100 < t ? 100 : t }, this.Status = function (t) { if (void 0 === t) return o; t = parseInt(t); o = isNaN(t) || t < -1 || 0 === a.length ? -1 : t >= a.length ? a.length - 1 : t }, this.RectParam = function (t, n, i, e) { s.RectParam(t, n, i, e) }, this.Rect = function (t) { if (void 0 === t) return s; s.Rect(t) }, this.Rotate = function (t) { if (void 0 === t) return f; f = "boolean" == typeof t && t; for (var n = 0; n < a.length; n++)a[n].Rotate(f) }, this.StatCount = function () { return a.length }, this.AddRStat = function (t, n, i) { t = parseInt(t); isNaN(t) || t < 0 || t - 1 > a.length ? (a.push(new PercentColumn), t = a.length - 1) : a.splice(t, 0, new PercentColumn), a[t].Color(i), u(t, n) }, this.ChangeRStat = function (t, n, i) { t = parseInt(t); !isNaN(t) && 0 <= t && t < a.length && (a[t].Color(i), u(t, n)) }, this.DelRStat = function (t) { t = parseInt(t); !isNaN(t) && 0 <= t && t < a.length ? (a.splice(t, 1), l.splice(t, 1)) : 0 < a.length && (a.pop(), l.pop()) }, this.BuildDefault = function () { for (var t = [57, 49, 49, 71, 28, 49, 21, 171, 114, 103], n = ["#0ff", "#00f", "#f00", "#0f0", "#0ff", "#00f", "#8500b6", "#f00", "#f0f", "#0f0"]; 0 < a.length;)this.DelRStat(); for (var i = 0; i < t.length; i++)this.AddRStat(i, t[i], n[i]) }, this.Print = function (t) { this.Rotate(f), d(), p(), t.clearRect(s.X(), s.Y(), s.W(), s.H()), t.fillStyle = "#ddd", t.fillRect(s.X(), s.Y(), s.W(), s.H()); for (var n = 0; n < a.length; n++)n <= o && a[n].Print(t); t.strokeStyle = "#000", t.strokeRect(s.X(), s.Y(), s.W(), s.H()) }, this.PrintText = function (t) { this.Rotate(f), d(), p(), t.save(), t.translate(s.X() + s.W() / 2, s.Y() + s.H() / 2), f || t.rotate(3 * Math.PI / 2), t.fillStyle = "#888", t.textAlign = "center", t.textBaseline = "middle", t.font = f ? (s.H() - 10 < 0 ? 0 : s.H() - 10) + "px Arial" : (s.W() - 10 < 0 ? 0 : s.W() - 10) + "px Arial", t.fillText(Math.floor(100 * r) / 100 + "% " + (o + 1) + "/" + a.length, 0, 0), t.restore() } } function BlinkStatus(t, n, i, e) { var r = new Rectangle(t, n, i, e), o = [], s = 0, a = !1; this.X = function (t) { if (void 0 === t) return r().X(); r().X(t) }, this.Y = function (t) { if (void 0 === t) return r().Y(); r().Y(t) }, this.W = function (t) { if (void 0 === t) return r().W(); r().W(t) }, this.H = function (t) { if (void 0 === t) return r().H(); r().H(t) }, this.Status = function (t) { if (void 0 === t) return s; t = parseInt(t); s = isNaN(t) || t < -1 ? -1 : t >= o.length ? o.length - 1 : t }, this.StatCount = function () { return o.length }, this.RectParam = function (t, n, i, e) { r.RectParam(t, n, i, e) }, this.Rect = function (t) { if (void 0 === t) return r; r.Rect(t) }, this.Rotate = function (t) { if (void 0 === t) return a; a = "boolean" == typeof t && t }, this.AddStatus = function (t, n) { void 0 === n && (n = "#000"); n = null === (n = n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)) ? "#000000" : n[0], t = parseInt(t); isNaN(t) || t < 0 || t > o.length - 1 ? o.push(n) : o.splice(t, 0, n) }, this.ChangeStatus = function (t, n) { void 0 === n && (n = "#000"); n = null === (n = n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)) ? "#000000" : n[0], t = parseInt(t); !isNaN(t) && 0 <= t && t < o.length && o.splice(t, 1, n) }, this.DelStatus = function (t) { t = parseInt(t); !isNaN(t) && 0 <= t && t < o.length ? o.splice(t, 1) : 0 < o.length && o.pop() }, this.BuildDefault = function () { for (var t = ["#00f", "#f00", "#0f0"], n = 0; n < t.length; n++)this.AddStatus(0, t[n]) }, this.Print = function (t) { t.fillStyle = 0 <= s && s < o.length ? o[s] : "#ddd", t.fillRect(r.X(), r.Y(), r.W(), r.H()), t.strokeStyle = "#000", t.strokeRect(r.X(), r.Y(), r.W(), r.H()) }, this.PrintText = function (t) { t.save(), t.translate(r.X() + r.W() / 2, r.Y() + r.H() / 2), a && t.rotate(3 * Math.PI / 2), t.fillStyle = "#888", t.textAlign = "center", t.textBaseline = "middle", t.font = a ? (r.W() - 2 < 0 ? 0 : r.W() - 2) + "px Arial" : (r.H() - 2 < 0 ? 0 : r.H() - 2) + "px Arial", t.fillText(s + 1 + "/" + o.length, 0, 0), t.restore() } } function NumberColumn(t, n, i, e, r) { var o = new Rectangle(t, n, i, e), s = !0, a = !1; this.X = function (t) { if (void 0 === t) return o().X(); o().X(t) }, this.Y = function (t) { if (void 0 === t) return o().Y(); o().Y(t) }, this.W = function (t) { if (void 0 === t) return o().W(); o().W(t) }, this.H = function (t) { if (void 0 === t) return o().H(); o().H(t) }, this.RectParam = function (t, n, i, e) { o.RectParam(t, n, i, e) }, this.Rect = function (t) { if (void 0 === t) return o; o.Rect(t) }, this.Number = function (t) { if (void 0 === t) return r; t = parseInt(t); r = isNaN(t) || t < 0 ? 0 : t }, this.Number(r), this.Prostoy = function (t) { if (void 0 === t) return s; s = "boolean" == typeof t && t }, this.Rotate = function (t) { if (void 0 === t) return a; a = "boolean" == typeof t && t }, this.Print = function (t) { t.fillStyle = s ? "#ff8000" : "#ff0", t.fillRect(o.X(), o.Y(), o.W(), o.H()), t.strokeStyle = "#000", t.strokeRect(o.X(), o.Y(), o.W(), o.H()), t.save(), t.translate(o.X() + o.W() / 2, o.Y() + o.H() / 2), a && t.rotate(3 * Math.PI / 2), t.fillStyle = "#000", t.textAlign = "center", t.textBaseline = "middle"; var n = (n = o.H() < o.W() ? o.H() - 3 : o.W() - 3) < 0 ? 0 : n; t.font = n + "px Arial", t.fillText(r, 0, 0), t.restore() } } function Diagram(t, n, i, e) { var o = 1e3, H = new Rectangle(t, n, i, e), P = [], W = [], N = [], s = [], a = [], l = !1, f = -1, m = !1; function u(t) { for (var n, i = null == t ? new Date : t, e = !1, r = 0; r < P.length; r++)s[r] != a[r] && (n = a[r] - s[r], s[r], n = 100 * (i - s[r]) / n, P[r].Percent(n), N[r].Prostoy(100 <= n), e = e || n < 100); l = l && e, i.setMilliseconds(i.getMilliseconds() + o), l && (f = null == t ? setTimeout(u, o) : setTimeout(u, o, i)) } this.minBoardW = function () { return (stW + 1) * (P.length + 1) + 5 * P.length }, this.minBoardH = function () { return 4 * (stH + 1) + szHP + szHB + szHN }, this.X = function (t) { if (void 0 === t) return H().X(); H().X(t) }, this.Y = function (t) { if (void 0 === t) return H().Y(); H().Y(t) }, this.W = function (t) { if (void 0 === t) return H().W(); H().W(t) }, this.H = function (t) { if (void 0 === t) return H().H(); H().H(t) }, this.RectParam = function (t, n, i, e) { H.RectParam(t, n, i, e) }, this.Rect = function (t) { if (void 0 === t) return H; H.Rect(t) }, this.ProcCount = function () { return P.length }, this.AddProc = function (t, n, i, e) { var r = parseInt(t), r = isNaN(r) || r < 0 || r >= P.length ? -1 : r, t = new Date; -1 == r ? (P.push(n), W.push(i), N.push(e), s.push(t), a.push(t)) : (P.splice(r, 0, n), W.splice(r, 0, i), N.splice(r, 0, e), s.splice(r, 0, t), a.splice(r, 0, t)) }, this.ChangeProc = function (t, n, i, e) { var r = parseInt(t), r = isNaN(r) || r < 0 || r >= P.length ? -1 : r, t = new Date; -1 != r && (P.splice(r, 1, n), W.splice(r, 1, i), N.splice(r, 1, e), s.splice(r, 1, t), a.splice(r, 1, t)) }, this.DelStove = function (t) { 0 != P.length && (t = parseInt(t), -1 == (t = isNaN(t) || t < 0 || t >= P.length ? -1 : t) ? (P.pop(), W.pop(), N.pop(), s.pop(), a.pop()) : (P.splice(t, 1), W.splice(t, 1), N.splice(t, 1), s.splice(t, 1), a.splice(t, 1))) }, this.StartDate = function (t, n) { t = parseInt(t); -1 != (t = isNaN(t) || t < 0 || t >= s.length ? -1 : t) && (s[t] = n) }, this.EndDate = function (t, n) { t = parseInt(t); -1 != (t = isNaN(t) || t < 0 || t >= s.length ? -1 : t) && (a[t] = n) }, this.ChangeStatProc = function (t, n, i) { t = parseInt(t); !isNaN(t) && 0 <= t && t < P.length && (P[t].Status(n), P[t].Percent(i)) }, this.ChangeStatBlink = function (t, n) { t = parseInt(t); !isNaN(t) && -1 <= t && t < W.length && W[t].Status(n) }, this.ChangeStatNumb = function (t, n) { t = parseInt(t); !isNaN(t) && 0 <= t && t < N.length && N[t].Prostoy(n) }, this.Rotate = function (t) { if (void 0 === t) return m; m = "boolean" == typeof t && t; for (var n = 0; n < P.length; n++)P[n].Rotate(m), N[n].Rotate(m), W[n].Rotate(m) }, this.BuildDefault = function () { for (; P.length < 48;) { P.push(new ProcessColumn(0, 0, 0, 0)), P[P.length - 1].BuildDefault(), W.push(new BlinkStatus(0, 0, 0, 0)), W[P.length - 1].BuildDefault(), N.push(new NumberColumn(0, 0, 0, 0, P.length)); var t = new Date; s.push(t), a.push(t) } }, this.Rebuild = function () { for (var t = H.X() + 2 + 1, n = H.Y() + 2 + 1, i = H.W() - 3 * (P.length + 1), e = H.H() - 3 * (P.length + 1), r = 0; r < P.length; r++) { var o, s = 0, a = 0, l = 0, f = 0, u = 0, c = 0, h = 0, d = 0, p = 0, v = 0, g = 0, R = 0; m ? (c = u = f = n, e -= o = (o = Math.ceil(e / (P.length - r))) < 4 ? 4 : o, R = g = v = o, d = 10, p = 17, l = (a = (s = t) + (h = (h = H.W() - 12 - 10 - 17) < 40 ? 40 : h) + 3) + 10 + 3, s = (a = (l = t) + p + 3) + 10 + 3) : (l = a = s = t, i -= o = (o = Math.ceil(i / (P.length - r))) < 4 ? 4 : o, p = d = h = o, g = 10, R = 17, c = (u = (f = n) + (v = (v = H.H() - 12 - 10 - 17) < 40 ? 40 : v) + 3) + 10 + 3), P[r].RectParam(s, f, h, v), W[r].RectParam(a, u, d, g), N[r].RectParam(l, c, p, R), m ? n += v + 2 + 1 : t += h + 2 + 1 } }, this.Print = function (t) { u(), this.Rotate(m), this.Rebuild(), t.clearRect(H.X(), H.Y(), H.W(), H.H()), t.fillStyle = "#ddd", t.fillRect(H.X(), H.Y(), H.W(), H.H()); for (var n = 0; n < P.length; n++)P[n].Print(t), W[n].Print(t), N[n].Print(t); t.strokeStyle = "#333", t.strokeRect(H.X(), H.Y(), H.W(), H.H()) }, this.PrintText = function (t) { for (var n = 0; n < P.length; n++)P[n].PrintText(t), W[n].PrintText(t) }, this.Cycle = function (t, n) { if (null == t || "boolean" != typeof t) return l; t && (this.CheckDate(), clearTimeout(f), l = !0, u(n)) }, this.CheckDate = function () { for (var t, n = 0; n < P.length; n++)s[n] > a[n] && (t = s[n], s[n] = a[n], a[n] = t) } }
\ No newline at end of file
diff --git a/Diagram-Canvas/DiagramStoveDll/NumberColumn.js b/Diagram-Canvas/DiagramStoveDll/NumberColumn.js
index 0c848d3..8f71564 100644
--- a/Diagram-Canvas/DiagramStoveDll/NumberColumn.js
+++ b/Diagram-Canvas/DiagramStoveDll/NumberColumn.js
@@ -2,7 +2,7 @@
//Основной прямоугольник
var rAll = new Rectangle(x, y, w, h);
//Текущий статус по простою
- var prostoy = false;
+ var prostoy = true;
/*Проценты поднимаются снизу вверх (false)
*или слева направо (true)*/
var rotate = false;
diff --git a/Diagram-Canvas/DiagramStoveDll/ProcessColumn.js b/Diagram-Canvas/DiagramStoveDll/ProcessColumn.js
index e30a118..601492e 100644
--- a/Diagram-Canvas/DiagramStoveDll/ProcessColumn.js
+++ b/Diagram-Canvas/DiagramStoveDll/ProcessColumn.js
@@ -8,7 +8,7 @@
//Проценты статуса
var percent = 0;
//Номер статуса
- var status = 0;
+ var status = -1;
/*Проценты поднимаются снизу вверх (false)
*или слева направо (true)*/
var rotate = false;
@@ -41,7 +41,7 @@
this.Status = function (val) {
if (val === undefined) return status;
var v = parseInt(val);
- status = (isNaN(v) || v < 0 || rStat.length === 0) ? 0 :
+ status = (isNaN(v) || v < -1 || rStat.length === 0) ? -1 :
(v >= rStat.length) ? (rStat.length - 1) : v;
};
//Функция изменения начальной координаты и размеров прямоугольника
@@ -110,7 +110,7 @@
this.BuildDefault = function () {
var defaultPoint = [57, 49, 49, 71, 28, 49, 21, 171, 114, 103];
var defaultColor = ["#0ff", "#00f", "#f00", "#0f0", "#0ff", "#00f", "#8500b6", "#f00", "#f0f", "#0f0"];
- while(rStat.length > 0)
+ while (rStat.length > 0)
this.DelRStat();
for (var i = 0; i < defaultPoint.length; i++)
this.AddRStat(i, defaultPoint[i], defaultColor[i]);
diff --git a/Diagram-Canvas/Test.js b/Diagram-Canvas/Test.js
index 5c89f5c..6277942 100644
--- a/Diagram-Canvas/Test.js
+++ b/Diagram-Canvas/Test.js
@@ -81,7 +81,7 @@ but2.onclick = function () {
else
for (var k = 0; k < count; k++)
t.AddRStat(k, arrPoint[k], arrColor[k]);
- t.Status(Math.floor(Math.random() * t.StatCount()));
+ t.Status(Math.floor(Math.random() * (t.StatCount() + 1) - 1));
t.Percent(Math.random() * 101);
t.Print(ctx);
if (chkText.checked)
diff --git a/Diagram-Canvas/index.html b/Diagram-Canvas/index.html
index c265233..6c20b41 100644
--- a/Diagram-Canvas/index.html
+++ b/Diagram-Canvas/index.html
@@ -19,7 +19,7 @@
Время клиента: 2018.02.27 08:41:24
- Время сервер:
+ Время сервера:
Время синхр.:
diff --git a/Diagram-Canvas/index.js b/Diagram-Canvas/index.js
index 3a03b77..541ee90 100644
--- a/Diagram-Canvas/index.js
+++ b/Diagram-Canvas/index.js
@@ -3,123 +3,166 @@ var htmlDateClient = document.getElementById("DateClient");
var htmlDateServer = document.getElementById("DateServer");
var htmlDateSynch = document.getElementById("DateSynch");
+var htmlErrMSG = document.getElementById("Error_Message");
+
var canvas = document.getElementsByTagName("canvas")[0];
var ctx = canvas.getContext("2d");
var diagram = new Diagram(0, 0, canvas.width, canvas.height);
+diagram.BuildDefault();
+diagram.Cycle(true);
var update_button = document.getElementById("Update_Button");
//Global Params
-//Start Show Date Now
+//Show Date Now \/ \/ \/
function FNL(a, b) { for (var d = "" + a; d.length < b;)d = "0" + d; return d }
function DateToString(date) { return date.getFullYear() + "." + FNL(date.getMonth() + 1, 2) + "." + FNL(date.getDate(), 2) + " " + FNL(date.getHours(), 2) + ":" + FNL(date.getMinutes(), 2) + ":" + FNL(date.getSeconds(), 2); }
-
var dateClient = null;
var dateServer = null;
+var dateSynch = null;
function PrintDateNow() {
- var tmp = new Date();
- htmlDateClient.innerHTML = DateToString(tmp);
- if (dateServer !== null)
- if (dateClient !== null)
- tmp =
-
- htmlDateServer.innerHTML = timeNow;
- htmlDateSynch.innerHTML = timeNow;
+ var dn = new Date();
+ if (dateServer !== null && dateClient !== null)
+ dateServer.setMilliseconds(dateServer.getMilliseconds() + (dn - dateClient));
+ dateClient = dn;
+ htmlDateClient.innerHTML = DateToString(dateClient);
+ if (dateServer != null)
+ htmlDateServer.innerHTML = DateToString(dateServer);
+ if (dateSynch !== null)
+ htmlDateSynch.innerHTML = DateToString(dateSynch);
setTimeout(PrintDateNow, 1000);
}
-
+function updateDateServer(date) {
+ if (typeof date.getMonth === 'function') {
+ dateClient = null;
+ dateServer = date;
+ } else
+ dateServer = null;
+}
+function updateDateSynch(date) {
+ if (typeof date.getMonth === 'function') {
+ dateSynch = date;
+ } else
+ dateSynch = null;
+}
PrintDateNow();
-/*
-//End Show Date Now
+//Show Date Now /\ /\ /\
-//Start Resize Canvas
+//Resize Canvas \/ \/ \/
function Resize() {
- if (window.innerWidth > window.innerHeight) {
- canvas.height = window.innerHeight - 20
- - document.getElementById("First_Head").offsetHeight
- - document.getElementById("Second_Head").offsetHeight
- - document.getElementById("Third_Head").offsetHeight;
- canvas.width = document.getElementById("Canvas_Body").offsetWidth;
- diagramStove.Rotate = 0;
- diagramStove.RectParam(0, 0, canvas.width, canvas.height);
- }
- else {
- canvas.height = diagramStove.ProcessCount() * 25;
- canvas.width = document.getElementById("Canvas_Body").offsetWidth;
- diagramStove.Rotate = 1;
- diagramStove.RectParam(0, 0, canvas.height, canvas.width);
- }
- ctx = canvas.getContext("2d");
- diagramStove.Print(ctx);
+ if (window.innerWidth > window.innerHeight) {
+ canvas.height =
+ window.innerHeight - 20
+ - document.getElementById("First_Head").offsetHeight
+ - document.getElementById("Second_Head").offsetHeight
+ - document.getElementById("Third_Head").offsetHeight;
+ canvas.width = document.getElementById("Canvas_Body").offsetWidth;
+ diagram.Rotate(false);
+ diagram.RectParam(0.5, 0.5, canvas.width - 1, canvas.height - 1);
+ }
+ else {
+ canvas.height = diagram.ProcCount() * 25;
+ canvas.width = document.getElementById("Canvas_Body").offsetWidth;
+ diagram.Rotate(true);
+ diagram.RectParam(0.5, 0.5, canvas.width - 1, canvas.height - 1);
+ }
+ ctx = canvas.getContext("2d");
+ diagram.Print(ctx);
}
window.addEventListener("load", Resize, false);
window.addEventListener("resize", Resize, false);
-//End Resize Canvas
+//Resize Canvas /\ /\ /\
-//Start Update Status
-diagramStove.BuildDefault();
+//Autoprint diagram \/ \/ \/
+function PrintCycle() {
+ diagram.Print(ctx);
+ setTimeout(PrintCycle, 1000);
+}
+PrintCycle();
+//Autoprint diagram /\ /\ /\
+
+//Update Status \/ \/ \/
function UpdateStatus() {
- var xhr = new XMLHttpRequest();
- xhr.open('POST', 'getinfo', true);
- xhr.send();
- xhr.onreadystatechange = function () {
- if (xhr.readyState != 4) return;
- if (xhr.status != 200) {
- document.getElementById("Error_Message").innerHTML = "Не удается установить соединение";
- $("#Error_Border").show();
- $("#Update_Button").show();
- return;
- }
- else
- $("#Error_Border").hide();
- var Pech = JSON.parse(xhr.responseText);
- ctx.clearRect(0, 0, canvas.width, canvas.height);
- for (var i = 1; i <= diagramStove.ProcessCount(); i++) {
- diagramStove.ChangeStatBlink(i, Pech[i].Bstatus);
- diagramStove.ChangeStatProc(i, Pech[i].Pstatus);
- diagramStove.ChangeStartDate(i, ConvDate(Pech[i].Start));
- diagramStove.ChangeEndDate(i, ConvDate(Pech[i].EndTeor));
- }
- var b = ConvDate(Pech[0].DateNow);
- dateUpdateHTML.innerHTML =
- b.getFullYear() + "." +
- FNL(b.getMonth() + 1, 2) + "." +
- FNL(b.getDate(), 2) + " " +
- FNL(b.getHours(), 2) + ":" +
- FNL(b.getMinutes(), 2) + ":" +
- FNL(b.getSeconds(), 2);
- if (Math.abs(b - new Date()) > 60000) {
- document.getElementById("Error_Message").innerHTML = "Разница между системным и серверным временем " + Math.floor(Math.abs(b - new Date()) / 1000) + " сек";
- $("#Error_Border").show();
- $("#Update_Button").hide();
- }
- else
- $("#Error_Border").hide();
- setTimeout(UpdateStatus, 60000);
- diagramStove.Print(ctx);
+ var xhr = new XMLHttpRequest();
+ xhr.open('POST', 'https://test1.mbucb.ru/api/currcycles', true);
+ xhr.send();
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState != 4) return;
+ if (xhr.status != 200) {
+ htmlErrMSG.innerHTML = "Не удается установить соединение";
+ $("#Error_Border").show();
+ $("#Update_Button").show();
+ return;
}
+ else
+ $("#Error_Border").hide();
+ var data = JSON.parse(xhr.responseText);
+ if (data.currTime === undefined) {
+ htmlErrMSG.innerHTML = "Ошибка в полученных данных";
+ $("#Error_Border").show();
+ $("#Update_Button").show();
+ return;
+ }
+ updateDateSynch(new Date());
+ updateDateServer(new Date(data.currTime));
+
+
+ /*
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ for (var i = 1; i <= diagramStove.ProcessCount(); i++) {
+ diagramStove.ChangeStatBlink(i, Pech[i].Bstatus);
+ diagramStove.ChangeStatProc(i, Pech[i].Pstatus);
+ diagramStove.ChangeStartDate(i, ConvDate(Pech[i].Start));
+ diagramStove.ChangeEndDate(i, ConvDate(Pech[i].EndTeor));
+ }
+ var b = ConvDate(Pech[0].DateNow);
+ dateUpdateHTML.innerHTML =
+ b.getFullYear() + "." +
+ FNL(b.getMonth() + 1, 2) + "." +
+ FNL(b.getDate(), 2) + " " +
+ FNL(b.getHours(), 2) + ":" +
+ FNL(b.getMinutes(), 2) + ":" +
+ FNL(b.getSeconds(), 2);
+ if (Math.abs(b - new Date()) > 60000) {
+ document.getElementById("Error_Message").innerHTML = "Разница между системным и серверным временем " + Math.floor(Math.abs(b - new Date()) / 1000) + " сек";
+ $("#Error_Border").show();
+ $("#Update_Button").hide();
+ }
+ else
+ $("#Error_Border").hide();
+ */
+ diagram.Print();
+ setTimeout(UpdateStatus, 60 * 1000);
+ }
}
UpdateStatus();
-function PrintCycle() {
- diagramStove.Print(ctx);
- setTimeout(PrintCycle, 1000);
-}
-PrintCycle();
-
function ConvDate(a) {
- a = a.split(".")[0].split("T");
- var d = a[0].split("-");
- var h = a[1].split(":");
- var date = new Date(d[0], parseInt(d[1]) - 1, d[2], h[0], h[1], h[2]);
- return date;
+ a = a.split(".")[0].split("T");
+ var d = a[0].split("-");
+ var h = a[1].split(":");
+ var date = new Date(d[0], parseInt(d[1]) - 1, d[2], h[0], h[1], h[2]);
+ return date;
}
update_button.onclick = function () {
- UpdateStatus();
+ UpdateStatus();
}
+//Update Status /\ /\ /\
+
+
//End Update Status
+
+
+
+
+/*
+//End Show Date Now
+
+
+
+
*/
\ No newline at end of file