X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=web%2Findex.html;fp=web%2Findex.html;h=24d58a725208a8e0de61b5c883d97417ef42d95f;hb=a2ad72fa6690b49639c60d0ea3754f31c9ba374b;hp=9170885ed902f4ce41728adc2dace7b4e6bf5ab9;hpb=97b05be5674c0fa9562ce531a12f89e7462dcc6b;p=pulsecounter.git
diff --git a/web/index.html b/web/index.html
index 9170885..24d58a7 100644
--- a/web/index.html
+++ b/web/index.html
@@ -55,6 +55,13 @@
ctx.lineTo(px(tmax), py(0));
ctx.strokeStyle = "black";
ctx.stroke();
+
+ ctx.fillStyle = "black";
+ ctx.font = "bold 8px Courier";
+ ctx.textAlign = "left";
+ ctx.fillText(showdate(tmin), px(tmin), py(0) + 16);
+ ctx.textAlign = "right";
+ ctx.fillText(showdate(tmax), px(tmax), py(0) + 16);
}
function yaxis() {
@@ -77,10 +84,12 @@
ctx.fillStyle = "black";
ctx.font = "bold 8px Courier";
- ctx.fillText(0, px(tmin) - 8, py(0));
+ ctx.textAlign = "right";
+ ctx.fillText(0, px(tmin) - 2, py(0));
for (i = 0; comb[1][i]; i++) {
- ctx.fillText(comb[1][i], px(tmin) - xzero + 2, py(comb[1][i]));
+ ctx.fillText(comb[1][i], px(tmin) - 2, py(comb[1][i]));
}
+ ctx.textAlign = "left";
ctx.fillText("l/h", px(tmin) + 2, py(hmax) + 8);
}
@@ -98,7 +107,7 @@
res.push([times[i][0], v]);
}
}
- res.push([times[i][0], v]);
+ if (i) res.push([times[i][0], v]);
return res;
}
@@ -119,7 +128,16 @@
function showloading() {
ctx.fillStyle = "green";
ctx.font = "bold 16px Courier";
- ctx.fillText("loading", (ww / 2) - 40 , (wh / 2) + 8);
+ ctx.textAlign="center";
+ ctx.fillText("...loading...", (ww / 2) , (wh / 2) + 8);
+ }
+
+ function showempty() {
+ ctx.fillStyle = "red";
+ ctx.font = "bold 24px Courier";
+ ctx.textAlign="center";
+ ctx.fillText("No data for the requested time interval",
+ (ww / 2) , (wh / 2) + 8);
}
function clearplot() {
@@ -127,16 +145,16 @@
}
function redraw() {
- if (cold_d.length && hot_d.length) {
+ clearplot();
+ if (cold_d.length || hot_d.length) {
tfact = (ww - xzero) / (tmax - tmin);
hfact = (wh - yzero) / hmax;
- clearplot();
xaxis();
yaxis();
drawplot(cold_d, "blue");
drawplot(hot_d, "red");
} else {
- showloading();
+ showempty();
}
}
@@ -147,8 +165,8 @@
(data.current.hot / 100).toFixed(2);
tmin = data.range.lo;
tmax = data.range.hi;
- dbg.innerHTML = "from " + tmin + " to " + tmax
- + "
from " + showdate(tmin) + " to " + showdate(tmax);
+ //dbg.innerHTML = "from " + tmin + " to " + tmax
+ // + "
from " + showdate(tmin) + " to " + showdate(tmax);
/* differetiate() updates hmax */
hmax = 0;
cold_d = differentiate(data.cold);
@@ -174,6 +192,8 @@
}
}
xmlhttp.open("GET", url, true);
+ clearplot();
+ showloading();
xmlhttp.send();
}
@@ -188,22 +208,48 @@
redraw();
}
- function initialize() {
- var tdy = new Date();
- var tmr;
+ function daystart(date) {
+ date.setMilliseconds(0);
+ date.setSeconds(0);
+ date.setMinutes(0);
+ date.setHours(0);
+ return date;
+ }
+
+ function beforeyesterday() {
+ 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());
+ }
- tdy.setMilliseconds(0);
- tdy.setSeconds(0);
- tdy.setMinutes(0);
- tdy.setHours(0);
- tmr = new Date(1*tdy + 86400000);
+ function initialize() {
dbg = document.getElementById("debug");
canvas = document.getElementById("plot");
ctx = canvas.getContext("2d");
resize();
+ today();
- xmlhttp = new XMLHttpRequest();
- sendquery(tdy.toISOString(), tmr.toISOString());
+ document.getElementById("today").onclick = today;
+ document.getElementById("yesterday").onclick = yesterday;
+ document.getElementById("beforeyesterday").onclick = beforeyesterday;
+ //document.getElementById("thisweek").onclick = thisweek;
+ //document.getElementById("lastweek").onclick = lastweek;
}
/* Set up */
@@ -262,6 +308,25 @@ canvas#plot {
height: 320px;
border: solid 1px black;
}
+div#queries {
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 10px;
+ text-align: center;
+}
+div.query {
+ display: inline-block;
+ width: 8em;
+ height: 8em;
+ border: solid 1px black;
+ background-color: lightgray;
+ cursor: pointer;
+ vertical-align: middle;
+}
+span.query {
+ display: inline-block;
+ vertical-align: middle; /* does not work for some reason */
+}
body {
margin: 0px;
}
@@ -277,6 +342,14 @@ body {
-