Commit 07/08/2025

This commit is contained in:
2025-08-07 15:04:53 +07:00
parent 446f031535
commit eba4f7852e
12 changed files with 387 additions and 229 deletions

View File

@@ -1,20 +1,20 @@
$(document).ready(function() {
// Your code here
console.log('pocreceiver.js is ready!');
//console.log('pocreceiver.js is ready!');
const path = window.location.pathname;
const ws = new WebSocket('ws://' + window.location.host + path + '/ws');
ws.onopen = function() {
console.log('WebSocket connection opened');
//console.log('WebSocket connection opened');
$('#indicatorDisconnected').addClass('visually-hidden');
$('#indicatorConnected').removeClass('visually-hidden');
setInterval(function() {
sendCommand({ command: "getZelloStatus" });
}, 5000);
}, 1000);
};
ws.onmessage = function(event) {
console.log('WebSocket message received:', event.data);
//console.log('WebSocket message received:', event.data);
let msg = {};
try {
msg = JSON.parse(event.data);
@@ -25,13 +25,13 @@ $(document).ready(function() {
}
if (msg.reply === "getZelloStatus" && msg.data !== undefined && msg.data.length > 0) {
const zelloData = msg.data;
console.log('Zello Status Data:', zelloData);
$('#zelloStatus').text(zelloData.status);
//console.log('Zello Status Data:', zelloData);
$('#zelloStatus').text(zelloData);
}
};
ws.onclose = function() {
console.log('WebSocket connection closed');
//console.log('WebSocket connection closed');
$('#indicatorDisconnected').removeClass('visually-hidden');
$('#indicatorConnected').addClass('visually-hidden');
};