forked from ethersex/ethersex
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathow.ht.m4
54 lines (47 loc) · 1.41 KB
/
ow.ht.m4
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
ifdef(`conf_ONEWIRE', `', `m4exit(1)')dnl
ifdef(`conf_ONEWIRE_INLINE', `', `m4exit(1)')dnl
<html>
<head>
<title>Ethersex 1-Wire Status</title>
<link rel="stylesheet" href="Sty.c" type="text/css"/>
<script src="scr.js" type="text/javascript"></script>
<script type="text/javascript">
var sensors;
function ecmd_1w_list_req() {
ArrAjax.ecmd('1w list', ecmd_1w_list_req_handler);
}
function ecmd_1w_list_req_handler(request) {
if (ecmd_error(request))
return;
sensors = request.responseText.split("\n");
var ow_table = $('ow_table');
for (var i = 0; i < sensors.length; i++) {
if (sensors[i] == "OK")
break;
ow_table.insertRow(i+1).innerHTML = "<td>" + sensors[i] + "</td><td id='ow" + i +"'>No data</td>";
ecmd_1w_convert_req(i);
setInterval('ecmd_1w_convert_req('+ i +')', 5000);
}
}
function ecmd_1w_convert_req(data) {
ArrAjax.ecmd('1w convert ' + sensors[data], ecmd_1w_convert_req_handler, 'GET', data);
}
function ecmd_1w_convert_req_handler(request, data) {
ArrAjax.ecmd('1w get ' + sensors[data], ecmd_1w_get_req_handler, 'GET', data);
}
function ecmd_1w_get_req_handler(request, data) {
var cell = $("ow" + data);
cell.innerHTML = request.responseText + '°C';
}
window.onload = function() {
ecmd_1w_list_req();
}
</script>
</head><body>
<h1>Ethersex 1-Wire Status</h1>
<table id='ow_table' border=1 cellspacing=0>
<tr><td>Address</td><td>Data</td></tr>
</table>
<div id="logconsole"></div>
</body>
</html>