-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
191 lines (149 loc) · 5.27 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather App</title>
<!-- <link rel="icon" type="image/png" href="./assets/sun.png"> -->
<link rel="icon" type="image/png" href="./assets/rainy-day.png">
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<link rel="stylesheet" href="./styles.css">
</head>
<body>
<div id="main">
<div id="app">
<div class='grid_container'>
<h1 id="page_title">Environment Monitoring</h1>
<div class="data">
<div class="item temperature">
<h2>Temperature</h2>
<p class="big-font" id="dash_temp">50 °C</p>
</div>
<div class="item air-quality">
<h2>Air Quality</h2>
<!-- <div class="air-quality-slider></div> -->
<!-- <p class=" big-font">${airQuality} ppm</p> -->
<p class="big-font" id="dash_aq">500</p>
</div>
<div class="item humidity">
<h2>Humidity</h2>
<p class="big-font" id="dash_hum">50 %</p>
</div>
</div>
<div id="aligner"></div>
</div>
</div>
<!-- <div id="delete_later">
<button onclick="activate_error_box(true, false)">Fire</button>
<button onclick="activate_error_box(false, true)">Gas</button>
<button onclick="activate_error_box(true, true)">Both</button>
</div> -->
<br />
<p> Temperature Graph</p>
<div class="hname">
<div id="temp" class="plot2d"></div>
<div id="gap"></div>
<p> Humidity Graph</p>
<div id="hum" class="plot2d"></div>
<div id="gap"></div>
<p> Air Quality Graph</p>
<div id="airquality" class="plot2d"></div>
<div id="gap"></div>
<p> Feels Like Temperature Graph</p>
<div id="feel" class="plot2d"></div>
<div id="gap"></div>
<p> <label> Temperature and Humidity vs Temperature Feel </label> </p>
<div id="Div" class="plot3d"></div>
<div id="gap"></div>
<p> <label> Temperature Feel and Humidity Vs Air Quality </label> </p>
<div id="mydiv" class="plot3d"></div>
<div id="gap"></div>
</div>
</div>
<div id="errBox">
<h2>Emergency Warning</h2>
<h3 id="warning_title"></h3>
<h3 id="warning_detail"></h3>
<h2 id="pol">Police Number: 112</h2>
<h2 id="amb">Ambulance Number: 108</h2>
<button type="button" onclick="activate_error_box(false, false)">Close</button>
</div>
<div id="bottom">
<p id="last_updated"></p>
<hr>
<p id="copyrights">© Basil Skaria, Bhushan Songire (May 2024)</p>
</div>
<!-- Main renderer -->
<script src="./qualityReadings.js"></script>
<!-- 2D plots -->
<script src="./plot_humidity.js"> </script>
<script src="./plot_feelslike.js"> </script>
<script src="./plot_air_quality.js"> </script>
<script src="./plot_temperature.js"></script>
<!-- 3D plots -->
<script src="./plotly_AQHum.js"> </script>
<script src="./plotly_HumTemp.js"></script>
<!-- SOS -->
<script src="./triggerError.js"></script>
<script>
var bs_obj_global;
var web_loop = true;
var interval_id;
</script>
<!-- initially plotting things: -->
<script type="module">
import { bs_obj } from "./initial_readings.js";
plot2_temperature(bs_obj.bs_temp);
plot2_humidity(bs_obj.bs_hum);
plot2_air_quality(bs_obj.bs_mq135);
plot2_feels_like(bs_obj.bs_feel);
plot3_hum_temp(bs_obj.bs_temp, bs_obj.bs_hum, bs_obj.bs_feel);
plot3_aq_hum(bs_obj.bs_feel, bs_obj.bs_hum, bs_obj.bs_mq135);
updateReadings(
bs_obj.bs_temp[bs_obj.bs_temp.length - 1],
bs_obj.bs_hum[bs_obj.bs_hum.length - 1],
bs_obj.bs_mq135[bs_obj.bs_mq135.length - 1],
);
bs_obj_global = bs_obj;
</script>
<!-- Getting real data and plotting that: -->
<script type="module">
import { login, get_data, var_random } from './fb_main.js';
console.log("Imported test_variable: ", var_random);
async function get_firebase_node() {
// console.log("Reached the function required!!!");
var bs_obj = await get_data();
plot2_temperature(bs_obj.bs_temp);
plot2_humidity(bs_obj.bs_hum);
plot2_air_quality(bs_obj.bs_mq135);
plot2_feels_like(bs_obj.bs_feel);
plot3_hum_temp(bs_obj.bs_temp, bs_obj.bs_hum, bs_obj.bs_feel);
plot3_aq_hum(bs_obj.bs_feel, bs_obj.bs_hum, bs_obj.bs_mq135);
updateReadings(
bs_obj.bs_temp[bs_obj.bs_temp.length - 1],
bs_obj.bs_hum[bs_obj.bs_hum.length - 1],
bs_obj.bs_mq135[bs_obj.bs_mq135.length - 1],
);
activate_error_box(bs_obj.bs_fire, bs_obj.bs_gas);
bs_obj_global = bs_obj;
}
login();
// get_firebase_node();
// every 10 sec:
var stamp = document.getElementById("last_updated");
stamp.style.color = '#FB9039';
interval_id = setInterval(get_firebase_node, 10000);
</script>
<script>
var stamp = document.getElementById("last_updated");
// const stamp = document.getElementById("last_updated");
function stop_fetching_data() {
clearInterval(interval_id);
console.log('Stopped fetching data.')
stamp.style.color = 'grey';
return true;
}
stamp.addEventListener('click', stop_fetching_data);
</script>
</body>
</html>