Skip to content

Commit ccd26c2

Browse files
committed
Added Corona tracker app - take input from user
1 parent af51d76 commit ccd26c2

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<a href="./api/dogRandom/index.html">dog-Random</a>
1616
<a href="./api/superHero/index.html">super-Hero</a>
1717
<a href="./projects/netflix/index.html">Netflix fetch-movies (WORK IN PROGRESS)</a>
18+
<a href="./projects//corona-tracker/index.html">Corona tracker app (WORK IN PROGRESS)</a>
1819

1920
<p style="font-size: 1.2rem">projects</p>
2021
<a href="./projects/addtocart/index.html">add-to-cart</a>

projects/corona-tracker/index.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Corona API</title>
8+
<!-- Bootstrap CSS -->
9+
<link
10+
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
11+
rel="stylesheet"
12+
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
13+
crossorigin="anonymous"
14+
/>
15+
</head>
16+
<body class="bg-light">
17+
<div class="background m-0">
18+
<div class="main position-relative p-2">
19+
<div class="covidbg-img"></div>
20+
<div class="container py-5">
21+
<div class="row justify-content-center align-items-center">
22+
<div class="col-6">
23+
<div class="content text-center">
24+
<h2 class="fw-bold bk-clr">Current Covid-19 Status Of India</h2>
25+
<div class="input-section py-3 position-relative text-center">
26+
<form action="" id="form" class="d-flex">
27+
<select class="form-select fw-bold" id="inputdata">
28+
<option value="">Select State</option>
29+
</select>
30+
<button type="submit" class="btn btn-primary fw-bold ms-2" id="special">Submit</button>
31+
</form>
32+
</div>
33+
</div>
34+
</div>
35+
<div class="col-6">
36+
<div class="main-img text-center"></div>
37+
</div>
38+
</div>
39+
<div class="container py-5 bg-white shadow-lg bg-small" id="detail" style="display: none">
40+
<h2 id="state"></h2>
41+
<div id="confirm"></div>
42+
<div id="active"></div>
43+
<div id="death"></div>
44+
<div id="recovered"></div>
45+
</div>
46+
</div>
47+
</div>
48+
</div>
49+
<script src="jquery-3.6.3.min.js"></script>
50+
<script src="main.js"></script>
51+
</body>
52+
</html>

projects/corona-tracker/jquery-3.6.3.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/corona-tracker/main.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
let state = document.getElementById('state');
2+
let confirm = document.getElementById('confirm');
3+
let active = document.getElementById('active');
4+
let death = document.getElementById('death');
5+
let recover = document.getElementById('recovered');
6+
7+
document.getElementById('detail').style.display = "none";
8+
9+
let form = document.getElementById('form');
10+
form.addEventListener('submit',function (e) {
11+
e.preventDefault();
12+
fetchData();
13+
});
14+
15+
document.addEventListener('DOMContentLoaded',function () {
16+
fetchData();
17+
});
18+
19+
20+
function fetchData () {
21+
let input = document.getElementById('inputdata').value;
22+
console.log(input);
23+
24+
$.ajax({
25+
url: `https://data.covid19india.org/data.json`,
26+
dataType: "json",
27+
method: "GET",
28+
success: function (res) {
29+
30+
document.getElementById('inputdata').innerHTML = "<option value=''>Select State</option>";
31+
console.log("All State Names:");
32+
res.statewise.forEach(state => {
33+
console.log(state.state);
34+
35+
let option = document.createElement('option');
36+
option.value = state.state.toLowerCase();
37+
option.textContent = state.state;
38+
document.getElementById('inputdata').appendChild(option);
39+
console.log();
40+
41+
});
42+
43+
updateData(res,input);
44+
}
45+
});
46+
}

0 commit comments

Comments
 (0)