X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=web%2Findex.html;h=9181b7963ac0e6f56b1458549282b035278d760e;hb=c304a2583cac01bbf48a3d43cb3299a24ec362e6;hp=0c6c1777b3a1870ac20e2ce6fc4f9843fb2e3785;hpb=52f2a01b64c56d1c0e27a411fe524a926b59c398;p=pulsecounter.git
diff --git a/web/index.html b/web/index.html
index 0c6c177..9181b79 100644
--- a/web/index.html
+++ b/web/index.html
@@ -9,7 +9,7 @@
var ww, wh;
var hmax, hfact;
var tmin, tmax, tfact;
- var xzero = 40, yzero = 48;
+ var xzero = 60, yzero = 48;
var cold_d = [], hot_d = [];
function showdate(utime) {
@@ -28,10 +28,10 @@
const mn = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
- function getcombx(lo, hi) {
+ function getcombx(tmin, tmax) {
var comb = [], lb = [];
var trange = tmax - tmin;
- var inc, inc2, base, t, dt;
+ var inc, inc2, base, base2, t, dt, zoff;
var label = function(t) { return "<<" + t.toFixed(1) + ">>"; }
function tohour(t) { var dt = new Date(t*1000); return dt.getHours(); }
function todow(t) { var dt = new Date(t*1000); return dow[dt.getDay()]; }
@@ -56,25 +56,28 @@
else { /* ~ one month */
/* TODO: make this a separate case with loop over months rather than
fixed number of seconds. */
- inc = 2592000;
+ inc = 86400;
inc2 = 2592000;
label = tomonth;
}
dt = new Date(tmin*1000);
- base = (Math.floor(tmin / inc) + 1) * inc + 60 * dt.getTimezoneOffset();
+ zoff = 60 * dt.getTimezoneOffset();
+ base = (Math.floor((tmin - zoff - 1) / inc) + 1) * inc + zoff;
for (t = base; t < tmax; t += inc)
comb.push(t);
- base = (Math.floor(tmin / inc2) + 1) * inc2 + 60 * dt.getTimezoneOffset();
- for (t = base; t < tmax; t += inc2)
+ base2 = (Math.floor((tmin - zoff - 1) / inc2) + 1) * inc2 + zoff;
+ for (t = base2; t < tmax; t += inc2)
lb.push([t, label(t)]);
- //dbg.innerHTML = "ord=" + ord + "
inc=" + inc + "
"
+ //dbg.innerHTML = "inc=" + inc + "
inc2=" + inc2 + "
"
+ // + "tmin=" + tmin + " tmax=" + tmax + "
"
+ // + "base=" + base + " base2=" + base2 + "
"
// + comb + "
" + lb;
return [comb, lb];
}
function xaxis() {
- var comb = getcombx(0, hmax);
+ var comb = getcombx(tmin, tmax);
var i;
ctx.beginPath();
@@ -241,10 +244,14 @@
document.getElementById("curhot").innerHTML =
(data.current.hot / 100).toFixed(2);
- document.getElementById("totcold").innerHTML =
- ((data.cold[data.cold.length - 1][1] - data.cold[0][1]) * 10);
- document.getElementById("tothot").innerHTML =
- ((data.hot[data.hot.length - 1][1] - data.hot[0][1]) * 10);
+ if (data.cold.length)
+ document.getElementById("totcold").innerHTML =
+ ((data.cold[data.cold.length - 1][1] - data.cold[0][1]) * 10);
+ else document.getElementById("totcold").innerHTML = "0";
+ if (data.hot.length)
+ document.getElementById("tothot").innerHTML =
+ ((data.hot[data.hot.length - 1][1] - data.hot[0][1]) * 10);
+ else document.getElementById("tothot").innerHTML = "0";
tmin = data.range.lo;
tmax = data.range.hi;