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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content = "height = device-height, width = 420, user-scalable = no" />
<title>WebIOPi | Gas Control</title>
<script type="text/javascript" src="/webiopi.js"></script>
<script type="text/javascript">
webiopi().ready(function() {
var GAS_PORT = 0;
webiopi().callMacro("gas_getPort", [ ], function(macro, args, data) {
GAS_PORT = parseInt(data)
});
var valveButton = w().createGPIOButton(GAS_PORT, "Gas Ventil: unbekannt");
valveButton.unbind("click");
valve_old_value = -1
valveButton.on("updateValue", function(event, gpio, old_value, value) {
if (valve_old_value != value) {
valveButton.text(value == 0 ? "Gas Ventil auf" : "Gas Ventil zu");
valve_old_value = value
}
});
$("#valve").html(valveButton);
var forceModes = [ "", "Online", "Offline" ];
var forceMode = forceModes[0];
var forceButton;
var onForce = function(macro, args, data) {
forceMode = data;
var style = (forceMode == "") ? "automatic" : forceMode;
var text = "Automatisch";
switch(forceMode)
{
case forceModes[0]:
break;
case forceModes[1]:
text = "Gas Ventil auf";
break;
case forceModes[2]:
text = "Gas Ventil zu";
break;
}
forceButton.attr("class", style.toUpperCase());
forceButton.text(text);
}
forceButton = webiopi().createButton("force", "Unbekannt", function() {
var i;
for (i = 0; i < forceModes.length; i++) {
if (forceModes[i] == forceMode)
break;
}
i = (i == forceModes.length - 1) ? 0 : i + 1;
webiopi().callMacro("gas_setForce", [ forceModes[i] ], onForce);
});
$("#force").html(forceButton);
w().refreshGPIO(true);
var forceRefresh = function() {
webiopi().callMacro("gas_getForce", [ ], onForce);
setTimeout(function() { forceRefresh() }, 1000);
};
forceRefresh();
});
</script>
<style type="text/css">
body {
margin: 50px 0px;
padding: 0px;
}
#content {
width: 300pt;
margin: 0px auto;
text-align: left;
padding: 15px;
border: 1px dashed #333;
background-color: #eee;
line-height: 35pt;
}
button {
width: auto;
}
.LOW {
background-color: red;
}
.HIGH {
background-color: green;
}
.ONLINE {
background-color: red;
}
.OFFLINE {
background-color: green;
}
.AUTOMATIC {
background-color: gray;
}
</style>
</head>
<body>
<div id="content">
Ventil: <span id="valve"></span><br />
Automatik: <span id="force"></span<br />
</div>
</body>
</html>
|