added telnet and reboot control, openrouterinit script

This commit is contained in:
wt committed 2024-06-26 15:59:10 +07:00
1 parent 0937112f04
commit 5279a9a6a6
23 files changed
+839 -26

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
const telnetenabled = document.querySelector('#telnetenable')
const telnetsettingbody = document.querySelector('.telnetsettingbody')
const settelnetsettingsbutton = document.querySelector('#set_telnet_settings')
const get_telnet_enabled_status = () => {
fetch(routes.telnet_status(), {
method: 'POST',
body: `{"token":"${localStorage.getItem("token")}"}`
}).then(res => res.json()).then(jsondata => {
if (jsondata.enabled === '1') {
telnetenabled.checked = true
// telnetsettingbody.classList.add('active')
return;
}
}).catch((error) => {
notification(`Ошибка на сервере: ${error}`, "error")
})
}
const set_telnet_enabled_status = (status) => {
fetch(routes.telnet_status_set(), {
method: 'POST',
body: `{"token":"${localStorage.getItem("token")}","enabled":"${status?1:0}"}`
}).then(res => res.json()).then(jsondata => {
if (jsondata.enabled === '1') {
telnetenabled.checked = true
// telnetsettingbody.classList.add('active')
}
notification("Настройки telnet сохранены", "success")
}).catch((error) => {
notification(`Ошибка на сервере: ${error}`, "error")
})
}
get_telnet_enabled_status()
telnetenabled.addEventListener('click', () => {
if (telnetenabled.checked) {
// telnetsettingbody.classList.add('active')
} else {
telnetsettingbody.classList.remove('active')
}
})
settelnetsettingsbutton.addEventListener('click', () => {
set_telnet_enabled_status(telnetenabled.checked)
})