-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html.template
93 lines (81 loc) · 3.09 KB
/
index.html.template
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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>LittleSleeper</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href={{ static_url("custom.css") }}>
</head>
<body>
<div class="container">
<div class="header">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation"><a href="http://%IP_ADDRESS%:8000/raspi.m3u">Audio Stream</a></li>
</ul>
</nav>
<h3 class="text-muted">LittleSleeper</h3>
</div>
<!-- current status -->
<div class="jumbotron">
<h1 class="time_stamp" id="quiet"><span id="time_quiet"></span></h1>
<h1 class="time_stamp" id="crying"><span id="time_crying"></span></h1>
</div>
<!-- scrolling volume plot -->
<div class="plot-container">
<div id="plot" class="plot-placeholder"></div>
</div>
<!-- history -->
<table class="table table-hover" id="history_table">
</table>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script language="javascript" type="text/javascript" src={{ static_url("jquery.flot.js") }}></script>
<script type="text/javascript">
$(function() {
var zeros = []
for (var i = 0; i < 3600; i++) { zeros.push([i, 0.0]); }
var plot = $.plot("#plot", [ zeros ], {
series: {
color: "#000",
shadowSize: 0, // Drawing is faster without shadows
lines: {
lineWidth: 2
}
},
yaxis: {
min: 0.0,
max: 1.0,
show: false
},
xaxis: {
show: false
},
grid: {
borderWidth: 0
}
});
var socket = new WebSocket("ws://%IP_ADDRESS%:8090/ws");
socket.onmessage = function (message) {
// update the text display
$("#time_quiet").text(JSON.parse(message.data).time_quiet);
$("#time_crying").text(JSON.parse(message.data).time_crying);
// update the history table
var table = "";
$.each(JSON.parse(message.data).crying_blocks, function( index, crying_block ) {
table = "<tr><td>" + crying_block.start_str + "</td><td>" + crying_block.duration + "</td></tr>" + table;
});
table = "<tr><th>Baby noise start</th><th>Duration</th></tr>" + table;
$("#history_table").html(table);
// update the plot of the volume levels for the past hour
var data = JSON.parse(message.data).audio_plot;
var vals = [];
for (var i = 0; i < data.length; i++) { vals.push([i, data[i]]); }
plot.setData([ vals ]);
plot.draw();
};
});
</script>
</body>
</html>