-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
116 lines (102 loc) · 2.54 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>HASS Assignment 1</title>
<script type="text/javascript" charset="utf8" src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Exo|Red+Hat+Display">
<style type="text/css">
body {
background-color: #003541;
color: white;
font-family: "Exo", "Red Hat Display", Segoe, "sans-serif";*/;
font-size: 1rem;
text-align: center;
}
.table{
margin-left: auto;
margin-right: auto;
}
th{
background-color: #014040;
color: #16FCFC;
padding: 5px;
}
tr:nth-child(odd) {
background-color: #027C7A;
padding: 5px;
}
tr:nth-child(even) {
background-color: #025F5E;
padding: 5px;
}
tr:hover {
background-color: #003541;
}
a:link {
color: aquamarine;
}
a:visited {
color: mediumaquamarine;
}
</style>
</head>
<body>
<!-- Reference: https://www.youtube.com/watch?v=Vi-pH2gQXAw -->
<p>
<a href="https://data.gov.sg/dataset/psi"> Current PSI readings in Singapore </a>
</p>
<div class="table" id="app" style="overflow-x:auto;">
<table id="datatable" class="table">
<thead>
<tr v-for="(result, index) in results['items']" :key="index">
<td v-text="'Updated as of: '+ result['timestamp']" colspan="7">Updated as of: </td>
</tr>
<tr>
<th>Metric</th>
<th>National</th>
<th>North</th>
<th>East</th>
<th>South</th>
<th>West</th>
<th>Central</th>
</tr>
</thead>
<tbody>
<tr v-for="(result, index) in results['items'][0]['readings']" :key="index">
<td v-text="index"></td>
<td v-text="result['national']"></td>
<td v-text="result['north']"></td>
<td v-text="result['east']"></td>
<td v-text="result['south']"></td>
<td v-text="result['west']"></td>
<td v-text="result['central']"></td>
</tr>
</tbody>
</table>
</div>
<script>
new Vue({
el: "#app",
data: {
results: []
},
methods: {
getData(){
const URL = "https://api.data.gov.sg/v1/environment/psi"
axios
.get(URL)
.then(response => {this.results = (response.data);})
}
},
mounted(){
this.getData();
}
})
</script>
<p> Designed by Ong Kian Eng using Axios and Vue <br>
<a href="https://github.com/okiane/HASS-assignment1/blob/main/index.html">See original code here</a>
</p>
</body>
</html>