This repository has been archived by the owner on May 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app2.js
90 lines (69 loc) · 2.6 KB
/
app2.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const audio = new Audio("error.wav");
let detector = 0;
var cI = (function() {
return {
online: function() { },
offline: function() { },
test: function() {
var displayStatus = document.querySelector("#status");
var checkingDisplay = document.querySelector("#checking");
var i = new Image();
i.onload = this.online;
i.onerror = this.offline;
i.src= `test.png?${String(Date())}`;
checkingDisplay.textContent = "[ 🟡 Checking ]";
}
};
})();
cI.online = function(){
detector = 1;
var displayStatus = document.querySelector("#status");
var displayStatusHolder = document.querySelector("#status-holder");
var checkingDisplay = document.querySelector("#checking");
displayStatus.textContent = "🚀 ONLINE";
displayStatus.style.color = "rgb(203, 253, 67)"
checkingDisplay.textContent = "[Wait..]";
document.body.style.backgroundColor = "rgb(49, 43, 43)";
displayStatusHolder.style.borderTop = `30px solid rgb(203, 253, 67)`;
document.querySelector(".log").textContent = `Online : ${Date()}`;
};
cI.offline = function(){
var displayStatus = document.querySelector("#status");
var displayStatusHolder = document.querySelector("#status-holder");
var checkingDisplay = document.querySelector("#checking");
displayStatus.textContent = "🚫 OFFLINE";
displayStatus.style.color = "white";
document.body.style.backgroundColor = 'red';
audio.play();
checkingDisplay.textContent = "[Wait..]";
displayStatusHolder.style.borderTop = `30px solid red`;
document.querySelector(".log").textContent = `Offline : ${Date()}`;
};
function setDelay(){
document.getElementById("timerTable").style.display = "none";
var delay = document.querySelector("#delayTime").value*1000;
if(delay>=3000){
}else{
delay = 3000;
alert("Delay can't be less than 3 Seconds!");
}
document.querySelector(".log").textContent = `You set interval of ${delay/1000} seconds. Kindly wait ${delay/1000} seconds.`
var intId = setInterval(function(){
detector = 0;
cI.test()
},delay);
setInterval(function(){
if(detector==0){
cI.offline()
}
},delay+900);
}
window.addEventListener("offline",()=>{
document.querySelector("#status").textContent = "❌ NOT CONNECTED";
audio.play();
})
function moreDetails(){
const moreDetails = document.getElementById("moreDetails");
console.log(navigator)
moreDetails.innerHTML = `Server Details: ${navigator.userAgent}`;
}