-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.html
62 lines (55 loc) · 1.79 KB
/
test.html
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
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>Test Functions</title>
</head>
<body>
<div id="display"></div>
<script src="js/covid19-model-india.js"></script>
<script>
let urls = [];
urls.push("https://api.covid19india.org/states_daily.json");
urls.push("https://api.covid19india.org/raw_data1.json");
urls.push("https://api.covid19india.org/raw_data2.json");
urls.push("https://api.covid19india.org/raw_data3.json");
urls.push("https://api.covid19india.org/raw_data4.json");
urls.push("https://api.covid19india.org/raw_data5.json");
urls.push("https://api.covid19india.org/raw_data6.json");
let promises = [];
urls.forEach(function(url) {
promises.push(fetch(url).then(data => data.json()));
});
Promise.all(promises).then(function(data) {
init(data);
});
function init(data)
{
let statesSeries = data[0].states_daily;
let caseSeries1 = data[1].raw_data;
let caseSeries2 = data[2].raw_data;
let caseSeries3 = data[3].raw_data;
let caseSeries = caseSeries1.concat(caseSeries2, caseSeries3);
const new_names = apiNewDistricts(caseSeries);
msg = "";
for (let i = 0; i < new_names.length; i++) {
msg += new_names[i] + "</br>";
}
document.getElementById("display").innerHTML = msg;
let t0 = new Date();
t0.setDate(t0.getDate() - 1);
let model = new Covid19ModelIndia(t0, statesSeries, caseSeries);
const state = model.indexStateName("Jharkhand");
const districtWise = model.binCountsByDistrict(caseSeries, new Date("1 May 2020"));
const districts = model.listDistrictsOfState(state);
let total = 0;
for (let i = 0; i < districts.length; i++) {
total += districtWise[districts[i]];
}
console.log("reported = " + total);
}
</script>
</body>
</html>