commit 20/08/2025

This commit is contained in:
2025-08-20 16:42:06 +07:00
parent 4f0a7a1560
commit 0c84449b77
28 changed files with 966 additions and 42 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,93 @@
$(document).ready(function() {
document.title = "Automatic Announcement System"
const ws = new WebSocket(window.location.pathname + '/ws');
ws.onopen = () => {
console.log('WebSocket connection established');
};
ws.onmessage = (event) => {
let rep = JSON.parse(event.data);
let cmd = rep.reply
let data = rep.data;
if (cmd && cmd.length > 0){
// console.log('Command:', cmd);
// console.log('Data:', data);
switch(cmd){
case "getCPUStatus" :
$('#cpustatus').text("CPU Usage: " + data)
break;
case "getMemoryStatus" :
$('#ramstatus').text("Memory Usage: " + data)
break;
case "getDiskStatus" :
$('#diskstatus').text("Disk Usage: " + data)
break;
case "getNetworkStatus" :
$('#networkstatus').text("Network Usage: " + data)
break;
}
}
};
ws.onclose = () => {
console.log('WebSocket connection closed');
};
// ws.onerror = (error) => {
// console.error('WebSocket error:', error);
// };
/**
* Send a command to the WebSocket server.
* @param {String} command command to send
* @param {String} data data to send
*/
function sendCommand(command, data){
if (ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify({ command, data }));
} else {
console.error('WebSocket is not open');
}
}
setInterval(()=>{
$('#datetimetext').text(new Date().toLocaleString());
sendCommand("getCPUStatus", "")
sendCommand("getMemoryStatus", "")
sendCommand("getDiskStatus", "")
sendCommand("getNetworkStatus", "")
}, 1000)
let sidemenu = new bootstrap.Offcanvas('#offcanvas-menu');
$('#showmenu').click(()=>{
sidemenu.show();
})
$('#soundbanklink').click(()=>{
sidemenu.hide();
$('#content').load('soundbank.html');
})
$('#messagebanklink').click(()=>{
sidemenu.hide();
$('#content').load('messagebank.html');
})
$('#languagelink').click(()=>{
sidemenu.hide();
$('#content').load('language.html');
})
$('#timerlink').click(()=>{
sidemenu.hide();
$('#content').load('timer.html');
})
$('#loglink').click(()=>{
sidemenu.hide();
$('#content').load('log.html');
})
$('#settinglink').click(()=>{
sidemenu.hide();
$('#content').load('setting.html');
})
$('#logoutlink').click(()=>{
window.location.href = "login.html"
})
});