forked from sonucodes/covidData
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
102 lines (73 loc) · 3.59 KB
/
index.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="Sonu Kumar Kushwaha">
<meta name="email" content="[email protected]">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
<link rel="stylesheet" href="./style.css">
<title> Covid-19 Stats</title>
</head>
<body>
<h3>Live Covid-19 Data</h3>
<h5>Global Data</h4>
<div id="main" >
</div>
<h5>Countries Data</h4>
<div class="apis" id="divResult">
</div>
<script>
const getCovidStats = async () => {
try {
const response = await fetch('https://api.covid19api.com/summary');
const data = await response.json();
global = data.Global;
data.Countries.forEach(i => {
const divResult = document.getElementById("divResult");
let markup = `
<div class="fixed-content card " data-aos="fade-up">
<h4 class="mt-4">${i.Country}</h4>
<p class="blue">New Confirmed :${i.NewConfirmed}</p>
<p class="blue">Total Confirmed :${i.TotalConfirmed}</p>
<p class="blue">New Deaths :${i.NewDeaths}</p>
<p class="blue">Total Deaths :${i.TotalDeaths}</p>
<p class="blue">New Recovered :${i.NewRecovered}</p>
<p class="blue">Total Recovered :${i.TotalRecovered}</p>
</div>
`;
divResult.insertAdjacentHTML('beforeend', markup)
})
}
catch (err) {
console.log(`Error: ${err}`);
alert(`Error: ${err}`);
}
finally {
let glob = `
<div class="fixed-content card " data-aos="fade-up">
<p class="blue">New Confirmed : ${global['NewConfirmed']}</p>
<p class="blue">Total Confirmed: ${global['TotalConfirmed']}</p>
<p class="blue">New Deaths: ${global['NewDeaths']}</p>
<p class="blue">Total Deaths: ${global['TotalDeaths']}</p>
<p class="blue">New Recovered: ${global['NewRecovered']}</p>
<p class="blue">Total Recovered: ${global['TotalRecovered']}</p>
</div>
`;
document.getElementById('main').insertAdjacentHTML('beforeend', glob)
}
};
getCovidStats();
</script>
<footer class="bottom">Made with ❤ By <a href="https://singlebucks.blogspot.com/">Sonu Kumar Kushwaha</a></footer>
<script src="./app.js"></script>
<script src="https://unpkg.com/aos@next/dist/aos.js"></script>
<script>
AOS.init();
</script>
</body>
<!--Made with love by Sonu Kumar Kushwaha -->
</html>