]> jspc29.x-matter.uni-frankfurt.de Git - labtools.git/commitdiff
adding inputs for custom min/max values
authorJan Michel <j.michel@gsi.de>
Wed, 9 Sep 2015 11:18:02 +0000 (13:18 +0200)
committerJan Michel <j.michel@gsi.de>
Wed, 9 Sep 2015 11:18:13 +0000 (13:18 +0200)
sensors/index.htm
sensors/style.css
sensors/update.pl

index 451caa85efada6ebe89d009d1018a86c3571b8f4..a27750f06de0d9106632e5102770c16dd59ec4c6 100644 (file)
@@ -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);
     }
 
  </script>
@@ -95,7 +96,7 @@
 <body>
 <div id="header">
   <h1>Temperature Measurements</h1>
-  <div id="info"></div>
+  <div id="settings" style="float:right">Min: <input type="text" name="mymin" id="min"><br>Max: <input type="text" name="mymax" id="max"></div>
 </div>
 <div id="container">
 </div>
index 2e255d4952f78ecf5be1d3a930bf037eb6871258..9d891b23088171d48a6a995f1625a5eab1f30db6 100644 (file)
@@ -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;
+  }
index 5362d0785f004bfe81dbc8a48f1bd8159d99eb1a..75e5dfb3cee9744d8469fac17ca8cab34997f275 100755 (executable)
@@ -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 .= "<table class=\"scale\"><tr>";
   $str .= sprintf("<td style=\"background-color:%4s;\">",findcolor(0,0,$steps,0));
   return $str.="</table>" if $max == $min;
-  $str .= sprintf("<td class=\"label\">%#2.3G",$min);
+  $str .= sprintf("<td class=\"label\">%3i",$min);
   for (my $i = 1;$i<$steps;$i++) {
     #     my $j = ($max-$min)/$steps*$i;
     $str .= sprintf("<td style=\"background-color:%7s;\" title=\"%.2f\">",findcolor($i,0,$steps,0),($max-$min)/$steps*$i+$min);
   }
-  $str .= sprintf("<td class=\"label\">%#2.3G",$max);
+  $str .= sprintf("<td class=\"label\">%3i",$max);
   $str .= "</table>\n";
   return $str;
 }