X-Git-Url: http://www.average.org/gitweb/?p=pulsecounter.git;a=blobdiff_plain;f=web%2Findex.html;h=490e21f6c273d6010d1668a310eb774b623a07fa;hp=24d58a725208a8e0de61b5c883d97417ef42d95f;hb=16c5c402a89494b17377d09dee6c97685ce1bdb1;hpb=a2ad72fa6690b49639c60d0ea3754f31c9ba374b diff --git a/web/index.html b/web/index.html index 24d58a7..490e21f 100644 --- a/web/index.html +++ b/web/index.html @@ -10,7 +10,7 @@ var ww, wh; var hmax, hfact; var tmin, tmax, tfact; - var xzero = 20, yzero = 20; + var xzero = 36, yzero = 24; var cold_d = [], hot_d = []; function showdate(utime) { @@ -25,16 +25,16 @@ var scl = Math.floor(d / ord); var inc, inc2, first, x, lb; - if (scl < 2) { inc = 0.1; inc2 = 0.5; } - else if (scl < 5) { inc = 0.2; inc2 = 1; } - else { inc = 0.5; inc2 = 2; } + if (scl < 2) { inc = 0.1; inc2 = 0.2; } + else if (scl < 5) { inc = 0.1; inc2 = 0.2; } + else { inc = 0.5; inc2 = 1; } inc *= ord; inc2 *= ord; first = (Math.floor(lo / inc) + 1) * inc; - for (x = 0; x < (d / inc) - 1.5; x++) + for (x = 0; x < (d / inc) - 1.2; x++) comb.push(first + inc * x); first = (Math.floor(lo / inc2) + 1) * inc2; - for (x = 0; x < (d / inc2) - 1.5; x++) + for (x = 0; x < (d / inc2) - 1.2; x++) lb.push(first + inc2 * x); //dbg.innerHTML = "ord=" + ord + "
inc=" + inc + "
" // + comb + "
" + lb; @@ -57,11 +57,11 @@ ctx.stroke(); ctx.fillStyle = "black"; - ctx.font = "bold 8px Courier"; + ctx.font = "bold 12px Courier"; ctx.textAlign = "left"; - ctx.fillText(showdate(tmin), px(tmin), py(0) + 16); + ctx.fillText(showdate(tmin), px(tmin), py(0) + 20); ctx.textAlign = "right"; - ctx.fillText(showdate(tmax), px(tmax), py(0) + 16); + ctx.fillText(showdate(tmax), px(tmax), py(0) + 20); } function yaxis() { @@ -83,14 +83,14 @@ ctx.stroke(); ctx.fillStyle = "black"; - ctx.font = "bold 8px Courier"; + ctx.font = "bold 12px Courier"; ctx.textAlign = "right"; - ctx.fillText(0, px(tmin) - 2, py(0)); + ctx.fillText(0, px(tmin) - 6, py(0)); for (i = 0; comb[1][i]; i++) { - ctx.fillText(comb[1][i], px(tmin) - 2, py(comb[1][i])); + ctx.fillText(comb[1][i].toFixed(1), px(tmin) - 6, py(comb[1][i])); } ctx.textAlign = "left"; - ctx.fillText("l/h", px(tmin) + 2, py(hmax) + 8); + ctx.fillText("l/h", px(tmin) + 4, py(hmax) + 8); } /* @ updates global var `hmax` */ @@ -216,6 +216,28 @@ return date; } + function prevweek() { + var tdy = daystart(new Date()); + var dow = tdy.getDay(); + var wstart, wend; + + wstart = new Date(1*tdy - 86400000 * (dow + 7)); + wend = new Date(1*wstart + 86400000 * 7); + xmlhttp = new XMLHttpRequest(); + sendquery(wstart.toISOString(), wend.toISOString()); + } + + function thisweek() { + var tdy = daystart(new Date()); + var dow = tdy.getDay(); + var wstart, wend; + + wstart = new Date(1*tdy - 86400000 * dow); + wend = new Date(1*wstart + 86400000 * 7); + xmlhttp = new XMLHttpRequest(); + sendquery(wstart.toISOString(), wend.toISOString()); + } + function beforeyesterday() { var tdy = daystart(new Date()); var ytd = new Date(1*tdy - 86400000); @@ -248,8 +270,8 @@ 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; + document.getElementById("thisweek").onclick = thisweek; + document.getElementById("prevweek").onclick = prevweek; } /* Set up */ @@ -306,7 +328,7 @@ canvas#plot { display: block; width: 640px; height: 320px; - border: solid 1px black; + /* border: solid 1px black; */ } div#queries { margin-left: auto; @@ -316,6 +338,7 @@ div#queries { } div.query { display: inline-block; + position: relative; width: 8em; height: 8em; border: solid 1px black; @@ -323,9 +346,13 @@ div.query { cursor: pointer; vertical-align: middle; } -span.query { - display: inline-block; - vertical-align: middle; /* does not work for some reason */ +div.label { + display: block; + width: 100%; + position: absolute; + top: 50%; + transform: translate(0, -50%); + vertical-align: middle; } body { margin: 0px; @@ -343,12 +370,12 @@ body {
-
PREV WEEK
-
DAY - BEFORE YESTERDAY
-
YESTERDAY
-
TODAY
-
THIS WEEK
+
PREVIOUS WEEK
+
DAY + BEFORE YESTERDAY
+
YESTERDAY
+
TODAY
+
THIS WEEK