-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorona.js
65 lines (29 loc) · 1.1 KB
/
corona.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
var corona = function () {
setTimeout(sendc, 3000);
function sendc() {
let request = new XMLHttpRequest();
request.open('GET', "https://corona-stats.online/ma?format=json");
request.onload = function () {
if (request.status === 200) {
corona(request.responseText);
} else {
console.log("We connected to the server, but it returned an error.");
sendc()
}
}
request.send()
}
function corona(data) {
document.getElementById("corona").innerHTML = ""
var cobj = JSON.parse(data)
let coronacont = document.getElementById("corona");
let string = "";
string += "<p class=fade-in>" + cobj.data[0].recovered + " : " + "المتعافون 😃" + "</p>"
string += "<p class=fade-in>" + cobj.data[0].deaths + " : " +"الوفيات 💀" + "</p>"
string += "<p class=fade-in>" + cobj.data[0].cases + " : " + "عدد الحالات 🤒" + "</p>"
coronacont.insertAdjacentHTML('beforeend', string);
return 0
}
}
corona()
setInterval(corona, 40000);