| 1 | var debug = true;
|
|---|
| 2 |
|
|---|
| 3 | function $(id) { return document.getElementById(id); }
|
|---|
| 4 | function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); }
|
|---|
| 5 | function valid(str) { if (str==undefined) return false; if (str.length==0) return false; return true;}
|
|---|
| 6 | function isSliding() { var z = $("body").getAttribute("data-visible"); return $("table"+z).offsetLeft!=0; }
|
|---|
| 7 |
|
|---|
| 8 | function cycleCol(el)
|
|---|
| 9 | {
|
|---|
| 10 | var col = el.getAttribute("data-color");
|
|---|
| 11 | col++;
|
|---|
| 12 | col %= 31;
|
|---|
| 13 | el.setAttribute("data-color", col);
|
|---|
| 14 | if (col>16)
|
|---|
| 15 | col = 31-col;
|
|---|
| 16 | var hex = col.toString(16);
|
|---|
| 17 | el.style.color = "#"+hex+"0"+hex+"0"+hex+"f";
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | function onload()
|
|---|
| 21 | {
|
|---|
| 22 | try { xmlHttp = new XMLHttpRequest(); }
|
|---|
| 23 | catch(e)
|
|---|
| 24 | {
|
|---|
| 25 | alert("Your browser doesn't support dynamic reload.");
|
|---|
| 26 | return;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | /*
|
|---|
| 30 | alert("0 -- "+navigator.appCodeName+"\n"+
|
|---|
| 31 | "1 -- "+navigator.appName+"\n"+
|
|---|
| 32 | "2 -- "+navigator.appVersion+"\n"+
|
|---|
| 33 | "3 -- "+navigator.platform+"\n"+
|
|---|
| 34 | "4 -- "+navigator.userAgent);
|
|---|
| 35 | */
|
|---|
| 36 | loadPage("fact", 0, 0);
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | function onresize()
|
|---|
| 40 | {
|
|---|
| 41 | var z = $("body").getAttribute("data-visible");
|
|---|
| 42 | doresize(z);
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | function loadPage(name, z, dz)
|
|---|
| 46 | {
|
|---|
| 47 | var xmlHttp = new XMLHttpRequest();
|
|---|
| 48 | xmlHttp.open('POST', name+'.table', true);
|
|---|
| 49 | xmlHttp.onload = function ()
|
|---|
| 50 | {
|
|---|
| 51 | if (xmlHttp.status!=200)
|
|---|
| 52 | {
|
|---|
| 53 | alert("ERROR[0] - HTTP request '"+name+".table': "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
|
|---|
| 54 | //setTimeout("loadPage('+name+')", 5000);
|
|---|
| 55 | /****** invalidate ******/
|
|---|
| 56 | return;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | buildPage(name, xmlHttp.responseText, z, dz);
|
|---|
| 60 | changePage(z, z+dz);
|
|---|
| 61 |
|
|---|
| 62 | //changePage(name, xmlHttp.resposeText);
|
|---|
| 63 | //slideOut(name, xmlHttp.responseText);
|
|---|
| 64 | //displayPage(name, xmlHttp.responseText);
|
|---|
| 65 | //onresize(true);
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | xmlHttp.send(null);
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | function buildPage(name, text, oldz, dz)
|
|---|
| 73 | {
|
|---|
| 74 | var fname = dz==0 ? "fact" : $("table"+oldz).getAttribute("data-file");
|
|---|
| 75 |
|
|---|
| 76 | var z = oldz + dz;
|
|---|
| 77 |
|
|---|
| 78 | var lines = text.split('\n');
|
|---|
| 79 |
|
|---|
| 80 | if (lines.length==0)
|
|---|
| 81 | {
|
|---|
| 82 | alert("buildPage - received data empty.");
|
|---|
| 83 | return;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | var table = $("table"+z);
|
|---|
| 87 | if (table != undefined)
|
|---|
| 88 | $("body").removeChild(table);
|
|---|
| 89 |
|
|---|
| 90 | table = document.createElement("table");
|
|---|
| 91 | table.setAttribute("class", "tborder");
|
|---|
| 92 | table.setAttribute("id", "table"+z);
|
|---|
| 93 | table.setAttribute("border", "0");
|
|---|
| 94 | table.setAttribute("cellspacing", "0");
|
|---|
| 95 | table.setAttribute("cellpadding", "6");
|
|---|
| 96 | table.setAttribute("width", "100%");
|
|---|
| 97 | table.setAttribute("style", "overflow:hidden;position:fixed;top:0px;left:"+window.innerWidth+"px;");
|
|---|
| 98 |
|
|---|
| 99 | // -----------------------------------------------------
|
|---|
| 100 |
|
|---|
| 101 | var th = document.createElement("thead");
|
|---|
| 102 | th.setAttribute("colspan", "3");
|
|---|
| 103 | th.setAttribute("width", "100%");
|
|---|
| 104 | table.appendChild(th);
|
|---|
| 105 |
|
|---|
| 106 | var htr = document.createElement("tr");
|
|---|
| 107 | th.appendChild(htr);
|
|---|
| 108 |
|
|---|
| 109 | var htd = document.createElement("td");
|
|---|
| 110 | htd.setAttribute("class", "thead");
|
|---|
| 111 | htd.setAttribute("colspan", "3");
|
|---|
| 112 | htd.setAttribute("width", "100%");
|
|---|
| 113 | htr.appendChild(htd);
|
|---|
| 114 |
|
|---|
| 115 | // -------------
|
|---|
| 116 |
|
|---|
| 117 | var htab = document.createElement("table");
|
|---|
| 118 | htab.setAttribute("width", "100%");
|
|---|
| 119 | htd.appendChild(htab);
|
|---|
| 120 |
|
|---|
| 121 | var hhtr = document.createElement("tr");
|
|---|
| 122 | htab.appendChild(hhtr);
|
|---|
| 123 |
|
|---|
| 124 | var htd0 = document.createElement("td");
|
|---|
| 125 | var htd1 = document.createElement("td");
|
|---|
| 126 | var htd2 = document.createElement("td");
|
|---|
| 127 | var htd3 = document.createElement("td");
|
|---|
| 128 | htd0.setAttribute("class", "tcell1");
|
|---|
| 129 | htd1.setAttribute("class", "tcell2");
|
|---|
| 130 | htd2.setAttribute("class", "tcell1");
|
|---|
| 131 | htd2.setAttribute("width", "1px");
|
|---|
| 132 | htd3.setAttribute("class", "tcell1");
|
|---|
| 133 | htd3.setAttribute("width", "1px");
|
|---|
| 134 | hhtr.appendChild(htd3);
|
|---|
| 135 | hhtr.appendChild(htd0);
|
|---|
| 136 | hhtr.appendChild(htd1);
|
|---|
| 137 | hhtr.appendChild(htd2);
|
|---|
| 138 |
|
|---|
| 139 | var div0 = document.createElement("div");
|
|---|
| 140 | var div1 = document.createElement("div");
|
|---|
| 141 | var div2 = document.createElement("div");
|
|---|
| 142 | var div3 = document.createElement("div");
|
|---|
| 143 | div0.setAttribute("style", "font-size:x-large;");
|
|---|
| 144 | div2.setAttribute("class", "icon_white");
|
|---|
| 145 | div2.setAttribute("onclick","this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('"+fname+"',"+z+","+(-dz)+");");
|
|---|
| 146 | div2.setAttribute("style", "background-position:-396px 50%;");
|
|---|
| 147 | div3.setAttribute("class", "icon_white");
|
|---|
| 148 | div3.setAttribute("onclick","this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact',"+z+","+(-z)+");");
|
|---|
| 149 | div3.setAttribute("style", "background-position:-575px 50%;");
|
|---|
| 150 |
|
|---|
| 151 | var sp0 = document.createElement("span");
|
|---|
| 152 | var sp1 = document.createElement("span");
|
|---|
| 153 | var sp2 = document.createElement("span");
|
|---|
| 154 | sp0.setAttribute("id", "ldot" +z);
|
|---|
| 155 | sp1.setAttribute("id", "title"+z);
|
|---|
| 156 | sp2.setAttribute("id", "rdot" +z);
|
|---|
| 157 | sp0.setAttribute("data-color", "3");
|
|---|
| 158 | sp2.setAttribute("data-color", "3");
|
|---|
| 159 | sp0.appendChild(document.createTextNode(" \u2022 "));
|
|---|
| 160 | sp1.appendChild(document.createTextNode(lines[0]));
|
|---|
| 161 | sp2.appendChild(document.createTextNode(" \u2022 "));
|
|---|
| 162 |
|
|---|
| 163 | div0.appendChild(sp0);
|
|---|
| 164 | div0.appendChild(sp1);
|
|---|
| 165 | div0.appendChild(sp2);
|
|---|
| 166 |
|
|---|
| 167 | div1.setAttribute("style", "font-size:small;");
|
|---|
| 168 | div1.setAttribute("id", "reporttime"+z);
|
|---|
| 169 | div1.appendChild(document.createTextNode("---"));
|
|---|
| 170 |
|
|---|
| 171 | htd0.appendChild(div0);
|
|---|
| 172 | htd1.appendChild(div1);
|
|---|
| 173 | if (dz!=0/* && z+dz!=0*/)
|
|---|
| 174 | htd2.appendChild(div2); // back
|
|---|
| 175 | if (lines[0]!="FACT")
|
|---|
| 176 | htd3.appendChild(div3); // home
|
|---|
| 177 |
|
|---|
| 178 | // -----------------------------------------------------
|
|---|
| 179 |
|
|---|
| 180 | var tbody = document.createElement("tbody");
|
|---|
| 181 | table.appendChild(tbody);
|
|---|
| 182 |
|
|---|
| 183 | // -----------------------------------------------------
|
|---|
| 184 |
|
|---|
| 185 | var tf = document.createElement("tfoot");
|
|---|
| 186 | table.appendChild(tf);
|
|---|
| 187 |
|
|---|
| 188 | var ftr = document.createElement("tr");
|
|---|
| 189 | tf.appendChild(ftr);
|
|---|
| 190 |
|
|---|
| 191 | var ftd = document.createElement("td");
|
|---|
| 192 | ftd.setAttribute("class", "tfoot");
|
|---|
| 193 | ftd.setAttribute("width", "100%");
|
|---|
| 194 | ftd.setAttribute("colspan", "3");
|
|---|
| 195 | ftr.appendChild(ftd);
|
|---|
| 196 |
|
|---|
| 197 | var ftab = document.createElement("table");
|
|---|
| 198 | ftab.setAttribute("width", "100%");
|
|---|
| 199 | ftd.appendChild(ftab);
|
|---|
| 200 |
|
|---|
| 201 | var ftd0 = document.createElement("td");
|
|---|
| 202 | var ftd1 = document.createElement("td");
|
|---|
| 203 |
|
|---|
| 204 | ftd0.setAttribute("class", "tcell1");
|
|---|
| 205 | ftd1.setAttribute("class", "tcell2");
|
|---|
| 206 |
|
|---|
| 207 | ftab.appendChild(ftd0);
|
|---|
| 208 | ftab.appendChild(ftd1);
|
|---|
| 209 |
|
|---|
| 210 | var fdiv0 = document.createElement("div");
|
|---|
| 211 | var fdiv1 = document.createElement("div");
|
|---|
| 212 |
|
|---|
| 213 | fdiv0.setAttribute("style", "font-size:x-large;");
|
|---|
| 214 | fdiv1.setAttribute("style", "font-size:small;");
|
|---|
| 215 | fdiv1.setAttribute("id", "localtime"+z);
|
|---|
| 216 |
|
|---|
| 217 | fdiv0.appendChild(document.createTextNode("logbook"));
|
|---|
| 218 | fdiv1.appendChild(document.createTextNode("loading..."));
|
|---|
| 219 |
|
|---|
| 220 | ftd0.appendChild(fdiv0);
|
|---|
| 221 | ftd1.appendChild(fdiv1);
|
|---|
| 222 |
|
|---|
| 223 | $("body").appendChild(table);
|
|---|
| 224 |
|
|---|
| 225 | var counter = 1;
|
|---|
| 226 | for (var i=1; i<lines.length; i++)
|
|---|
| 227 | {
|
|---|
| 228 | lines[i] = trim(lines[i]);
|
|---|
| 229 |
|
|---|
| 230 | if (lines[i].length==0 || lines[i][0] == '#')
|
|---|
| 231 | continue;
|
|---|
| 232 |
|
|---|
| 233 | var cols = lines[i].split(':');
|
|---|
| 234 | if (cols.length != 3 && cols.length !=4)
|
|---|
| 235 | {
|
|---|
| 236 | alert("Size mismatch #"+i+": '"+lines[i]+"' N(cols)="+cols.length);
|
|---|
| 237 | continue;
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | var check = cols[1].split("=");
|
|---|
| 241 |
|
|---|
| 242 | if (check.length>1 && (check[0]=="camera" || check[0]=="hist"))
|
|---|
| 243 | {
|
|---|
| 244 | var data = cols[1].substring(check[0].length+1).split("/");
|
|---|
| 245 |
|
|---|
| 246 | var tr = document.createElement("tr");
|
|---|
| 247 | tr.setAttribute("class", "row");
|
|---|
| 248 | //tr.setAttribute("style", "margin:0;padding:0;");
|
|---|
| 249 |
|
|---|
| 250 | var td = document.createElement("td");
|
|---|
| 251 | td.setAttribute("class", "container");
|
|---|
| 252 | td.setAttribute("id", "container");
|
|---|
| 253 | //td.setAttribute("onclick", "save();");
|
|---|
| 254 | td.setAttribute("colspan", "3");
|
|---|
| 255 | tr.appendChild(td);
|
|---|
| 256 |
|
|---|
| 257 | var canv = document.createElement("canvas");
|
|---|
| 258 | canv.setAttribute("id", "canvas"+z);
|
|---|
| 259 | canv.setAttribute("width", "1");
|
|---|
| 260 | canv.setAttribute("height", "1");
|
|---|
| 261 | canv.setAttribute("data-type", check[0]);
|
|---|
| 262 | canv.setAttribute("data-file", data[0]);
|
|---|
| 263 | canv.setAttribute("data-data", cols[1].substring(check[0].length+data[0].length+2));
|
|---|
| 264 | canv.setAttribute("style", "display:none;");
|
|---|
| 265 | td.appendChild(canv);
|
|---|
| 266 |
|
|---|
| 267 | var img = document.createElement("img");
|
|---|
| 268 | img.src = "dummy.png";//needed in firefox
|
|---|
| 269 | img.setAttribute("id", "image"+z);
|
|---|
| 270 | img.setAttribute("style", "width:1px;height:1px;");
|
|---|
| 271 | td.appendChild(img);
|
|---|
| 272 |
|
|---|
| 273 | tbody.appendChild(tr);
|
|---|
| 274 | continue;
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | var tr = document.createElement("tr");
|
|---|
| 278 | tr.setAttribute("class", "row");
|
|---|
| 279 | if (valid(cols[0]))
|
|---|
| 280 | tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[0]+"',"+z+",-1);");
|
|---|
| 281 | if (valid(cols[3]))
|
|---|
| 282 | tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[3]+"',"+z+",+1);");
|
|---|
| 283 | //tr.setAttribute("id", cols[0]+"_row");
|
|---|
| 284 |
|
|---|
| 285 | var td0 = document.createElement("td");
|
|---|
| 286 | td0.setAttribute("class", "tcol0");
|
|---|
| 287 | if (valid(cols[0]))
|
|---|
| 288 | {
|
|---|
| 289 | var sp = document.createElement("div");
|
|---|
| 290 | sp.setAttribute("class", "icon_black");
|
|---|
| 291 | sp.setAttribute("style", "background-position: -144px 50%;");
|
|---|
| 292 | td0.appendChild(sp);
|
|---|
| 293 | }
|
|---|
| 294 | tr.appendChild(td0);
|
|---|
| 295 |
|
|---|
| 296 | var td1 = document.createElement("td");
|
|---|
| 297 | td1.setAttribute("class", "tcol1");
|
|---|
| 298 | td1.setAttribute("width", "100%");
|
|---|
| 299 | tr.appendChild(td1);
|
|---|
| 300 |
|
|---|
| 301 | var td2 = document.createElement("td");
|
|---|
| 302 | td2.setAttribute("class", "tcol2");
|
|---|
| 303 | td2.setAttribute("width", "18px");
|
|---|
| 304 | if (valid(cols[3]))
|
|---|
| 305 | {
|
|---|
| 306 | var sp = document.createElement("div");
|
|---|
| 307 | sp.setAttribute("class", "icon_black");
|
|---|
| 308 | sp.setAttribute("style", "background-position: -108px 50%;");
|
|---|
| 309 | td2.appendChild(sp);
|
|---|
| 310 | }
|
|---|
| 311 | tr.appendChild(td2);
|
|---|
| 312 |
|
|---|
| 313 | var tab = document.createElement("table");
|
|---|
| 314 | tab.setAttribute("width", "100%");
|
|---|
| 315 | td1.appendChild(tab);
|
|---|
| 316 |
|
|---|
| 317 | var innertr = document.createElement("tr");
|
|---|
| 318 | tab.appendChild(innertr);
|
|---|
| 319 |
|
|---|
| 320 | var cell1 = document.createElement("td");
|
|---|
| 321 | cell1.setAttribute("class", "tcell1");
|
|---|
| 322 | //cell1.setAttribute("id", cols[0]+"_title");
|
|---|
| 323 | cell1.appendChild(document.createTextNode(cols[1]));
|
|---|
| 324 |
|
|---|
| 325 | var cell2 = document.createElement("td");
|
|---|
| 326 | cell2.setAttribute("class", "tcell2");
|
|---|
| 327 | cell2.setAttribute("id", "data"+counter);
|
|---|
| 328 | cell2.setAttribute("data-form", cols[2]);
|
|---|
| 329 | cell2.appendChild(document.createTextNode("---"));
|
|---|
| 330 |
|
|---|
| 331 | innertr.appendChild(cell1);
|
|---|
| 332 | innertr.appendChild(cell2);
|
|---|
| 333 |
|
|---|
| 334 | tbody.appendChild(tr);
|
|---|
| 335 |
|
|---|
| 336 | counter++;
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 | // ---------------------------------------
|
|---|
| 340 |
|
|---|
| 341 | tr = document.createElement("tr");
|
|---|
| 342 | tr.setAttribute("class", "row");
|
|---|
| 343 |
|
|---|
| 344 | if (debug == true)
|
|---|
| 345 | {
|
|---|
| 346 | td = document.createElement("td");
|
|---|
| 347 | td.setAttribute("id", "debug"+z);
|
|---|
| 348 | td.setAttribute("colspan", "3");
|
|---|
| 349 | tr.appendChild(td);
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | tbody.appendChild(tr);
|
|---|
| 353 |
|
|---|
| 354 | // ---------------------------------------
|
|---|
| 355 |
|
|---|
| 356 | table.setAttribute("data-file", name);
|
|---|
| 357 | doresize(z);
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 | function doresize(z)
|
|---|
| 361 | {
|
|---|
| 362 | // 393 / 482 488/482 / 200 200+482-488
|
|---|
| 363 | var img = $("image"+z);
|
|---|
| 364 | var canv = $("canvas"+z);
|
|---|
| 365 | if (img == undefined || canv == undefined)
|
|---|
| 366 | return;
|
|---|
| 367 |
|
|---|
| 368 | var h = $("table"+z).offsetHeight;
|
|---|
| 369 | if (h == 0)
|
|---|
| 370 | return;
|
|---|
| 371 |
|
|---|
| 372 | var W = window.innerWidth;
|
|---|
| 373 | var H = window.innerHeight;
|
|---|
| 374 |
|
|---|
| 375 | var ih = H - h + parseInt(img.style.height, 10);
|
|---|
| 376 |
|
|---|
| 377 | img.style.width = W +"px";
|
|---|
| 378 | img.style.height= ih+"px";
|
|---|
| 379 |
|
|---|
| 380 | canv.width = W;
|
|---|
| 381 | canv.height = ih;
|
|---|
| 382 |
|
|---|
| 383 | // ------ debug -----
|
|---|
| 384 | if (debug == true)
|
|---|
| 385 | {
|
|---|
| 386 | $('debug'+z).innerHTML = "";
|
|---|
| 387 | $('debug'+z).innerHTML += "|W="+W +"/"+H;
|
|---|
| 388 | $('debug'+z).innerHTML += "|H="+h+"/"+$("table"+z).offsetHeight+"/"+img.offsetHeight;
|
|---|
| 389 | $('debug'+z).innerHTML += "|I="+img.style.height+"+"+H+"-"+h;
|
|---|
| 390 | }
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | var intervalSlide = null;
|
|---|
| 394 |
|
|---|
| 395 | function changePage(oldz, newz)
|
|---|
| 396 | {
|
|---|
| 397 | // No page displayed yet
|
|---|
| 398 | if (oldz==newz)
|
|---|
| 399 | {
|
|---|
| 400 | $("table"+newz).style.left="0px";
|
|---|
| 401 | $("body").setAttribute("data-visible", newz);
|
|---|
| 402 |
|
|---|
| 403 | doresize(0);
|
|---|
| 404 |
|
|---|
| 405 | //setInterval(refresh_text, 1000);
|
|---|
| 406 | //setInterval(refresh_graphics, 5000);
|
|---|
| 407 |
|
|---|
| 408 | refresh_text();
|
|---|
| 409 | refresh_graphics();
|
|---|
| 410 | return;
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | //intervalSlide = setInterval("doSlideOut("+z+")", 25);
|
|---|
| 414 |
|
|---|
| 415 | //var k = (z+1)%2;
|
|---|
| 416 | //$("table"+k).style.display="";
|
|---|
| 417 | //$("table"+z).style.display="";
|
|---|
| 418 | //$("table"+k).style.zIndex="0";
|
|---|
| 419 | //$("table"+z).style.zIndex="1";
|
|---|
| 420 | //$("table"+k).style.left=0;
|
|---|
| 421 | //$("table"+z).style.left=0;
|
|---|
| 422 | //$("table"+k).style.backgroundColor = "#ffffff";
|
|---|
| 423 | //$("table"+z).style.backgroundColor = "#ffffff";
|
|---|
| 424 | //doresize(k);
|
|---|
| 425 | //intervalSlide = setInterval("doSlide("+z+",1)", 50);
|
|---|
| 426 |
|
|---|
| 427 | if (newz>oldz)
|
|---|
| 428 | $("table"+newz).style.left=window.innerWidth+"px";
|
|---|
| 429 | else
|
|---|
| 430 | $("table"+newz).style.left=(-window.innerWidth-1)+"px";
|
|---|
| 431 |
|
|---|
| 432 | //window.clearTimeout(timeoutText);
|
|---|
| 433 | //window.clearTimeout(timeoutGraphics);
|
|---|
| 434 |
|
|---|
| 435 | $("body").setAttribute("data-visible", newz);
|
|---|
| 436 | intervalSlide = setInterval(doShift, 75, oldz, newz);
|
|---|
| 437 | }
|
|---|
| 438 |
|
|---|
| 439 | function doShift(oldz, newz)
|
|---|
| 440 | {
|
|---|
| 441 | var t0 = $("table"+oldz);
|
|---|
| 442 | var t1 = $("table"+newz);
|
|---|
| 443 |
|
|---|
| 444 | if (t0.style.display=="none")
|
|---|
| 445 | {
|
|---|
| 446 | clearInterval(intervalSlide);
|
|---|
| 447 | $("body").removeChild(t0);
|
|---|
| 448 | return;
|
|---|
| 449 | }
|
|---|
| 450 |
|
|---|
| 451 | var x0 = t0.offsetLeft;
|
|---|
| 452 | var x1 = t1.offsetLeft;
|
|---|
| 453 |
|
|---|
| 454 | var W = window.innerWidth;
|
|---|
| 455 |
|
|---|
| 456 | if (newz<oldz)
|
|---|
| 457 | {
|
|---|
| 458 | x0 += W/5;
|
|---|
| 459 | x1 += W/5;
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | if (newz>oldz)
|
|---|
| 463 | {
|
|---|
| 464 | x0 -= W/5;
|
|---|
| 465 | x1 -= W/5;
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | if ((newz<oldz && x1>=0) || (newz>oldz && x1<=0))
|
|---|
| 469 | {
|
|---|
| 470 | t0.style.display="none";
|
|---|
| 471 | x1 = 0;
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | t0.style.left = x0+"px";
|
|---|
| 475 | t1.style.left = x1+"px";
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | /*
|
|---|
| 479 | function doSlide(z, dir)
|
|---|
| 480 | {
|
|---|
| 481 | var k = (z+1)%2;
|
|---|
| 482 |
|
|---|
| 483 | var W = window.innerWidth;
|
|---|
| 484 |
|
|---|
| 485 | var tz = $("table"+z);
|
|---|
| 486 | var tk = $("table"+k);
|
|---|
| 487 |
|
|---|
| 488 | var xz = tz.offsetLeft;
|
|---|
| 489 | var xk = tk.offsetLeft;
|
|---|
| 490 |
|
|---|
| 491 | var ixz = parseInt(xz, 10);
|
|---|
| 492 | var ikz = parseInt(xk, 10);
|
|---|
| 493 |
|
|---|
| 494 | ixz += dir*W/10;
|
|---|
| 495 | ikz -= dir*W/10;
|
|---|
| 496 |
|
|---|
| 497 | tz.style.left = parseInt(ixz, 10)+"px";
|
|---|
| 498 | tk.style.left = parseInt(ikz, 10)+"px";
|
|---|
| 499 |
|
|---|
| 500 | if (ixz>W/2)
|
|---|
| 501 | {
|
|---|
| 502 | clearInterval(intervalSlide);
|
|---|
| 503 |
|
|---|
| 504 | $("table"+k).style.zIndex="1";
|
|---|
| 505 | $("table"+z).style.zIndex="0";
|
|---|
| 506 |
|
|---|
| 507 | $("body").setAttribute("data-visible", k);
|
|---|
| 508 | doresize(k);
|
|---|
| 509 |
|
|---|
| 510 | intervalSlide = setInterval("doSlide("+z+",-1)", 50);
|
|---|
| 511 | }
|
|---|
| 512 | if (ikz>0)
|
|---|
| 513 | {
|
|---|
| 514 | clearInterval(intervalSlide);
|
|---|
| 515 |
|
|---|
| 516 | tz.style.left = 0;
|
|---|
| 517 | tk.style.left = 0;
|
|---|
| 518 |
|
|---|
| 519 | tz.style.display="none";
|
|---|
| 520 | }
|
|---|
| 521 | }
|
|---|
| 522 |
|
|---|
| 523 |
|
|---|
| 524 | function doSlideOut(z)
|
|---|
| 525 | {
|
|---|
| 526 | var table = $("table"+z);
|
|---|
| 527 |
|
|---|
| 528 | var W = window.innerWidth;
|
|---|
| 529 | var x = table.offsetLeft;
|
|---|
| 530 |
|
|---|
| 531 | var ix = parseInt(x, 10);
|
|---|
| 532 | if (ix>W)
|
|---|
| 533 | {
|
|---|
| 534 | clearInterval(intervalSlide);
|
|---|
| 535 |
|
|---|
| 536 | table.style.display="none";
|
|---|
| 537 |
|
|---|
| 538 | z = (z+1)%2;
|
|---|
| 539 | table = $("table"+z);
|
|---|
| 540 |
|
|---|
| 541 | table.style.display="";
|
|---|
| 542 | table.style.left = window.innerWidth+"px";
|
|---|
| 543 |
|
|---|
| 544 | $("body").setAttribute("data-visible", z);
|
|---|
| 545 | doresize(z);
|
|---|
| 546 |
|
|---|
| 547 | intervalSlide = setInterval("doSlideIn("+z+")", 25);
|
|---|
| 548 | return;
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 | ix += W/10;
|
|---|
| 552 | table.style.left=ix+"px";
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 | function doSlideIn(z)
|
|---|
| 556 | {
|
|---|
| 557 | var table = $("table"+z);
|
|---|
| 558 |
|
|---|
| 559 | var W = window.innerWidth;
|
|---|
| 560 | var x = table.offsetLeft;
|
|---|
| 561 |
|
|---|
| 562 | var ix = parseInt(x, 10);
|
|---|
| 563 |
|
|---|
| 564 | ix -= W/10;
|
|---|
| 565 | if (ix<0)
|
|---|
| 566 | ix = 0;
|
|---|
| 567 |
|
|---|
| 568 | table.style.left=ix+"px";
|
|---|
| 569 |
|
|---|
| 570 | if (ix<=0)
|
|---|
| 571 | {
|
|---|
| 572 | clearInterval(intervalSlide);
|
|---|
| 573 | return;
|
|---|
| 574 | }
|
|---|
| 575 | }
|
|---|
| 576 | */
|
|---|
| 577 |
|
|---|
| 578 | var timeoutText = null;
|
|---|
| 579 |
|
|---|
| 580 | function refresh_text()
|
|---|
| 581 | {
|
|---|
| 582 | var z=$("body").getAttribute("data-visible");
|
|---|
| 583 | var table = $("table"+z);
|
|---|
| 584 |
|
|---|
| 585 | // Is sliding or no file defined?
|
|---|
| 586 | var fname = table.getAttribute("data-file");
|
|---|
| 587 | if (isSliding() || !valid(fname))
|
|---|
| 588 | {
|
|---|
| 589 | timeoutText = setTimeout(refresh_text, 1000);
|
|---|
| 590 | return;
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 | var xmlHttp = new XMLHttpRequest();
|
|---|
| 594 | xmlHttp.open('POST', fname+'.txt', true);
|
|---|
| 595 | xmlHttp.onload = function ()
|
|---|
| 596 | {
|
|---|
| 597 | if (xmlHttp.status!=200)
|
|---|
| 598 | {
|
|---|
| 599 | alert("ERROR[1] - HTTP request '"+fname+".txt': "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
|
|---|
| 600 | timeoutText = setTimeout(refresh_text, 10000);
|
|---|
| 601 | return;
|
|---|
| 602 | }
|
|---|
| 603 |
|
|---|
| 604 | if (!isSliding())
|
|---|
| 605 | {
|
|---|
| 606 | cycleCol($("ldot"+z));
|
|---|
| 607 | update_text(fname, xmlHttp.responseText);
|
|---|
| 608 | }
|
|---|
| 609 | timeoutText = setTimeout(refresh_text, 3000);
|
|---|
| 610 | };
|
|---|
| 611 | xmlHttp.send(null);
|
|---|
| 612 | }
|
|---|
| 613 |
|
|---|
| 614 | function strike(e, status)
|
|---|
| 615 | {
|
|---|
| 616 | if (!e)
|
|---|
| 617 | return;
|
|---|
| 618 |
|
|---|
| 619 | if (!status)
|
|---|
| 620 | e.style.textDecoration="line-through";
|
|---|
| 621 | else
|
|---|
| 622 | e.style.textDecoration="";
|
|---|
| 623 | }
|
|---|
| 624 |
|
|---|
| 625 | function gray(id, str)
|
|---|
| 626 | {
|
|---|
| 627 | var e = $(id);
|
|---|
| 628 | if (!e)
|
|---|
| 629 | return;
|
|---|
| 630 |
|
|---|
| 631 | if (valid(str))
|
|---|
| 632 | {
|
|---|
| 633 | e.style.color="#000";
|
|---|
| 634 | e.style.textDecoration="";
|
|---|
| 635 | }
|
|---|
| 636 | else
|
|---|
| 637 | {
|
|---|
| 638 | e.style.color="#daa";
|
|---|
| 639 | e.style.textDecoration="line-through";
|
|---|
| 640 | }
|
|---|
| 641 |
|
|---|
| 642 | }
|
|---|
| 643 |
|
|---|
| 644 | var date0 = null;
|
|---|
| 645 |
|
|---|
| 646 | function update_text(fname, result)
|
|---|
| 647 | {
|
|---|
| 648 | var z=$("body").getAttribute("data-visible");
|
|---|
| 649 | var table = $("table"+z);
|
|---|
| 650 |
|
|---|
| 651 | if (table.getAttribute("data-file") != fname)
|
|---|
| 652 | return;
|
|---|
| 653 |
|
|---|
| 654 | var tokens = result.split('\n');
|
|---|
| 655 |
|
|---|
| 656 | // ----------------------------------------------------
|
|---|
| 657 |
|
|---|
| 658 | var time = $("reporttime"+z);
|
|---|
| 659 | var ltime = $("localtime"+z);
|
|---|
| 660 |
|
|---|
| 661 | var date1 = new Date();
|
|---|
| 662 |
|
|---|
| 663 | if (tokens[0].length!=13)
|
|---|
| 664 | {
|
|---|
| 665 | if (date0 != null)
|
|---|
| 666 | strike(time, date0.getTime()+60000>date1.getTime());
|
|---|
| 667 | // FIXME: Reset display to "---" values -- no connection
|
|---|
| 668 | return;
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| 671 | var date2 = new Date();
|
|---|
| 672 | date2.setTime(tokens[0]);
|
|---|
| 673 |
|
|---|
| 674 | strike(time, date2.getTime()+60000>date1.getTime());
|
|---|
| 675 |
|
|---|
| 676 | date0 = date2;
|
|---|
| 677 |
|
|---|
| 678 | var utc = date0.toUTCString();
|
|---|
| 679 |
|
|---|
| 680 | time.innerHTML =
|
|---|
| 681 | "• "+utc.substr(utc.length-12, 8)+" UTC •"
|
|---|
| 682 | ltime.innerHTML =
|
|---|
| 683 | "• "+date1.toLocaleString()+" •";
|
|---|
| 684 |
|
|---|
| 685 | // ----------------------------------------------------
|
|---|
| 686 |
|
|---|
| 687 | var p = table.tBodies.length==3 ? 1 : 0;
|
|---|
| 688 | var tbody = table.tBodies[p];
|
|---|
| 689 |
|
|---|
| 690 | for (var line=1; line<tokens.length; line++)
|
|---|
| 691 | {
|
|---|
| 692 | var c = tbody.rows[line-1].cells[1];
|
|---|
| 693 | if (c == undefined)
|
|---|
| 694 | continue;
|
|---|
| 695 |
|
|---|
| 696 | var e = c.childNodes[0].rows[0].cells[1];
|
|---|
| 697 | if (e == undefined)
|
|---|
| 698 | continue;
|
|---|
| 699 |
|
|---|
| 700 | var form = e.getAttribute("data-form");
|
|---|
| 701 | if (form==undefined)
|
|---|
| 702 | continue;
|
|---|
| 703 |
|
|---|
| 704 | var cols = tokens[line].split('\t');
|
|---|
| 705 | for (var col=1; col<cols.length; col++)
|
|---|
| 706 | form = form.replace("\$"+(col-1), cols[col].length==0 ? "--" : cols[col]);
|
|---|
| 707 |
|
|---|
| 708 | if (cols.length<=1)
|
|---|
| 709 | form = "---";
|
|---|
| 710 |
|
|---|
| 711 | var newe = document.createElement("div");
|
|---|
| 712 | newe.innerHTML = form;
|
|---|
| 713 | e.replaceChild(newe, e.lastChild);
|
|---|
| 714 |
|
|---|
| 715 | e.parentNode.parentNode.parentNode.parentNode.style.background=cols[0];
|
|---|
| 716 | }
|
|---|
| 717 | }
|
|---|
| 718 |
|
|---|
| 719 | // http://billmill.org/static/canvastutorial/index.html
|
|---|
| 720 | // http://www.netmagazine.com/tutorials/learning-basics-html5-canvas
|
|---|
| 721 | // http://www.alistapart.com/articles/responsive-web-design/
|
|---|
| 722 |
|
|---|
| 723 | function refresh_graphics()
|
|---|
| 724 | {
|
|---|
| 725 | var z = $("body").getAttribute("data-visible");
|
|---|
| 726 |
|
|---|
| 727 | var canvas = $("canvas"+z);
|
|---|
| 728 |
|
|---|
| 729 | // Is sliding or no data file defined?
|
|---|
| 730 | var fname = canvas==null ? "" : canvas.getAttribute("data-file");
|
|---|
| 731 | if (isSliding() || !valid(fname))
|
|---|
| 732 | {
|
|---|
| 733 | timeoutGraphics = setTimeout(refresh_graphics, 1000);
|
|---|
| 734 | return;
|
|---|
| 735 | }
|
|---|
| 736 |
|
|---|
| 737 | var xmlHttp = new XMLHttpRequest();
|
|---|
| 738 | xmlHttp.open('POST', fname, true);
|
|---|
| 739 | xmlHttp.onload = function()
|
|---|
| 740 | {
|
|---|
| 741 | if (xmlHttp.status!=200)
|
|---|
| 742 | {
|
|---|
| 743 | alert("ERROR[2] - Request '"+fname+"': "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
|
|---|
| 744 | timeoutGraphics = setTimeout(refresh_graphics, 10000);
|
|---|
| 745 | //****** invalidate ******
|
|---|
| 746 | return;
|
|---|
| 747 | }
|
|---|
| 748 |
|
|---|
| 749 | if (!isSliding())
|
|---|
| 750 | {
|
|---|
| 751 | cycleCol($("rdot"+z));
|
|---|
| 752 | process_eventdata(xmlHttp.responseText);
|
|---|
| 753 | }
|
|---|
| 754 | timeoutGraphics = setTimeout(refresh_graphics, 5000)
|
|---|
| 755 | };
|
|---|
| 756 | xmlHttp.send(null);
|
|---|
| 757 | }
|
|---|
| 758 |
|
|---|
| 759 |
|
|---|
| 760 | function hueToRGB(hue)
|
|---|
| 761 | {
|
|---|
| 762 | hue /= 3;
|
|---|
| 763 | hue %= 6;
|
|---|
| 764 |
|
|---|
| 765 | if (hue<1) return parseInt(255*hue, 10);
|
|---|
| 766 | if (hue<3) return parseInt(255, 10);
|
|---|
| 767 | if (hue<4) return parseInt(255*(4-hue), 10);
|
|---|
| 768 |
|
|---|
| 769 | /*
|
|---|
| 770 | if (hue<1*5/4) return parseInt(255*hue*4/5);
|
|---|
| 771 | if (hue<2*5/4) return parseInt(255);
|
|---|
| 772 | if (hue<3*5/4) return parseInt(255*(3*5/4-hue)*4/5);
|
|---|
| 773 | */
|
|---|
| 774 | /*
|
|---|
| 775 | if (hue<1.5) return parseInt(255*hue/1.5);
|
|---|
| 776 | if (hue<3.0) return parseInt(255);
|
|---|
| 777 | if (hue<4.5) return parseInt(255*(4.5-hue)/1.5);
|
|---|
| 778 | */
|
|---|
| 779 | return 0.
|
|---|
| 780 | }
|
|---|
| 781 |
|
|---|
| 782 | function hueToHex(flt)
|
|---|
| 783 | {
|
|---|
| 784 | var s = hueToRGB(flt).toString(16);
|
|---|
| 785 | return s.length==2 ? s : "0"+s;
|
|---|
| 786 | }
|
|---|
| 787 |
|
|---|
| 788 | function HLStoRGB(hue)
|
|---|
| 789 | {
|
|---|
| 790 | hue *= 14;
|
|---|
| 791 |
|
|---|
| 792 | var sr = hueToHex(20-hue);
|
|---|
| 793 | var sg = hueToHex(14-hue);
|
|---|
| 794 | var sb = hueToHex(26-hue);
|
|---|
| 795 |
|
|---|
| 796 | return sr+sg+sb;
|
|---|
| 797 | }
|
|---|
| 798 |
|
|---|
| 799 |
|
|---|
| 800 | function color(col)
|
|---|
| 801 | {
|
|---|
| 802 | if (col==65533)
|
|---|
| 803 | col = 0;
|
|---|
| 804 |
|
|---|
| 805 | var hue = col/128;
|
|---|
| 806 | return HLStoRGB(hue);
|
|---|
| 807 | }
|
|---|
| 808 |
|
|---|
| 809 | function toHex(str, idx)
|
|---|
| 810 | {
|
|---|
| 811 | var ch = str[idx].toString(16);
|
|---|
| 812 | return ch.length==2 ? ch : "0"+ch;
|
|---|
| 813 | }
|
|---|
| 814 |
|
|---|
| 815 | function drawHex(ctx, x, y, col)
|
|---|
| 816 | {
|
|---|
| 817 | ctx.fillStyle = "#"+color(col);
|
|---|
| 818 |
|
|---|
| 819 | ctx.save();
|
|---|
| 820 |
|
|---|
| 821 | ctx.translate(x, y);
|
|---|
| 822 | ctx.scale(1/2, 1/3);
|
|---|
| 823 |
|
|---|
| 824 | ctx.beginPath();
|
|---|
| 825 | ctx.moveTo( 1, 1);
|
|---|
| 826 | ctx.lineTo( 0, 2);
|
|---|
| 827 | ctx.lineTo(-1, 1);
|
|---|
| 828 | ctx.lineTo(-1, -1);
|
|---|
| 829 | ctx.lineTo( 0, -2);
|
|---|
| 830 | ctx.lineTo( 1, -1);
|
|---|
| 831 | ctx.fill();
|
|---|
| 832 |
|
|---|
| 833 | ctx.restore();
|
|---|
| 834 | }
|
|---|
| 835 |
|
|---|
| 836 | function drawDisc(ctx, x, y, r, col)
|
|---|
| 837 | {
|
|---|
| 838 | ctx.fillStyle = "#"+color(col);
|
|---|
| 839 |
|
|---|
| 840 | ctx.save();
|
|---|
| 841 |
|
|---|
| 842 | ctx.translate(x, y);
|
|---|
| 843 |
|
|---|
| 844 | ctx.beginPath();
|
|---|
| 845 | ctx.arc(0, 0, r, 0, Math.PI*2, true);
|
|---|
| 846 | ctx.fill();
|
|---|
| 847 |
|
|---|
| 848 | ctx.restore();
|
|---|
| 849 | }
|
|---|
| 850 |
|
|---|
| 851 | function beginDrawCam(scale)
|
|---|
| 852 | {
|
|---|
| 853 | var z = $("body").getAttribute("data-visible");
|
|---|
| 854 | var canv = $("canvas"+z);
|
|---|
| 855 |
|
|---|
| 856 | var w = Math.min(canv.width/scale, canv.height/scale);
|
|---|
| 857 |
|
|---|
| 858 | var ctx = canv.getContext("2d");
|
|---|
| 859 |
|
|---|
| 860 | ctx.save();
|
|---|
| 861 | ctx.translate(canv.width/2, canv.height/2);
|
|---|
| 862 | ctx.scale(w*2, w*2);
|
|---|
| 863 |
|
|---|
| 864 | return ctx;
|
|---|
| 865 | }
|
|---|
| 866 |
|
|---|
| 867 | function position(s, ring, i)
|
|---|
| 868 | {
|
|---|
| 869 | switch (s)
|
|---|
| 870 | {
|
|---|
| 871 | case 0: this.x = ring - i*0.5; this.y = + i; break;
|
|---|
| 872 | case 1: this.x = ring*0.5 - i; this.y = ring ; break;
|
|---|
| 873 | case 2: this.x = -ring*0.5 - i*0.5; this.y = ring - i; break;
|
|---|
| 874 | case 3: this.x = -ring + i*0.5; this.y = - i; break;
|
|---|
| 875 | case 4: this.x = -ring*0.5 + i; this.y = -ring ; break;
|
|---|
| 876 | case 5: this.x = ring*0.5 + i*0.5; this.y = -ring + i; break;
|
|---|
| 877 | }
|
|---|
| 878 |
|
|---|
| 879 | this.d = function() { return this.x*this.x + this.y*this.y*3/4; }
|
|---|
| 880 | }
|
|---|
| 881 |
|
|---|
| 882 | function drawFullCam(data)
|
|---|
| 883 | {
|
|---|
| 884 | var ctx = beginDrawCam(80.5);
|
|---|
| 885 | ctx.rotate(Math.PI/2);
|
|---|
| 886 |
|
|---|
| 887 | ctx.scale(1, Math.sqrt(3)/2);
|
|---|
| 888 |
|
|---|
| 889 | drawHex(ctx, -0.5, 0, data.charCodeAt(0));
|
|---|
| 890 |
|
|---|
| 891 | var cnt = 1;
|
|---|
| 892 | for (var ring=1; ring<24; ring++)
|
|---|
| 893 | {
|
|---|
| 894 | for (var s=0; s<6; s++)
|
|---|
| 895 | {
|
|---|
| 896 | for (var i=1; i<=ring; i++)
|
|---|
| 897 | {
|
|---|
| 898 | var pos = new position(s, ring, i);
|
|---|
| 899 | if (pos.d() - pos.x > 395.75)
|
|---|
| 900 | continue;
|
|---|
| 901 |
|
|---|
| 902 | drawHex(ctx, pos.x-0.5, -pos.y, data.charCodeAt(cnt++));
|
|---|
| 903 | }
|
|---|
| 904 | }
|
|---|
| 905 | }
|
|---|
| 906 |
|
|---|
| 907 | drawHex(ctx, -6.5, 22, data.charCodeAt(1438));
|
|---|
| 908 | drawHex(ctx, -6.5, -22, data.charCodeAt(1439));
|
|---|
| 909 |
|
|---|
| 910 | ctx.restore();
|
|---|
| 911 | }
|
|---|
| 912 |
|
|---|
| 913 | function drawCam(data)
|
|---|
| 914 | {
|
|---|
| 915 | var ctx = beginDrawCam(27);
|
|---|
| 916 | ctx.rotate(Math.PI/6);
|
|---|
| 917 | ctx.scale(1, Math.sqrt(3)/2);
|
|---|
| 918 |
|
|---|
| 919 | drawHex(ctx, 0, 0, data.charCodeAt(0));
|
|---|
| 920 |
|
|---|
| 921 | var cnt = 1;
|
|---|
| 922 | for (var ring=1; ring<=7; ring++)
|
|---|
| 923 | {
|
|---|
| 924 | for (var s=0; s<6; s++)
|
|---|
| 925 | {
|
|---|
| 926 | for (var i=1; i<=ring; i++)
|
|---|
| 927 | {
|
|---|
| 928 | var pos = new position(s, ring, i);
|
|---|
| 929 | if (pos.d() > 44)
|
|---|
| 930 | continue;
|
|---|
| 931 |
|
|---|
| 932 | if (ring==7)
|
|---|
| 933 | {
|
|---|
| 934 | if (i==6 && (s==0 || s==3))
|
|---|
| 935 | continue;
|
|---|
| 936 | if (i==1 && (s==1 || s==4))
|
|---|
| 937 | continue;
|
|---|
| 938 | }
|
|---|
| 939 |
|
|---|
| 940 | drawHex(ctx, pos.x, pos.y, data.charCodeAt(cnt++));
|
|---|
| 941 | }
|
|---|
| 942 | }
|
|---|
| 943 | }
|
|---|
| 944 |
|
|---|
| 945 | ctx.restore();
|
|---|
| 946 | }
|
|---|
| 947 |
|
|---|
| 948 | function drawCamLegend(canv)
|
|---|
| 949 | {
|
|---|
| 950 | var vals = canv.getAttribute("data-data").split("/");
|
|---|
| 951 | var diff = vals[1]-vals[0];
|
|---|
| 952 |
|
|---|
| 953 | var cw = canv.width;
|
|---|
| 954 | var ch = canv.height;
|
|---|
| 955 |
|
|---|
| 956 | var ctx = canv.getContext("2d");
|
|---|
| 957 |
|
|---|
| 958 | ctx.font = "8pt Arial";
|
|---|
| 959 | ctx.textAlign = "right";
|
|---|
| 960 | ctx.textBaseline = "top";
|
|---|
| 961 |
|
|---|
| 962 | for (var i=0; i<9; i++)
|
|---|
| 963 | {
|
|---|
| 964 | ctx.strokeStyle = "#"+color(16*i);
|
|---|
| 965 | ctx.strokeText((vals[0]-diff*(i-8)/8)+vals[2], cw-5, 135-i*15);
|
|---|
| 966 | }
|
|---|
| 967 | }
|
|---|
| 968 |
|
|---|
| 969 | function drawGraph(canv, data)
|
|---|
| 970 | {
|
|---|
| 971 | var cw = canv.width;
|
|---|
| 972 | var ch = canv.height;
|
|---|
| 973 |
|
|---|
| 974 | var ctx = canv.getContext("2d");
|
|---|
| 975 |
|
|---|
| 976 | var vals = canv.getAttribute("data-data").split("/");
|
|---|
| 977 |
|
|---|
| 978 | var dw = 3; // tick width
|
|---|
| 979 |
|
|---|
| 980 | var fs = 8; // font size
|
|---|
| 981 |
|
|---|
| 982 | ctx.font = fs+"pt Arial";
|
|---|
| 983 | ctx.textAlign = "right";
|
|---|
| 984 |
|
|---|
| 985 | var dim0 = ctx.measureText(vals[0]);
|
|---|
| 986 | var dim1 = ctx.measureText(vals[1]);
|
|---|
| 987 |
|
|---|
| 988 | var tw = vals.length>=2 ? Math.max(dim0.width, dim1.width)+dw+2 : 0;
|
|---|
| 989 |
|
|---|
| 990 | var ml = vals.length>=2 ? 5+tw : 10; // margin left
|
|---|
| 991 | var mr = 10; // margin right
|
|---|
| 992 |
|
|---|
| 993 | var mt = vals.length>=2 ? fs/2+5 : 5; // margin top
|
|---|
| 994 | var mb = vals.length>=2 ? fs/2+4 : 5; // margin bottom
|
|---|
| 995 |
|
|---|
| 996 | var nx = 20;
|
|---|
| 997 | var ny = 10;
|
|---|
| 998 |
|
|---|
| 999 | var w = cw-ml-mr;
|
|---|
| 1000 | var h = ch-mt-mb;
|
|---|
| 1001 |
|
|---|
| 1002 | ctx.strokeStyle = "#808080";
|
|---|
| 1003 |
|
|---|
| 1004 | // --- data ---
|
|---|
| 1005 | ctx.beginPath();
|
|---|
| 1006 | ctx.moveTo(ml, ch-mb-data.charCodeAt(0)/128*h);
|
|---|
| 1007 | for (var i=1; i<data.length; i++)
|
|---|
| 1008 | ctx.lineTo(ml+w/(data.length-1)*i, ch-mb-data.charCodeAt(i)/128*h);
|
|---|
| 1009 |
|
|---|
| 1010 | // --- finalize data ---
|
|---|
| 1011 | ctx.lineTo(cw-mr, ch-mb);
|
|---|
| 1012 | ctx.lineTo(ml, ch-mb);
|
|---|
| 1013 | ctx.fillStyle = "#"+color(100);
|
|---|
| 1014 | ctx.stroke();
|
|---|
| 1015 | ctx.fill();
|
|---|
| 1016 |
|
|---|
| 1017 | ctx.strokeStyle = "#000000";
|
|---|
| 1018 |
|
|---|
| 1019 | ctx.beginPath();
|
|---|
| 1020 |
|
|---|
| 1021 | // --- axes ---
|
|---|
| 1022 | ctx.moveTo(ml, mt);
|
|---|
| 1023 | ctx.lineTo(ml, ch-mb);
|
|---|
| 1024 | ctx.lineTo(cw-mr, ch-mb);
|
|---|
| 1025 |
|
|---|
| 1026 | for (var i=0; i<nx; i++)
|
|---|
| 1027 | {
|
|---|
| 1028 | ctx.moveTo(ml+w/nx*i, ch-mb-dw);
|
|---|
| 1029 | ctx.lineTo(ml+w/nx*i, ch-mb+dw);
|
|---|
| 1030 | }
|
|---|
| 1031 | for (var i=0; i<ny; i++)
|
|---|
| 1032 | {
|
|---|
| 1033 | ctx.moveTo(ml-dw, mb+h/ny*i);
|
|---|
| 1034 | ctx.lineTo(ml+dw, mb+h/ny*i);
|
|---|
| 1035 | }
|
|---|
| 1036 | ctx.stroke();
|
|---|
| 1037 | ctx.closePath();
|
|---|
| 1038 |
|
|---|
| 1039 | if (vals.length>=2)
|
|---|
| 1040 | {
|
|---|
| 1041 | ctx.textBaseline = "bottom";
|
|---|
| 1042 | ctx.strokeText(vals[0], ml-dw-2, ch-1);
|
|---|
| 1043 |
|
|---|
| 1044 | ctx.textBaseline = "top";
|
|---|
| 1045 | ctx.strokeText(vals[1], ml-dw-2, 0);
|
|---|
| 1046 | }
|
|---|
| 1047 | }
|
|---|
| 1048 |
|
|---|
| 1049 | function process_eventdata(result)
|
|---|
| 1050 | {
|
|---|
| 1051 | var z = $("body").getAttribute("data-visible");
|
|---|
| 1052 | var canv = $("canvas"+z);
|
|---|
| 1053 | if (canv == undefined)
|
|---|
| 1054 | return;
|
|---|
| 1055 |
|
|---|
| 1056 | var type = canv.getAttribute("data-type");
|
|---|
| 1057 |
|
|---|
| 1058 | var ctx = canv.getContext("2d");
|
|---|
| 1059 | ctx.clearRect(0, 0, canv.width, canv.height);
|
|---|
| 1060 |
|
|---|
| 1061 | switch (type)
|
|---|
| 1062 | {
|
|---|
| 1063 | case "hist": drawGraph(canv, result); break;
|
|---|
| 1064 | //case "camera": drawCam(result); break;
|
|---|
| 1065 | case "camera": drawFullCam(result); drawCamLegend(canv); break;
|
|---|
| 1066 | }
|
|---|
| 1067 |
|
|---|
| 1068 | $("image"+z).src = canv.toDataURL("image/png");
|
|---|
| 1069 | }
|
|---|
| 1070 |
|
|---|
| 1071 | /*
|
|---|
| 1072 | function save()
|
|---|
| 1073 | {
|
|---|
| 1074 | var z = $("body").getAttribute("data-visible");
|
|---|
| 1075 |
|
|---|
| 1076 | var canvas = $("canvas"+z);
|
|---|
| 1077 | var img = canvas.toDataURL("image/png");
|
|---|
| 1078 |
|
|---|
| 1079 | img = img.replace("image/png", "image/octet-stream");
|
|---|
| 1080 |
|
|---|
| 1081 | document.location.href = img;
|
|---|
| 1082 | }
|
|---|
| 1083 | */
|
|---|
| 1084 | window['onload'] = onload;
|
|---|