-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vaccine.html
95 lines (88 loc) · 3.55 KB
/
Vaccine.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="author" content="Mayur Madnani">
<meta name="description" content="Dashboard for visualizing COVID-19 spread">
<meta name="keywords" content="COVID-19, Tracker, Global, India, Vaccine Slots">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>COVID-19 India</title>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/moment-2.24.0.min.js"></script>
<link rel="shortcut icon" type="image/jpg" href="img/covid.ico" />
<link rel="stylesheet" href="css/gh-fork-ribbon-0.2.3.min.css" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/vaccine_page.css" type="text/css" media="all" />
</head>
<body>
<a class="github-fork-ribbon" href="https://github.com/mayurmadnani/covidtracer" data-ribbon="Fork me on GitHub"
title="Fork me on GitHub">Fork me on GitHub</a>
<div class="header">
<div class="logo">
<img src="img/coronavirus.png" class="faa-spin animated" />
CovidTracer
</div>
<div class="nav-bar">
<ul class="nav">
<li><a href="index.html">Home</a></li>
<li><a href="Global.html">Global</a></li>
<li><a href="India.html">India</a></li>
<li style="background-color:#F7B301;"><a href="Vaccine.html">Vaccine slots- India</a></li>
</ul>
</div>
</div>
<form id="profileForm">
<table>
<tr>
<td>Pincode:</td>
<td><input type="text" name="pincode" id="pincode" /></td>
</tr>
<tr>
<td>Date:</td>
<td><input type="date" name="date" id="date" /></td>
</tr>
<tr>
<td>
<button type="submit">Check vaccine Slots</button>
</td>
</tr>
</table>
</form>
<div id="sessions" />
<button id="backToTopButton">
<span class="chevron"></span>
</button>
<script src="utils/back-to-top.js"></script>
</body>
</html>
<script>
$(document).ready(function () {
$('#profileForm').on('submit', function (e) {
e.preventDefault();
var pincode = $('#pincode').val();
var date = moment($("#date").val(), "YYYY-MM-DD").format("DD-MM-YYYY");
fetch(`https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByPin?pincode=${pincode}&date=${date}`)
.then(response => response.json())
.then(data => {
if(data.sessions==null || data.sessions.length==0)
window.alert("No data available");
else
showSessions(data);
});
});
});
showSessions = data => {
$(".session").remove();
const sessionsDiv = document.querySelector('#sessions');
data.sessions.forEach(session => {
const sessionElement = document.createElement('p');
sessionElement.setAttribute("class", "session");
sessionElement.innerText = `Center: ${session.name},${session.block_name},${session.district_name},${session.state_name}\n` +
`Time: ${session.date} ${session.from}-${session.to}\n`+
`Fee: ${session.fee_type}\n`+
`Capacity: ${session.available_capacity}\n`+
`Vaccine: ${session.vaccine}` ;
sessionsDiv.append(sessionElement);
});
}
</script>