-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
169 lines (158 loc) · 4.74 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
<!DOCTYPE html>
<html>
<head>
<title>Mint Peaks</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://cdn.socket.io/socket.io-1.3.5.js"></script>
<script type="text/javascript">
var socket = io('http://mintpeaks.com:3000');
socket.on('connect', function() {
document.getElementById('disconnected').style.display = 'none';
document.getElementById('connected').style.display = 'block';
});
socket.on('heartbeat', function(data) {
// Because we can be connected to the socket.io server, but the tessel itself isn't
// we show this is the case.
if (data.tessel) {
document.getElementById('tessel_disconnected').style.display = 'none';
}
else {
document.getElementById('tessel_disconnected').style.display = 'inline';
}
// Pulse the dot on heartbeat so we know we're alive.
var span = document.getElementById('connected').getElementsByTagName('span')[0];
span.style.visibility = 'visible';
setTimeout(function() { span.style.visibility = 'hidden'; }, 500);
})
socket.on('received_data', function(data) {
var temperature = Number(data.temperature).toFixed(1);
var humidity = Number(data.humidity).toFixed(1);
document.title = 'Mint Peaks (' + temperature + '°C/' + humidity + '%)';
document.getElementById('temperature_reading').innerHTML = temperature;
document.getElementById('humidity_reading').innerHTML = humidity;
});
</script>
<style>
@font-face {
font-family: 'entypo';
src: url('/assets/entypo.eot');
src: url('/assets/entypo.eot?#iefix') format('embedded-opentype'),
url('/assets/entypo.woff') format('woff'),
url('/assets/entypo.ttf') format('truetype'),
url('/assets/entypo.svg#entypo') format('svg');
font-weight: normal;
font-style: normal;
}
html, body {
margin: 0;
padding: 0;
height: 100%;
}
body {
background: #ddf6f7;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
color: rgba(0, 0, 0, 0.7);
}
.data {
text-align: center;
font-size: 6em;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.reading {
padding: 5% 8%;
}
.icon {
font-family: 'entypo';
color: rgba(0, 0, 0, 0.1);
font-size: 72px;
}
footer {
position: absolute;
bottom: 25px;
left: 0px;
width: 100%;
font-size: 1em;
opacity: 0.5;
}
footer .status {
float: left;
padding-left: 25px;
}
footer .author {
float: right;
padding-right: 25px;
}
footer a {
color: #334849;
}
#connected { display: none; }
#connected span { color: green; visibility: hidden; }
#disconnected span { color: red; }
#tessel_disconnected { display: none;}
@media only screen and (min-width: 1600px) {
/* big screens */
.data {
font-size: 9em;
}
}
@media only screen and (max-width: 767px) {
/* phones */
.data {
font-size: 4em;
}
footer {
text-align: center;
font-size: 0.9em;
}
footer .status, footer .author {
float: none;
padding: 0.2em 0;
}
}
@media only screen and (max-width: 767px) and (orientation: portrait) {
/* portrait phones */
.data {
flex-direction: column;
}
}
</style>
</head>
<body>
<div class='data'>
<div class='reading temperature'>
<div class='icon'>📿</div>
<span id="temperature_reading">0.00</span>
°C
</div>
<div class='reading humidity'>
<div class='icon'>💦</div>
<span id="humidity_reading">0.00</span>
%
</div>
</div>
<footer>
<div class="status">
<div id="disconnected">
<span>●</span>
Disconnected
</div>
<div id="connected">
<span>●</span>
Connected
<small id="tessel_disconnected">Tessel disconnected</small>
</div>
</div>
<div class="author">
Built by
<a href="http://miha.rebernik.info">Miha Rebernik</a>
|
<a href="https://github.com/mihar/mintpeaks-com">source code</a>
</div>
</footer>
</body>
</html>