Commit 06/08/2025

This commit is contained in:
2025-08-06 09:29:14 +07:00
parent 8290418100
commit 158f3ea4c2
12 changed files with 345 additions and 23 deletions

View File

@@ -9,7 +9,7 @@ $(document).ready(function() {
$('#indicatorDisconnected').addClass('visually-hidden');
$('#indicatorConnected').removeClass('visually-hidden');
setInterval(function() {
ws.send(JSON.stringify({ command: "getZelloStatus" }));
sendCommand({ command: "getZelloStatus" });
}, 5000);
};
@@ -39,4 +39,12 @@ $(document).ready(function() {
ws.onerror = function(error) {
console.error('WebSocket error:', error);
};
function sendCommand(command) {
if (ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify(command));
} else {
console.error('WebSocket is not open. Unable to send command:', command);
}
}
});

View File

@@ -79,7 +79,7 @@ $(document).ready(function() {
function sendCommand(cmd) {
if (ws.readyState === WebSocket.OPEN) {
ws.send(cmd);
ws.send(JSON.stringify(cmd));
} else {
console.error('WebSocket is not open. Unable to send command:', JSON.stringify(cmd));
}

View File

@@ -40,23 +40,23 @@ $(document).ready(function() {
return;
}
if (msg.reply === "getConfig" && msg.data !== undefined ) {
const configData = msg.data;
const configData = JSON.parse(msg.data);
console.log('Config Data:', configData);
$('#zelloUsername').val(configData.ZelloUsername || '');
$('#zelloPassword').val(configData.ZelloPassword || '');
$('#zelloChannel').val(configData.ZelloChannel || '');
if ("community" === configData.ZelloServer) {
$('#zelloUsername').val(configData.zelloUsername || '');
$('#zelloPassword').val(configData.zelloPassword || '');
$('#zelloChannel').val(configData.zelloChannel || '');
if ("community" === configData.zelloServer) {
$('#zellocommunity').prop('checked', true);
$('#zelloWorkNetworkName').val('').prop('disabled', true);
$('#zelloEnterpriseServerDomain').val('').prop('disabled', true);
} else if ("work" === configData.ZelloServer) {
} else if ("work" === configData.zelloServer) {
$('#zellowork').prop('checked', true);
$('#zelloWorkNetworkName').val(configData.ZelloWorkNetworkName || '').prop('disabled', false);
$('#zelloWorkNetworkName').val(configData.zelloWorkNetworkName || '').prop('disabled', false);
$('#zelloEnterpriseServerDomain').val('').prop('disabled', true);
} else if ("enterprise" === configData.ZelloServer) {
} else if ("enterprise" === configData.zelloServer) {
$('#zelloenterprise').prop('checked', true);
$('#zelloWorkNetworkName').val('').prop('disabled', true);
$('#zelloEnterpriseServerDomain').val(configData.ZelloEnterpriseServerDomain || '').prop('disabled', false);
$('#zelloEnterpriseServerDomain').val(configData.zelloEnterpriseServerDomain || '').prop('disabled', false);
}
for (let i = 1; i <= 8; i++) {
@@ -72,8 +72,8 @@ $(document).ready(function() {
dropdownMenu.append(item);
});
// Set button text to selected message if present
if (configData[`M${i}`]) {
dropdownButton.text(configData[`M${i}`]);
if (configData[`m${i}`]) {
dropdownButton.text(configData[`m${i}`]);
} else {
dropdownButton.text('');
}
@@ -176,7 +176,7 @@ $(document).ready(function() {
function sendCommand(cmd) {
if (ws.readyState === WebSocket.OPEN) {
ws.send(cmd);
ws.send(JSON.stringify(cmd));
} else {
console.error('WebSocket is not open. Unable to send command:', JSON.stringify(cmd));
}