From 402d4216444b543de8ed0a53498f612275b0e286 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 9 Sep 2015 13:18:02 +0200 Subject: [PATCH] adding inputs for custom min/max values --- sensors/index.htm | 5 +++-- sensors/style.css | 13 +++++++++++++ sensors/update.pl | 25 +++++++++++++++++-------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/sensors/index.htm b/sensors/index.htm index 451caa8..a27750f 100644 --- a/sensors/index.htm +++ b/sensors/index.htm @@ -86,7 +86,8 @@ // makeNameChange(a[i]); // } - setTimeout("getdata('update.pl',UpdatePage)",1000); + options = "min="+document.getElementById("min").value+"&max="+document.getElementById("max").value; + setTimeout("getdata('update.pl?'+options,UpdatePage)",1000); } @@ -95,7 +96,7 @@
diff --git a/sensors/style.css b/sensors/style.css index 2e255d4..9d891b2 100644 --- a/sensors/style.css +++ b/sensors/style.css @@ -93,3 +93,16 @@ table.scale { .scale td { min-width:12px; } + +input { + width:50px; + background:#fff; + font-size:15px; +} + +#settings { + text-align:right; + position:absolute; + top:10px; + right:50px; + } diff --git a/sensors/update.pl b/sensors/update.pl index 5362d07..75e5dfb 100755 --- a/sensors/update.pl +++ b/sensors/update.pl @@ -14,6 +14,8 @@ my $max = -1000; my $query = CGI->new; my $lines = $query->param('lines') || 50; +my $mymin = $query->param('min'); +my $mymax = $query->param('max'); sub defineScale { @@ -23,7 +25,9 @@ sub defineScale { $min = floor($min/5)*5; $max = ceil($max/5)*5; - + + $min = $mymin if defined $mymin && $mymin ne ""; + $max = $mymax if defined $mymax && $mymax ne ""; } @@ -34,12 +38,17 @@ sub findcolor { my $step = (($max-$min)/1000.); - if ($v == 0) { - $r = 220; - $g = 220; - $b = 220; - } else { + $r = 170; + $g = 170; + $b = 170; + } + elsif($v<$min || $v>$max) { + $r = 230; + $g = 230; + $b = 230; + } + else { $v -= $min; $v = $v/$step if $step; if ($v<240) { $r = 255-$v/240*255;} @@ -73,12 +82,12 @@ sub DrawScale { $str .= ""; $str .= sprintf("
",findcolor(0,0,$steps,0)); return $str.="
" if $max == $min; - $str .= sprintf("%#2.3G",$min); + $str .= sprintf("%3i",$min); for (my $i = 1;$i<$steps;$i++) { # my $j = ($max-$min)/$steps*$i; $str .= sprintf("",findcolor($i,0,$steps,0),($max-$min)/$steps*$i+$min); } - $str .= sprintf("%#2.3G",$max); + $str .= sprintf("%3i",$max); $str .= "\n"; return $str; } -- 2.43.0