-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathconsoleinfo.js
46 lines (41 loc) · 1.22 KB
/
consoleinfo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
document.addEventListener("DOMContentLoaded", consoleStatus, false);
function consoleStatus() {
let recv = fetch("http://127.0.0.1:7657/welcome");
recv.then(routerConsoleSuccess, routerConsoleError);
}
function routerConsoleSuccess(myJson) {
console.warn("(consoleinfo)", myJson);
contentUpdateById("router-check", "consoleSuccessStatus");
let routerness = document.querySelectorAll(".routerness");
if (routerness !== null) {
unhide(routerness);
}
}
function routerConsoleError(error) {
console.error("(consoleinfo)", error);
contentUpdateById("router-check", "consoleFailedStatus");
let routerness = document.querySelectorAll(".routerness");
if (routerness !== null) {
hide(routerness);
}
}
function hide(elementsToHide) {
const elements = Array.isArray(elementsToHide)
? elementsToHide
: [elementsToHide];
elements.forEach((element) => {
console.log("(consoleinfo) hiding");
el.classList.add("hidden");
});
}
function unhide(elementsToShow) {
const elements = Array.isArray(elementsToShow)
? elementsToShow
: [elementsToShow];
elements.forEach((element) => {
if (element.style) {
console.log("(consoleinfo) unhiding");
el.classList.remove("hidden");
}
});
}