Commit 285b780d authored by Christoffer Ackelman's avatar Christoffer Ackelman

JS: Autoformat files

parent 220549a4
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -98,36 +98,11 @@ var Pwr = { ...@@ -98,36 +98,11 @@ var Pwr = {
mAccess_RtEventsAck: 1 << 18, mAccess_RtEventsAck: 1 << 18,
mAccess_RtPlc: 1 << 19, mAccess_RtPlc: 1 << 19,
mAccess_RtNavigator: 1 << 20, mAccess_RtNavigator: 1 << 20,
mAccess_AllRt: 1 << 2 | mAccess_AllRt: 1 << 2 | 1 << 3 | 1 << 4 | 1 << 5 | 1 << 0 | 1 << 1 | 1 << 25 |
1 << 3 | 1 << 18 | 1 << 19 | 1 << 20 | 1 << 6 | 1 << 7 | 1 << 8 | 1 << 9 | 1 << 10 |
1 << 4 | 1 << 11 | 1 << 12 | 1 << 13 | 1 << 14 | 1 << 15,
1 << 5 | mAccess_AllOperators: 1 << 6 | 1 << 7 | 1 << 8 | 1 << 9 | 1 << 10 | 1 << 11 |
1 << 0 | 1 << 12 | 1 << 13 | 1 << 14 | 1 << 15,
1 << 1 |
1 << 25 |
1 << 18 |
1 << 19 |
1 << 20 |
1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllOperators: 1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllPwr: ~0, mAccess_AllPwr: ~0,
mAdef_pointer: 1, mAdef_pointer: 1,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
"use strict"; "use strict";
/** Start OpWind **/
function OpWindMenu() { function OpWindMenu() {
this.gdh = 0; this.gdh = 0;
this.buttons = null; this.buttons = null;
...@@ -14,8 +12,9 @@ function OpWindMenu() { ...@@ -14,8 +12,9 @@ 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";
}
this.gdh = new Gdh(); this.gdh = new Gdh();
this.gdh.open_cb = this.gdh_init_cb; this.gdh.open_cb = this.gdh_init_cb;
...@@ -48,7 +47,8 @@ function OpWindMenu() { ...@@ -48,7 +47,8 @@ function OpWindMenu() {
button.type = "button"; button.type = "button";
button.className = "leftmenu-button"; button.className = "leftmenu-button";
button.value = text; button.value = text;
button.addEventListener('click', new Function("menu.button_cb(\"" + button.value + "\")")); button.addEventListener('click',
new Function("menu.button_cb(\"" + button.value + "\")"));
context.appendChild(button); context.appendChild(button);
context.appendChild(document.createElement("br")); context.appendChild(document.createElement("br"));
return button; return button;
...@@ -67,24 +67,27 @@ function OpWindMenu() { ...@@ -67,24 +67,27 @@ function OpWindMenu() {
context.appendChild(self.user_text); context.appendChild(self.user_text);
context.appendChild(document.createElement("hr")); context.appendChild(document.createElement("hr"));
document.getElementById("login_button").addEventListener("click", function (event) { document.getElementById("login_button")
if (document.getElementById("login_frame").style.visibility == 'hidden') { .addEventListener("click", function (event) {
if (document.getElementById("login_frame").style.visibility ==
'hidden') {
document.getElementById("login_user").value = ""; document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = ""; document.getElementById("login_passw").value = "";
document.getElementById("login_frame").style.visibility = 'visible'; document.getElementById("login_frame").style.visibility = 'visible';
document.getElementById("login_frame").style.height = '120px'; document.getElementById("login_frame").style.height = '120px';
document.getElementById("login_user").focus(); document.getElementById("login_user").focus();
} } else {
else {
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height = '0px';
} }
}); });
document.getElementById("apply_button").addEventListener("click", function (event) { document.getElementById("apply_button")
.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';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height = '0px';
var c = new JopCrypt(); var c = new JopCrypt();
...@@ -93,11 +96,13 @@ function OpWindMenu() { ...@@ -93,11 +96,13 @@ function OpWindMenu() {
self.user = user; self.user = user;
self.gdh.login(user, passwd, self.login_cb, self); self.gdh.login(user, passwd, self.login_cb, self);
}); });
document.getElementById("cancel_button").addEventListener("click", function (event) { document.getElementById("cancel_button")
.addEventListener("click", function (event) {
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height = '0px';
}); });
document.getElementById("logout_button").addEventListener("click", function (event) { document.getElementById("logout_button")
.addEventListener("click", function (event) {
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height = '0px';
self.priv = 0; self.priv = 0;
...@@ -110,25 +115,29 @@ function OpWindMenu() { ...@@ -110,25 +115,29 @@ function OpWindMenu() {
//document.getElementById("login_frame").setAttribute("style", "visibility:hidden;height:10px"; //document.getElementById("login_frame").setAttribute("style", "visibility:hidden;height:10px";
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height = '0px';
} } else {
else {
document.getElementById("login_button").remove(); document.getElementById("login_button").remove();
document.getElementById("login_frame").remove(); document.getElementById("login_frame").remove();
} }
if (result.enable_language) if (result.enable_language) {
self.add_menu_button(context, "Language"); self.add_menu_button(context, "Language");
}
if (result.enable_alarmlist) { if (result.enable_alarmlist) {
self.add_menu_button(context, "AlarmList"); self.add_menu_button(context, "AlarmList");
self.add_menu_button(context, "EventList"); self.add_menu_button(context, "EventList");
} }
if (result.enable_eventlog) if (result.enable_eventlog) {
self.add_menu_button(context, "EventLog"); self.add_menu_button(context, "EventLog");
if (result.enable_navigator) }
if (result.enable_navigator) {
self.add_menu_button(context, "Navigator"); self.add_menu_button(context, "Navigator");
if (!result.disable_help) }
if (!result.disable_help) {
self.add_menu_button(context, "Help"); self.add_menu_button(context, "Help");
if (!result.disable_proview) }
if (!result.disable_proview) {
self.add_menu_button(context, "ProviewR"); self.add_menu_button(context, "ProviewR");
}
context.appendChild(document.createElement("hr")); context.appendChild(document.createElement("hr"));
...@@ -143,69 +152,66 @@ function OpWindMenu() { ...@@ -143,69 +152,66 @@ function OpWindMenu() {
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_AllOperators | Pwr.mAccess_System |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Instrument))) {
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else } else {
window.open("ev.html?list=alarm", "_blank"); window.open("ev.html?list=alarm", "_blank");
} }
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_AllOperators | Pwr.mAccess_System |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Instrument))) {
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else } else {
window.open("ev.html?list=event", "_blank"); window.open("ev.html?list=event", "_blank");
} }
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_AllOperators | Pwr.mAccess_System |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Instrument))) {
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else } else {
window.alert("Not yet implemented"); 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"); console.log("Navigator activated");
if (!(self.is_authorized(Pwr.mAccess_RtNavigator | if (!(self.is_authorized(Pwr.mAccess_RtNavigator | Pwr.mAccess_System |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Instrument))) {
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else } else {
window.open("xtt.html", "_blank"); 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"); 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_AllOperators | Pwr.mAccess_System |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_Maintenance | Pwr.mAccess_Process |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Instrument))) {
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else { } 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;
console.log("url", url); console.log("url", url);
window.open(url, "_blank"); window.open(url, "_blank");
...@@ -221,25 +227,22 @@ function OpWindMenu() { ...@@ -221,25 +227,22 @@ function OpWindMenu() {
if (sts & 1) { if (sts & 1) {
self.priv = result; self.priv = result;
sessionStorage.setItem("pwr_privilege", self.priv); sessionStorage.setItem("pwr_privilege", self.priv);
if (self.user_text != null) if (self.user_text != null) {
self.user_text.textContent = self.user + " on " + self.host; self.user_text.textContent = self.user + " on " + self.host;
}
console.log("Login", self.user, "Priv", self.priv); console.log("Login", self.user, "Priv", self.priv);
} } else {
else {
self.priv = 0; self.priv = 0;
self.user = "none"; self.user = "none";
sessionStorage.setItem("pwr_privilege", self.priv); sessionStorage.setItem("pwr_privilege", self.priv);
if (self.user_text != null) if (self.user_text != null) {
self.user_text.textContent = "None on " + self.host; self.user_text.textContent = "None on " + self.host;
}
console.log("Login failure", "Priv", self.priv); console.log("Login failure", "Priv", self.priv);
} }
}; };
} }
var menu = new OpWindMenu(); var menu = new OpWindMenu();
menu.init(); menu.init();
/** End OpWind **/
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