Commit 5d4e1cd6 authored by Christoffer Ackelman's avatar Christoffer Ackelman

JS: Change from fuzzy to strict equality checks.

parent 285b780d
...@@ -93,7 +93,7 @@ function Cli(cliTable) { ...@@ -93,7 +93,7 @@ function Cli(cliTable) {
var c = cmd.charAt(i); var c = cmd.charAt(i);
switch (state) { switch (state) {
case CliC.STATE_INIT: case CliC.STATE_INIT:
if (c == CliC.SPACE || c == CliC.TAB) { if (c === CliC.SPACE || c === CliC.TAB) {
break; break;
} else { } else {
state = CliC.STATE_VERB; state = CliC.STATE_VERB;
...@@ -101,20 +101,20 @@ function Cli(cliTable) { ...@@ -101,20 +101,20 @@ function Cli(cliTable) {
} }
break; break;
case CliC.STATE_SPACE: case CliC.STATE_SPACE:
if (c == CliC.SPACE || c == CliC.TAB) { if (c === CliC.SPACE || c === CliC.TAB) {
break; break;
} }
if (c == '/') { if (c === '/') {
state = CliC.STATE_QUAL; state = CliC.STATE_QUAL;
start_pos = i; start_pos = i;
} else if (c == '=') { } else if (c === '=') {
if (this.qualifierCount === 0) { if (this.qualifierCount === 0) {
state = CliC.STATE_ERROR; state = CliC.STATE_ERROR;
this.status = CliC.SYNTAX_ERROR; this.status = CliC.SYNTAX_ERROR;
break; break;
} }
state = CliC.STATE_EQUAL; state = CliC.STATE_EQUAL;
} else if (c == '"') { } else if (c === '"') {
state = CliC.STATE_QUOTE_VERB; state = CliC.STATE_QUOTE_VERB;
break; break;
} else { } else {
...@@ -123,8 +123,8 @@ function Cli(cliTable) { ...@@ -123,8 +123,8 @@ function Cli(cliTable) {
} }
break; break;
case CliC.STATE_VERB: case CliC.STATE_VERB:
if (c == CliC.SPACE || c == CliC.TAB) { if (c === CliC.SPACE || c === CliC.TAB) {
if (this.verbCount == CliC.VERB_VECT_SIZE) { if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR; state = CliC.STATE_ERROR;
break; break;
} }
...@@ -135,8 +135,8 @@ function Cli(cliTable) { ...@@ -135,8 +135,8 @@ function Cli(cliTable) {
this.verb[this.verbCount++] = cmd.substring(start_pos, i); this.verb[this.verbCount++] = cmd.substring(start_pos, i);
} }
state = CliC.STATE_SPACE; state = CliC.STATE_SPACE;
} else if (c == '/') { } else if (c === '/') {
if (this.verbCount == CliC.VERB_VECT_SIZE) { if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR; state = CliC.STATE_ERROR;
break; break;
} }
...@@ -147,8 +147,8 @@ function Cli(cliTable) { ...@@ -147,8 +147,8 @@ function Cli(cliTable) {
} }
break; break;
case CliC.STATE_VERB_EXACT: case CliC.STATE_VERB_EXACT:
if (c == '"') { if (c === '"') {
if (this.verbCount == CliC.VERB_VECT_SIZE) { if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR; state = CliC.STATE_ERROR;
break; break;
} }
...@@ -157,15 +157,15 @@ function Cli(cliTable) { ...@@ -157,15 +157,15 @@ function Cli(cliTable) {
} }
break; break;
case CliC.STATE_QUAL: case CliC.STATE_QUAL:
if (c == CliC.SPACE || c == CliC.TAB) { if (c === CliC.SPACE || c === CliC.TAB) {
this.qualifier[this.qualifierCount++] = this.qualifier[this.qualifierCount++] =
cmd.substring(start_pos, i).toUpperCase(); cmd.substring(start_pos, i).toUpperCase();
state = CliC.STATE_SPACE; state = CliC.STATE_SPACE;
} else if (c == '=') { } else if (c === '=') {
this.qualifier[this.qualifierCount++] = this.qualifier[this.qualifierCount++] =
cmd.substring(start_pos, i).toUpperCase(); cmd.substring(start_pos, i).toUpperCase();
state = CliC.STATE_EQUAL; state = CliC.STATE_EQUAL;
} else if (c == '/') { } else if (c === '/') {
this.qualifier[this.qualifierCount++] = this.qualifier[this.qualifierCount++] =
cmd.substring(start_pos, i).toUpperCase(); cmd.substring(start_pos, i).toUpperCase();
state = CliC.STATE_QUAL; state = CliC.STATE_QUAL;
...@@ -173,11 +173,11 @@ function Cli(cliTable) { ...@@ -173,11 +173,11 @@ function Cli(cliTable) {
} }
break; break;
case CliC.STATE_QUALVALUE: case CliC.STATE_QUALVALUE:
if (c == CliC.SPACE || c == CliC.TAB) { if (c === CliC.SPACE || c === CliC.TAB) {
this.qualValue[this.qualifierCount - 1] = this.qualValue[this.qualifierCount - 1] =
cmd.substring(start_pos, i); cmd.substring(start_pos, i);
state = CliC.STATE_SPACE; state = CliC.STATE_SPACE;
} else if (c == '/') { } else if (c === '/') {
this.qualValue[this.qualifierCount - 1] = this.qualValue[this.qualifierCount - 1] =
cmd.substring(start_pos, i); cmd.substring(start_pos, i);
state = CliC.STATE_QUAL; state = CliC.STATE_QUAL;
...@@ -185,7 +185,7 @@ function Cli(cliTable) { ...@@ -185,7 +185,7 @@ function Cli(cliTable) {
} }
break; break;
case CliC.STATE_QUALVALUE_EXACT: case CliC.STATE_QUALVALUE_EXACT:
if (c == '"') { if (c === '"') {
this.qualValue[this.qualifierCount - 1] = this.qualValue[this.qualifierCount - 1] =
cmd.substring(start_pos, i); cmd.substring(start_pos, i);
state = CliC.STATE_SPACE; state = CliC.STATE_SPACE;
...@@ -200,10 +200,10 @@ function Cli(cliTable) { ...@@ -200,10 +200,10 @@ function Cli(cliTable) {
start_pos = i; start_pos = i;
break; break;
case CliC.STATE_EQUAL: case CliC.STATE_EQUAL:
if (c == CliC.SPACE || c == CliC.TAB) { if (c === CliC.SPACE || c === CliC.TAB) {
break; break;
} }
if (c == '"') { if (c === '"') {
state = CliC.STATE_QUOTE_QUALVALUE; state = CliC.STATE_QUOTE_QUALVALUE;
} else { } else {
state = CliC.STATE_QUALVALUE; state = CliC.STATE_QUALVALUE;
...@@ -212,7 +212,7 @@ function Cli(cliTable) { ...@@ -212,7 +212,7 @@ function Cli(cliTable) {
break; break;
} }
if (state == CliC.STATE_ERROR) { if (state === CliC.STATE_ERROR) {
break; break;
} }
} }
...@@ -221,7 +221,7 @@ function Cli(cliTable) { ...@@ -221,7 +221,7 @@ function Cli(cliTable) {
case CliC.STATE_ERROR: case CliC.STATE_ERROR:
return ""; return "";
case CliC.STATE_VERB: case CliC.STATE_VERB:
if (this.verbCount == CliC.VERB_VECT_SIZE) { if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR; state = CliC.STATE_ERROR;
break; break;
} }
...@@ -233,7 +233,7 @@ function Cli(cliTable) { ...@@ -233,7 +233,7 @@ function Cli(cliTable) {
} }
break; break;
case CliC.STATE_VERB_EXACT: case CliC.STATE_VERB_EXACT:
if (this.verbCount == CliC.VERB_VECT_SIZE) { if (this.verbCount === CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR; state = CliC.STATE_ERROR;
break; break;
} }
...@@ -272,7 +272,7 @@ function Cli(cliTable) { ...@@ -272,7 +272,7 @@ function Cli(cliTable) {
if (this.verb[0].length > this.cliTable[i].command.length) { if (this.verb[0].length > this.cliTable[i].command.length) {
continue; continue;
} }
if (this.verb[0] == if (this.verb[0] ===
(this.cliTable[i].command.substring(0, this.verb[0].length))) { (this.cliTable[i].command.substring(0, this.verb[0].length))) {
this.verb[0] = this.cliTable[i].command; this.verb[0] = this.cliTable[i].command;
found = true; found = true;
...@@ -291,19 +291,19 @@ function Cli(cliTable) { ...@@ -291,19 +291,19 @@ function Cli(cliTable) {
if (this.cliTable[this.cliTableIndex].qualifier[i] === null) { if (this.cliTable[this.cliTableIndex].qualifier[i] === null) {
break; break;
} }
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg1")) { if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg1")) {
this.configuredVerbs++; this.configuredVerbs++;
} }
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg2")) { if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg2")) {
this.configuredVerbs++; this.configuredVerbs++;
} }
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg3")) { if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg3")) {
this.configuredVerbs++; this.configuredVerbs++;
} }
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg4")) { if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg4")) {
this.configuredVerbs++; this.configuredVerbs++;
} }
if (this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg5")) { if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg5")) {
this.configuredVerbs++; this.configuredVerbs++;
} }
} }
...@@ -319,7 +319,7 @@ function Cli(cliTable) { ...@@ -319,7 +319,7 @@ function Cli(cliTable) {
this.cliTable[this.cliTableIndex].qualifier[i].length) { this.cliTable[this.cliTableIndex].qualifier[i].length) {
continue; continue;
} }
if (this.qualifier[j] == if (this.qualifier[j] ===
(this.cliTable[this.cliTableIndex].qualifier[i].substring(0, (this.cliTable[this.cliTableIndex].qualifier[i].substring(0,
this.qualifier[j].length))) { this.qualifier[j].length))) {
this.cliQualifierIndex[j] = i; this.cliQualifierIndex[j] = i;
...@@ -346,32 +346,20 @@ function Cli(cliTable) { ...@@ -346,32 +346,20 @@ function Cli(cliTable) {
*/ */
this.qualifierFound = function (qual) { this.qualifierFound = function (qual) {
if (qual == ("cli_arg1")) { if (qual === ("cli_arg1")) {
if (this.verbCount < 2 || this.configuredVerbs < 1) { return !(this.verbCount < 2 || this.configuredVerbs < 1);
return false;
}
return true;
} }
if (qual == ("cli_arg2")) { if (qual === ("cli_arg2")) {
if (this.verbCount < 3 || this.configuredVerbs < 2) { return !(this.verbCount < 3 || this.configuredVerbs < 2);
return false;
}
return true;
} }
if (qual == ("cli_arg3")) { if (qual === ("cli_arg3")) {
if (this.verbCount < 4 || this.configuredVerbs < 3) { return !(this.verbCount < 4 || this.configuredVerbs < 3);
return false;
}
return true;
} }
if (qual == ("cli_arg4")) { if (qual === ("cli_arg4")) {
if (this.verbCount < 5 || this.configuredVerbs < 4) { return !(this.verbCount < 5 || this.configuredVerbs < 4);
return false;
}
return true;
} }
for (var i = 0; i < this.qualifierCount; i++) { for (var i = 0; i < this.qualifierCount; i++) {
if (qual == (this.qualifier[i])) { if (qual === (this.qualifier[i])) {
return true; return true;
} }
} }
...@@ -384,31 +372,31 @@ function Cli(cliTable) { ...@@ -384,31 +372,31 @@ function Cli(cliTable) {
* @return Returns the value of the qualifier. * @return Returns the value of the qualifier.
*/ */
this.getQualValue = function (qual) { this.getQualValue = function (qual) {
if (qual == ("cli_arg1")) { if (qual === ("cli_arg1")) {
if (this.verbCount < 2 || this.configuredVerbs < 1) { if (this.verbCount < 2 || this.configuredVerbs < 1) {
return ""; return "";
} }
return this.verb[1]; return this.verb[1];
} }
if (qual == ("cli_arg2")) { if (qual === ("cli_arg2")) {
if (this.verbCount < 3 || this.configuredVerbs < 2) { if (this.verbCount < 3 || this.configuredVerbs < 2) {
return ""; return "";
} }
return this.verb[2]; return this.verb[2];
} }
if (qual == ("cli_arg3")) { if (qual === ("cli_arg3")) {
if (this.verbCount < 4 || this.configuredVerbs < 3) { if (this.verbCount < 4 || this.configuredVerbs < 3) {
return this.verb[3]; return this.verb[3];
} }
} }
if (qual == ("cli_arg4")) { if (qual === ("cli_arg4")) {
if (this.verbCount < 5 || this.configuredVerbs < 4) { if (this.verbCount < 5 || this.configuredVerbs < 4) {
return ""; return "";
} }
return this.verb[4]; return this.verb[4];
} }
for (var i = 0; i < this.qualifierCount; i++) { for (var i = 0; i < this.qualifierCount; i++) {
if (qual == (this.qualifier[i])) { if (qual === (this.qualifier[i])) {
if (this.qualValue[i] === null) { if (this.qualValue[i] === null) {
return ""; return "";
} else { } else {
......
...@@ -200,7 +200,7 @@ function Gdh() { ...@@ -200,7 +200,7 @@ function Gdh() {
}; };
this.ws.onmessage = function (e) { this.ws.onmessage = function (e) {
if (typeof e.data == "string") { if (typeof e.data === "string") {
console.log("String message received", e, e.data); console.log("String message received", e, e.data);
} else { } else {
if (e.data instanceof ArrayBuffer) { if (e.data instanceof ArrayBuffer) {
...@@ -322,7 +322,7 @@ function Gdh() { ...@@ -322,7 +322,7 @@ function Gdh() {
var esize = dv.getUint32(j); var esize = dv.getUint32(j);
j += 4; j += 4;
var sub = this.gdh.sub[eid]; var sub = this.gdh.sub[eid];
if (typeof sub == 'undefined') { if (typeof sub === 'undefined') {
j += esize; j += esize;
} else { } else {
var value; var value;
...@@ -333,7 +333,7 @@ function Gdh() { ...@@ -333,7 +333,7 @@ function Gdh() {
j += 1; j += 1;
} else { } else {
var elements = esize; var elements = esize;
if (elements != sub.elements) { if (elements !== sub.elements) {
console.log("Subscription size error", elements, console.log("Subscription size error", elements,
sub.elements, eid); sub.elements, eid);
} }
...@@ -350,7 +350,7 @@ function Gdh() { ...@@ -350,7 +350,7 @@ function Gdh() {
j += 4; j += 4;
} else { } else {
var elements = esize / 4; var elements = esize / 4;
if (elements != sub.elements) { if (elements !== sub.elements) {
console.log("Subscription size error", elements, console.log("Subscription size error", elements,
sub.elements, eid); sub.elements, eid);
} }
...@@ -377,7 +377,7 @@ function Gdh() { ...@@ -377,7 +377,7 @@ function Gdh() {
j += 4; j += 4;
} else { } else {
var elements = esize / 4; var elements = esize / 4;
if (elements != sub.elements) { if (elements !== sub.elements) {
console.log("Subscription size error", elements, console.log("Subscription size error", elements,
sub.elements, eid); sub.elements, eid);
} }
...@@ -403,7 +403,7 @@ function Gdh() { ...@@ -403,7 +403,7 @@ function Gdh() {
value = String.fromCharCode.apply(null, iarr); value = String.fromCharCode.apply(null, iarr);
} else { } else {
var elements = sub.elements; var elements = sub.elements;
if (elements != sub.elements) { if (elements !== sub.elements) {
console.log("Subscription size error", elements, console.log("Subscription size error", elements,
sub.elements, eid); sub.elements, eid);
} }
...@@ -425,7 +425,7 @@ function Gdh() { ...@@ -425,7 +425,7 @@ function Gdh() {
this.gdh.sub[eid].value = value; 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); console.log("** GetObjectRefInfoAll received removed", id);
break; break;
} }
...@@ -953,9 +953,7 @@ function Gdh() { ...@@ -953,9 +953,7 @@ function Gdh() {
sub.elements = elements; sub.elements = elements;
this.sub[this.subscriptionCount] = sub; this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++; this.subscriptionCount++;
if (!this.listSent) { if (this.listSent) {
return sub.refid;
} else {
var size = 0; var size = 0;
var len = 0; var len = 0;
...@@ -997,6 +995,8 @@ function Gdh() { ...@@ -997,6 +995,8 @@ function Gdh() {
this.next_id++; this.next_id++;
return sub.refid;
} else {
return sub.refid; return sub.refid;
} }
}; };
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ function PwrtStatus(sts) { ...@@ -17,7 +17,7 @@ function PwrtStatus(sts) {
return (sts % 2 === 0); return (sts % 2 === 0);
}; };
this.oddSts = function () { this.oddSts = function () {
return (sts % 2 == 1); return (sts % 2 === 1);
}; };
this.getSts = function () { this.getSts = function () {
return sts; return sts;
...@@ -178,7 +178,7 @@ function CdhrNumber(value, sts) { ...@@ -178,7 +178,7 @@ function CdhrNumber(value, sts) {
return (sts % 2 === 0); return (sts % 2 === 0);
}; };
this.oddSts = function () { this.oddSts = function () {
return (sts % 2 == 1); return (sts % 2 === 1);
}; };
this.getSts = function () { this.getSts = function () {
return sts; return sts;
......
...@@ -84,7 +84,6 @@ function Ev() { ...@@ -84,7 +84,6 @@ function Ev() {
document.title = "Event List"; document.title = "Event List";
break; break;
default: default:
;
} }
this.priv = sessionStorage.getItem("pwr_privilege"); this.priv = sessionStorage.getItem("pwr_privilege");
...@@ -97,7 +96,7 @@ function Ev() { ...@@ -97,7 +96,7 @@ function Ev() {
this.ctx.gdh = new Gdh(); this.ctx.gdh = new Gdh();
this.ctx.gdh.open_cb = this.gdh_init_cb; 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) { this.ctx.gdraw.canvas.addEventListener("click", function (event) {
var y = event.pageY - self.ctx.gdraw.offset_top; var y = event.pageY - self.ctx.gdraw.offset_top;
...@@ -109,33 +108,33 @@ function Ev() { ...@@ -109,33 +108,33 @@ function Ev() {
} }
}); });
document.addEventListener("keydown", function (event) { document.addEventListener("keydown", function (event) {
if (event.keyCode == 40) { if (event.keyCode === 40) {
self.ctx.event_handler(Plow.eEvent_Key_Down); self.ctx.event_handler(Plow.eEvent_Key_Down);
event.preventDefault(); event.preventDefault();
} else if (event.keyCode == 39) { } else if (event.keyCode === 39) {
if (event.shiftKey) { if (event.shiftKey) {
self.ctx.event_handler(Plow.eEvent_Key_ShiftRight); self.ctx.event_handler(Plow.eEvent_Key_ShiftRight);
} else { } else {
self.ctx.event_handler(Plow.eEvent_Key_Right); self.ctx.event_handler(Plow.eEvent_Key_Right);
} }
event.preventDefault(); event.preventDefault();
} else if (event.keyCode == 37) { } else if (event.keyCode === 37) {
self.ctx.event_handler(Plow.eEvent_Key_Left); self.ctx.event_handler(Plow.eEvent_Key_Left);
event.preventDefault(); event.preventDefault();
} else if (event.keyCode == 38) { } else if (event.keyCode === 38) {
self.ctx.event_handler(Plow.eEvent_Key_Up); self.ctx.event_handler(Plow.eEvent_Key_Up);
event.preventDefault(); event.preventDefault();
} else if (event.keyCode == 82) { } else if (event.keyCode === 82) {
if (event.ctrlKey) { if (event.ctrlKey) {
self.ctx.event_handler(Plow.eEvent_Key_CtrlR); self.ctx.event_handler(Plow.eEvent_Key_CtrlR);
} }
event.preventDefault(); event.preventDefault();
} else if (event.keyCode == 76) { } else if (event.keyCode === 76) {
if (event.ctrlKey) { if (event.ctrlKey) {
self.ctx.event_handler(Plow.eEvent_Key_CtrlL); self.ctx.event_handler(Plow.eEvent_Key_CtrlL);
} }
event.preventDefault(); event.preventDefault();
} else if (event.keyCode == 71) { } else if (event.keyCode === 71) {
if (event.ctrlKey) { if (event.ctrlKey) {
self.ctx.event_handler(Plow.eEvent_Key_CtrlG); self.ctx.event_handler(Plow.eEvent_Key_CtrlG);
} }
...@@ -261,11 +260,11 @@ function Ev() { ...@@ -261,11 +260,11 @@ function Ev() {
} }
}); });
} };
this.is_authorized = function (access) { this.is_authorized = function (access) {
return (this.priv & access) ? true : false; return !!(this.priv & access);
} };
this.gdh_init_cb = function () { this.gdh_init_cb = function () {
if (self.priv == null) { if (self.priv == null) {
...@@ -276,7 +275,7 @@ function Ev() { ...@@ -276,7 +275,7 @@ function Ev() {
self.ctx.gdh.listSent = true; self.ctx.gdh.listSent = true;
self.trace_cyclic(); self.trace_cyclic();
} };
this.login_cb = function (id, data, sts, result) { this.login_cb = function (id, data, sts, result) {
console.log("Login:", sts, result); console.log("Login:", sts, result);
...@@ -296,7 +295,7 @@ function Ev() { ...@@ -296,7 +295,7 @@ function Ev() {
return; return;
} }
if (self.type == EvC.eType_AlarmList) { if (self.type === EvC.eType_AlarmList) {
self.ctx.set_nodraw(); self.ctx.set_nodraw();
for (var i = result.length - 1; i >= 0; i--) { for (var i = result.length - 1; i >= 0; i--) {
...@@ -348,7 +347,7 @@ function Ev() { ...@@ -348,7 +347,7 @@ function Ev() {
self.ctx.configure(); self.ctx.configure();
self.ctx.reset_nodraw(); self.ctx.reset_nodraw();
self.ctx.draw(); self.ctx.draw();
} else if (self.type == EvC.eType_EventList) { } else if (self.type === EvC.eType_EventList) {
self.ctx.set_nodraw(); self.ctx.set_nodraw();
for (var i = result.length - 1; i >= 0; i--) { for (var i = result.length - 1; i >= 0; i--) {
var e = result[i]; var e = result[i];
...@@ -372,17 +371,17 @@ function Ev() { ...@@ -372,17 +371,17 @@ function Ev() {
for (var o = this.ctx.get_first_object(); o !== null; for (var o = this.ctx.get_first_object(); o !== null;
o = this.ctx.get_next_object(o)) { o = this.ctx.get_next_object(o)) {
var item = o.get_userdata(); var item = o.get_userdata();
if (item.e.eventId.nix == event_id.nix && if (item.e.eventId.nix === event_id.nix &&
item.e.eventId.idx == event_id.idx) { item.e.eventId.idx === event_id.idx) {
return item; return item;
} }
} }
return null; return null;
} };
this.is_authorized = function (access) { this.is_authorized = function (access) {
return (this.priv & access) ? true : false; return !!(this.priv & access);
} };
this.ack = function () { this.ack = function () {
if (!this.is_authorized(Pwr.mAccess_RtEventsAck)) { if (!this.is_authorized(Pwr.mAccess_RtEventsAck)) {
...@@ -408,26 +407,28 @@ function Ev() { ...@@ -408,26 +407,28 @@ function Ev() {
} }
this.ctx.configure(); this.ctx.configure();
this.ctx.draw(); this.ctx.draw();
} };
this.ack_cb = function (id, data, sts) { this.ack_cb = function (id, data, sts) {
console.log("ack sts", sts); console.log("ack sts", sts);
} };
this.open_objectgraph_cb = function (id, data, sts, result) { this.open_objectgraph_cb = function (id, data, sts, result) {
if ((sts & 1) != 0) { if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
} else {
data.location.href = data.location.href =
"ge.html?graph=" + result.param1 + "&instance=" + result.fullname; "ge.html?graph=" + result.param1 + "&instance=" + result.fullname;
data.document.title = result.fullname; data.document.title = result.fullname;
} else {
data.document.write("Error status " + sts);
} }
} };
this.open_graph_cb = function (id, data, sts, result) { this.open_graph_cb = function (id, data, sts, result) {
if ((sts & 1) != 0) { if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
} else {
var idx = result.param1.indexOf('.'); var idx = result.param1.indexOf('.');
if (idx != -1) { if (idx !== -1) {
result.param1 = result.param1.substring(0, idx); result.param1 = result.param1.substring(0, idx);
} }
...@@ -438,18 +439,18 @@ function Ev() { ...@@ -438,18 +439,18 @@ function Ev() {
data.location.href = "ge.html?graph=" + result.param1 + instancestr; data.location.href = "ge.html?graph=" + result.param1 + instancestr;
data.document.title = result.param1; data.document.title = result.param1;
} else {
data.document.write("Error status " + sts);
} }
} };
this.open_plc_cb = function (id, data, sts, result) { this.open_plc_cb = function (id, data, sts, result) {
if ((sts & 1) != 0) { if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
} else {
var param1; var param1;
if (result.param1 !== "") { if (result.param1 === "") {
param1 = "&obj=" + result.param1;
} else {
param1 = ""; param1 = "";
} else {
param1 = "&obj=" + result.param1;
} }
console.log("flow.html?vid=" + result.objid.vid + "&oix=" + console.log("flow.html?vid=" + result.objid.vid + "&oix=" +
result.objid.oix + param1); result.objid.oix + param1);
...@@ -457,61 +458,59 @@ function Ev() { ...@@ -457,61 +458,59 @@ function Ev() {
"flow.html?vid=" + result.objid.vid + "&oix=" + result.objid.oix + "flow.html?vid=" + result.objid.vid + "&oix=" + result.objid.oix +
param1; param1;
data.document.title = "Trace " + result.fullname; data.document.title = "Trace " + result.fullname;
} else {
data.document.write("Error status " + sts);
} }
} };
this.open_navigator_cb = function (id, data, sts, result) { this.open_navigator_cb = function (id, data, sts, result) {
console.log("Open navigator", sts); console.log("Open navigator", sts);
if ((sts & 1) != 0) { if ((sts & 1) === 0) {
console.log("Error status " + sts);
} else {
localStorage.setItem("XttMethodNavigator", result.fullname); localStorage.setItem("XttMethodNavigator", result.fullname);
console.log("storage", localStorage.getItem("XttMethodNavigator")); console.log("storage", localStorage.getItem("XttMethodNavigator"));
} else {
console.log("Error status " + sts);
} }
} };
this.open_objectgraph_cb = function (id, data, sts, result) { this.open_objectgraph_cb = function (id, data, sts, result) {
if ((sts & 1) != 0) { if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
} else {
var classname = result.classname.toLowerCase(); var classname = result.classname.toLowerCase();
if (classname.substring(0, 1) == "$") { if (classname.substring(0, 1) === "$") {
classname = classname.substring(1); classname = classname.substring(1);
} }
var graphname = "pwr_c_" + classname; var graphname = "pwr_c_" + classname;
data.location.href = data.location.href =
"ge.html?graph=" + graphname + "&instance=" + result.fullname; "ge.html?graph=" + graphname + "&instance=" + result.fullname;
data.document.title = graphname + " " + result.fullname; data.document.title = graphname + " " + result.fullname;
} else {
data.document.write("Error status " + sts);
} }
} };
this.open_helpclass_cb = function (id, data, sts, result) { this.open_helpclass_cb = function (id, data, sts, result) {
if ((sts & 1) != 0) { if ((sts & 1) === 0) {
console.log("open_helpclass", result.param1);
var url = location.protocol + "//" + location.host + result.param1;
data.location.href = url;
} else {
data.document.write("Error status " + sts); data.document.write("Error status " + sts);
} else {
console.log("open_helpclass", result.param1);
data.location.href =
location.protocol + "//" + location.host + result.param1;
} }
} };
this.methods_init = function () { this.methods_init = function () {
localStorage.setItem("EvMethodNavigator", ""); localStorage.setItem("EvMethodNavigator", "");
} };
this.collapse = function () { this.collapse = function () {
this.ctx.set_nodraw(); this.ctx.set_nodraw();
for (var i = 0; i < this.ctx.a.size(); i++) { for (var i = 0; i < this.ctx.a.size(); i++) {
var node = this.ctx.a.get(i); var node = this.ctx.a.get(i);
if (node.level == 0) { if (node.level === 0) {
node.userdata.close(this); node.userdata.close(this);
} }
} }
this.ctx.reset_nodraw(); this.ctx.reset_nodraw();
this.ctx.draw(); this.ctx.draw();
} };
this.trace_cyclic = function () { this.trace_cyclic = function () {
self.ctx.gdh.mhSync(self.mhSyncIdx, self.sync_cb, self); self.ctx.gdh.mhSync(self.mhSyncIdx, self.sync_cb, self);
...@@ -650,7 +649,11 @@ function Ev() { ...@@ -650,7 +649,11 @@ function Ev() {
break; break;
case Plow.eEvent_Key_Down: { case Plow.eEvent_Key_Down: {
var o = self.ctx.get_select(); var o = self.ctx.get_select();
if (o != null) { if (o == null) {
o = self.ctx.a.a[0];
o.set_select(true);
o.set_invert(true);
} else {
var next = self.ctx.get_next_object(o); var next = self.ctx.get_next_object(o);
if (next != null) { if (next != null) {
o.set_select(false); o.set_select(false);
...@@ -661,10 +664,6 @@ function Ev() { ...@@ -661,10 +664,6 @@ function Ev() {
self.ctx.scroll(next.y_low, 0.10); self.ctx.scroll(next.y_low, 0.10);
} }
} }
} else {
o = self.ctx.a.a[0];
o.set_select(true);
o.set_invert(true);
} }
break; break;
...@@ -732,9 +731,9 @@ function Ev() { ...@@ -732,9 +731,9 @@ function Ev() {
var vars = query.split('&'); var vars = query.split('&');
var typestr = vars[0].substring(5); var typestr = vars[0].substring(5);
if (typestr == "event") { if (typestr === "event") {
type = EvC.eType_EventList; type = EvC.eType_EventList;
} else if (typestr == "block") { } else if (typestr === "block") {
type = EvC.eType_BlockList; type = EvC.eType_BlockList;
} else { } else {
type = EvC.eType_AlarmList; type = EvC.eType_AlarmList;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -12,7 +12,7 @@ function OpWindMenu() { ...@@ -12,7 +12,7 @@ function OpWindMenu() {
this.init = function () { this.init = function () {
this.host = window.location.hostname; this.host = window.location.hostname;
if (this.host == "") { if (this.host === "") {
this.host = "localhost"; this.host = "localhost";
} }
...@@ -22,8 +22,8 @@ function OpWindMenu() { ...@@ -22,8 +22,8 @@ function OpWindMenu() {
}; };
this.is_authorized = function (access) { this.is_authorized = function (access) {
return (this.priv & access) ? true : false; return !!(this.priv & access);
} };
this.get_opplace = function () { this.get_opplace = function () {
var query = window.location.search.substring(1); var query = window.location.search.substring(1);
...@@ -69,7 +69,7 @@ function OpWindMenu() { ...@@ -69,7 +69,7 @@ function OpWindMenu() {
document.getElementById("login_button") document.getElementById("login_button")
.addEventListener("click", function (event) { .addEventListener("click", function (event) {
if (document.getElementById("login_frame").style.visibility == if (document.getElementById("login_frame").style.visibility ===
'hidden') { 'hidden') {
document.getElementById("login_user").value = ""; document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = ""; document.getElementById("login_passw").value = "";
...@@ -85,7 +85,7 @@ function OpWindMenu() { ...@@ -85,7 +85,7 @@ function OpWindMenu() {
.addEventListener("click", function (event) { .addEventListener("click", function (event) {
var user = document.getElementById("login_user").value; var user = document.getElementById("login_user").value;
var passwd = document.getElementById("login_passw").value; var passwd = document.getElementById("login_passw").value;
if (user.trim() == "") { if (user.trim() === "") {
return; return;
} }
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility = 'hidden';
...@@ -150,66 +150,64 @@ function OpWindMenu() { ...@@ -150,66 +150,64 @@ function OpWindMenu() {
this.button_cb = function (text) { this.button_cb = function (text) {
if (self.info.enable_language && text == "Language") { if (self.info.enable_language && text === "Language") {
console.log("Language activated"); console.log("Language activated");
} else if (self.info.enable_alarmlist && text == "AlarmList") { } else if (self.info.enable_alarmlist && text === "AlarmList") {
console.log("AlarmList activated"); console.log("AlarmList activated");
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite | if (self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators | Pwr.mAccess_System | Pwr.mAccess_AllOperators | Pwr.mAccess_System |
Pwr.mAccess_Maintenance | Pwr.mAccess_Process | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Instrument))) { Pwr.mAccess_Instrument)) {
window.alert("Not authorized for this operation");
} else {
window.open("ev.html?list=alarm", "_blank"); window.open("ev.html?list=alarm", "_blank");
} else {
window.alert("Not authorized for this operation");
} }
} else if (self.info.enable_alarmlist && text == "EventList") { } else if (self.info.enable_alarmlist && text === "EventList") {
console.log("EventList activated"); console.log("EventList activated");
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite | if (self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators | Pwr.mAccess_System | Pwr.mAccess_AllOperators | Pwr.mAccess_System |
Pwr.mAccess_Maintenance | Pwr.mAccess_Process | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Instrument))) { Pwr.mAccess_Instrument)) {
window.alert("Not authorized for this operation");
} else {
window.open("ev.html?list=event", "_blank"); window.open("ev.html?list=event", "_blank");
} else {
window.alert("Not authorized for this operation");
} }
} else if (self.info.enable_eventlog && text == "EventLog") { } else if (self.info.enable_eventlog && text === "EventLog") {
console.log("EventLog activated"); console.log("EventLog activated");
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite | if (self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators | Pwr.mAccess_System | Pwr.mAccess_AllOperators | Pwr.mAccess_System |
Pwr.mAccess_Maintenance | Pwr.mAccess_Process | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Instrument))) { Pwr.mAccess_Instrument)) {
window.alert("Not authorized for this operation");
} else {
window.alert("Not yet implemented"); window.alert("Not yet implemented");
} else {
window.alert("Not authorized for this operation");
} }
} else if (self.info.enable_navigator && text == "Navigator") { } else if (self.info.enable_navigator && text === "Navigator") {
console.log("Navigator activated"); console.log("Navigator activated");
if (!(self.is_authorized(Pwr.mAccess_RtNavigator | Pwr.mAccess_System | if (self.is_authorized(Pwr.mAccess_RtNavigator | Pwr.mAccess_System |
Pwr.mAccess_Maintenance | Pwr.mAccess_Process | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Instrument))) { Pwr.mAccess_Instrument)) {
window.alert("Not authorized for this operation");
} else {
window.open("xtt.html", "_blank"); window.open("xtt.html", "_blank");
} else {
window.alert("Not authorized for this operation");
} }
} else if (!self.info.disable_help && text == "Help") { } else if (!self.info.disable_help && text === "Help") {
console.log("Help activated"); console.log("Help activated");
window.open("xtt_help_index.html", "_blank"); 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"); console.log("ProviewR activated");
window.open("http://www.proview.se", "_blank"); window.open("http://www.proview.se", "_blank");
} else { } else {
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite | if (self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators | Pwr.mAccess_System | Pwr.mAccess_AllOperators | Pwr.mAccess_System |
Pwr.mAccess_Maintenance | Pwr.mAccess_Process | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Instrument))) { Pwr.mAccess_Instrument)) {
window.alert("Not authorized for this operation");
} else {
for (var i = 0; i < self.info.buttons.length; i++) { 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); console.log("Found", self.info.buttons[i].text);
var name = self.info.buttons[i].name; var name = self.info.buttons[i].name;
var n = name.indexOf(".pwg"); var n = name.indexOf(".pwg");
if (n != -1) { if (n !== -1) {
name = name.substring(0, n); name = name.substring(0, n);
} }
var url = "ge.html?graph=" + name; var url = "ge.html?graph=" + name;
...@@ -218,6 +216,8 @@ function OpWindMenu() { ...@@ -218,6 +216,8 @@ function OpWindMenu() {
break; break;
} }
} }
} else {
window.alert("Not authorized for this operation");
} }
} }
}; };
......
This diff is collapsed.
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