LaundrySorcery

Log | Files | Refs

commit 6de59be89fe463add0b50d7d195b34696790ba54
parent 0f5c469890e7487595aedef62dd870e89a1ee6e9
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Wed,  6 Jun 2018 17:07:16 +0000

Improve the delta_t handling

Diffstat:
www/delta_t.sh | 16++++++++++++++++
www/index.sh | 17++---------------
www/print_delta_t.sh | 7+++++++
3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/www/delta_t.sh b/www/delta_t.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +declare TIME +declare DTIME +declare ON + +ON=false +OTIME=`<on_file` +if [[ $OTIME -ge 0 ]] +then + ON=true + TIME=`date +%s` + DTIME=$(( TIME-OTIME )) +else + DTIME="-1" +fi diff --git a/www/index.sh b/www/index.sh @@ -1,19 +1,6 @@ #!/bin/bash -declare TIME -declare DTIME -declare ON - -ON=false -OTIME=`<on_file` -if [[ $OTIME -ge 0 ]] -then - ON=true - TIME=`date +%s` - DTIME=$(( TIME-OTIME )) -else - DTIME="-1" -fi +source delta_t.sh cat <<-EOF Content-Type: text/html @@ -43,7 +30,7 @@ Content-Type: text/html } } setInterval(function(){ if(delta_t>=0){delta_t++}; updateDisplay();}, 1000); - setInterval(function(){ readTextFile("on_file");}, 5*1000); + setInterval(function(){ readTextFile("print_delta_t.sh");}, 5*1000); function readTextFile(file){ var rawFile = new XMLHttpRequest(); rawFile.open("GET", file, true); diff --git a/www/print_delta_t.sh b/www/print_delta_t.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +source delta_t.sh + +echo "Content-Type: text/plain" +echo +echo "$DTIME"