]> www.average.org Git - pulsecounter.git/blobdiff - web/index.html
increase graph font even more
[pulsecounter.git] / web / index.html
index 490e21f6c273d6010d1668a310eb774b623a07fa..50998a2b0a6963003fe1ec2aafc72bda60dae44e 100644 (file)
@@ -5,12 +5,11 @@
 <head>
 <script>
   var dbg;
-  var xmlhttp;
   var canvas, ctx;
   var ww, wh;
   var hmax, hfact;
   var tmin, tmax, tfact;
-  var xzero = 36, yzero = 24;
+  var xzero = 40, yzero = 24;
   var cold_d = [], hot_d = [];
 
   function showdate(utime) {
@@ -26,7 +25,7 @@
     var inc, inc2, first, x, lb;
 
     if (scl < 2) { inc = 0.1; inc2 = 0.2; }
-    else if (scl < 5) { inc = 0.1; inc2 = 0.2; }
+    else if (scl < 5) { inc = 0.1; inc2 = 0.5; }
     else { inc = 0.5; inc2 = 1; }
     inc *= ord;
     inc2 *= ord;
@@ -57,7 +56,7 @@
     ctx.stroke();
 
     ctx.fillStyle = "black";
-    ctx.font = "bold 12px Courier";
+    ctx.font = "bold 16px Courier";
     ctx.textAlign = "left";
     ctx.fillText(showdate(tmin), px(tmin), py(0) + 20);
     ctx.textAlign = "right";
     ctx.stroke();
 
     ctx.fillStyle = "black";
-    ctx.font = "bold 12px Courier";
+    ctx.font = "bold 16px Courier";
     ctx.textAlign = "right";
     ctx.fillText(0, px(tmin) - 6, py(0));
     for (i = 0; comb[1][i]; i++) {
       ctx.fillText(comb[1][i].toFixed(1), px(tmin) - 6, py(comb[1][i]));
     }
     ctx.textAlign = "left";
-    ctx.fillText("l/h", px(tmin) + 4, py(hmax) + 8);
+    ctx.fillText("l/min", px(tmin) + 4, py(hmax) + 12);
   }
 
   /* @ updates global var `hmax` */
       dv = times[i+1][1] - times[i][1];
       dt = times[i+1][0] - times[i][0];
       if (dt != 0 && dv != 0) {
-        v = (dv / dt) * 360 ; /* Litres per hour */
+        v = (dv / dt) * 600 ; /* Litres per min */
         if (hmax < v) hmax = v;
         res.push([times[i][0], v]);
       }
     redraw();
   }
 
-  function iso2qu(idate) {
-    return idate.replace("T", "+").replace("0Z", "");
-  }
-
-  function sendquery(lo, hi) {
-    var url = "query.cgi" + "?lo=" + iso2qu(lo) + "&hi=" + iso2qu(hi);
+  function sendreq(qstr) {
+    var url = "query.cgi" + qstr;
+    var xmlhttp = new XMLHttpRequest();
 
     //dbg.innerHTML = url;
     xmlhttp.onreadystatechange = function() {
     xmlhttp.send();
   }
 
+  function iso2qu(idate) {
+    return idate.replace("T", "+").replace("0Z", "");
+  }
+
+  function sendquery(lo, hi) {
+    return sendreq("?lo=" + iso2qu(lo) + "&hi=" + iso2qu(hi));
+  }
+
   function resize() {
     ww = window.innerWidth - 4;
     if (ww > window.innerHeight) ww = window.innerHeight;
 
     wstart = new Date(1*tdy - 86400000 * (dow + 7));
     wend = new Date(1*wstart + 86400000 * 7);
-    xmlhttp = new XMLHttpRequest();
     sendquery(wstart.toISOString(), wend.toISOString());
   }
 
 
     wstart = new Date(1*tdy - 86400000 * dow);
     wend = new Date(1*wstart + 86400000 * 7);
-    xmlhttp = new XMLHttpRequest();
     sendquery(wstart.toISOString(), wend.toISOString());
   }
 
     var tdy = daystart(new Date());
     var ytd = new Date(1*tdy - 86400000);
     var byd = new Date(1*ytd - 86400000);
-    xmlhttp = new XMLHttpRequest();
     sendquery(byd.toISOString(), ytd.toISOString());
   }
 
   function yesterday() {
     var tdy = daystart(new Date());
     var ytd = new Date(1*tdy - 86400000);
-    xmlhttp = new XMLHttpRequest();
     sendquery(ytd.toISOString(), tdy.toISOString());
   }
 
   function today() {
     var tdy = daystart(new Date());
     var tmr = new Date(1*tdy + 86400000);
-    xmlhttp = new XMLHttpRequest();
     sendquery(tdy.toISOString(), tmr.toISOString());
   }
 
   function initialize() {
+    var qstr = window.location.search;
+
     dbg = document.getElementById("debug");
     canvas = document.getElementById("plot");
     ctx = canvas.getContext("2d");
     resize();
-    today();
+    if (qstr) sendreq(qstr);
+    else today();
     
     document.getElementById("today").onclick = today;
     document.getElementById("yesterday").onclick = yesterday;
   }
 
   /* Set up */
-  if(window.attachEvent) {
-    window.attachEvent('onload', initialize);
-    window.attachEvent('onresize', resize);
-  } else {
-    window.onload = initialize;
-    window.onresize = resize;
-  }
+  window.onload = initialize;
+  window.onresize = resize;
 </script>
 <style>
 @font-face {
@@ -342,9 +339,9 @@ div.query {
   width: 8em;
   height: 8em;
   border: solid 1px black;
+  border-radius: 1em;
   background-color: lightgray;
   cursor: pointer;
-  vertical-align: middle;
 }
 div.label {
   display: block;
@@ -352,7 +349,6 @@ div.label {
   position: absolute;
   top: 50%;
   transform: translate(0, -50%);
-  vertical-align: middle;
 }
 body {
   margin: 0px;