diff --git a/src/html/assets/js/connection.js b/src/html/assets/js/connection.js
index 97479ad..90950d0 100644
--- a/src/html/assets/js/connection.js
+++ b/src/html/assets/js/connection.js
@@ -5,16 +5,19 @@ console.log("Initializing websocket");
socket.onopen = () => {
console.log("WebSocket connected");
+ window.connected = true;
};
socket.onerror = (err) => {
console.error("WebSocket error:", err);
+ window.connected = false;
};
socket.onclose = () => {
console.log("WebSocket closed");
+ window.connected = false;
};
window.send_data = function(value){
@@ -23,7 +26,7 @@ window.send_data = function(value){
console.log("Sent data : "+value);
} else {
setTimeout(() => send_data(value),50)
- console.log("Failed to send_data, socket readyState = "+socket.readyState);
+ //console.log("Failed to send_data, socket readyState = "+socket.readyState);
}
}
diff --git a/src/html/assets/js/index.js b/src/html/assets/js/index.js
index 800f940..22cd1f9 100644
--- a/src/html/assets/js/index.js
+++ b/src/html/assets/js/index.js
@@ -1,10 +1,1004 @@
-document.addEventListener("DOMContentLoaded", function () {
- console.log("Index page loaded");
-
- send_data("Hello from Index.html")
+$(document).ready(function() {
+ console.log("index page loaded");
+ send_data(JSON.stringify({request: "GET_CONTACT_SETUP"}));
+
+ let $c1Index = $('#c1Index');
+ let $c2Index = $('#c2Index');
+ let $c3Index = $('#c3Index');
+ let $c4Index = $('#c4Index');
+ let $c5Index = $('#c5Index');
+ let $c6Index = $('#c6Index');
+ let $c7Index = $('#c7Index');
+ let $c8Index = $('#c8Index');
+
+ // Events for Contact Description clicks
+ // for changing contact Description
+ let $c1Description = $('#c1Description');
+ $c1Description.on('dblclick', () => {
+ let newDescription = prompt("Enter Description for Contact 1:", $c1Description.text());
+ if (ValidString(newDescription)) {
+ if (newDescription!== $c1Description.text()) {
+ // Send the new description to the server
+ // Example: send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", contact: "c1", description: newDescription}));
+ send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", args: {contact: "c1", description: newDescription}}));
+ $c1Description.text(newDescription);
+ }
+
+ }
+ });
+ let $c2Description = $('#c2Description');
+ $c2Description.on('dblclick', () => {
+ let newDescription = prompt("Enter Description for Contact 2:", $c2Description.text());
+ if (ValidString(newDescription)) {
+ if (newDescription !== $c2Description.text()) {
+ // Send the new description to the server
+ // Example: send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", contact: "c2", description: newDescription}));
+ send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", args: {contact: "c2", description: newDescription}}));
+ $c2Description.text(newDescription);
+ }
+ }
+ });
+ let $c3Description = $('#c3Description');
+ $c3Description.on('dblclick', () => {
+ let newDescription = prompt("Enter Description for Contact 3:", $c3Description.text());
+ if (ValidString(newDescription)) {
+ if (newDescription !== $c3Description.text()) {
+ // Send the new description to the server
+ // Example: send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", contact: "c3", description: newDescription}));
+ send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", args: {contact: "c3", description: newDescription}}));
+ $c3Description.text(newDescription);
+ }
+ }
+ });
+ let $c4Description = $('#c4Description');
+ $c4Description.on('dblclick', () => {
+ let newDescription = prompt("Enter Description for Contact 4:", $c4Description.text());
+ if (ValidString(newDescription)) {
+ if (newDescription !== $c4Description.text()) {
+ // Send the new description to the server
+ // Example: send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", contact: "c4", description: newDescription}));
+ send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", args: {contact: "c4", description: newDescription}}));
+ $c4Description.text(newDescription);
+ }
+ }
+ });
+ let $c5Description = $('#c5Description');
+ $c5Description.on('dblclick', () => {
+ let newDescription = prompt("Enter Description for Contact 5:", $c5Description.text());
+ if (ValidString(newDescription)) {
+ if (newDescription !== $c5Description.text()) {
+ // Send the new description to the server
+ // Example: send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", contact: "c5", description: newDescription}));
+ send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", args: {contact: "c5", description: newDescription}}));
+ $c5Description.text(newDescription);
+ }
+ }
+ });
+ let $c6Description = $('#c6Description');
+ $c6Description.on('dblclick', () => {
+ let newDescription = prompt("Enter Description for Contact 6:", $c6Description.text());
+ if (ValidString(newDescription)) {
+ if (newDescription !== $c6Description.text()) {
+ // Send the new description to the server
+ // Example: send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", contact: "c6", description: newDescription}));
+ send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", args: {contact: "c6", description: newDescription}}));
+ $c6Description.text(newDescription);
+ }
+ }
+ });
+
+ let $c7Description = $('#c7Description');
+ $c7Description.on('dblclick', () => {
+ let newDescription = prompt("Enter Description for Contact 7:", $c7Description.text());
+ if (ValidString(newDescription)) {
+ if (newDescription !== $c7Description.text()) {
+ // Send the new description to the server
+ // Example: send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", contact: "c7", description: newDescription}));
+ send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", args: {contact: "c7", description: newDescription}}));
+ $c7Description.text(newDescription);
+ }
+ }
+ });
+ let $c8Description = $('#c8Description');
+ $c8Description.on('dblclick', () => {
+ let newDescription = prompt("Enter Description for Contact 8:", $c8Description.text());
+ if (ValidString(newDescription)) {
+ if (newDescription !== $c8Description.text()) {
+ // Send the new description to the server
+ // Example: send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", contact: "c8", description: newDescription}));
+ send_data(JSON.stringify({request: "SET_CONTACT_DESCRIPTION", args: {contact: "c8", description: newDescription}}));
+ $c8Description.text(newDescription);
+ }
+ }
+ });
+
+ let $c1Email = $('#c1Email');
+ $c1Email.on('dblclick', () => {
+ ShowModal('emailModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_EMAIL", args: {contact: "c1", email: result}}));
+ $c1Email.text(result);
+ })
+ });
+ let $c2Email = $('#c2Email');
+ $c2Email.on('dblclick', () => {
+ ShowModal('emailModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_EMAIL", args: {contact: "c2", email: result}}));
+ $c2Email.text(result);
+ })
+ });
+ let $c3Email = $('#c3Email');
+ $c3Email.on('dblclick', () => {
+ ShowModal('emailModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_EMAIL", args: {contact: "c3", email: result}}));
+ $c3Email.text(result);
+ })
+ });
+ let $c4Email = $('#c4Email');
+ $c4Email.on('dblclick', () => {
+ ShowModal('emailModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_EMAIL", args: {contact: "c4", email: result}}));
+ $c4Email.text(result);
+ })
+ });
+ let $c5Email = $('#c5Email');
+ $c5Email.on('dblclick', () => {
+ ShowModal('emailModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_EMAIL", args: {contact: "c5", email: result}}));
+ $c5Email.text(result);
+ })
+ });
+ let $c6Email = $('#c6Email');
+ $c6Email.on('dblclick', () => {
+ ShowModal('emailModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_EMAIL", args: {contact: "c6", email: result}}));
+ $c6Email.text(result);
+ })
+ });
+ let $c7Email = $('#c7Email');
+ $c7Email.on('dblclick', () => {
+ ShowModal('emailModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_EMAIL", args: {contact: "c7", email: result}}));
+ $c7Email.text(result);
+ })
+ });
+ let $c8Email = $('#c8Email');
+ $c8Email.on('dblclick', () => {
+ ShowModal('emailModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_EMAIL", args: {contact: "c8", email: result}}));
+ $c8Email.text(result);
+ })
+ });
+
+ let $c1Modbus = $('#c1Modbus');
+ $c1Modbus.on('dblclick', () => {
+ ShowModal('modbusModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MODBUS", args: {contact: "c1", modbus: result}}));
+ $c1Modbus.text(result);
+ })
+ });
+ let $c2Modbus = $('#c2Modbus');
+ $c2Modbus.on('dblclick', () => {
+ ShowModal('modbusModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MODBUS", args: {contact: "c2", modbus: result}}));
+ $c2Modbus.text(result);
+ })
+ });
+ let $c3Modbus = $('#c3Modbus');
+ $c3Modbus.on('dblclick', () => {
+ ShowModal('modbusModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MODBUS", args: {contact: "c3", modbus: result}}));
+ $c3Modbus.text(result);
+ })
+ });
+ let $c4Modbus = $('#c4Modbus');
+ $c4Modbus.on('dblclick', () => {
+ ShowModal('modbusModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MODBUS", args: {contact: "c4", modbus: result}}));
+ $c4Modbus.text(result);
+ })
+ });
+ let $c5Modbus = $('#c5Modbus');
+ $c5Modbus.on('dblclick', () => {
+ ShowModal('modbusModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MODBUS", args: {contact: "c5", modbus: result}}));
+ $c5Modbus.text(result);
+ })
+ });
+ let $c6Modbus = $('#c6Modbus');
+ $c6Modbus.on('dblclick', () => {
+ ShowModal('modbusModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MODBUS", args: {contact: "c6", modbus: result}}));
+ $c6Modbus.text(result);
+ })
+ });
+ let $c7Modbus = $('#c7Modbus');
+ $c7Modbus.on('dblclick', () => {
+ ShowModal('modbusModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MODBUS", args: {contact: "c7", modbus: result}}));
+ $c7Modbus.text(result);
+ })
+ });
+ let $c8Modbus = $('#c8Modbus');
+ $c8Modbus.on('dblclick', () => {
+ ShowModal('modbusModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MODBUS", args: {contact: "c8", modbus: result}}));
+ $c8Modbus.text(result);
+ })
+ });
+
+ let $c1VX3K = $('#c1VX3K');
+ $c1VX3K.on('dblclick', () => {
+ ShowModal('vx3kModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_VX3K", args: {contact: "c1", vx3k: result}}));
+ $c1VX3K.text(result);
+ })
+ });
+ let $c2VX3K = $('#c2VX3K');
+ $c2VX3K.on('dblclick', () => {
+ ShowModal('vx3kModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_VX3K", args: {contact: "c2", vx3k: result}}));
+ $c2VX3K.text(result);
+ })
+ });
+ let $c3VX3K = $('#c3VX3K');
+ $c3VX3K.on('dblclick', () => {
+ ShowModal('vx3kModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_VX3K", args: {contact: "c3", vx3k: result}}));
+ $c3VX3K.text(result);
+ })
+ });
+ let $c4VX3K = $('#c4VX3K');
+ $c4VX3K.on('dblclick', () => {
+ ShowModal('vx3kModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_VX3K", args: {contact: "c4", vx3k: result}}));
+ $c4VX3K.text(result);
+ })
+ });
+ let $c5VX3K = $('#c5VX3K');
+ $c5VX3K.on('dblclick', () => {
+ ShowModal('vx3kModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_VX3K", args: {contact: "c5", vx3k: result}}));
+ $c5VX3K.text(result);
+ })
+ });
+ let $c6VX3K = $('#c6VX3K');
+ $c6VX3K.on('dblclick', () => {
+ ShowModal('vx3kModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_VX3K", args: {contact: "c6", vx3k: result}}));
+ $c6VX3K.text(result);
+ })
+ });
+ let $c7VX3K = $('#c7VX3K');
+ $c7VX3K.on('dblclick', () => {
+ ShowModal('vx3kModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_VX3K", args: {contact: "c7", vx3k: result}}));
+ $c7VX3K.text(result);
+ })
+ });
+ let $c8VX3K = $('#c8VX3K');
+ $c8VX3K.on('dblclick', () => {
+ ShowModal('vx3kModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_VX3K", args: {contact: "c8", vx3k: result}}));
+ $c8VX3K.text(result);
+ })
+ });
+
+ let $c1Mqtt = $('#c1Mqtt');
+ $c1Mqtt.on('dblclick', () => {
+ ShowModal('mqttModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MQTT", args: {contact: "c1", mqtt: result}}));
+ $c1Mqtt.text(result);
+ })
+ });
+ let $c2Mqtt = $('#c2Mqtt');
+ $c2Mqtt.on('dblclick', () => {
+ ShowModal('mqttModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MQTT", args: {contact: "c2", mqtt: result}}));
+ $c2Mqtt.text(result);
+ })
+ });
+ let $c3Mqtt = $('#c3Mqtt');
+ $c3Mqtt.on('dblclick', () => {
+ ShowModal('mqttModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MQTT", args: {contact: "c3", mqtt: result}}));
+ $c3Mqtt.text(result);
+ })
+ });
+ let $c4Mqtt = $('#c4Mqtt');
+ $c4Mqtt.on('dblclick', () => {
+ ShowModal('mqttModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MQTT", args: {contact: "c4", mqtt: result}}));
+ $c4Mqtt.text(result);
+ })
+ });
+ let $c5Mqtt = $('#c5Mqtt');
+ $c5Mqtt.on('dblclick', () => {
+ ShowModal('mqttModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MQTT", args: {contact: "c5", mqtt: result}}));
+ $c5Mqtt.text(result);
+ })
+ });
+ let $c6Mqtt = $('#c6Mqtt');
+ $c6Mqtt.on('dblclick', () => {
+ ShowModal('mqttModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MQTT", args: {contact: "c6", mqtt: result}}));
+ $c6Mqtt.text(result);
+ })
+ });
+ let $c7Mqtt = $('#c7Mqtt');
+ $c7Mqtt.on('dblclick', () => {
+ ShowModal('mqttModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MQTT", args: {contact: "c7", mqtt: result}}));
+ $c7Mqtt.text(result);
+ })
+ });
+ let $c8Mqtt = $('#c8Mqtt');
+ $c8Mqtt.on('dblclick', () => {
+ ShowModal('mqttModal')
+ .then((result) => {
+ send_data(JSON.stringify({request: "SET_CONTACT_MQTT", args: {contact: "c8", mqtt: result}}));
+ $c8Mqtt.text(result);
+ })
+ });
+
+
socket.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log("Received from server:", data);
+ switch (data.response) {
+ case "GET_CONTACT_SETUP":
+ // Update the contact setup display
+ // Example: $('#contactSetup').text(data.args.contactSetup);
+ $c1Description.text(GetContactInputData_Description(data, 'c1'));
+ $c2Description.text(GetContactInputData_Description(data, 'c2'));
+ $c3Description.text(GetContactInputData_Description(data, 'c3'));
+ $c4Description.text(GetContactInputData_Description(data, 'c4'));
+ $c5Description.text(GetContactInputData_Description(data, 'c5'));
+ $c6Description.text(GetContactInputData_Description(data, 'c6'));
+ $c7Description.text(GetContactInputData_Description(data, 'c7'));
+ $c8Description.text(GetContactInputData_Description(data, 'c8'));
+ if (GetContactInputData_EnableEmail(data, 'c1')) {
+ $c1Email.text(GetContactInputData_EmailRecipient(data, 'c1'));
+ } else $c1Email.text("N/A");
+ if (GetContactInputData_EnableEmail(data, 'c2')) {
+ $c2Email.text(GetContactInputData_EmailRecipient(data, 'c2'));
+ } else $c2Email.text("N/A");
+ if (GetContactInputData_EnableEmail(data, 'c3')) {
+ $c3Email.text(GetContactInputData_EmailRecipient(data, 'c3'));
+ } else $c3Email.text("N/A");
+ if (GetContactInputData_EnableEmail(data, 'c4')) {
+ $c4Email.text(GetContactInputData_EmailRecipient(data, 'c4'));
+ } else $c4Email.text("N/A");
+ if (GetContactInputData_EnableEmail(data, 'c5')) {
+ $c5Email.text(GetContactInputData_EmailRecipient(data, 'c5'));
+ } else $c5Email.text("N/A");
+ if (GetContactInputData_EnableEmail(data, 'c6')) {
+ $c6Email.text(GetContactInputData_EmailRecipient(data, 'c6'));
+ } else $c6Email.text("N/A");
+ if (GetContactInputData_EnableEmail(data, 'c7')) {
+ $c7Email.text(GetContactInputData_EmailRecipient(data, 'c7'));
+ } else $c7Email.text("N/A");
+ if (GetContactInputData_EnableEmail(data, 'c8')) {
+ $c8Email.text(GetContactInputData_EmailRecipient(data, 'c8'));
+ } else $c8Email.text("N/A");
+ if (GetContactInputData_EnableModbus(data, 'c1')) {
+ $c1Modbus.text(GetContactInputData_ModbusRegister(data, 'c1'));
+ } else $c1Modbus.text("N/A");
+ if (GetContactInputData_EnableModbus(data, 'c2')) {
+ $c2Modbus.text(GetContactInputData_ModbusRegister(data, 'c2'));
+ } else $c2Modbus.text("N/A");
+ if (GetContactInputData_EnableModbus(data, 'c3')) {
+ $c3Modbus.text(GetContactInputData_ModbusRegister(data, 'c3'));
+ } else $c3Modbus.text("N/A");
+ if (GetContactInputData_EnableModbus(data, 'c4')) {
+ $c4Modbus.text(GetContactInputData_ModbusRegister(data, 'c4'));
+ } else $c4Modbus.text("N/A");
+ if (GetContactInputData_EnableModbus(data, 'c5')) {
+ $c5Modbus.text(GetContactInputData_ModbusRegister(data, 'c5'));
+ } else $c5Modbus.text("N/A");
+ if (GetContactInputData_EnableModbus(data, 'c6')) {
+ $c6Modbus.text(GetContactInputData_ModbusRegister(data, 'c6'));
+ } else $c6Modbus.text("N/A");
+ if (GetContactInputData_EnableModbus(data, 'c7')) {
+ $c7Modbus.text(GetContactInputData_ModbusRegister(data, 'c7'));
+ } else $c7Modbus.text("N/A");
+ if (GetContactInputData_EnableModbus(data, 'c8')) {
+ $c8Modbus.text(GetContactInputData_ModbusRegister(data, 'c8'));
+ } else $c8Modbus.text("N/A");
+ if (GetContactInputData_EnableVX3K(data, 'c1')) {
+ let _f = GetContactInputData_VX3KFrameID(data, 'c1');
+ let _c = GetContactInputData_VX3KContactID(data, 'c1');
+ if (ValidVX3KFrameID(_f) && ValidVX3KContactID(_c)) {
+ $c1VX3K.text(_f + ":" + _c);
+ } else $c1VX3K.text("N/A");
+ $c1VX3K.text(GetContactInputData_VX3KFrameID(data, 'c1') + " / " + GetContactInputData_VX3KContactID(data, 'c1'));
+ } else $c1VX3K.text("N/A");
+ if (GetContactInputData_EnableVX3K(data, 'c2')) {
+ let _f = GetContactInputData_VX3KFrameID(data, 'c2');
+ let _c = GetContactInputData_VX3KContactID(data, 'c2');
+ if (ValidVX3KFrameID(_f) && ValidVX3KContactID(_c)) {
+ $c2VX3K.text(_f + ":" + _c);
+ } else $c2VX3K.text("N/A");
+ } else $c2VX3K.text("N/A");
+ if (GetContactInputData_EnableVX3K(data, 'c3')) {
+ let _f = GetContactInputData_VX3KFrameID(data, 'c3');
+ let _c = GetContactInputData_VX3KContactID(data, 'c3');
+ if (ValidVX3KFrameID(_f) && ValidVX3KContactID(_c)) {
+ $c3VX3K.text(_f + ":" + _c);
+ } else $c3VX3K.text("N/A");
+ } else $c3VX3K.text("N/A");
+ if (GetContactInputData_EnableVX3K(data, 'c4')) {
+ let _f = GetContactInputData_VX3KFrameID(data, 'c4');
+ let _c = GetContactInputData_VX3KContactID(data, 'c4');
+ if (ValidVX3KFrameID(_f) && ValidVX3KContactID(_c)) {
+ $c4VX3K.text(_f + ":" + _c);
+ } else $c4VX3K.text("N/A");
+ } else $c4VX3K.text("N/A");
+ if (GetContactInputData_EnableVX3K(data, 'c5')) {
+ let _f = GetContactInputData_VX3KFrameID(data, 'c5');
+ let _c = GetContactInputData_VX3KContactID(data, 'c5');
+ if (ValidVX3KFrameID(_f) && ValidVX3KContactID(_c)) {
+ $c5VX3K.text(_f + ":" + _c);
+ } else $c5VX3K.text("N/A");
+ } else $c5VX3K.text("N/A");
+ if (GetContactInputData_EnableVX3K(data, 'c6')) {
+ let _f = GetContactInputData_VX3KFrameID(data, 'c6');
+ let _c = GetContactInputData_VX3KContactID(data, 'c6');
+ if (ValidVX3KFrameID(_f) && ValidVX3KContactID(_c)) {
+ $c6VX3K.text(_f + ":" + _c);
+ } else $c6VX3K.text("N/A");
+ } else $c6VX3K.text("N/A");
+ if (GetContactInputData_EnableVX3K(data, 'c7')) {
+ let _f = GetContactInputData_VX3KFrameID(data, 'c7');
+ let _c = GetContactInputData_VX3KContactID(data, 'c7');
+ if (ValidVX3KFrameID(_f) && ValidVX3KContactID(_c)) {
+ $c7VX3K.text(_f + ":" + _c);
+ } else $c7VX3K.text("N/A");
+ } else $c7VX3K.text("N/A");
+ if (GetContactInputData_EnableVX3K(data, 'c8')) {
+ let _f = GetContactInputData_VX3KFrameID(data, 'c8');
+ let _c = GetContactInputData_VX3KContactID(data, 'c8');
+ if (ValidVX3KFrameID(_f) && ValidVX3KContactID(_c)) {
+ $c8VX3K.text(_f + ":" + _c);
+ } else $c8VX3K.text("N/A");
+ } else $c8VX3K.text("N/A");
+ if (GetContactInputData_EnableMQTT(data, 'c1')) {
+ $c1Mqtt.text("Enabled");
+ } else $c1Mqtt.text("Disabled");
+ if (GetContactInputData_EnableMQTT(data, 'c2')) {
+ $c2Mqtt.text("Enabled");
+ } else $c2Mqtt.text("Disabled");
+ if (GetContactInputData_EnableMQTT(data, 'c3')) {
+ $c3Mqtt.text("Enabled");
+ } else $c3Mqtt.text("Disabled");
+ if (GetContactInputData_EnableMQTT(data, 'c4')) {
+ $c4Mqtt.text("Enabled");
+ } else $c4Mqtt.text("Disabled");
+ if (GetContactInputData_EnableMQTT(data, 'c5')) {
+ $c5Mqtt.text("Enabled");
+ } else $c5Mqtt.text("Disabled");
+ if (GetContactInputData_EnableMQTT(data, 'c6')) {
+ $c6Mqtt.text("Enabled");
+ } else $c6Mqtt.text("Disabled");
+ if (GetContactInputData_EnableMQTT(data, 'c7')) {
+ $c7Mqtt.text("Enabled");
+ } else $c7Mqtt.text("Disabled");
+ if (GetContactInputData_EnableMQTT(data, 'c8')) {
+ $c8Mqtt.text("Enabled");
+ } else $c8Mqtt.text("Disabled");
+
+ setInterval(() => {
+ // requesting update every second
+ send_data(JSON.stringify({request: "GET_CONTACT_STATUS"}));
+ }, 1000);
+ break;
+ case "GET_CONTACT_STATUS":
+ // Update the contact status display
+ // Example: $('#contactStatus').text(data.args.contactStatus);
+ if (GetContactStatus(data,'c1') == 1) {
+ $c1Index.css('background-color', 'green');
+ $c1Description.css('background-color', 'green');
+ } else {
+ $c1Index.css('background-color', '');
+ $c1Description.css('background-color', '');
+
+ }
+ if (GetContactStatus(data, 'c2') == 1) {
+ $c2Index.css('background-color', 'green');
+ $c2Description.css('background-color', 'green');
+ } else {
+ $c2Index.css('background-color', '');
+ $c2Description.css('background-color', '');
+ }
+ if (GetContactStatus(data,'c3') == 1) {
+ $c3Index.css('background-color', 'green');
+ $c3Description.css('background-color', 'green');
+ } else {
+ $c3Index.css('background-color', '');
+ $c3Description.css('background-color', '');
+ }
+ if (GetContactStatus(data, 'c4') == 1) {
+ $c4Index.css('background-color', 'green');
+ $c4Description.css('background-color', 'green');
+ } else {
+ $c4Index.css('background-color', '');
+ $c4Description.css('background-color', '');
+ }
+ if (GetContactStatus(data, 'c5') == 1) {
+ $c5Index.css('background-color', 'green');
+ $c5Description.css('background-color', 'green');
+ } else {
+ $c5Index.css('background-color', '');
+ $c5Description.css('background-color', '');
+ }
+ if (GetContactStatus(data, 'c6') == 1) {
+ $c6Index.css('background-color', 'green');
+ $c6Description.css('background-color', 'green');
+ } else {
+ $c6Index.css('background-color', '');
+ $c6Description.css('background-color', '');
+ }
+ if (GetContactStatus(data, 'c7') == 1) {
+ $c7Index.css('background-color', 'green');
+ $c7Description.css('background-color', 'green');
+ } else {
+ $c7Index.css('background-color', '');
+ $c7Description.css('background-color', '');
+ }
+ if (GetContactStatus(data, 'c8') == 1) {
+ $c8Index.css('background-color', 'green');
+ $c8Description.css('background-color', 'green');
+ } else {
+ $c8Index.css('background-color', '');
+ $c8Description.css('background-color', '');
+ }
+ break;
+ default:
+ console.error("Unknown response:", data);
+ }
+
};
-});
\ No newline at end of file
+
+
+
+
+
+
+});
+
+/**
+ * Show a modal dialog and return a promise that resolves when the save button is clicked or rejects when the close button is clicked.
+ * @param {string} modalId Modal ID to show
+ * @param {string} prevData Previous data to pre-fill the modal (if needed)
+ * @returns {Promise} Promise that resolves or rejects based on user action
+ */
+function ShowModal(modalId, prevData) {
+ return new Promise((resolve) => {
+ const $modal = $('#' + modalId);
+ const $btnSave = $modal.find('#btnSave');
+ const btnClose = $modal.find('#btnClose');
+
+ function cleanup(){
+ $btnSave.off('click', onSave);
+ btnClose.off('click', onClose);
+ }
+
+ function onSave() {
+ console.log("Save button clicked in modal: " + modalId);
+ switch (modalId) {
+ case 'emailModal':
+ $disableEmail = $modal.find('#disableEmail');
+ $enableEmail = $modal.find('#enableEmail');
+ $emailInput = $modal.find('#emailInput');
+
+ if ($disableEmail.is(':checked')) {
+ // Handle disabling email
+ resolve("Disabled");
+ } else if ($enableEmail.is(':checked')) {
+ // Handle enabling email
+ if (ValidEmail($emailInput.val())) {
+ resolve($emailInput.val());
+ } else {
+ alert("Please enter a valid email address.");
+ return;
+ }
+ }
+ break;
+ case 'mqttModal':
+ $disableMqtt = $modal.find('#disableMqtt');
+ $enableMqtt = $modal.find('#enableMqtt');
+ if ($disableMqtt.is(':checked')) {
+ // Handle disabling MQTT
+ resolve("Disabled");
+ } else if ($enableMqtt.is(':checked')) {
+ // Handle enabling MQTT
+ resolve("Enabled");
+ }
+ break;
+ case 'modbusModal':
+ $disableModbus = $modal.find('#disableModbus');
+ $enableModbus = $modal.find('#enableModbus');
+ $modbusRegister = $modal.find('#modbusRegister');
+ if ($disableModbus.is(':checked')) {
+ // Handle disabling Modbus
+ resolve("Disabled");
+ } else if ($enableModbus.is(':checked')) {
+ // Handle enabling Modbus
+ if (ValidModbusRegister($modbusRegister.val())) {
+ resolve($modbusRegister.val());
+ } else {
+ alert("Please enter a valid Modbus register.");
+ return;
+ }
+ }
+ break;
+ case 'vx3kModal':
+ $disableVX3K = $modal.find('#disableVX3K');
+ $enableVX3K = $modal.find('#enableVX3K');
+ $VX3KFrameID = $modal.find('#VX3KFrameID');
+ $VX3KContactID = $modal.find('#VX3KContactID');
+ if ($disableVX3K.is(':checked')) {
+ // Handle disabling VX3K
+ resolve("Disabled");
+ } else if ($enableVX3K.is(':checked')) {
+ // Handle enabling VX3K
+ if (ValidVX3KFrameID($VX3KFrameID.val()) && ValidVX3KContactID($VX3KContactID.val())) {
+ resolve($VX3KFrameID.val() + ":" + $VX3KContactID.val());
+ } else {
+ alert("Please enter a valid VX3K Frame ID (0-39) and Contact ID (0-15).");
+ return;
+ }
+ }
+ break;
+
+ }
+
+ cleanup();
+ $modal.modal('hide');
+ }
+
+ function onClose() {
+ console.log("Close button clicked in modal: " + modalId);
+ cleanup();
+ $modal.modal('hide');
+ }
+
+ $btnSave.on('click', onSave);
+ btnClose.on('click', onClose);
+
+
+
+ $modal.on('shown.bs.modal', () => {
+ console.log("Modal shown: " + modalId);
+ switch (modalId) {
+ case 'emailModal':
+ $disableEmail = $modal.find('#disableEmail');
+ $enableEmail = $modal.find('#enableEmail');
+ $emailInput = $modal.find('#emailInput');
+ if (ValidEmail(prevData)) {
+ $disableEmail.prop('checked', false);
+ $enableEmail.prop('checked', true);
+ $emailInput.val(prevData);
+ $emailInput.prop('disabled', false);
+ } else {
+ $disableEmail.prop('checked', true);
+ $enableEmail.prop('checked', false);
+ $emailInput.val('');
+ $emailInput.prop('disabled', true);
+ }
+ $disableEmail.on('change', () => {
+ $emailInput.prop('disabled', $disableEmail.is(':checked'));
+ });
+
+ $enableEmail.on('change', () => {
+ $emailInput.prop('disabled', !$enableEmail.is(':checked'));
+ });
+
+ break;
+ case 'mqttModal':
+ $disableMqtt = $modal.find('#disableMqtt');
+ $enableMqtt = $modal.find('#enableMqtt');
+ if ("Enabled" === prevData) {
+ $disableMqtt.prop('checked', false);
+ $enableMqtt.prop('checked', true);
+ } else {
+ $disableMqtt.prop('checked', true);
+ $enableMqtt.prop('checked', false);
+ }
+
+ break;
+ case 'modbusModal':
+ $disableModbus = $modal.find('#disableModbus');
+ $enableModbus = $modal.find('#enableModbus');
+ $modbusRegister = $modal.find('#modbusRegister');
+ if (ValidModbusRegister(prevData)) {
+ $disableModbus.prop('checked', false);
+ $enableModbus.prop('checked', true);
+ $modbusRegister.val(prevData);
+ $modbusRegister.prop('disabled', false);
+ } else {
+ $disableModbus.prop('checked', true);
+ $enableModbus.prop('checked', false);
+ $modbusRegister.val('');
+ $modbusRegister.prop('disabled', true);
+ }
+ $disableModbus.on('change', () => {
+ $modbusRegister.prop('disabled', $disableModbus.is(':checked'));
+ });
+ $enableModbus.on('change', () => {
+ $modbusRegister.prop('disabled', !$enableModbus.is(':checked'));
+ });
+ break;
+ case 'vx3kModal':
+ $disableVX3K = $modal.find('#disableVX3K');
+ $enableVX3K = $modal.find('#enableVX3K');
+ $VX3KFrameID = $modal.find('#VX3KFrameID');
+ $VX3KContactID = $modal.find('#VX3KContactID');
+
+
+ if (ValidVX3KData(prevData)) {
+ const parts = prevData.split(':');
+ $disableVX3K.prop('checked', false);
+ $enableVX3K.prop('checked', true);
+ $VX3KFrameID.val(parts[0]);
+ $VX3KContactID.val(parts[1]);
+ $VX3KFrameID.prop('disabled', false);
+ $VX3KContactID.prop('disabled', false);
+
+ } else {
+ $disableVX3K.prop('checked', true);
+ $enableVX3K.prop('checked', false);
+ $VX3KFrameID.val('');
+ $VX3KContactID.val('');
+ $VX3KFrameID.prop('disabled', true);
+ $VX3KContactID.prop('disabled', true);
+ }
+
+ $disableVX3K.on('change', () => {
+ $VX3KFrameID.prop('disabled', $disableVX3K.is(':checked'));
+ $VX3KContactID.prop('disabled', $disableVX3K.is(':checked'));
+ });
+ $enableVX3K.on('change', () => {
+ $VX3KFrameID.prop('disabled', !$enableVX3K.is(':checked'));
+ $VX3KContactID.prop('disabled', !$enableVX3K.is(':checked'));
+ });
+ break;
+ }
+
+ });
+ $modal.modal('show');
+ });
+}
+
+/**
+ * Check if a string is valid (not empty or whitespace)
+ * @param {string} str String to validate
+ * @returns {boolean} true if valid, false otherwise
+ */
+function ValidString(str) {
+ return str && str.trim() !== '';
+}
+
+/**
+ * Validate an email address.
+ * @param {String} email Email address to validate
+ * @returns {boolean} true if valid, false otherwise
+ */
+function ValidEmail(email) {
+ const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+ return emailPattern.test(email);
+}
+
+/**
+ * Validate a Modbus register.
+ * @param {string} register Modbus register to validate
+ * @returns {boolean} true if valid, false otherwise
+ */
+function ValidModbusRegister(register) {
+ // Assuming Modbus register is a valid number or a valid string representation of a register
+ const registerPattern = /^\d+$/; // Only digits allowed for simplicity
+ return registerPattern.test(register);
+}
+
+/**
+ * Validate VX3K data format.
+ * @param {string} data data to validate, expected format is "frameID:contactID"
+ * @returns {boolean} true if valid, false otherwise
+ */
+function ValidVX3KData(data){
+ if (ValidString(data) && data.includes(':')) {
+ const parts = data.split(':');
+ if (parts.length === 2) {
+ return ValidVX3KFrameID(parts[0]) && ValidVX3KContactID(parts[1]);
+ }
+ }
+ return false;
+}
+
+
+
+/**
+ * Check if a VX3K Frame ID is valid. A valid VX3K Frame ID is actually number between 0 and 39.
+ * @param {string} frameID
+ * @returns {boolean} true if frameID is valid, false otherwise
+ */
+function ValidVX3KFrameID(frameID){
+ const id = parseInt(frameID, 10);
+ return !isNaN(id) && id >= 0 && id <= 39;
+}
+
+/**
+ * Check if a VX3K Contact ID is valid. A valid VX3K Contact ID is actually number between 0 and 15.
+ * @param {string} contactID
+ * @returns {boolean} true if contactID is valid, false otherwise
+ */
+function ValidVX3KContactID(contactID){
+ const id = parseInt(contactID, 10);
+ return !isNaN(id) && id >= 0 && id <= 15;
+}
+
+/**
+ * Get the contact status from the object. Object structure is expected to be:
+ * {
+ * args: {
+ * contactkey: {
+ * Status: 1 or 0
+ * }
+ * }
+ * @param {object} obj Object containing contact data
+ * @param {string} contactkey Contact key to check status for
+ * @returns {number} 1 if contact is active, 0 if not
+ */
+function GetContactStatus(obj, contactkey){
+ return obj?.args?.[contactkey]?.Status === 1 ? 1 : 0;
+}
+
+/**
+ * Get the ContactID from the object. Object structure is expected to be:
+ * {
+ * args: {
+ * contactkey: {
+ * ContactID: "some_id"
+ * }
+ * }
+ * @param {object} obj Object containing contact data
+ * @param {string} contactkey Contact key to retrieve ContactID for
+ * @returns {string} ContactID or N/A if not found
+ */
+function GetContactInputData_ContactID(obj, contactkey) {
+ return obj?.args?.[contactkey]?.ContactID || "N/A";
+}
+
+/**
+ * Get the Description from the object. Object structure is expected to be:
+ * {
+ * args: {
+ * contactkey: {
+ * Description: "some description"
+ * }
+ * }
+ * @param {object} obj Object containing contact data
+ * @param {string} contactkey Contact key to retrieve Description for
+ * @returns {string} Description or "N/A" if not found
+ */
+function GetContactInputData_Description(obj, contactkey) {
+ return obj?.args?.[contactkey]?.Description || "N/A";
+}
+
+/**
+ * Get the EnableEmail flag from the object. Object structure is expected to be:
+ * {
+ * args: {
+ * contactkey: {
+ * EnableEmail: true or false
+ * }
+ * }
+ * @param {object} obj
+ * @param {string} contactkey
+ * @returns {boolean} true if EnableEmail is set, false otherwise
+ */
+function GetContactInputData_EnableEmail(obj, contactkey) {
+ return obj?.args?.[contactkey]?.EnableEmail || false;
+}
+
+/**
+ * Get the EmailRecipient from the object. Object structure is expected to be:
+ * @param {object} obj
+ * @param {string} contactkey
+ * @returns {string} EmailRecipient or "N/A" if not found
+ */
+function GetContactInputData_EmailRecipient(obj, contactkey) {
+ return obj?.args?.[contactkey]?.EmailRecipient || "N/A";
+}
+
+/**
+ * Get the EnableMQTT flag from the object. Object structure is expected to be:
+ * @param {object} obj
+ * @param {string} contactkey
+ * @returns {boolean} true if EnableMQTT is set, false otherwise
+ */
+function GetContactInputData_EnableMQTT(obj, contactkey) {
+ return obj?.args?.[contactkey]?.EnableMQTT || false;
+}
+
+/**
+ * Get the EnableModbus flag from the object. Object structure is expected to be:
+ * @param {object} obj
+ * @param {string} contactkey
+ * @returns {boolean} true if EnableModbus is set, false otherwise
+ */
+function GetContactInputData_EnableModbus(obj, contactkey) {
+ return obj?.args?.[contactkey]?.EnableModbus || false;
+}
+
+/**
+ * Get the ModbusRegister from the object. Object structure is expected to be:
+ * @param {object} obj
+ * @param {string} contactkey
+ * @returns {string} ModbusRegister or "N/A" if not found
+ */
+function GetContactInputData_ModbusRegister(obj, contactkey) {
+ return obj?.args?.[contactkey]?.ModbusRegister || "N/A";
+}
+
+/**
+ * Get the EnableVX3K flag from the object. Object structure is expected to be:
+ * @param {object} obj
+ * @param {string} contactkey
+ * @returns {boolean} true if EnableVX3K is set, false otherwise
+ */
+function GetContactInputData_EnableVX3K(obj, contactkey) {
+ return obj?.args?.[contactkey]?.EnableVX3K || false;
+}
+
+/**
+ * Get the VX3KFrameID from the object. Object structure is expected to be:
+ * @param {object} obj
+ * @param {string} contactkey
+ * @returns {string} VX3KFrameID or "N/A" if not found
+ */
+function GetContactInputData_VX3KFrameID(obj, contactkey) {
+ return obj?.args?.[contactkey]?.VX3KFrameID || "N/A";
+}
+
+/**
+ * Get the VX3KContactID from the object. Object structure is expected to be:
+ * @param {object} obj
+ * @param {string} contactkey
+ * @returns {string} VX3KContactID or "N/A" if not found
+ */
+function GetContactInputData_VX3KContactID(obj, contactkey) {
+ return obj?.args?.[contactkey]?.VX3KContactID || "N/A";
+}
diff --git a/src/html/assets/js/jquery-3.7.1.min.js b/src/html/assets/js/jquery-3.7.1.min.js
new file mode 100644
index 0000000..7f37b5d
--- /dev/null
+++ b/src/html/assets/js/jquery-3.7.1.min.js
@@ -0,0 +1,2 @@
+/*! jQuery v3.7.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */
+!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue.toString,a=o.call(Object),le={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},C=ie.document,u={type:!0,src:!0,nonce:!0,noModule:!0};function m(e,t,n){var r,i,o=(n=n||C).createElement("script");if(o.text=e,t)for(r in u)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e}var t="3.7.1",l=/HTML$/i,ce=function(e,t){return new ce.fn.init(e,t)};function c(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!v(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+ge+")"+ge+"*"),x=new RegExp(ge+"|>"),j=new RegExp(g),A=new RegExp("^"+t+"$"),D={ID:new RegExp("^#("+t+")"),CLASS:new RegExp("^\\.("+t+")"),TAG:new RegExp("^("+t+"|[*])"),ATTR:new RegExp("^"+p),PSEUDO:new RegExp("^"+g),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ge+"*(even|odd|(([+-]|)(\\d*)n|)"+ge+"*(?:([+-]|)"+ge+"*(\\d+)|))"+ge+"*\\)|)","i"),bool:new RegExp("^(?:"+f+")$","i"),needsContext:new RegExp("^"+ge+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ge+"*((?:-\\d)?\\d*)"+ge+"*\\)|)(?=[^-]|$)","i")},N=/^(?:input|select|textarea|button)$/i,q=/^h\d$/i,L=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,H=/[+~]/,O=new RegExp("\\\\[\\da-fA-F]{1,6}"+ge+"?|\\\\([^\\r\\n\\f])","g"),P=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},M=function(){V()},R=J(function(e){return!0===e.disabled&&fe(e,"fieldset")},{dir:"parentNode",next:"legend"});try{k.apply(oe=ae.call(ye.childNodes),ye.childNodes),oe[ye.childNodes.length].nodeType}catch(e){k={apply:function(e,t){me.apply(e,ae.call(t))},call:function(e){me.apply(e,ae.call(arguments,1))}}}function I(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(V(e),e=e||T,C)){if(11!==p&&(u=L.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return k.call(n,a),n}else if(f&&(a=f.getElementById(i))&&I.contains(e,a)&&a.id===i)return k.call(n,a),n}else{if(u[2])return k.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&e.getElementsByClassName)return k.apply(n,e.getElementsByClassName(i)),n}if(!(h[t+" "]||d&&d.test(t))){if(c=t,f=e,1===p&&(x.test(t)||m.test(t))){(f=H.test(t)&&U(e.parentNode)||e)==e&&le.scope||((s=e.getAttribute("id"))?s=ce.escapeSelector(s):e.setAttribute("id",s=S)),o=(l=Y(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+Q(l[o]);c=l.join(",")}try{return k.apply(n,f.querySelectorAll(c)),n}catch(e){h(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return re(t.replace(ve,"$1"),e,n,r)}function W(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function F(e){return e[S]=!0,e}function $(e){var t=T.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function B(t){return function(e){return fe(e,"input")&&e.type===t}}function _(t){return function(e){return(fe(e,"input")||fe(e,"button"))&&e.type===t}}function z(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&R(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function X(a){return F(function(o){return o=+o,F(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function U(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function V(e){var t,n=e?e.ownerDocument||e:ye;return n!=T&&9===n.nodeType&&n.documentElement&&(r=(T=n).documentElement,C=!ce.isXMLDoc(T),i=r.matches||r.webkitMatchesSelector||r.msMatchesSelector,r.msMatchesSelector&&ye!=T&&(t=T.defaultView)&&t.top!==t&&t.addEventListener("unload",M),le.getById=$(function(e){return r.appendChild(e).id=ce.expando,!T.getElementsByName||!T.getElementsByName(ce.expando).length}),le.disconnectedMatch=$(function(e){return i.call(e,"*")}),le.scope=$(function(){return T.querySelectorAll(":scope")}),le.cssHas=$(function(){try{return T.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}}),le.getById?(b.filter.ID=function(e){var t=e.replace(O,P);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(O,P);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):t.querySelectorAll(e)},b.find.CLASS=function(e,t){if("undefined"!=typeof t.getElementsByClassName&&C)return t.getElementsByClassName(e)},d=[],$(function(e){var t;r.appendChild(e).innerHTML="",e.querySelectorAll("[selected]").length||d.push("\\["+ge+"*(?:value|"+f+")"),e.querySelectorAll("[id~="+S+"-]").length||d.push("~="),e.querySelectorAll("a#"+S+"+*").length||d.push(".#.+[+~]"),e.querySelectorAll(":checked").length||d.push(":checked"),(t=T.createElement("input")).setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),r.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&d.push(":enabled",":disabled"),(t=T.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||d.push("\\["+ge+"*name"+ge+"*="+ge+"*(?:''|\"\")")}),le.cssHas||d.push(":has"),d=d.length&&new RegExp(d.join("|")),l=function(e,t){if(e===t)return a=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!le.sortDetached&&t.compareDocumentPosition(e)===n?e===T||e.ownerDocument==ye&&I.contains(ye,e)?-1:t===T||t.ownerDocument==ye&&I.contains(ye,t)?1:o?se.call(o,e)-se.call(o,t):0:4&n?-1:1)}),T}for(e in I.matches=function(e,t){return I(e,null,null,t)},I.matchesSelector=function(e,t){if(V(e),C&&!h[t+" "]&&(!d||!d.test(t)))try{var n=i.call(e,t);if(n||le.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){h(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(O,P),e[3]=(e[3]||e[4]||e[5]||"").replace(O,P),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||I.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&I.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return D.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&j.test(n)&&(t=Y(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(O,P).toLowerCase();return"*"===e?function(){return!0}:function(e){return fe(e,t)}},CLASS:function(e){var t=s[e+" "];return t||(t=new RegExp("(^|"+ge+")"+e+"("+ge+"|$)"))&&s(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=I.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function T(e,n,r){return v(n)?ce.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?ce.grep(e,function(e){return e===n!==r}):"string"!=typeof n?ce.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(ce.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||k,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:S.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof ce?t[0]:t,ce.merge(this,ce.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:C,!0)),w.test(r[1])&&ce.isPlainObject(t))for(r in t)v(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=C.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==n.ready?n.ready(e):e(ce):ce.makeArray(e,this)}).prototype=ce.fn,k=ce(C);var E=/^(?:parents|prev(?:Until|All))/,j={children:!0,contents:!0,next:!0,prev:!0};function A(e,t){while((e=e[t])&&1!==e.nodeType);return e}ce.fn.extend({has:function(e){var t=ce(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,Ce=/^$|^module$|\/(?:java|ecma)script/i;xe=C.createDocumentFragment().appendChild(C.createElement("div")),(be=C.createElement("input")).setAttribute("type","radio"),be.setAttribute("checked","checked"),be.setAttribute("name","t"),xe.appendChild(be),le.checkClone=xe.cloneNode(!0).cloneNode(!0).lastChild.checked,xe.innerHTML="",le.noCloneChecked=!!xe.cloneNode(!0).lastChild.defaultValue,xe.innerHTML="",le.option=!!xe.lastChild;var ke={thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};function Se(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&fe(e,t)?ce.merge([e],n):n}function Ee(e,t){for(var n=0,r=e.length;n",""]);var je=/<|?\w+;/;function Ae(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function Re(e,t){return fe(e,"table")&&fe(11!==t.nodeType?t:t.firstChild,"tr")&&ce(e).children("tbody")[0]||e}function Ie(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function We(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Fe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(_.hasData(e)&&(s=_.get(e).events))for(i in _.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),C.head.appendChild(r[0])},abort:function(){i&&i()}}});var Jt,Kt=[],Zt=/(=)\?(?=&|$)|\?\?/;ce.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Kt.pop()||ce.expando+"_"+jt.guid++;return this[e]=!0,e}}),ce.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Zt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Zt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=v(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Zt,"$1"+r):!1!==e.jsonp&&(e.url+=(At.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||ce.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=ie[r],ie[r]=function(){o=arguments},n.always(function(){void 0===i?ce(ie).removeProp(r):ie[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Kt.push(r)),o&&v(i)&&i(o[0]),o=i=void 0}),"script"}),le.createHTMLDocument=((Jt=C.implementation.createHTMLDocument("").body).innerHTML="",2===Jt.childNodes.length),ce.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(le.createHTMLDocument?((r=(t=C.implementation.createHTMLDocument("")).createElement("base")).href=C.location.href,t.head.appendChild(r)):t=C),o=!n&&[],(i=w.exec(e))?[t.createElement(i[1])]:(i=Ae([e],t,o),o&&o.length&&ce(o).remove(),ce.merge([],i.childNodes)));var r,i,o},ce.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(ce.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},ce.expr.pseudos.animated=function(t){return ce.grep(ce.timers,function(e){return t===e.elem}).length},ce.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=ce.css(e,"position"),c=ce(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=ce.css(e,"top"),u=ce.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),v(t)&&(t=t.call(e,n,ce.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},ce.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){ce.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===ce.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===ce.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=ce(e).offset()).top+=ce.css(e,"borderTopWidth",!0),i.left+=ce.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-ce.css(r,"marginTop",!0),left:t.left-i.left-ce.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===ce.css(e,"position"))e=e.offsetParent;return e||J})}}),ce.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;ce.fn[t]=function(e){return M(this,function(e,t,n){var r;if(y(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),ce.each(["top","left"],function(e,n){ce.cssHooks[n]=Ye(le.pixelPosition,function(e,t){if(t)return t=Ge(e,n),_e.test(t)?ce(e).position()[n]+"px":t})}),ce.each({Height:"height",Width:"width"},function(a,s){ce.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){ce.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return M(this,function(e,t,n){var r;return y(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?ce.css(e,t,i):ce.style(e,t,n,i)},s,n?e:void 0,n)}})}),ce.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){ce.fn[t]=function(e){return this.on(t,e)}}),ce.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.on("mouseenter",e).on("mouseleave",t||e)}}),ce.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){ce.fn[n]=function(e,t){return 0 {
const data = JSON.parse(event.data);
console.log("Received from server:", data);
+ if (data.response === "GET_SETTING") {
+ $('#smtpServer').val(data.args.smtpServer);
+ $('#smtpPort').val(data.args.smtpPort);
+ $('#smtpUsername').val(data.args.smtpUsername);
+ $('#smtpPassword').val(data.args.smtpPassword);
+ $('#smtpSSL').prop('checked', data.args.smtpSSL);
+ $('#smtpSenderAddress').val(data.args.smtpSenderAddress);
+ $('#smtpSenderName').val(data.args.smtpSenderName);
+ $('#smtpSubject').val(data.args.smtpSubject);
+ $('#vx3kIP').val(data.args.vx3kIP);
+ $('#vx3kPort').val(data.args.vx3kPort);
+ $('#mqttBrokerIP').val(data.args.mqttBrokerIP);
+ $('#mqttPort').val(data.args.mqttPort);
+ $('#mqttUsername').val(data.args.mqttUsername);
+ $('#mqttPassword').val(data.args.mqttPassword);
+ $('#mqttClientID').val(data.args.mqttClientID);
+ $('#mqttTopic').val(data.args.mqttTopic);
+ } else if (data.response === "RESET_DEFAULT") {
+ alert(data.args);
+ } else if (data.response === "SET_SETTING") {
+ alert(data.args);
+ }
};
+
+ // first request to get settings
send_data(JSON.stringify({request:"GET_SETTING"}));
});
\ No newline at end of file
diff --git a/src/html/index.html b/src/html/index.html
index 840ca4d..4ae222c 100644
--- a/src/html/index.html
+++ b/src/html/index.html
@@ -25,7 +25,144 @@
+
+
+
+
+ | C-IN |
+ Description |
+ Email |
+ Modbus |
+ VX-3000 |
+ MQTT |
+
+
+
+
+ | 1 |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+
+
+ | 2 |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+
+
+ | 3 |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+
+
+ | 4 |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+
+
+ | 5 |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+
+
+ | 6 |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+
+
+ | 7 |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+
+
+ | 8 |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+ N/A |
+
+
+
+
+
+
+
+
+