zhao/public/js/home.js
2022-09-08 12:09:16 +08:00

27 lines
1004 B
JavaScript

const now = new Date()
const tomorrow = now.getDay() + 1
if (tomorrow >= 1 && tomorrow <= 5){
document.querySelectorAll(`th:nth-child(${tomorrow + 1})`).forEach(cell => {
cell.style.fontWeight = 900
cell.classList.add('table-active')
})
document.querySelectorAll(`tr td:nth-child(${tomorrow + 1})`).forEach(cell => {
cell.style.fontWeight = 900
cell.classList.add('table-warning')
})
}
filesize.partial({base: 2, standard: "jedec"})
const zhao = io('ws://zhao', { path: '/status/socket.io', })
zhao.on('status', (status) => {
zhao_temp.innerText = status.cpu.temperature.toFixed(2)
zhao_cpu.innerText = status.cpu.load.toFixed(2)
zhao_mem.innerText = filesize(status.memory.available)
})
const pi = io('ws://pi', { path: '/status/socket.io', })
pi.on('status', (status) => {
pi_temp.innerText = status.cpu.temperature.toFixed(2)
pi_cpu.innerText = status.cpu.load.toFixed(2)
pi_mem.innerText = filesize(status.memory.available)
})