-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.html
73 lines (56 loc) · 1.45 KB
/
client.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
<html>
<head>
<title>
Demo Temperatures
</title>
<style media="screen">
table {
color: #333;
font-family: Helvetica, Arial, sans-serif;
width: 640px;
border-collapse:
collapse; border-spacing: 0;
}
td, th {
border: 1px solid transparent; /* No more visible border */
height: 30px;
transition: all 0.3s; /* Simple transition for hover effect */
}
th {
background: #DFDFDF; /* Darken header a bit */
font-weight: bold;
}
td {
background: #FAFAFA;
text-align: center;
}
tr:nth-child(even) td { background: #F1F1F1; }
tr:nth-child(odd) td { background: #FEFEFE; }
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
setInterval(function() {
callServer();
}, 2000);
function callServer() {
var url = "http://localhost:5000/api/";
function displayResult(response) {
if (response) {
var tbl="<table><tr><th>Location</th><th>Sensor ID</th><th>Temperature</th></tr>";
for(var i in response.sensors) {
tbl=tbl+ "<tr><td>"+response.locations[i]+"</td><td>" + i + "</td><td>" + response.sensors[i] + "</td></tr>";
console.log(i + response.sensors[i]);
}
tbl=tbl+"</table>";
$('#temp').html(tbl);
} else if (response.error)
alert("error: " + response.error.message);
};
$.get(url, displayResult, "json");
}
</script>
</head>
<body>
Temperatures : <span id="temp"></span>
</body>
</html>