-
Notifications
You must be signed in to change notification settings - Fork 10
/
proxyinfo.js
62 lines (56 loc) · 1.74 KB
/
proxyinfo.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
document.addEventListener("DOMContentLoaded", proxyStatus, false);
function proxyStatus() {
console.log("(proxyinfo) checking proxy status");
fetch("http://proxy.i2p", { cache: "no-store" }).then(
proxyStatusSuccess,
proxyStatusError
);
}
function proxyStatusSuccess(myJson) {
console.warn("(proxyinfo)", myJson);
contentUpdateById("proxy-check", "proxySuccessStatus");
let readyness = document.querySelectorAll(".readyness");
if (readyness !== null) {
unhide(readyness);
}
}
function proxyStatusError(error) {
console.error("(proxyinfo)", error);
contentUpdateById("proxy-check", "proxyFailedStatus");
let readyness = document.querySelectorAll(".readyness");
if (readyness !== null) {
hide(readyness);
}
}
function hide(elements) {
console.log("(proxyinfo) hiding", elements);
const elems = Array.isArray(elements) ? elements : [elements];
elems.forEach((elem) => {
if (elem.style) {
console.log("(proxyinfo) hiding");
elem.classList.add("hidden");
}
});
}
function unhide(elements) {
console.log("(proxyinfo) unhiding", elements);
const elems = Array.isArray(elements) ? elements : [elements];
elems.forEach((elem) => {
if (elem.style) {
console.log("(proxyinfo) unhiding");
elem.classList.remove("hidden");
}
});
}
//TODO: Don't hard-code this.
fetch("http://127.0.0.1:7657/themes/console/light/images/i2plogo.png")
.then((myJson) => {
console.log("(proxyinfo) img test pass", myJson);
var consoleLinks = document.querySelectorAll(".application-info");
unhide(consoleLinks);
})
.catch((error) => {
console.log("(proxyinfo) img test fail", error);
var consoleLinks = document.querySelectorAll(".application-info");
hide(consoleLinks);
});