-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindia.js
52 lines (50 loc) · 2.05 KB
/
india.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
function indian_data(choice) {
document.getElementById("extra").style.display = "flex";
myxml.onreadystatechange = function () {
if (this.status == 200 && this.readyState == 4) {
var indian, foreign, okay, dead, name, live;
document.getElementById("statelist").style.display = "block";
if (choice == 0) {
var base = JSON.parse(this.response).data.summary;
var all = base.total;
indian = base.confirmedCasesIndian;
foreign = base.confirmedCasesForeign;
okay = base.discharged;
dead = base.deaths;
live = all - (okay + dead);
document.getElementById("header2").innerHTML =
"Total Cases(India)=" + all;
document.getElementById("states").selectedIndex = 0;
document.getElementById("extra").style.display = "flex";
} else {
var base = JSON.parse(this.response).data.regional[choice - 1];
all = base.totalConfirmed;
indian = base.confirmedCasesIndian;
foreign = base.confirmedCasesForeign;
okay = base.discharged;
dead = base.deaths;
live = all - (okay + dead);
document.getElementById("header3").style.display = "block";
document.getElementById("header3").innerHTML =
base.loc + " : " + base.totalConfirmed;
//alert(dead);
document.getElementById("extra").style.display = "none";
}
var label1 = ["Indian", "Foreign"];
var label2 = ["Discharged", "Deaths", "Ongoing treatment"];
var data1 = [indian, foreign];
var data2 = [okay, dead, live];
currchart1.destroy();
currchart2.destroy();
currchart1 = makepie(label1, data1, "c1", "Citizens affected");
currchart2 = makepie(label2, data2, "c2", "Condition");
} else {
document.getElementById("c1").innerHTML =
"ERROR CONNECTING TO API. KINDLY REFRESH THE PAGE!" +
" HTTP code:" +
this.status;
}
};
myxml.open("GET", "https://api.rootnet.in/covid19-in/stats/latest", true);
myxml.send();
}