print_gpio_state() {
GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
if [ "$GPIOVALUE" = "1" ]; then
- echo "1"
+ echo -n "true"
else
- echo "0"
+ echo -n "false"
fi
}
gpio_is_on() {
- GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
+ GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
[ "$GPIOVALUE" = "1" ]
}
echo "Content-type: text/html"
echo ""
-
+echo "{"
for CHECKID in $VALID_ONOFF_IDS; do
VAL=""
VAL="$(eval echo \$GPIO_$CHECKID)"
fi
echo -n "$CHECKID:"
print_gpio_state $CHECKID
+ echo ","
done
-
+echo "-1:false}"
# echo "<html>"
# echo "<head>"
# echo "<title>Realraum Relay Switch</title>"
}
gpio_is_on() {
- GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
+ GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
[ "$GPIOVALUE" = "1" ]
}
echo "<head>"
echo "<title>Realraum Relay Power</title>"
echo '<script type="text/javascript">'
+echo 'function updateButtons(data)
+{
+
+}'
echo 'function sendButton( onoff, btn )'
echo '{'
echo ' var req = new XMLHttpRequest();'
echo "<div class=\"switchbox\">"
echo "<span class=\"alignbuttonsleft\">"
if gpio_is_on $DISPID; then
- echo " <button class=\"onbutton enableborder\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
- echo " <button class=\"offbutton\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
+ echo " <button id=\"onbtn_$DISPID\" class=\"onbutton enableborder\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
+ echo " <button id=\"offbtn_$DISPID\" class=\"offbutton\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
else
- echo " <button class=\"onbutton\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
- echo " <button class=\"offbutton enableborder\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
+ echo " <button id=\"onbtn_$DISPID\" class=\"onbutton\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
+ echo " <button id=\"offbtn_$DISPID\" class=\"offbutton enableborder\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
fi
echo "</span>"
echo -n "<div class=\"switchnameright\">$NAME</div>"