forked from swee/MeowNex
Prepare for contribution #1
1 changed files with 16 additions and 28 deletions
20
script.js
20
script.js
|
@ -1,32 +1,20 @@
|
||||||
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
|
// Fetching the run value for the first time
|
||||||
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
|
||||||
return new bootstrap.Tooltip(tooltipTriggerEl)
|
|
||||||
})
|
|
||||||
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
||||||
fetch ("run.txt")
|
fetch ("run.txt")
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("run").innerHTML = y);
|
.then(y => document.getElementById("run").innerHTML = y);
|
||||||
|
// Fetching the block value for the first time
|
||||||
fetch ("block.txt")
|
fetch ("block.txt")
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("blocked").innerHTML = y);
|
.then(y => document.getElementById("blocked").innerHTML = y);
|
||||||
async function reboot(){
|
|
||||||
document.getElementById("rebooticon").innerHTML = "<i class=\"fas fa-power-off fa-fade\"></i>"
|
|
||||||
fetch ("reboot.run")
|
|
||||||
.then(x => x.text())
|
|
||||||
.then(y => document.getElementById("rebooticon").innerHTML = y);
|
|
||||||
await delay(2000)
|
|
||||||
document.getElementById("rebooticon").innerHTML = "<i class=\"fas fa-power-off\"></i>"
|
|
||||||
}
|
|
||||||
async function refresh(){
|
async function refresh(){
|
||||||
document.getElementById("refresh").innerHTML = "<i class=\"fas fa-sync fa-spin\"></i>"
|
// Refresh the HTML to show the spinners
|
||||||
document.getElementById("run").innerHTML = "<span class=\"spinner-grow\"></span>"
|
document.getElementById("run").innerHTML = "<span class=\"spinner-grow\"></span>"
|
||||||
document.getElementById("blocked").innerHTML = "<span class=\"spinner-grow\"></span>"
|
document.getElementById("blocked").innerHTML = "<span class=\"spinner-grow\"></span>"
|
||||||
|
// Then fetch the values the same way as on the first part of the script.
|
||||||
fetch ("run.txt")
|
fetch ("run.txt")
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("run").innerHTML = y)
|
.then(y => document.getElementById("run").innerHTML = y)
|
||||||
fetch ("block.txt")
|
fetch ("block.txt")
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("blocked").innerHTML = y);
|
.then(y => document.getElementById("blocked").innerHTML = y);
|
||||||
await delay(2000)
|
|
||||||
document.getElementById("refresh").innerHTML = "<i class=\"fas fa-refresh\"></i>"
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue