blob: 17c67c13e85fd306f82854eaa858a131a1b3842a (
plain)
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
|
<!DOCTYPE html>
<!--
vim: shiftwidth=4 tabstop=4 noexpandtab
-->
<html>
<head>
<title>IoT</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./webiot.css" type="text/css">
</head>
<body>
<main>
<h1>IoT</h1>
{{range .Hs100}}
<div class="card">
<h3 class="card-first-item">{{.Name}}</h3>
<button onclick="api('{{.Ip}}', 'on')">on</button>
<button class="card-last-item" onclick="api('{{.Ip}}', 'off')">off</button>
</div>
{{end}}
<script>
function api(host, state) {
const xhttp = new XMLHttpRequest();
xhttp.open(
"POST",
"/api?host=" + host + "&state=" + state,
true
);
xhttp.send();
}
</script>
</main>
</body>
</html>
|