-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
94 lines (80 loc) · 3.43 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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Covid-19 locations</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">COVID-19 current case locations*</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="https://ethan1141.github.io/covid-19-locations/index.html">Locations <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="https://ethan1141.github.io/covid-19-locations/location.html?loc=">Sites</a>
</li>
</ul>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="d-flex">
<div class="col-6 text-center">
<h1 id="title"></h1>
</div>
<div class="col-6 text-center">
<h2 id="date"></h2>
</div>
</div>
<div class="col-12 d-flex flex-wrap" id="sites">
</div>
</div>
</div>
<footer>
<p>
* Data provided by data.nsw.gov.au
</p>
<p>This work is licensed under a Creative Commons Attribution License.</p>
</footer>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
let json = JSON.parse(xhttp.responseText);
// Typical action to be performed when the document is ready:
document.getElementById("title").innerHTML = json.title;
document.getElementById("date").innerHTML = "Date: " + json.date;
var sub = [];
for (var i = 0; i < json.data.monitor.length;i++) {
let a = json.data.monitor;
if (!sub.includes(a[i].Suburb.trim())) {
sub.push(a[i].Suburb.trim());
}
}
sub.sort();
for (var j = 0; j < sub.length; j++) {
var container = document.createElement('div');
container.classList.add("m-3");
var suburb = document.createElement('h2');
suburb.innerHTML = '<a href="https://ethan1141.github.io/covid-19-locations/location.html?loc=' + sub[j] + '">'+sub[j]+'</a>';
container.appendChild(suburb);
document.getElementById("sites").appendChild(container);
}
console.log(sub);
}
};
xhttp.open("GET", "https://data.nsw.gov.au/data/dataset/0a52e6c1-bc0b-48af-8b45-d791a6d8e289/resource/f3a28eed-8c2a-437b-8ac1-2dab3cf760f9/download/covid-case-locations-20210701-1729.json", true);
xhttp.send();
</script>
</body>
</html>