-
Notifications
You must be signed in to change notification settings - Fork 30
/
cam.html
221 lines (213 loc) · 8.05 KB
/
cam.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ conf.station.name}} - Cam </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Tor Hveem">
<link href="/static/fa/css/font-awesome.css" rel="stylesheet">
<link rel="shortcut icon" href="/static/favicon.png">
<link href="/static/meteocons-font/FONT/Font-face/stylesheet.css" rel="stylesheet">
<link href="/static/screen.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style type="text/css">
html, body, .cam {
height: 100%;
}
.cam * {
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
.cam {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
min-height: 100%;
background-size: contain;
background-repeat: no-repeat;
background-position: 50% 50%;
}
.cam img {
border: 1px solid #000;
position: relative;
top: 0;
left: 0;
width: auto;
height: 100%;
}
.cam .sidebar {
position: absolute;
top: 0;
left: 0;
width: 150px;
height: 100%;
}
body {
background: #c9c9c9;
background: #222426;
background: #111;
margin: 0;
padding: 0;
text-align: center;
text-shadow: 1px 1px black;
font-size: 100%;
}
#current_weather .span1 {
border: 0;
background: inherit;
}
.sparkline path {
stroke: rgba(255, 255, 255, 0.8);
stroke-width: 2px;
fill: none;
}
body, .sparkline path, h5, .high, .avg, .min, .wind, .temp, .pressure, .hum, .rain, #pressuresparkline path, #windsparkline path, #sparkline path {
color: #ededed;
stroke: rgba(255, 255, 255, 1);
font-size:1.5vw;
line-height: 1;
font-weight: 800;
}
.unit {
/* color: 666; */
background: rgba(0,0,0,0.5);
}
#current_weather i {
font-size: 3vw;
}
.widget h5 {
margin: 10px;
/*background: rgba(0,0,0,0.2);*/
}
.widget {
text-align: center;
width: 8vw;
}
.blue {
color: #4d8fc8;
}
.blue {
color: steelblue;
}
.red {
color: #b5152b;
}
.purple{
color: #8c52e2;
}
.green {
color: #5c8843;
}
</style>
</head>
<body>
<div class="cam" id="current_weather">
<!--<img src="{{conf.webcam.url}}?nocache=1">-->
<script>
var src="{{conf.webcam.url}}";
</script>
<div class="sidebar">
<div title="Time of latest weather data from weather station" class="widget blue">
<h5><i class="blue fa fa-clock-o"></i></h5>
<h5 class="unit" data-texttransition="current.datetime | date"></h5>
</div>
<div title="Temperature" class="widget">
<h5><i class="red avg icon-met icon-temp"></i></h5>
<h5 class="unit avg" title="Temperature" data-texttransition="current.outtemp | temp"></h5>
</div>
<div title="Rain" class="widget">
<h5><i class="blue fa fa-tint"></i> </h5>
<h5 class="unit rain" title="Daily rain" data-texttransition="current.dayrain | rain"></h5>
</div>
<div title="Wind speed" class="widget">
<h5><i class="purple icon-met icon-wind"></i></h5>
<h5 class="avg unit" title="Average wind speeds" data-texttransition="current.windspeed | wind"></h5>
</div>
<div title="Wind direction" class="widget">
<h5><i class="purple fa fa-arrow-up" title="Wind direction" data-style="current.winddir | rotate"></i></h5>
<h5 class="high unit" title="Wind direction" data-texttransition="current.winddir | degree">
</h5>
</div>
<div>
</div>
<script src="/static/js/watch.js"></script>
<script src="/static/js/rivets.min.js"></script>
<script src="/static/js/d3.v3.min.js"></script>
<script src="/static/js/amatyrlib.js"></script>
<script>
days = ["Sundag","Mondag","Tirsdag","Onsdag","Torsdag","Fredag","Laurdag"],
months = ["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","Desember"];
Number.prototype.pad = function (len) {
return (new Array(len+1).join("0") + this).slice(-len);
}
function updateDate() {
var d = new Date();
document.getElementById("date").innerHTML = days[d.getDay()] + " " + d.getDate() + ". " + months[d.getMonth()] + " " +d.getFullYear() + " " + d.getHours().pad(2) + ":" + d.getMinutes().pad(2) + ":" + d.getSeconds().pad(2);
};
//updateDate();
var imgSwap = function () {
var newImg = new Image();
var url = src + "?" + new Date().getTime();
newImg.src = url;
var el = document.querySelector('.cam');
console.log(url);
el.style['background-image'] = 'url("'+url+'")';
newImg.addEventListener("load", function (evt) {
var el = document.querySelector('.cam');
el.style['background-image'] = 'url("'+newImg.src+'")';
//console.log(newImg.fileModifiedDate);
//updateDate();
});
};
imgSwap();
setInterval(imgSwap, 30000);
</script>
<script>
var amatyr = {
apiurl : "/api/"
};
var amatyrlib = new amatyrlib();
var current_weather;
// Fetch current weather
d3.json(amatyr.apiurl + 'now', function(json) {
current_weather = {
current: json[0]
};
rivets.bind(document.getElementById('current_weather'), current_weather);
});
// Draw sparkline
/*
d3.json(amatyr.apiurl+'recent', function(json) {
var tdata = [];
var wdata = [];
var pdata = [];
json.forEach(function(k, v) {
// Ordered wrong way, so unshift
tdata.unshift(k.outtemp);
wdata.unshift(k.windspeed);
pdata.unshift(k.barometer);
});
tsl = new sparkline('#sparkline', tdata, 'outtemp', tdata.length, 38, 'basis', true, 60*1000, 1000);
wsl = new sparkline('#windsparkline', wdata, 'windspeed', wdata.length, 38, 'basis', true, 60*1000, 1000);
psl = new sparkline('#pressuresparkline', pdata, 'barometer', pdata.length, 38, 'basis', true, 60*1000, 1000);
// Update each minute
setInterval(wsl.update, 60*1000);
setInterval(tsl.update, 60*1000);
setInterval(psl.update, 60*1000);
});*/
// Fetch current weather with 1 minute interval
setInterval(function() { d3.json(amatyr.apiurl + 'now', function(json) {
// Update each key with new val
for(key in current_weather.current) {
current_weather.current[key] = json[0][key]
}
}) }, 60*1000);
</script>
<script type="text/javascript"> var _paq = _paq || []; (function(){ var u=(("https:" == document.location.protocol) ? "https://statistikk.idrift.no/" : "http://statistikk.idrift.no/"); _paq.push(['setSiteId', 116]); _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script>
</body>
</html>