-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfront-overview.php
More file actions
309 lines (271 loc) · 8.8 KB
/
front-overview.php
File metadata and controls
309 lines (271 loc) · 8.8 KB
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<div class="row">
<div id="slides" style="display: none">
<div id="slide1">
<div class="span6">
<h3>Vindhastighet</h3>
<p id="no-weather-data">Ingen väderdata</p>
<div id="windgraph" style="width: 100%;"></div>
</div>
<div class="span6">
<h3> </h3>
<div id="windgauge_now"></div>
<div id="windgauge" style="padding-left: 50px"></div>
</div>
</div>
<div id="slide1">
<div class="span6">
<h3>Vindriktning</h3>
<div id="winddirection" style="width: 570px; height: 280px; margin-top: 20px; background-image: url('img/skarstad.jpg'); background-position: center;">
<canvas id="wdcanvas" width="570" height="280" />
</div>
</div>
<div class="span6">
<h3> </h3>
<table class="table" id="wdtable"></table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="span6">
<h3>Nästa lift <span id="load-0-loadno"></span></h3>
<p>
Flygplan: <span id="load-0-aircraft"></span>
<span id="load-0-15min" style="display: none" class="label label-important">15 minuter call</span>
<span id="load-0-30min" style="display: none" class="label label-warning">30 minuter call</span></p>
<table class="table" id="load-0">
</table>
</div>
<div class="span6">
<h3>Liften därpå <span id="load-1-loadno"></span></h3>
<p>
Flygplan: <span id="load-1-aircraft"></span>
<span id="load-1-15min" style="display: none" class="label label-important">15 minuter call</span>
<span id="load-1-30min" style="display: none" class="label label-warning">30 minuter call</span></p>
<table class="table" id="load-1">
</table>
</div>
</div>
<script>
var refreshTimer = 0;
var wd_ctx = null;
var altcolors = {
"3000": '#6fc6f2',
"1500": '#1b8ee0',
"600": '#1270b3',
"0": '#ff4545'
};
var wind_data = {
"3000": 0,
"1500": 0,
"600": 0,
"0": 0
};
function refresh() {
clearTimeout(refreshTimer);
refreshTimer = setInterval(function() {
$.getJSON("load.php", fill_load);
$.getJSON("time.php", fill_time);
}, 10000);
$.getJSON("load.php", fill_load);
$.getJSON("time.php", fill_time);
}
google.load('visualization', '1', {packages:['gauge', 'corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var windgauge_now_options = {
width: 200*2, height: 200,
redFrom: 11, redTo: 12,
yellowFrom:8, yellowTo: 11,
minorTicks: 1, max: 12,
majorTicks: ['0','','','','4','','6','','8', '', '', '11', '12']
};
var windgauge_options = {
width: 150*2, height: 150,
redFrom: 11, redTo: 12,
yellowFrom:8, yellowTo: 11,
minorTicks: 1, max: 12,
majorTicks: ['0','','','','4','','6','','8', '', '', '11', '12']
};
windgauge = new google.visualization.Gauge(
document.getElementById('windgauge'));
windgauge_now = new google.visualization.Gauge(
document.getElementById('windgauge_now'));
windgraph = new google.visualization.LineChart(
document.getElementById('windgraph'));
weather_func = function() {
$.getJSON("weather.php", function(wdata) {
update_wdir(wdata);
weather = wdata.station;
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Tid');
data.addColumn('number', 'Medel');
data.addColumn('number', 'Max');
limit = new Date().getTime() / 1000 - 3600;
max = 0.0;
mean = 0.0;
nmean = 0;
skipped = 0;
for(idx in weather) {
row = weather[idx];
if(limit > row.time) {
skipped++;
continue;
}
lmax = parseFloat(row.wind.max);
lmean = parseFloat(row.wind.mean);
data.addRow([new Date(row.time*1000), lmean, lmax]);
if(lmax > max)
max = lmax;
mean += lmean;
nmean++;
}
/* do not paint empty data */
if(nmean == 0) {
if (skipped > 0) {
$("#no-weather-data").text('Väderdatan är för gammal, kontrollera väderstationen');
}
return;
}
graphMax = max + 1.0;
if(graphMax < 5.0) {
graphMax = 5.0;
}
$("#no-weather-data").slideUp();
mean = mean / nmean;
var formatter_short = new google.visualization.DateFormat(
{pattern: 'HH:mm'});
formatter_short.format(data, 0);
var windgraph_options = {curveType: "function",
height: 350,
vAxis: {format: '#', gridlines: {count: 6},
viewWindowMode:'explicit',
viewWindow: {min: 0, max: graphMax}},
hAxis: {format: 'HH:mm'}
};
windgraph.draw(data, windgraph_options);
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Tim-medel', Math.round(mean*10)/10],
['Tim-max', Math.round(max*10)/10],
]);
windgauge.draw(data, windgauge_options);
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Medel', Math.round(lmean*10)/10],
['Max', Math.round(lmax*10)/10],
]);
windgauge_now.draw(data, windgauge_now_options);
});
};
setInterval(weather_func, 10000);
weather_func();
}
function update_wdir(weather) {
var html = "<tr><th style=\"width: 30px;\"> </th>";
html += "<th>Höjd</th><th>Riktning</th>";
html += "<th>Hastighet</th><th>Temperatur</th>";
html += "</tr>";
latest = 0;
latest_idx = 0;
for(idx in weather.station) {
if(weather.station[idx].time > latest) {
latest = weather.station[idx].time;
latest_idx = idx;
}
}
gnd_speed = weather.station[idx].wind.mean;
gnd_temp = weather.station[idx].temperature;
if (weather.station[idx].wind.direction != null) {
gnd_dir = weather.station[idx].wind.direction;
} else {
gnd_dir = "???";
}
altitudes = [];
for(altitude in weather.lfv) {
altitudes.push(parseInt(altitude));
}
altitudes.sort(function(a,b){return b - a});
for(idx in altitudes) {
altitude = altitudes[idx];
html += "<tr>";
html += "<td style='background-color: " + altcolors[altitude] + "'> </td>";
html += "<td>" + altitude + "</td>";
html += "<td>" + weather.lfv[altitude].direction + " °</td>";
html += "<td>" + weather.lfv[altitude].speed + " m/s</td>";
html += "<td>" + weather.lfv[altitude].temperature + " °C</td></tr>";
wind_data[altitude] = weather.lfv[altitude].direction;
}
html += "<tr>";
html += "<td style='background-color: " + altcolors[0] + "'> </td>";
html += "<td>Mark</td>";
html += "<td>" + gnd_dir + " °</td>";
html += "<td>" + gnd_speed + " m/s</td>";
html += "<td>" + gnd_temp + " °C</td></tr>";
wind_data[0] = gnd_dir;
$("#wdtable").html(html);
}
function draw_needle(x, y, color, dir) {
wd_ctx.save();
//wd_ctx.translate(x, y);
wd_ctx.translate(215, 120);
wd_ctx.rotate(dir + Math.PI);
for(i = 0; i < 2; i++) {
wd_ctx.beginPath();
wd_ctx.moveTo(0, 10);
wd_ctx.lineTo(0, 110);
wd_ctx.moveTo(0, 10);
wd_ctx.lineTo(-5, 15);
wd_ctx.moveTo(0, 10);
wd_ctx.lineTo(5, 15);
wd_ctx.lineWidth = 4-i;
if(i == 0)
wd_ctx.strokeStyle = 'black';
else
wd_ctx.strokeStyle = color;
wd_ctx.stroke();
}
wd_ctx.restore();
}
function draw_wd() {
wd_ctx.clearRect(0, 0, 570, 290);
wd_ctx.save();
wd_ctx.translate(70, 20);
draw_needle(50, 50, '#6fc6f2', Math.PI/180 * wind_data[3000]);
draw_needle(150, 100, '#1b8ee0', Math.PI/180 * wind_data[1500]);
draw_needle(250, 150, '#1270b3', Math.PI/180 * wind_data[600]);
draw_needle(350, 200, '#ff4545', Math.PI/180 * wind_data[0]);
wd_ctx.restore();
}
$(function() {
$('#slides').slidesjs({
width: 940,
height: 290,
pagination: false,
generatePagination: false,
play: {
active: true,
auto: true,
interval: 20000,
swap: true,
},
callback: {
loaded: function(){
$('.slidesjs-play').hide(0);
$('.slidesjs-stop').hide(0);
$('.slidesjs-next').text('>').click(function() {
$('.slidesjs-play').click();
$('.slidesjs-stop').hide(0);
});
$('.slidesjs-previous').text('<').click(function() {
$('.slidesjs-play').click();
$('.slidesjs-stop').hide(0);
});
}
}
});
refresh();
wd_ctx = document.getElementById('wdcanvas').getContext('2d');
setInterval(draw_wd, 10000);
});
</script>