Commit 87910e91 authored by Christoffer Ackelman's avatar Christoffer Ackelman

== and != should never be used in JavaScript, use === and !== instead.

parent 5d22cf54
......@@ -6,7 +6,7 @@ function PwrtStatus(sts) {
this.sts = sts;
this.evenSts = function () { return (sts % 2 === 0); };
this.oddSts = function () { return (sts % 2 == 1); };
this.oddSts = function () { return (sts % 2 === 1); };
this.getSts = function () { return sts; };
}
......@@ -363,7 +363,7 @@ function Gdh() {
};
this.ws.onmessage = function (e) {
if (typeof e.data == "string") {
if (typeof e.data === "string") {
console.log("String message received", e, e.data);
} else {
if (e.data instanceof ArrayBuffer) {
......@@ -459,7 +459,7 @@ function Gdh() {
var esize = dv.getUint32(j);
j += 4;
var sub = this.gdh.sub[eid];
if (typeof sub == 'undefined') {
if (typeof sub === 'undefined') {
j += esize;
console.log("sub undefined");
} else {
......@@ -474,7 +474,7 @@ function Gdh() {
value = dv.getFloat32(j);
j += 4;
} else {
if (esize != sub.elements * 4)
if (esize !== sub.elements * 4)
console.log("Subscription size error", esize, sub.elements, eid);
value = new Array(sub.elements);
for (var k = 0; k < sub.elements; k++) {
......@@ -513,7 +513,7 @@ function Gdh() {
this.gdh.sub[eid].value = value;
}
}
if (typeof this.gdh.pending[id] == 'undefined') {
if (typeof this.gdh.pending[id] === 'undefined') {
console.log("** GetObjectRefInfoAll received removed", id);
break;
}
......@@ -888,10 +888,9 @@ function Gdh() {
if (!this.listSent) {
return sub.refid;
} else {
var size = 0;
var len = 0;
size = 12 + sub.name.length;
var size = 12 + sub.name.length;
var buf = new Uint8Array(size + 10);
buf[0] = Msg.REF_OBJECT_INFO;
......@@ -931,10 +930,9 @@ function Gdh() {
if (this.debug) console.log("refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function (refid) {
var size = 0;
var len = 0;
size = 4;
var size = 4;
var buf = new Uint8Array(size + 10);
buf[0] = Msg.UNREF_OBJECT_INFO;
......@@ -1499,7 +1497,7 @@ var Flow = {
eSave_Arrow_p1: 1405,
eSave_Arrow_p2: 1406,
eSave_Triangle_rect_part: 2000
}
};
function GDraw(ctx) {
this.ctx = ctx;
......@@ -1511,7 +1509,7 @@ function GDraw(ctx) {
this.rect = function (x, y, width, height) {
this.gctx.strokeRect(x, y, width, height);
}
};
this.line = function (x1, y1, x2, y2) {
this.gctx.beginPath();
this.gctx.moveTo(x1, y1);
......@@ -1526,13 +1524,13 @@ function FlowArray(ctx) {
this.add = function (elem) {
this.a.push(elem);
}
};
this.size = function () {
return this.a.length;
}
};
this.get = function (idx) {
return this.a[idx];
}
};
this.open = function (lines, row) {
var end = false;
var i;
......@@ -1626,14 +1624,14 @@ function FlowArray(ctx) {
this.draw = function (g, p, node, highlight) {
for (var i = 0; i < this.a.length; i++)
this.a[i].draw(g, p, node, highlight);
}
};
this.search_by_name = function (name) {
var uname = name.toUpperCase();
for (var i = 0; i < this.a.length; i++) {
if (this.a[i] instanceof FlowNode) {
console.log("Search", this.a[i].n_name, name);
if (this.a[i].n_name.toUpperCase() == uname)
if (this.a[i].n_name.toUpperCase() === uname)
return this.a[i];
}
}
......@@ -1649,7 +1647,7 @@ function FlowNodeClass(ctx) {
this.draw = function (g, p, node, highlight) {
this.a.draw(g, p, node, highlight);
}
};
this.open = function (lines, row) {
var end = false;
......@@ -1682,7 +1680,7 @@ function FlowNodeClass(ctx) {
break;
}
return i;
}
};
this.event_handler = function (x, y) {
return 0;
......@@ -1840,7 +1838,7 @@ function FlowLine(ctx) {
g.setLineDash([]);
break;
}
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -1927,9 +1925,9 @@ function FlowRect(ctx) {
break;
}
return i;
}
};
this.draw = function (g, p, node, highlight) {
if ((this.display_level & this.ctx.display_level) == 0)
if ((this.display_level & this.ctx.display_level) === 0)
return;
var x = (this.ll.x + p.x) * this.ctx.zoom_factor;
......@@ -1972,7 +1970,7 @@ function FlowArc(ctx) {
var r = (this.ur.x - this.ll.x) / 2 * this.ctx.zoom_factor;
var x = (this.ll.x + p.x) * this.ctx.zoom_factor + r;
var y = (this.ll.y + p.y) * this.ctx.zoom_factor + r;
if (this.angel1 == 90 || this.angel1 == 270)
if (this.angel1 === 90 || this.angel1 === 270)
var a1 = (this.angel1 + 90) / 180 * Math.PI;
else
var a1 = (this.angel1 - 90) / 180 * Math.PI;
......@@ -1985,10 +1983,10 @@ function FlowArc(ctx) {
if (highlight)
g.strokeStyle = "red";
g.beginPath()
g.beginPath();
g.arc(x, y, r, a1, a2, false);
g.stroke();
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -2065,7 +2063,7 @@ function FlowText(ctx) {
if (highlight)
g.fillStyle = "red";
g.fillText(this.text, x, y);
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -2136,13 +2134,13 @@ function FlowArrow(ctx) {
}
if (highlight)
g.fillStyle = "red";
g.beginPath()
g.beginPath();
g.moveTo(x1, y1);
g.lineTo(x2, y2);
g.lineTo(x3, y3);
g.lineTo(x1, y1);
g.fill();
}
};
this.open = function (lines, row) {
var end = false;
......@@ -2204,10 +2202,10 @@ function FlowTriangle(ctx) {
g.lineWidth = 1;
var dtype = this.prototype.draw_type;
if (dtype == Flow.eDrawType_Inherit && node != null)
if (dtype === Flow.eDrawType_Inherit && node != null)
dtype = node.fill_color;
if (this.prototype.fill == 1) {
if (this.prototype.fill === 1) {
switch (dtype) {
case Flow.eDrawType_LineRed:
g.fillStyle = "red";
......@@ -2237,7 +2235,7 @@ function FlowTriangle(ctx) {
g.lineTo(x1, y2);
g.stroke();
}
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -2273,7 +2271,7 @@ function FlowConPoint(ctx) {
this.ctx = ctx;
this.draw = function (g, p, node, highlight) {
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -2328,7 +2326,7 @@ function FlowAnnot(ctx) {
return;
if (node.annotv[this.number] == null)
return;
if ((this.display_level & this.ctx.display_level) == 0)
if ((this.display_level & this.ctx.display_level) === 0)
return;
var tsize = 0;
......@@ -2367,7 +2365,7 @@ function FlowAnnot(ctx) {
g.fillText(tokens[i], x, y);
y += tsize * 1.4;
}
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -2443,7 +2441,7 @@ function FlowCon(ctx) {
var p = new FlowPoint(ctx);
p.x = 0;
p.y = 0;
if (this.temporary_ref != 0 || this.cc.con_type == Flow.eConType_Reference)
if (this.temporary_ref !== 0 || this.cc.con_type === Flow.eConType_Reference)
this.ref_a.draw(g, p, null, highlight);
else {
this.line_a.draw(g, p, null, highlight);
......@@ -2451,7 +2449,7 @@ function FlowCon(ctx) {
this.arrow_a.draw(g, p, null, highlight);
}
this.redraw = false;
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -2571,9 +2569,9 @@ function FlowCon(ctx) {
break;
}
return i;
}
};
this.connect = function () {
}
};
this.scan = function () {
}
}
......@@ -2605,7 +2603,7 @@ function FlowNode(ctx) {
if (!this.redraw)
return;
if (this.nc.group != Flow.eNodeGroup_Document) {
if (this.nc.group !== Flow.eNodeGroup_Document) {
var x = this.x_left * this.ctx.zoom_factor;
var y = this.y_low * this.ctx.zoom_factor - 1;
var width = (this.x_right - this.x_left) * this.ctx.zoom_factor;
......@@ -2618,7 +2616,7 @@ function FlowNode(ctx) {
this.nc.draw(g, this.pos, this, this.highlight);
this.redraw = false;
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -2701,7 +2699,7 @@ function FlowNode(ctx) {
break;
}
sb.push(c);
if (k == lines[i].length - 1)
if (k === lines[i].length - 1)
sb.push('\n');
}
if (end_found)
......@@ -2743,16 +2741,16 @@ function FlowNode(ctx) {
}
console.log("Node", this.trace_attr_type, this.n_name);
return i;
}
};
this.connect = function () {
if (this.trace_object == "" || this.trace_attribute == "")
if (this.trace_object === "" || this.trace_attribute === "")
return;
if (this.trace_attr_type == Flow.eTraceType_User)
if (this.trace_attr_type === Flow.eTraceType_User)
return;
var n = this.trace_attribute.indexOf('#');
if (n != -1)
if (n !== -1)
this.trace_attribute = this.trace_attribute.substring(0, n);
var o = this.trace_object + "." + this.trace_attribute;
......@@ -2773,26 +2771,23 @@ function FlowNode(ctx) {
this.p = this.ctx.gdh.refObjectInfo(o, pwr_type, 1);
console.log("connecting", o, this.p);
}
};
this.scan = function () {
if (this.p == 0)
if (this.p === 0)
return;
var v1 = this.ctx.gdh.getObjectRefInfo(this.p);
var evaluate = true;
if (this.first_scan)
this.first_scan = false;
else if (v1 == this.old_value)
else if (v1 === this.old_value)
return;
if (v1)
this.highlight = true;
else
this.highlight = false;
this.highlight = !!v1;
this.old_value = v1;
this.redraw = true;
}
};
this.event_handler = function (x, y) {
var zx = x / this.ctx.zoom_factor + ctx.x_left;
......@@ -2811,10 +2806,10 @@ function FlowNode(ctx) {
return 1;
}
return 0;
}
};
this.set_select = function (select) {
if (select != this.select) {
if (select !== this.select) {
this.select = select;
this.redraw = true;
if (this.select)
......@@ -2846,7 +2841,7 @@ function FlowCtx() {
this.draw = function () {
this.a.draw(this.gdraw.gctx, null, null, false);
}
};
this.open = function (lines, row) {
var end = false;
for (var i = row; i < lines.length; i++) {
......@@ -2933,31 +2928,31 @@ function FlowCtx() {
console.log("ctx connect", this.a.size());
for (var i = 0; i < this.a.size(); i++)
this.a.get(i).connect();
}
};
this.scan = function () {
for (var i = 0; i < this.a.size(); i++)
this.a.get(i).scan();
}
};
this.event_handler = function (x, y) {
var sts = 0;
for (var i = 0; i < this.a.size(); i++) {
if (this.a.get(i) instanceof FlowNode) {
sts = this.a.get(i).event_handler(x, y);
if (sts == 1)
if (sts === 1)
break;
}
}
if (sts == 1)
if (sts === 1)
this.draw();
}
};
this.set_select = function (select) {
for (var i = 0; i < this.a.size(); i++) {
if (this.a.get(i) instanceof FlowNode)
this.a.get(i).set_select(select);
}
}
};
this.search_object = function (name) {
console.log("Searching for ", name);
......@@ -2965,7 +2960,7 @@ function FlowCtx() {
if (node != null)
console.log("Found", name);
return node;
}
};
this.center_object = function (o) {
console.log("center_object", o.pos.x * this.zoom_factor + this.offset_x, window.innerWidth, o.pos.x * this.zoom_factor + this.offset_x - window.innerWidth / 2);
console.log("center_object", o.pos.y * this.zoom_factor + this.offset_y, window.innerHeight, o.pos.y * this.zoom_factor + this.offset_y - window.innerHeight / 2);
......@@ -2998,7 +2993,7 @@ function FlowFrame() {
req.read_cb(lines, 0);
});
req.send(null);
}
};
this.read_func = function (lines, row) {
console.log("this.ctx:", self.ctx);
......@@ -3050,7 +3045,7 @@ function FlowFrame() {
o.set_select(true);
}
}
}
};
this.flow_open = function () {
console.log("flow_open");
......@@ -3058,24 +3053,24 @@ function FlowFrame() {
self.ctx.connect();
self.ctx.gdh.refObjectInfoList(self.ctx.gdh.refObjectInfoListReply);
self.timer = setTimeout(self.flow_cyclic, 1000);
}
};
this.flow_scan = function () {
self.ctx.scan();
}
};
this.flow_cyclic = function () {
self.ctx.gdh.getRefObjectInfoAll(self.flow_scan);
self.ctx.draw();
self.timer = setTimeout(self.flow_cyclic, 1000);
}
};
this.flow_close = function () {
console.log("Close function", self.timer);
clearTimeout(self.timer);
for (var i in self.ctx.gdh.pending)
delete self.ctx.gdh.pending[i];
}
};
this.get_filename = function () {
var query = window.location.search.substring(1);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -39,7 +39,7 @@ function JopCrypt() {
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00
];
this.shifts2 =
......@@ -67,7 +67,7 @@ function JopCrypt() {
0x00080020, 0x00080030, 0x20080020, 0x20080030,
0x00090020, 0x00090030, 0x20090020, 0x20090030,
0x00080820, 0x00080830, 0x20080820, 0x20080830,
0x00090820, 0x00090830, 0x20090820, 0x20090830,
0x00090820, 0x00090830, 0x20090820, 0x20090830
],
[
/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
......@@ -86,7 +86,7 @@ function JopCrypt() {
0x10000400, 0x12000400, 0x10002400, 0x12002400,
0x10200400, 0x12200400, 0x10202400, 0x12202400,
0x10000404, 0x12000404, 0x10002404, 0x12002404,
0x10200404, 0x12200404, 0x10202404, 0x12202404,
0x10200404, 0x12200404, 0x10202404, 0x12202404
],
[
/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
......@@ -105,7 +105,7 @@ function JopCrypt() {
0x08000200, 0x08000201, 0x08040200, 0x08040201,
0x09000200, 0x09000201, 0x09040200, 0x09040201,
0x08000202, 0x08000203, 0x08040202, 0x08040203,
0x09000202, 0x09000203, 0x09040202, 0x09040203,
0x09000202, 0x09000203, 0x09040202, 0x09040203
],
[
/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
......@@ -124,7 +124,7 @@ function JopCrypt() {
0x04020000, 0x04120000, 0x04020100, 0x04120100,
0x04020008, 0x04120008, 0x04020108, 0x04120108,
0x04021000, 0x04121000, 0x04021100, 0x04121100,
0x04021008, 0x04121008, 0x04021108, 0x04121108,
0x04021008, 0x04121008, 0x04021108, 0x04121108
],
[
/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
......@@ -143,7 +143,7 @@ function JopCrypt() {
0x00101000, 0x10101000, 0x00111000, 0x10111000,
0x00101004, 0x10101004, 0x00111004, 0x10111004,
0x20101000, 0x30101000, 0x20111000, 0x30111000,
0x20101004, 0x30101004, 0x20111004, 0x30111004,
0x20101004, 0x30101004, 0x20111004, 0x30111004
],
[
/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
......@@ -162,7 +162,7 @@ function JopCrypt() {
0x02000001, 0x0A000001, 0x02000009, 0x0A000009,
0x02000401, 0x0A000401, 0x02000409, 0x0A000409,
0x02020001, 0x0A020001, 0x02020009, 0x0A020009,
0x02020401, 0x0A020401, 0x02020409, 0x0A020409,
0x02020401, 0x0A020401, 0x02020409, 0x0A020409
],
[
/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
......@@ -181,7 +181,7 @@ function JopCrypt() {
0x00200200, 0x00200300, 0x00280200, 0x00280300,
0x01200200, 0x01200300, 0x01280200, 0x01280300,
0x00200210, 0x00200310, 0x00280210, 0x00280310,
0x01200210, 0x01200310, 0x01280210, 0x01280310,
0x01200210, 0x01200310, 0x01280210, 0x01280310
],
[
/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
......@@ -200,8 +200,8 @@ function JopCrypt() {
0x00000820, 0x04000820, 0x00040820, 0x04040820,
0x00000822, 0x04000822, 0x00040822, 0x04040822,
0x00002820, 0x04002820, 0x00042820, 0x04042820,
0x00002822, 0x04002822, 0x00042822, 0x04042822,
],
0x00002822, 0x04002822, 0x00042822, 0x04042822
]
];
this.SPtrans =
......@@ -223,7 +223,7 @@ function JopCrypt() {
0x80820200, 0x00020200, 0x00820000, 0x80800200,
0x00800000, 0x80000200, 0x80020000, 0x00000000,
0x00020000, 0x00800000, 0x80800200, 0x00820200,
0x80000000, 0x80820000, 0x00000200, 0x80020200,
0x80000000, 0x80820000, 0x00000200, 0x80020200
],
[
/* nibble 1 */
......@@ -242,7 +242,7 @@ function JopCrypt() {
0x10042000, 0x00002000, 0x00000000, 0x10000004,
0x00000004, 0x10042004, 0x00042000, 0x10040000,
0x10040004, 0x00040000, 0x00002004, 0x10002000,
0x10002004, 0x00000004, 0x10040000, 0x00042000,
0x10002004, 0x00000004, 0x10040000, 0x00042000
],
[
/* nibble 2 */
......@@ -261,7 +261,7 @@ function JopCrypt() {
0x40010040, 0x41000000, 0x01000000, 0x41010040,
0x00010000, 0x01000040, 0x41000040, 0x00010040,
0x01000040, 0x00000000, 0x41010000, 0x40000040,
0x41000000, 0x40010040, 0x00000040, 0x01010000,
0x41000000, 0x40010040, 0x00000040, 0x01010000
],
[
/* nibble 3 */
......@@ -280,7 +280,7 @@ function JopCrypt() {
0x04000000, 0x04100402, 0x00100402, 0x00100000,
0x04100402, 0x00000002, 0x04000400, 0x00100402,
0x00100002, 0x00100400, 0x04100000, 0x04000402,
0x00000402, 0x04000000, 0x04000002, 0x04100400,
0x00000402, 0x04000000, 0x04000002, 0x04100400
],
[
/* nibble 4 */
......@@ -299,7 +299,7 @@ function JopCrypt() {
0x02000108, 0x00000100, 0x00000000, 0x02004108,
0x02004008, 0x02004100, 0x00000108, 0x00004000,
0x00004100, 0x02004008, 0x02000100, 0x00000108,
0x00000008, 0x00004108, 0x02004000, 0x02000008,
0x00000008, 0x00004108, 0x02004000, 0x02000008
],
[
/* nibble 5 */
......@@ -318,7 +318,7 @@ function JopCrypt() {
0x20080810, 0x00080800, 0x00080000, 0x20000810,
0x20000010, 0x20080000, 0x00080810, 0x00000000,
0x00000800, 0x20000010, 0x20000810, 0x20080800,
0x20080000, 0x00000810, 0x00000010, 0x20080010,
0x20080000, 0x00000810, 0x00000010, 0x20080010
],
[
/* nibble 6 */
......@@ -337,7 +337,7 @@ function JopCrypt() {
0x00000000, 0x00400081, 0x00400080, 0x00001080,
0x00000081, 0x00001000, 0x00401081, 0x00400000,
0x00401080, 0x00000001, 0x00001001, 0x00401081,
0x00400001, 0x00401080, 0x00401000, 0x00001001,
0x00400001, 0x00401080, 0x00401000, 0x00001001
],
[
/* nibble 7 */
......@@ -376,7 +376,7 @@ function JopCrypt() {
var value = Math.floor(b);
return (value >= 0 ? value : value + 256);
}
};
this.fourBytesToInt = function (b, offset) {
var value;
......@@ -384,17 +384,17 @@ function JopCrypt() {
value = this.byteToUnsigned(b[offset++]);
value |= (this.byteToUnsigned(b[offset++]) << 8);
value |= (this.byteToUnsigned(b[offset++]) << 16);
value |= (this.byteToUnsigned(b[offset++]) << 24);
value |= (this.byteToUnsigned(b[offset]) << 24);
return value;
}
};
this.intToFourBytes = function (iValue, b, offset) {
b[offset++] = ((iValue) & 0xff);
b[offset++] = ((iValue >>> 8) & 0xff);
b[offset++] = ((iValue >>> 16) & 0xff);
b[offset++] = ((iValue >>> 24) & 0xff);
}
b[offset] = ((iValue >>> 24) & 0xff);
};
this.PERM_OP = function (a, b, n, m, results) {
var t;
......@@ -405,7 +405,7 @@ function JopCrypt() {
results[0] = a;
results[1] = b;
}
};
this.HPERM_OP = function (a, n, m) {
var t;
......@@ -414,7 +414,7 @@ function JopCrypt() {
a = a ^ t ^ (t >>> (16 - n));
return (a);
}
};
this.des_set_key = function (key) {
var schedule = new Array(this.ITERATIONS * 2);
......@@ -476,7 +476,7 @@ function JopCrypt() {
schedule[j++] = s & 0xffffffff;
}
return schedule;
}
};
this.D_ENCRYPT = function (L, R, S, E0, E1, s) {
var t, u, v;
......@@ -498,7 +498,7 @@ function JopCrypt() {
this.SPtrans[6][(u >>> 24) & 0x3f];
return L;
}
};
this.body = function (schedule, Eswap0, Eswap1) {
var left = 0;
......@@ -545,11 +545,12 @@ function JopCrypt() {
out[0] = left; out[1] = right;
return (out);
}
};
this.crypt = function (salt, original) {
while (salt.length < 2)
while (salt.length < 2) {
salt += "A";
}
var buffer;
var charZero = salt.charAt(0) + '';
......@@ -564,7 +565,7 @@ function JopCrypt() {
var Eswap0 = this.con_salt[ccZ];
var Eswap1 = this.con_salt[ccO] << 4;
var key = new Array(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0);
var key = [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0];
for (var i = 0; i < key.length && i < original.length; i++) {
var iChar = original.charCodeAt(i);
......@@ -585,12 +586,13 @@ function JopCrypt() {
for (var j = 0, c = 0; j < 6; j++) {
c <<= 1;
if ((b[y] & u) != 0)
if ((b[y] & u) !== 0) {
c |= 1;
}
u >>>= 1;
if (u == 0) {
if (u === 0) {
y++;
u = 0x80;
}
......@@ -609,7 +611,7 @@ function PwrtStatus(sts) {
this.sts = sts;
this.evenSts = function () { return (sts % 2 === 0); };
this.oddSts = function () { return (sts % 2 == 1); };
this.oddSts = function () { return (sts % 2 === 1); };
this.getSts = function () { return sts; };
}
......@@ -781,7 +783,7 @@ function CdhrNumber(value, sts) {
this.sts = sts;
this.evenSts = function () { return (sts % 2 === 0); };
this.oddSts = function () { return (sts % 2 == 1); };
this.oddSts = function () { return (sts % 2 === 1); };
this.getSts = function () { return sts; };
}
......@@ -973,7 +975,7 @@ function Gdh() {
};
this.ws.onmessage = function (e) {
if (typeof e.data == "string") {
if (typeof e.data === "string") {
console.log("String message received", e, e.data);
} else {
if (e.data instanceof ArrayBuffer) {
......@@ -1069,7 +1071,7 @@ function Gdh() {
var esize = dv.getUint32(j);
j += 4;
var sub = this.gdh.sub[eid];
if (typeof sub == 'undefined')
if (typeof sub === 'undefined')
j += esize;
else {
var value;
......@@ -1083,7 +1085,7 @@ function Gdh() {
value = dv.getFloat32(j);
j += 4;
} else {
if (esize != sub.elements * 4)
if (esize !== sub.elements * 4)
console.log("Subscription size error", esize, sub.elements, eid);
value = new Array(sub.elements);
for (var k = 0; k < sub.elements; k++) {
......@@ -1122,7 +1124,7 @@ function Gdh() {
this.gdh.sub[eid].value = value;
}
}
if (typeof this.gdh.pending[id] == 'undefined') {
if (typeof this.gdh.pending[id] === 'undefined') {
console.log("** GetObjectRefInfoAll received removed", id);
break;
}
......@@ -1490,10 +1492,9 @@ function Gdh() {
if (!this.listSent) {
return sub.refid;
} else {
var size = 0;
var len = 0;
size = 12 + sub.name.length;
var size = 12 + sub.name.length;
var buf = new Uint8Array(size + 10);
buf[0] = Msg.REF_OBJECT_INFO;
......@@ -1533,10 +1534,9 @@ function Gdh() {
if (this.debug) console.log("refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function (refid) {
var size = 0;
var len = 0;
size = 4;
var size = 4;
var buf = new Uint8Array(size + 10);
buf[0] = Msg.UNREF_OBJECT_INFO;
......@@ -1909,7 +1909,7 @@ function OpWindMenu() {
this.init = function () {
this.host = window.location.hostname;
if (this.host == "")
if (this.host === "")
this.host = "localhost";
this.gdh = new Gdh();
......@@ -1918,8 +1918,8 @@ function OpWindMenu() {
};
this.is_authorized = function (access) {
return (this.priv & access) ? true : false;
}
return !!(this.priv & access);
};
this.get_opplace = function () {
var query = window.location.search.substring(1);
......@@ -1963,7 +1963,7 @@ function OpWindMenu() {
context.appendChild(document.createElement("hr"));
document.getElementById("login_button").addEventListener("click", function (event) {
if (document.getElementById("login_frame").style.visibility == 'hidden') {
if (document.getElementById("login_frame").style.visibility === 'hidden') {
document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = "";
document.getElementById("login_frame").style.visibility = 'visible';
......@@ -1977,7 +1977,7 @@ function OpWindMenu() {
document.getElementById("apply_button").addEventListener("click", function (event) {
var user = document.getElementById("login_user").value;
var passwd = document.getElementById("login_passw").value;
if (user.trim() == "")
if (user.trim() === "")
return;
document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px';
......@@ -2030,9 +2030,9 @@ function OpWindMenu() {
};
this.button_cb = function (text) {
if (self.info.enable_language && text == "Language") {
if (self.info.enable_language && text === "Language") {
console.log("Language activated");
} else if (self.info.enable_alarmlist && text == "AlarmList") {
} else if (self.info.enable_alarmlist && text === "AlarmList") {
console.log("AlarmList activated");
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
......@@ -2041,7 +2041,7 @@ function OpWindMenu() {
window.alert("Not authorized for this operation");
else
window.alert("Not yet implemented");
} else if (self.info.enable_eventlog && text == "EventLog") {
} else if (self.info.enable_eventlog && text === "EventLog") {
console.log("EventLog activated");
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
......@@ -2051,7 +2051,7 @@ function OpWindMenu() {
window.alert("Not authorized for this operation");
else
window.alert("Not yet implemented");
} else if (self.info.enable_navigator && text == "Navigator") {
} else if (self.info.enable_navigator && text === "Navigator") {
console.log("Navigator activated");
if (!(self.is_authorized(Pwr.mAccess_RtNavigator |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
......@@ -2059,10 +2059,10 @@ function OpWindMenu() {
window.alert("Not authorized for this operation");
else
window.open("xtt.html", "_blank");
} else if (!self.info.disable_help && text == "Help") {
} else if (!self.info.disable_help && text === "Help") {
console.log("Help activated");
window.open("xtt_help_index.html", "_blank");
} else if (!self.info.disable_proview && text == "ProviewR") {
} else if (!self.info.disable_proview && text === "ProviewR") {
console.log("ProviewR activated");
window.open("http://www.proview.se", "_blank");
} else {
......@@ -2073,11 +2073,11 @@ function OpWindMenu() {
window.alert("Not authorized for this operation");
else {
for (var i = 0; i < self.info.buttons.length; i++) {
if (self.info.buttons[i].text == text) {
if (self.info.buttons[i].text === text) {
console.log("Found", self.info.buttons[i].text);
var name = self.info.buttons[i].name;
var n = name.indexOf(".pwg");
if (n != -1)
if (n !== -1)
name = name.substring(0, n);
var url = "ge.html?graph=" + name;
console.log("url", url);
......
......@@ -6,7 +6,7 @@ function PwrtStatus(sts) {
this.sts = sts;
this.evenSts = function () { return (sts % 2 === 0); };
this.oddSts = function () { return (sts % 2 == 1); };
this.oddSts = function () { return (sts % 2 === 1); };
this.getSts = function () { return sts; };
}
......@@ -178,7 +178,7 @@ function CdhrNumber(value, sts) {
this.sts = sts;
this.evenSts = function () { return (sts % 2 === 0); };
this.oddSts = function () { return (sts % 2 == 1); };
this.oddSts = function () { return (sts % 2 === 1); };
this.getSts = function () { return sts; };
}
......@@ -275,7 +275,7 @@ function Cli(cliTable) {
var c = cmd.charAt(i);
switch (state) {
case CliC.STATE_INIT:
if (c == CliC.SPACE || c == CliC.TAB)
if (c === CliC.SPACE || c === CliC.TAB)
break;
else {
state = CliC.STATE_VERB;
......@@ -283,19 +283,19 @@ function Cli(cliTable) {
}
break;
case CliC.STATE_SPACE:
if (c == CliC.SPACE || c == CliC.TAB)
if (c === CliC.SPACE || c === CliC.TAB)
break;
if (c == '/') {
if (c === '/') {
state = CliC.STATE_QUAL;
start_pos = i;
} else if (c == '=') {
} else if (c === '=') {
if (this.qualifierCount === 0) {
state = CliC.STATE_ERROR;
this.status = CliC.SYNTAX_ERROR;
break;
}
state = CliC.STATE_EQUAL;
} else if (c == '"') {
} else if (c === '"') {
state = CliC.STATE_QUOTE_VERB;
break;
} else {
......@@ -304,8 +304,8 @@ function Cli(cliTable) {
}
break;
case CliC.STATE_VERB:
if (c == CliC.SPACE || c == CliC.TAB) {
if (this.verbCount == CliC.VERB_VECT_SIZE) {
if (c === CliC.SPACE || c === CliC.TAB) {
if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
......@@ -314,8 +314,8 @@ function Cli(cliTable) {
else
this.verb[this.verbCount++] = cmd.substring(start_pos, i);
state = CliC.STATE_SPACE;
} else if (c == '/') {
if (this.verbCount == CliC.VERB_VECT_SIZE) {
} else if (c === '/') {
if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
......@@ -325,8 +325,8 @@ function Cli(cliTable) {
}
break;
case CliC.STATE_VERB_EXACT:
if (c == '"') {
if (this.verbCount == CliC.VERB_VECT_SIZE) {
if (c === '"') {
if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
......@@ -335,30 +335,30 @@ function Cli(cliTable) {
}
break;
case CliC.STATE_QUAL:
if (c == CliC.SPACE || c == CliC.TAB) {
if (c === CliC.SPACE || c === CliC.TAB) {
this.qualifier[this.qualifierCount++] = cmd.substring(start_pos, i).toUpperCase();
state = CliC.STATE_SPACE;
} else if (c == '=') {
} else if (c === '=') {
this.qualifier[this.qualifierCount++] = cmd.substring(start_pos, i).toUpperCase();
state = CliC.STATE_EQUAL;
} else if (c == '/') {
} else if (c === '/') {
this.qualifier[this.qualifierCount++] = cmd.substring(start_pos, i).toUpperCase();
state = CliC.STATE_QUAL;
start_pos = i;
}
break;
case CliC.STATE_QUALVALUE:
if (c == CliC.SPACE || c == CliC.TAB) {
if (c === CliC.SPACE || c === CliC.TAB) {
this.qualValue[this.qualifierCount - 1] = cmd.substring(start_pos, i);
state = CliC.STATE_SPACE;
} else if (c == '/') {
} else if (c === '/') {
this.qualValue[this.qualifierCount - 1] = cmd.substring(start_pos, i);
state = CliC.STATE_QUAL;
start_pos = i;
}
break;
case CliC.STATE_QUALVALUE_EXACT:
if (c == '"') {
if (c === '"') {
this.qualValue[this.qualifierCount - 1] = cmd.substring(start_pos, i);
state = CliC.STATE_SPACE;
}
......@@ -372,9 +372,9 @@ function Cli(cliTable) {
start_pos = i;
break;
case CliC.STATE_EQUAL:
if (c == CliC.SPACE || c == CliC.TAB)
if (c === CliC.SPACE || c === CliC.TAB)
break;
if (c == '"') {
if (c === '"') {
state = CliC.STATE_QUOTE_QUALVALUE;
} else {
state = CliC.STATE_QUALVALUE;
......@@ -383,7 +383,7 @@ function Cli(cliTable) {
break;
}
if (state == CliC.STATE_ERROR)
if (state === CliC.STATE_ERROR)
break;
}
switch (state) {
......@@ -391,7 +391,7 @@ function Cli(cliTable) {
case CliC.STATE_ERROR:
return "";
case CliC.STATE_VERB:
if (this.verbCount == CliC.VERB_VECT_SIZE) {
if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
......@@ -401,7 +401,7 @@ function Cli(cliTable) {
this.verb[this.verbCount++] = cmd.substring(start_pos, i);
break;
case CliC.STATE_VERB_EXACT:
if (this.verbCount == CliC.VERB_VECT_SIZE) {
if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
......@@ -438,7 +438,7 @@ function Cli(cliTable) {
for (i = 0; i < this.cliTable.length; i++) {
if (this.verb[0].length > this.cliTable[i].command.length)
continue;
if (this.verb[0] == (this.cliTable[i].command.substring(0, this.verb[0].length))) {
if (this.verb[0] === (this.cliTable[i].command.substring(0, this.verb[0].length))) {
this.verb[0] = this.cliTable[i].command;
found = true;
break;
......@@ -455,15 +455,15 @@ function Cli(cliTable) {
for (i = 0; i < this.cliTable[this.cliTableIndex].qualifier.length; i++) {
if (this.cliTable[this.cliTableIndex].qualifier[i] === null)
break;
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg1"))
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg1"))
this.configuredVerbs++;
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg2"))
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg2"))
this.configuredVerbs++;
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg3"))
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg3"))
this.configuredVerbs++;
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg4"))
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg4"))
this.configuredVerbs++;
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg5"))
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg5"))
this.configuredVerbs++;
}
......@@ -474,7 +474,7 @@ function Cli(cliTable) {
break;
if (this.qualifier[j].length > this.cliTable[this.cliTableIndex].qualifier[i].length)
continue;
if (this.qualifier[j] == (this.cliTable[this.cliTableIndex].qualifier[i].substring(0, this.qualifier[j].length))) {
if (this.qualifier[j] === (this.cliTable[this.cliTableIndex].qualifier[i].substring(0, this.qualifier[j].length))) {
this.cliQualifierIndex[j] = i;
found = true;
this.qualifier[j] = this.cliTable[this.cliTableIndex].qualifier[i];
......@@ -498,28 +498,24 @@ function Cli(cliTable) {
* @return Returns true if the qualifier is present.
*/
this.qualifierFound = function (qual) {
if (qual == ("cli_arg1")) {
if (this.verbCount < 2 || this.configuredVerbs < 1)
return false;
return true;
if (qual === ("cli_arg1")) {
return !(this.verbCount < 2 || this.configuredVerbs < 1);
}
if (qual == ("cli_arg2")) {
if (this.verbCount < 3 || this.configuredVerbs < 2)
return false;
return true;
if (qual === ("cli_arg2")) {
return !(this.verbCount < 3 || this.configuredVerbs < 2);
}
if (qual == ("cli_arg3")) {
if (this.verbCount < 4 || this.configuredVerbs < 3)
return false;
return true;
if (qual === ("cli_arg3")) {
return !(this.verbCount < 4 || this.configuredVerbs < 3);
}
if (qual == ("cli_arg4")) {
if (this.verbCount < 5 || this.configuredVerbs < 4)
return false;
return true;
if (qual === ("cli_arg4")) {
return !(this.verbCount < 5 || this.configuredVerbs < 4);
}
for (var i = 0; i < this.qualifierCount; i++) {
if (qual == (this.qualifier[i]))
if (qual === (this.qualifier[i]))
return true;
}
return false;
......@@ -531,27 +527,27 @@ function Cli(cliTable) {
* @return Returns the value of the qualifier.
*/
this.getQualValue = function (qual) {
if (qual == ("cli_arg1")) {
if (qual === ("cli_arg1")) {
if (this.verbCount < 2 || this.configuredVerbs < 1)
return "";
return this.verb[1];
}
if (qual == ("cli_arg2")) {
if (qual === ("cli_arg2")) {
if (this.verbCount < 3 || this.configuredVerbs < 2)
return "";
return this.verb[2];
}
if (qual == ("cli_arg3")) {
if (qual === ("cli_arg3")) {
if (this.verbCount < 4 || this.configuredVerbs < 3)
return this.verb[3];
}
if (qual == ("cli_arg4")) {
if (qual === ("cli_arg4")) {
if (this.verbCount < 5 || this.configuredVerbs < 4)
return "";
return this.verb[4];
}
for (var i = 0; i < this.qualifierCount; i++) {
if (qual == (this.qualifier[i])) {
if (qual === (this.qualifier[i])) {
if (this.qualValue[i] === null)
return "";
else
......@@ -751,7 +747,7 @@ function Gdh() {
};
this.ws.onmessage = function (e) {
if (typeof e.data == "string") {
if (typeof e.data === "string") {
console.log("String message received", e, e.data);
} else {
if (e.data instanceof ArrayBuffer) {
......@@ -847,7 +843,7 @@ function Gdh() {
var esize = dv.getUint32(j);
j += 4;
var sub = this.gdh.sub[eid];
if (typeof sub == 'undefined')
if (typeof sub === 'undefined')
j += esize;
else {
var value;
......@@ -861,7 +857,7 @@ function Gdh() {
value = dv.getFloat32(j);
j += 4;
} else {
if (esize != sub.elements * 4)
if (esize !== sub.elements * 4)
console.log("Subscription size error", esize, sub.elements, eid);
value = new Array(sub.elements);
for (var k = 0; k < sub.elements; k++) {
......@@ -900,7 +896,7 @@ function Gdh() {
this.gdh.sub[eid].value = value;
}
}
if (typeof this.gdh.pending[id] == 'undefined') {
if (typeof this.gdh.pending[id] === 'undefined') {
console.log("** GetObjectRefInfoAll received removed", id);
break;
}
......@@ -1275,10 +1271,9 @@ function Gdh() {
if (!this.listSent) {
return sub.refid;
} else {
var size = 0;
var len = 0;
size = 12 + sub.name.length;
var size = 12 + sub.name.length;
var buf = new Uint8Array(size + 10);
buf[0] = Msg.REF_OBJECT_INFO;
......@@ -1318,10 +1313,9 @@ function Gdh() {
if (this.debug) console.log("refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function (refid) {
var size = 0;
var len = 0;
size = 4;
var size = 4;
var buf = new Uint8Array(size + 10);
buf[0] = Msg.UNREF_OBJECT_INFO;
......@@ -1773,7 +1767,7 @@ var Plow = {
eEvent_ObjectDeleted: 10,
RELATIVE_POSITION: 1,
NEXT_RELATIVE_POSITION: 2
}
};
function PlowNodeClass(ctx) {
this.a = new PlowArray(ctx);
this.ctx = ctx;
......@@ -1783,7 +1777,7 @@ function PlowNodeClass(ctx) {
this.draw = function (g, p, node, highlight) {
this.a.draw(g, p, node, highlight);
}
};
this.insert = function (elem) {
this.a.add(elem);
......@@ -1796,10 +1790,10 @@ function PlowArray(ctx) {
this.add = function (elem) {
this.a.push(elem);
}
};
this.insertNode = function (elem, destination, code) {
var idx = this.find(elem);
if (idx != -1)
if (idx !== -1)
return;
if (destination == null) {
......@@ -1815,19 +1809,19 @@ function PlowArray(ctx) {
}
} else {
var dest_idx = this.find(destination);
if (dest_idx == -1)
if (dest_idx === -1)
return;
switch (code) {
case Plow.DEST_INTOFIRST:
if (dest_idx == this.a.length - 1)
if (dest_idx === this.a.length - 1)
this.a.push(elem);
else
this.a.splice(dest_idx + 1, 0, elem);
elem.level = destination.level + 1;
break;
case Plow.DEST_INTOLAST: {
if (dest_idx == this.a.length - 1)
if (dest_idx === this.a.length - 1)
this.a.push(elem);
else {
idx = this.a.length;
......@@ -1837,7 +1831,7 @@ function PlowArray(ctx) {
break;
}
}
if (idx == this.a.length)
if (idx === this.a.length)
this.a.push(elem);
else
this.a.splice(idx, 0, elem);
......@@ -1846,7 +1840,7 @@ function PlowArray(ctx) {
break;
}
case Plow.DEST_AFTER: {
if (dest_idx == this.a.length - 1)
if (dest_idx === this.a.length - 1)
this.a.push(elem);
else {
var i;
......@@ -1867,31 +1861,31 @@ function PlowArray(ctx) {
break;
}
}
}
};
this.size = function () {
return this.a.length;
}
};
this.get = function (idx) {
return this.a[idx];
}
};
this.draw = function (g, p, node, highlight) {
for (var i = 0; i < this.a.length; i++)
this.a[i].draw(g, p, node, highlight);
}
};
this.set_borders = function (node) {
for (var i = 0; i < this.a.length; i++)
this.a[i].set_borders(node);
}
};
this.configure = function () {
for (var i = 0; i < this.a.length; i++) {
this.a[i].pos.x = this.a[i].level * 1.0;
this.a[i].pos.y = i * 1.0;
this.a[i].pos.y = i;
}
}
};
this.close_node = function (node) {
var idx = this.find(node);
if (idx == -1)
if (idx === -1)
return;
var level = node.level;
var i;
......@@ -1900,19 +1894,19 @@ function PlowArray(ctx) {
break;
}
var next_idx = i;
if (next_idx == idx + 1)
if (next_idx === idx + 1)
return;
for (i = idx + 1; i < next_idx; i++) {
// Event backcall
if (ctx.select_object == this.a[idx + 1])
if (ctx.select_object === this.a[idx + 1])
ctx.select_object = null;
this.ctx.event_cb(Plow.eEvent_ObjectDeleted, this.a[idx + 1], 0, 0);
this.a.splice(idx + 1, 1);
}
}
};
this.get_parent_object = function (node) {
var idx = this.find(node);
if (idx == -1)
if (idx === -1)
return null;
for (var i = idx; i >= 0; i--) {
......@@ -1920,62 +1914,62 @@ function PlowArray(ctx) {
return this.a[i];
}
return null;
}
};
this.get_first_child = function (node) {
var idx = this.find(node);
if (idx == -1)
if (idx === -1)
return null;
if (this.a.length == idx - 1)
if (this.a.length === idx - 1)
return null;
if (this.a[idx + 1].level > node.level)
return this.a[idx + 1];
return null;
}
};
this.get_next_sibling = function (node) {
var found = false;
for (var i = 0; i < this.a.length; i++) {
if (this.a[i] == node) {
if (this.a[i] === node) {
found = true;
continue;
}
if (found) {
if (this.a[i].level == node.level)
if (this.a[i].level === node.level)
return this.a[i];
if (this.a[i].level < node.level)
return null;
}
}
return null;
}
};
this.get_next_object = function (node) {
for (var i = 0; i < this.a.length; i++) {
if (this.a[i] == node) {
if (i == this.a.length - 1)
if (this.a[i] === node) {
if (i === this.a.length - 1)
return null;
return this.a[i + 1];
}
}
return null;
}
};
this.get_previous_object = function (node) {
for (var i = 0; i < this.a.length; i++) {
if (this.a[i] == node) {
if (i == 0)
if (this.a[i] === node) {
if (i === 0)
return null;
return this.a[i - 1];
}
}
return null;
}
};
this.find = function (elem) {
for (var i = 0; i < this.a.length; i++) {
if (this.a[i] == elem)
if (this.a[i] === elem)
return i;
}
return -1;
......@@ -2014,15 +2008,15 @@ function PlowNode(ctx, nc, level) {
if (number >= 10)
return;
this.annotv[number] = text;
}
};
this.set_annotation_pixmap = function (number, pixmap) {
if (number >= 10)
return;
this.pixmapv[number] = pixmap;
}
};
this.draw_object = function () {
this.draw(this.ctx.gdraw.gctx, null, null, false);
}
};
this.draw = function (g, p, node, highlight) {
var x = this.x_left * this.ctx.zoom_factor;
var y = this.y_low * this.ctx.zoom_factor - 1;
......@@ -2034,38 +2028,35 @@ function PlowNode(ctx, nc, level) {
g.fillRect(x, y, width, height);
this.nc.draw(g, this.pos, this, this.highlight);
}
};
this.connect = function () {
if (this.trace_object == "" || this.trace_attribute == "")
if (this.trace_object === "" || this.trace_attribute === "")
return;
var n = this.trace_attribute.indexOf('#');
if (n != -1)
if (n !== -1)
this.trace_attribute = this.trace_attribute.substring(0, n);
var o = this.trace_object + "." + this.trace_attribute;
this.p = ctx.gdh.refObjectInfo(o, this.trace_attr_type);
console.log("connecting", o, this.p);
}
};
this.scan = function () {
if (this.p == 0)
if (this.p === 0)
return;
var v1 = ctx.gdh.getRefObjectInfo(this.p);
var evaluate = true;
if (this.first_scan)
this.first_scan = false;
else if (v1 == this.old_value)
else if (v1 === this.old_value)
return;
if (v1)
this.highlight = true;
else
this.highlight = false;
this.highlight = !!v1;
this.old_value = v1;
this.draw_object();
}
};
this.set_borders = function () {
this.x_left = 1e37;
......@@ -2073,7 +2064,7 @@ function PlowNode(ctx, nc, level) {
this.y_low = 1e37;
this.y_high = -1e37;
nc.a.set_borders(this);
}
};
this.event_handler = function (event, x, y) {
if ((x - this.ctx.offset_x) / this.ctx.zoom_factor >= this.x_left &&
......@@ -2084,7 +2075,7 @@ function PlowNode(ctx, nc, level) {
return 1;
}
return 0;
}
};
this.set_select = function (select) {
if (select) {
......@@ -2092,27 +2083,26 @@ function PlowNode(ctx, nc, level) {
this.ctx.select_object = this;
} else {
this.select = false;
if (this.ctx.select_object == this)
if (this.ctx.select_object === this)
this.ctx.select_object = null;
}
if (select != this.select)
if (select !== this.select)
this.draw_object();
}
};
this.set_invert = function (invert) {
this.invert = invert;
this.draw_object();
}
};
this.set_userdata = function (userdata) {
this.userdata = userdata;
}
};
this.get_userdata = function () {
return this.userdata;
}
};
this.in_icon = function (x, y) {
if (x >= this.x_left * this.ctx.zoom_factor &&
x <= (this.x_left + 1.75) * this.ctx.zoom_factor)
return true;
return false;
return x >= this.x_left * this.ctx.zoom_factor &&
x <= (this.x_left + 1.75) * this.ctx.zoom_factor;
}
}
......@@ -2165,7 +2155,7 @@ function PlowAnnot(ctx, x, y, text_size, text_color, annot_type, number) {
var x = (this.p.x + p0.x) * this.ctx.zoom_factor;
var y = (this.p.y + p0.y) * this.ctx.zoom_factor - tsize / 4;
if ((this.annot_type & Plow.RELATIVE_POSITION) != 0) {
if ((this.annot_type & Plow.RELATIVE_POSITION) !== 0) {
var rel_x = (p0.x + node.relative_position + this.RELATIVE_OFFSET) * this.ctx.zoom_factor;
if (x < rel_x)
x = rel_x;
......@@ -2176,10 +2166,10 @@ function PlowAnnot(ctx, x, y, text_size, text_color, annot_type, number) {
g.fillText(tokens[i], x, y);
y += tsize * 1.4;
}
if ((this.annot_type & Plow.NEXT_RELATIVE_POSITION) != 0 || (this.annot_type & Plow.RELATIVE_POSITION) != 0) {
if ((this.annot_type & Plow.NEXT_RELATIVE_POSITION) !== 0 || (this.annot_type & Plow.RELATIVE_POSITION) !== 0) {
node.relative_position = (x + g.measureText(node.annotv[this.number]).width) / this.ctx.zoom_factor - p0.x;
}
}
};
this.set_borders = function (node) {
}
}
......@@ -2217,7 +2207,7 @@ function PlowAnnotPixmap(ctx, x, y, number) {
gctx.drawImage(img, x, y);
}
}
};
this.set_borders = function (node) {
}
}
......@@ -2277,7 +2267,7 @@ function PlowRect(ctx, x, y, width, height, fill_color, border_color, fill, fix_
}
g.fillRect(x, y, width, height);
}
}
};
this.set_borders = function (node) {
if (this.ll.x + node.pos.x < node.x_left)
node.x_left = this.ll.x + node.pos.x;
......@@ -2323,23 +2313,23 @@ function PlowCtx() {
this.gdraw.gctx.fillStyle = "white";
this.gdraw.gctx.fillRect(0, 0, this.gdraw.canvas.width, this.gdraw.canvas.height);
this.a.draw(this.gdraw.gctx, null, null, false);
}
};
this.connect = function () {
for (var i = 0; i < this.a.size(); i++)
this.a.get(i).connect();
}
};
this.scan = function () {
console.log("ctx scan", this.a.size());
for (var i = 0; i < this.a.size(); i++)
this.a.get(i).scan();
}
};
this.set_nodraw = function () {
this.nodraw++;
}
};
this.reset_nodraw = function () {
this.nodraw--;
}
};
this.event_handler = function (event, x, y) {
var sts = 0;
......@@ -2349,11 +2339,11 @@ function PlowCtx() {
for (var i = 0; i < this.a.size(); i++) {
if (this.a.get(i) instanceof PlowNode) {
sts = this.a.get(i).event_handler(event, x, y);
if (sts == 1)
if (sts === 1)
break;
}
}
if (sts == 1) {
if (sts === 1) {
this.event_cb(event, this.event_object, x, y);
this.draw();
}
......@@ -2369,58 +2359,56 @@ function PlowCtx() {
this.event_cb(event, null, 0, 0);
break;
}
}
};
this.set_select = function (select) {
for (var i = 0; i < this.a.size(); i++) {
if (this.a.get(i) instanceof PlowNode)
this.a.get(i).set_select(select);
}
}
};
this.set_invert = function (invert) {
for (var i = 0; i < this.a.size(); i++) {
if (this.a.get(i) instanceof PlowNode)
this.a.get(i).set_invert(invert);
}
}
};
this.get_select = function () {
return this.select_object;
}
};
this.insert = function (n, dest) {
this.a.add(n);
}
};
this.insertNode = function (n, destination, destCode) {
this.a.insertNode(n, destination, destCode);
}
};
this.insert_nc = function (nc) {
this.a_nc.add(nc);
}
};
this.configure = function () {
this.a.configure();
this.a.set_borders();
var height = this.a.a.length * 1.0 * this.zoom_factor;
this.gdraw.canvas.height = height;
}
this.gdraw.canvas.height = this.a.a.length * this.zoom_factor;
};
this.get_parent_object = function (o) {
return this.a.get_parent_object(o);
}
};
this.get_next_object = function (o) {
return this.a.get_next_object(o);
}
};
this.get_previous_object = function (o) {
return this.a.get_previous_object(o);
}
};
this.close_node = function (o) {
this.a.close_node(o);
}
};
this.is_visible = function (o) {
if ((o.y_high * this.zoom_factor <= window.pageYOffset + window.innerHeight - this.gdraw.offset_top) &&
(o.y_low * this.zoom_factor >= window.pageYOffset - this.gdraw.offset_top))
return true;
return false;
}
return (o.y_high * this.zoom_factor <= window.pageYOffset + window.innerHeight - this.gdraw.offset_top) &&
(o.y_low * this.zoom_factor >= window.pageYOffset - this.gdraw.offset_top);
};
this.scroll = function (y, factor) {
window.scrollTo(window.scrollX, y * this.zoom_factor - window.innerHeight * factor + this.gdraw.offset_top)
}
......@@ -2451,7 +2439,7 @@ function Xtt() {
this.ctx.gdh = new Gdh();
this.ctx.gdh.open_cb = this.gdh_init_cb;
this.ctx.gdh.init()
this.ctx.gdh.init();
this.ctx.gdraw.canvas.addEventListener("click", function (event) {
var y = event.pageY - self.ctx.gdraw.offset_top;
......@@ -2462,30 +2450,30 @@ function Xtt() {
xtt.ctx.event_handler(Plow.eEvent_MB1Click, x, y);
});
document.addEventListener("keydown", function (event) {
if (event.keyCode == 40) {
if (event.keyCode === 40) {
self.ctx.event_handler(Plow.eEvent_Key_Down);
event.preventDefault();
} else if (event.keyCode == 39) {
} else if (event.keyCode === 39) {
if (event.shiftKey)
self.ctx.event_handler(Plow.eEvent_Key_ShiftRight);
else
self.ctx.event_handler(Plow.eEvent_Key_Right);
event.preventDefault();
} else if (event.keyCode == 37) {
} else if (event.keyCode === 37) {
self.ctx.event_handler(Plow.eEvent_Key_Left);
event.preventDefault();
} else if (event.keyCode == 38) {
} else if (event.keyCode === 38) {
self.ctx.event_handler(Plow.eEvent_Key_Up);
event.preventDefault();
} else if (event.keyCode == 82) {
} else if (event.keyCode === 82) {
if (event.ctrlKey)
self.ctx.event_handler(Plow.eEvent_Key_CtrlR);
event.preventDefault();
} else if (event.keyCode == 76) {
} else if (event.keyCode === 76) {
if (event.ctrlKey)
self.ctx.event_handler(Plow.eEvent_Key_CtrlL);
event.preventDefault();
} else if (event.keyCode == 71) {
} else if (event.keyCode === 71) {
if (event.ctrlKey)
self.ctx.event_handler(Plow.eEvent_Key_CtrlG);
event.preventDefault();
......@@ -2531,17 +2519,17 @@ function Xtt() {
});
window.addEventListener("storage", function (event) {
if (event.newValue == "")
if (event.newValue === "")
return;
localStorage.setItem("XttMethodNavigator", "");
self.display_object(event.newValue);
});
}
};
this.is_authorized = function (access) {
return (this.priv & access) ? true : false;
}
return !!(this.priv & access);
};
this.gdh_init_cb = function () {
if (self.priv == null)
......@@ -2552,7 +2540,7 @@ function Xtt() {
self.ctx.gdh.listSent = true;
self.trace_cyclic();
}
};
this.login_cb = function (id, data, sts, result) {
console.log("Login:", sts, result);
......@@ -2576,14 +2564,14 @@ function Xtt() {
self.ctx.configure();
if (data.open_next != null) {
if (data.open_next.length == 0) {
if (data.open_next.length === 0) {
self.ctx.reset_nodraw();
return;
}
var child = self.ctx.a.get_first_child(data.node);
while (child != null) {
if (child.userdata.name == data.open_next[0]) {
if (data.open_next.length == 1) {
if (child.userdata.name === data.open_next[0]) {
if (data.open_next.length === 1) {
child.set_select(true);
child.set_invert(true);
if (!self.ctx.is_visible(child))
......@@ -2601,16 +2589,16 @@ function Xtt() {
self.ctx.reset_nodraw();
self.ctx.draw();
}
};
this.open_attributes_cb = function (id, node, sts, result) {
self.ctx.set_nodraw();
for (var i = 0; i < result.length; i++) {
result[i].objid = node.userdata.objid;
result[i].full_name = node.userdata.full_name + "." + result[i].name;
if ((result[i].flags & Pwr.mAdef_array) != 0)
if ((result[i].flags & Pwr.mAdef_array) !== 0)
new XttItemAttrArray(self, result[i], node, Plow.DEST_INTOLAST);
else if ((result[i].flags & Pwr.mAdef_class) != 0)
else if ((result[i].flags & Pwr.mAdef_class) !== 0)
new XttItemAttrObject(self, result[i], node, Plow.DEST_INTOLAST);
else
new XttItemAttr(self, result[i], node, Plow.DEST_INTOLAST);
......@@ -2619,39 +2607,38 @@ function Xtt() {
self.ctx.configure();
self.ctx.reset_nodraw();
self.ctx.draw();
}
};
this.open_plc_cb = function (id, data, sts, result) {
if ((sts & 1) != 0) {
if ((sts & 1) !== 0) {
data.location.href = "flow.html?vid=" + result.objid.vid + "&oix=" + result.objid.oix;
data.document.title = "Trace " + result.fullname;
} else
data.document.write("Error status " + sts);
}
};
this.open_objectgraph_cb = function (id, data, sts, result) {
if ((sts & 1) != 0) {
if ((sts & 1) !== 0) {
var graphname = "pwr_c_" + result.classname.toLowerCase();
data.location.href = "ge.html?graph=" + graphname + "&instance=" + result.fullname;
data.document.title = graphname + " " + result.fullname;
} else
data.document.write("Error status " + sts);
}
};
this.open_crr_cb = function (id, node, sts, crrdata) {
if ((sts & 1) == 0) {
if ((sts & 1) === 0) {
return;
}
node.userdata.open_crossreferences(self, crrdata);
}
};
this.open_helpclass_cb = function (id, data, sts, result) {
if ((sts & 1) != 0) {
var url = location.protocol + "//" + location.host + "/pwr_doc/en_us/orm/pwrb_" + result.classname.toLowerCase() + ".html";
data.location.href = url;
if ((sts & 1) !== 0) {
data.location.href = location.protocol + "//" + location.host + "/pwr_doc/en_us/orm/pwrb_" + result.classname.toLowerCase() + ".html";
} else
data.document.write("Error status " + sts);
}
};
this.plow_event = function (event, object, x, y) {
var item = null;
......@@ -2763,7 +2750,7 @@ function Xtt() {
} else if (o.userdata instanceof XttItemCrr) {
var idx = o.userdata.name.lastIndexOf('-');
var ostring = "";
if (idx != -1) {
if (idx !== -1) {
ostring = "&obj=" + o.userdata.name.substring(idx + 1);
}
window.open("flow.html?vid=" + o.userdata.objid.vid + "&oix=" + o.userdata.objid.oix + ostring);
......@@ -2780,7 +2767,7 @@ function Xtt() {
break;
}
}
}
};
this.createNodeClasses = function () {
var r1 = new PlowRect(this.ctx, 0, 0, 50, 1.0, Plow.COLOR_WHITE, Plow.COLOR_WHITE, true, false);
......@@ -2796,34 +2783,34 @@ function Xtt() {
this.ncObject.insert(a12);
this.ncObject.insert(p1);
this.ctx.insert_nc(this.ncObject);
}
};
this.methods_init = function () {
localStorage.setItem("XttMethodNavigator", "");
}
};
this.collapse = function () {
this.ctx.set_nodraw();
for (var i = 0; i < this.ctx.a.size(); i++) {
var node = this.ctx.a.get(i);
if (node.level == 0)
if (node.level === 0)
node.userdata.close(this);
}
this.ctx.reset_nodraw();
this.ctx.draw();
}
};
this.display_object = function (name) {
var i = name.indexOf('.');
if (i != -1)
if (i !== -1)
name = name.substring(0, i);
var path = name.split('-');
var idx = 0;
this.collapse();
for (var j = idx; j < this.ctx.a.size(); j++) {
if (this.ctx.a.get(j).userdata.name == path[0]) {
if (j == this.ctx.a.size() - 1) {
if (this.ctx.a.get(j).userdata.name === path[0]) {
if (j === this.ctx.a.size() - 1) {
var node = this.ctx.a.get(j);
node.set_select(true);
node.set_invert(true);
......@@ -2837,7 +2824,7 @@ function Xtt() {
break;
}
}
}
};
this.trace_cyclic = function () {
self.ctx.gdh.getRefObjectInfoAll(self.trace_scan);
......@@ -2886,7 +2873,7 @@ function XttItemObject(xtt, object_info, destination, destCode) {
this.node.set_annotation_pixmap(0, Bitmaps.leaf);
this.open_children = function (xtt, open_next) {
if (this.node.node_open != 0)
if (this.node.node_open !== 0)
this.close(xtt);
else if (!this.has_children)
this.open_attributes(xtt);
......@@ -2895,22 +2882,22 @@ function XttItemObject(xtt, object_info, destination, destCode) {
this.node.node_open |= Plow.OPEN_CHILDREN;
this.node.set_annotation_pixmap(0, Bitmaps.openmap);
}
}
};
this.open_attributes = function (xtt) {
if (this.node.node_open != 0)
if (this.node.node_open !== 0)
this.close(xtt);
else {
xtt.ctx.gdh.getAllClassAttributes(this.cid, this.objid, xtt.open_attributes_cb, this.node)
xtt.ctx.gdh.getAllClassAttributes(this.cid, this.objid, xtt.open_attributes_cb, this.node);
this.node.node_open |= Plow.OPEN_ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
}
}
};
this.open_crossreferences = function (xtt, crrdata) {
if (this.node.node_open != 0)
if (this.node.node_open !== 0)
this.close(xtt);
else {
for (var i = 0; i < crrdata.length; i++) {
......@@ -2921,7 +2908,7 @@ function XttItemObject(xtt, object_info, destination, destCode) {
xtt.ctx.configure();
xtt.ctx.draw();
}
}
};
this.close = function (xtt) {
if (this.node.node_open & Plow.OPEN_CHILDREN) {
......@@ -3009,7 +2996,7 @@ function XttItemAttr(xtt, info, destination, destCode) {
};
this.open_attributes = function (xtt) {
}
};
this.close = function (xtt) {
var parent = xtt.ctx.get_parent_object(this.node);
......@@ -3018,13 +3005,13 @@ function XttItemAttr(xtt, info, destination, destCode) {
parent.set_select(true);
parent.set_invert(true);
}
}
};
this.scan = function (xtt) {
if (!this.refid)
return;
var value = xtt.ctx.gdh.getObjectRefInfo(this.refid);
if (this.firstScan || value != this.old_value) {
if (this.firstScan || value !== this.old_value) {
var value_str;
switch (this.type) {
......@@ -3056,7 +3043,7 @@ function XttItemAttr(xtt, info, destination, destCode) {
xtt.scan_update = true;
}
this.firstScan = false;
}
};
this.scan_close = function (xtt) {
xtt.ctx.gdh.unrefObjectInfo(this.refid);
};
......@@ -3078,7 +3065,7 @@ function XttItemAttrArray(xtt, info, destination, destCode) {
this.open_children = function (xtt, open_next) {
this.open_attributes(xtt);
}
};
this.open_attributes = function (xtt) {
var info = new AttributeInfo();
......@@ -3088,18 +3075,18 @@ function XttItemAttrArray(xtt, info, destination, destCode) {
info.flags = this.flags & ~Pwr.mAdef_array;
info.size = this.size / this.elements;
info.elements = 1;
info.name = ""
info.full_name = ""
info.classname = ""
info.name = "";
info.full_name = "";
info.classname = "";
xtt.ctx.set_nodraw();
for (var i = 0; i < this.elements; i++) {
info.name = this.name + "[" + i + "]";
info.full_name = this.full_name + "[" + i + "]";
console.log("AttrArray", info.name, info.type);
if ((info.flags & Pwr.mAdef_array) != 0)
if ((info.flags & Pwr.mAdef_array) !== 0)
new XttItemAttrArray(xtt, info, this.node, Plow.DEST_INTOLAST);
else if ((info.flags & Pwr.mAdef_class) != 0)
else if ((info.flags & Pwr.mAdef_class) !== 0)
new XttItemAttrObject(xtt, info, this.node, Plow.DEST_INTOLAST);
else
new XttItemAttr(xtt, info, this.node, Plow.DEST_INTOLAST);
......@@ -3145,17 +3132,17 @@ function XttItemAttrObject(xtt, info, destination, destCode) {
this.open_children = function (xtt, open_next) {
this.open_attributes(xtt);
}
};
this.open_attributes = function (xtt) {
if (this.node.node_open != 0)
if (this.node.node_open !== 0)
this.close(xtt);
else {
xtt.ctx.gdh.getAllClassAttributes(this.cid, this.objid, xtt.open_attributes_cb, this.node)
xtt.ctx.gdh.getAllClassAttributes(this.cid, this.objid, xtt.open_attributes_cb, this.node);
this.node.node_open |= Plow.OPEN_ATTRIBUTES;
}
}
};
this.close = function (xtt) {
if (this.node.node_open & Plow.OPEN_ATTRIBUTES) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment