commit 6fb6a23eb2a2a405c32e5b66c05eb94d3155f185
parent 773dc21f4ca0a6a3905ad69edc2ffc9b1e0117ea
Author: Dominik Schmidt <das1993@hotmail.com>
Date: Thu, 7 Jun 2018 15:34:01 +0000
Rename .sh to .cgi, for easier handling in thttpd
Diffstat:
10 files changed, 116 insertions(+), 116 deletions(-)
diff --git a/www/index.cgi b/www/index.cgi
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+source delta_t.sh
+
+cat <<-EOF
+Content-Type: text/html
+
+<!DOCTYPE html>
+<HTML>
+ <head>
+ <title>LaundrySorcery</title>
+ <meta charset="UTF-8"/>
+ <style type="text/CSS">
+
+ </style>
+ </head>
+ <body>
+ <H1>Laundry Status</H1>
+ <div id="statusLine">The laundry machine is <span id="delta_t"></span></div>
+ <script type="text/JavaScript">
+ <!--
+ delta_t=${DTIME};
+ function updateDisplay(){
+ var dt=document.getElementById("delta_t");
+ if(delta_t < 0){
+ dt.textContent="off";
+ }
+ else{
+ dt.textContent="on since "+timeSince(delta_t);
+ }
+ }
+ setInterval(function(){ if(delta_t>=0){delta_t++}; updateDisplay();}, 1000);
+ setInterval(function(){ readTextFile("print_delta_t.cgi");}, 5*1000);
+ function readTextFile(file){
+ var rawFile = new XMLHttpRequest();
+ rawFile.open("GET", file, true);
+ rawFile.onreadystatechange = function ()
+ {
+ if(rawFile.readyState === 4)
+ {
+ if(rawFile.status === 200 || rawFile.status == 0)
+ {
+ delta_t = rawFile.responseText;
+ }
+ }
+ }
+ rawFile.send(null);
+ }
+ function timeSince(delta_t) {
+ var seconds = delta_t;
+ var timeValues=[
+ [60, "seconds"],
+ [60, "minutes"],
+ [24, "hours"],
+ [7, "days"],
+ [30.25, "weeks"]
+ ];
+ var str="";
+ for(i=0; i<timeValues.length; i++){
+ var timeValue=timeValues[i];
+ if(delta_t > 0){
+ str=(delta_t % timeValue[0]) + " " + timeValue[1]+", "+str;
+ delta_t=Math.floor(delta_t/timeValue[0]);
+ }
+ }
+ return str.substr(0,str.length-2);
+ }
+ updateDisplay();
+ -->
+ </script>
+ <H1>Light Sensor Data</H1>
+ <div id="SensorPanel">
+ <div><img src="light_5min.cgi" /></div>
+ <div><img src="light_1h.cgi" /></div>
+ <div><img src="light_1d.cgi" /></div>
+ </div>
+ <script type="text/javascript">
+ <!--
+ panel=document.getElementById("SensorPanel");
+ function updatePanels(){
+ panels=panel.getElementsByTagName("img");
+ for(i=0; i<panels.length; i++){
+ if(!panels[i].orig_src){
+ panels[i].orig_src=panels[i].src;
+ }
+ panels[i].src=panels[i].orig_src+"#"+new Date().getTime();
+ }
+ }
+ setInterval(updatePanels,10*1000);
+ -->
+ </script>
+ </body>
+</HTML>
+EOF
diff --git a/www/index.sh b/www/index.sh
@@ -1,94 +0,0 @@
-#!/bin/bash
-
-source delta_t.sh
-
-cat <<-EOF
-Content-Type: text/html
-
-<!DOCTYPE html>
-<HTML>
- <head>
- <title>LaundrySorcery</title>
- <meta charset="UTF-8"/>
- <style type="text/CSS">
-
- </style>
- </head>
- <body>
- <H1>Laundry Status</H1>
- <div id="statusLine">The laundry machine is <span id="delta_t"></span></div>
- <script type="text/JavaScript">
- <!--
- delta_t=${DTIME};
- function updateDisplay(){
- var dt=document.getElementById("delta_t");
- if(delta_t < 0){
- dt.textContent="off";
- }
- else{
- dt.textContent="on since "+timeSince(delta_t);
- }
- }
- setInterval(function(){ if(delta_t>=0){delta_t++}; updateDisplay();}, 1000);
- setInterval(function(){ readTextFile("print_delta_t.sh");}, 5*1000);
- function readTextFile(file){
- var rawFile = new XMLHttpRequest();
- rawFile.open("GET", file, true);
- rawFile.onreadystatechange = function ()
- {
- if(rawFile.readyState === 4)
- {
- if(rawFile.status === 200 || rawFile.status == 0)
- {
- delta_t = rawFile.responseText;
- }
- }
- }
- rawFile.send(null);
- }
- function timeSince(delta_t) {
- var seconds = delta_t;
- var timeValues=[
- [60, "seconds"],
- [60, "minutes"],
- [24, "hours"],
- [7, "days"],
- [30.25, "weeks"]
- ];
- var str="";
- for(i=0; i<timeValues.length; i++){
- var timeValue=timeValues[i];
- if(delta_t > 0){
- str=(delta_t % timeValue[0]) + " " + timeValue[1]+", "+str;
- delta_t=Math.floor(delta_t/timeValue[0]);
- }
- }
- return str.substr(0,str.length-2);
- }
- updateDisplay();
- -->
- </script>
- <H1>Light Sensor Data</H1>
- <div id="SensorPanel">
- <div><img src="light_5min.sh" /></div>
- <div><img src="light_1h.sh" /></div>
- <div><img src="light_1d.sh" /></div>
- </div>
- <script type="text/javascript">
- <!--
- panel=document.getElementById("SensorPanel");
- function updatePanels(){
- panels=panel.getElementsByTagName("img");
- for(i=0; i<panels.length; i++){
- if(!panels[i].orig_src){
- panels[i].orig_src=panels[i].src;
- }
- panels[i].src=panels[i].orig_src+"#"+new Date().getTime();
- }
- }
- setInterval(updatePanels,10*1000);
- -->
- </script>
- </body>
-</HTML>
-EOF
diff --git a/www/light_1d.cgi b/www/light_1d.cgi
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+START="-$((24*60*60))"
+RESOLUTION="900"
+source generate_image.sh
diff --git a/www/light_1d.sh b/www/light_1d.sh
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-START="-$((24*60*60))"
-RESOLUTION="900"
-source generate_image.sh
diff --git a/www/light_1h.cgi b/www/light_1h.cgi
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+START="-$((60*60))"
+RESOLUTION="60"
+source generate_image.sh
diff --git a/www/light_1h.sh b/www/light_1h.sh
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-START="-$((60*60))"
-RESOLUTION="60"
-source generate_image.sh
diff --git a/www/light_5min.cgi b/www/light_5min.cgi
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+START="-300"
+RESOLUTION="1"
+source generate_image.sh
diff --git a/www/light_5min.sh b/www/light_5min.sh
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-START="-300"
-RESOLUTION="1"
-source generate_image.sh
diff --git a/www/print_delta_t.cgi b/www/print_delta_t.cgi
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+source delta_t.sh
+
+echo "Content-Type: text/plain"
+echo
+echo "$DTIME"
diff --git a/www/print_delta_t.sh b/www/print_delta_t.sh
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-source delta_t.sh
-
-echo "Content-Type: text/plain"
-echo
-echo "$DTIME"