Files
openrouter/src/web/js/info/uptime.js
T
wt ec54166f8f
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
bootstrap frontend
2025-04-23 17:54:48 +07:00

24 lines
864 B
JavaScript

const uptime = document.querySelector('#infouptime')
const get_uptime = () => {
fetch(routes.uptime()).then(data => data.json()).then(jsondata => {
if (jsondata.uptime.hour === '0' && jsondata.uptime.minute === '0') {
uptime.value = jsondata.uptime.second + "s "
return
}
if (jsondata.uptime.hour === '0') {
uptime.value = jsondata.uptime.minute + "m " + jsondata.uptime.second + "s "
return
}
uptime.value = jsondata.uptime.hour + "h " + jsondata.uptime.minute + "m " + jsondata.uptime.second + "s "
}).catch((error) => {
notification(`Ошибка на сервере: ${error}`, "error")
})
}
window.addEventListener('load', () => {
if (infosection.classList.contains('active')) {
uptimeintervalid = setInterval(get_uptime, 1000)
}
})