-
Notifications
You must be signed in to change notification settings - Fork 1
/
about.html
178 lines (156 loc) · 7.35 KB
/
about.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Automatic Weather Station</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="icon" href="assets/Icon.png" type="image/png">
<link rel="apple-touch-icon" href="assets/Icon.png">
<meta name="google-site-verification" content="LEG3Rx9PyPZzUVvMXUo1elkyCv_hz1olrUGshqy0T_4" />
<style>
.hidden {
display: none;
}
.loading {
visibility: hidden;
}
</style>
</head>
<body>
<div class="info flow-up">
<header>
<body class="loading">
<main>
<div class="current">
<section class="location">
<div class="city flow-up">Makerlab, HCMC</div>
<div class="date flow-up"></div>
<div id="temperature"></div>
<div class="details">
<div class="col">
<img src="images/humidity.png">
<div>
<p id="humidity" class="humidity"></p>
</div>
</div>
<div class="col">
<img src="images/UV.png">
<div>
<p id="UV" class="humidity"></p>
</div>
</div>
</div>
</div><a href="https://raw.githubusercontent.com/dngvmnh/Automatic_Weather_Station/main/assets/UVI.png" target="_blank" class="aqi-button flow-up">Refer to Ultraviolet Index Levels</a></div>
</div>
<script>
const channelID = '2604448';
const apiKey = 'UQNBZGODZAF499TP';
async function getData1() {
const url = `https://api.thingspeak.com/channels/${channelID}/fields/1/last.json?api_key=${apiKey}`;
try {
const response = await fetch(url);
const data = await response.json();
return data.field1;
} catch (error) {
console.error(`Error fetching data from field 1:`, error);
}
}
async function getData2() {
const url = `https://api.thingspeak.com/channels/${channelID}/fields/2/last.json?api_key=${apiKey}`;
try {
const response = await fetch(url);
const data = await response.json();
return data.field2;
} catch (error) {
console.error(`Error fetching data from field 2:`, error);
}
}
async function getData3() {
const url = `https://api.thingspeak.com/channels/${channelID}/fields/3/last.json?api_key=${apiKey}`;
try {
const response = await fetch(url);
const data = await response.json();
return data.field3;
} catch (error) {
console.error(`Error fetching data from field 3:`, error);
}
}
async function updateWeatherData() {
const temperatureElement = document.getElementById('temperature');
const humidityElement = document.getElementById('humidity');
const UVElement = document.getElementById('UV');
try {
const temperature = await getData1();
const humidity = await getData2();
const UV = await getData3();
temperatureElement.innerText = (temperature !== undefined && !isNaN(temperature)) ? `${temperature}°C` : 'Data not available';
temperatureElement.className = 'temp';
humidityElement.innerText = (humidity !== undefined && !isNaN(humidity)) ? `${parseFloat(humidity).toFixed(2)}%` : 'Data not available';
humidityElement.className = 'humidity';
UVElement.innerText = (UV !== undefined && !isNaN(UV)) ? `${UV}` : 'Data not available';
UVElement.className = 'UV';
} catch (error) {
console.error('Error updating weather data:', error);
}
}
window.onload = updateWeatherData;
</script>
</section></body>
<div class="big-container">
<div class="container">
<div class="container-title flow-up">Temperature</div>
<div class="iframe-container">
<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/2604448/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
</div>
<div class="container">
<div class="container-title flow-up">Humidity</div>
<div class="iframe-container">
<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/2604448/charts/2?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
</div>
<div class="container">
<div class="container-title flow-up">Ultraviolet Intensity</div>
<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/2604448/charts/3?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
<div class="container">
<div class="container-title flow-up">Luminous Intensity</div>
<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/2604448/charts/4?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
<div class="container">
<div class="container-title flow-up">Atmospheric Pressure</div>
<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/2604448/charts/5?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
<div class="container">
<div class="container-title flow-up">Elevation</div>
<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/2604448/charts/6?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"></iframe>
</div>
</div>
<div class="down-arrow">
<a href="index.html">
<i class="fas fa-chevron-down"></i>
</a>
</div>
<div class="footer">
<h3>© Automatic Weather Station, built by Vu Minh Dang and Tran Thuc Bao, open-sourced by Makerlab.</h3>
<div class="social-media">
<a href="https://github.com/dngvmnh/automatic_weather_station"><img src="assets/AWS.png" class="icon_1" /></a>
<a href="https://github.com/makerlabvn"><i class="sm fa-brands fa-github"></i></a>
<a href="https://www.facebook.com/makerlabvn/"><i class="sm fa-brands fa-facebook"></i></a>
<a href="https://www.makerlab.vn/"><img src="assets/maker_lab_vn.png" class="icon" /></a>
</div>
</div>
</div>
<script src="script.js"></script>
<script>
window.addEventListener('load', () => {
setTimeout(() => {
document.body.classList.remove('loading');
}, 500);
});
</script>
</body>
</body>
</html>