source: trunk/FACT++/www/smartfact/index.js@ 13929

Last change on this file since 13929 was 13929, checked in by tbretz, 12 years ago
Store mapping as 6-bit encoded string
File size: 38.6 KB
Line 
1"use strict";
2
3var debug = false;
4
5var map = new Array(1440);
6
7function $(id) { return document.getElementById(id); }
8function $new(name) { return document.createElement(name); }
9function $txt(txt) { return document.createTextNode(txt); }
10function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); }
11function valid(str) { if (!str) return false; if (str.length==0) return false; return true;}
12function isSliding() { var z = $("body").getAttribute("data-visible"); return $("table"+z) ? $("table"+z).offsetLeft!=0 : false; }
13function htmlDecode(input) { var e = $new('div'); e.innerHTML = input; return e.firstChild ? e.firstChild.nodeValue : input; }
14function setUTC(el, time) { var str = time.toUTCString(); var utc = str.substr(str.length-12, 8); el.innerHTML = "• "+utc+" UTC •"; }
15
16function cycleCol(el)
17{
18 var col = el.getAttribute("data-color");
19 col++;
20 col %= 31;
21 el.setAttribute("data-color", col);
22 if (col>16)
23 col = 31-col;
24 var hex = col.toString(16);
25 el.style.color = "#"+hex+"0"+hex+"0"+hex+"f";
26}
27
28function onload()
29{
30 try { var dummy = new XMLHttpRequest(); }
31 catch(e)
32 {
33 // FIXME: Add a message to the body.
34 alert("Your browser doesn't support dynamic reload.");
35 return;
36 }
37
38 var name = location.hash.length==0 ? "fact" : location.hash.substr(1);
39
40 var args = location.search.substr(1).split('&');
41
42 for (var i=0; i<args.length; i++)
43 {
44 switch (args[i])
45 {
46 case "max": $("body").setAttribute("data-max", "yes"); continue;
47 case "noslide": $("body").setAttribute("data-noslide", "yes"); continue;
48 }
49
50 var entry = args[i].split('=');
51 if (entry.length!=2)
52 continue;
53
54 switch (entry[0])
55 {
56 case "w": $("body").setAttribute("data-width", entry[1]); break;
57 case "h": $("body").setAttribute("data-height", entry[1]); break;
58 }
59 }
60
61
62 /*
63 alert("0 -- "+navigator.appCodeName+"\n"+
64 "1 -- "+navigator.appName+"\n"+
65 "2 -- "+navigator.appVersion+"\n"+
66 "3 -- "+navigator.platform+"\n"+
67 "4 -- "+navigator.userAgent);
68 */
69 loadPage(name, 0, 0);
70}
71
72function onresize()
73{
74 var z = $("body").getAttribute("data-visible");
75
76 //$("table"+z).style.width="100%";
77 $("image"+z).style.width="1px";
78 $("canvas"+z).width=1;
79
80 doresize(z);
81
82}
83
84function loadPage(name, z, dz)
85{
86 if (isSliding())
87 return;
88
89 var xmlPage = new XMLHttpRequest();
90 xmlPage.open('POST', "struct/"+name+'.page', true);
91 xmlPage.onload = function ()
92 {
93 if (xmlPage.status!=200)
94 {
95 alert("ERROR[0] - HTTP request '"+name+".page': "+xmlPage.statusText+" ["+xmlPage.status+"]");
96 //setTimeout("loadPage('+name+')", 5000);
97 /****** invalidate ******/
98 return;
99 }
100
101 buildPage(name, xmlPage.responseText, z, dz);
102 changePage(z, z+dz);
103
104 //changePage(name, xmlHttp.resposeText);
105 //slideOut(name, xmlHttp.responseText);
106 //displayPage(name, xmlHttp.responseText);
107 //onresize(true);
108 };
109
110 xmlPage.send(null);
111
112 location.hash = name;
113}
114
115function sendCommand(command)
116{
117 var debug = false;
118
119 var uri = "index.php?";
120 if (debug==true)
121 uri += "debug&";
122 uri += command;
123
124 var xmlCmd = new XMLHttpRequest();
125 xmlCmd.open('POST', uri, true);
126 xmlCmd.onload = function ()
127 {
128 if (xmlCmd.status!=200)
129 {
130 alert("ERROR[1] - HTTP request: "+xmlCmd.statusText+" ["+xmlCmd.status+"]");
131 return;
132 }
133
134 if (xmlCmd.responseText.length==0)
135 {
136 alert("No proper acknowledgment of command execution received.");
137 return;
138 }
139
140 var txt = xmlCmd.responseText.split('\n');
141 switch (txt[0])
142 {
143 case "1": alert("dimctrl unreachable."); break;
144 case "2": /*success*/ break;
145 default: alert("Return code '"+txt[0]+"' unknown."); break;
146 }
147 if (txt.length>1)
148 alert(xmlCmd.responseText);
149 };
150 xmlCmd.send(null);
151}
152
153
154function submit(script)
155{
156 var inputs = document.getElementsByTagName("input");
157
158 var args = "start="+script+".dim";
159 for (var i=0; i<inputs.length; i++)
160 args += "&"+inputs[i].name+"="+inputs[i].value;
161
162 //alert(args);
163
164 sendCommand(args);
165}
166
167function buildPage(name, text, oldz, dz)
168{
169 var fname = dz==0 ? "fact" : $("table"+oldz).getAttribute("data-file");
170
171 var z = oldz + dz;
172
173 var lines = text.split('\n');
174
175 if (lines.length==0)
176 {
177 alert("buildPage - received data empty.");
178 return;
179 }
180
181 if (lines[0].length==0)
182 {
183 alert("buildPage - title missing");
184 return;
185 }
186
187 var title = lines[0];
188 var is_cmd = title[0]=='*';
189 if (is_cmd)
190 title = title.substr(1);
191
192 var table = $("table"+z);
193 if (table)
194 $("body").removeChild(table);
195
196 table = $new("table");
197 table.setAttribute("class", "tborder");
198 table.id = "table"+z;
199 table.border = 0;
200 table.cellSpacing = 0;
201 table.cellPadding = "0px";
202 /*table.width = "100%";*/
203 //table.setAttribute("style", "overflow:hidden;position:fixed;top:0px;left:"+window.innerWidth+"px;")
204 table.setAttribute("style", "position:absolute;top:0px;left:"+window.innerWidth+"px;width:100%;");
205
206 // -----------------------------------------------------
207
208 var th = $new("thead");
209 th.colSpan = 3;
210 th.width = "100%";
211 table.appendChild(th);
212
213 var htr = $new("tr");
214 th.appendChild(htr);
215
216 var htd = $new("td");
217 htd.setAttribute("class", "thead");
218 htd.colSpan = 3;
219 htd.width = "100%";
220 htr.appendChild(htd);
221
222 // -------------
223
224 var htab = $new("table");
225 htab.width = "100%";
226 htd.appendChild(htab);
227
228 var hhtr = $new("tr");
229 htab.appendChild(hhtr);
230
231 var htd0 = $new("td");
232 var htd1 = $new("td");
233 var htd2 = $new("td");
234 var htd3 = $new("td");
235 var htd4 = $new("td");
236 htd0.setAttribute("class", "tcell1");
237 htd1.setAttribute("class", "tcell2");
238 htd2.setAttribute("class", "tcell1");
239 htd2.setAttribute("width", "1px");
240 htd3.setAttribute("class", "tcell1");
241 htd3.setAttribute("width", "1px");
242 htd4.setAttribute("width", "1px");
243 hhtr.appendChild(htd4);
244 hhtr.appendChild(htd3);
245 hhtr.appendChild(htd0);
246 hhtr.appendChild(htd1);
247 hhtr.appendChild(htd2);
248/*
249 htd0.style.verticalAlign = "middle";
250 htd1.style.verticalAlign = "middle";
251 htd2.style.verticalAlign = "middle";
252 htd3.style.verticalAlign = "middle";
253 htd4.style.verticalAlign = "middle";
254*/
255 var div1 = $new("div");
256 var div2 = $new("div");
257 var div3 = $new("div");
258 var div4 = $new("div");
259 div4.id = "warn"+z;
260 div2.setAttribute("class", "icon_white");
261 div4.setAttribute("class", "icon_color");
262 div2.setAttribute("style", "background-position:-396px 50%;");
263 div4.setAttribute("style", "display:none;background-position:-12px -12px;");
264 div2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage(fname, z, -dz); };
265 div4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('error', z, +1); };
266
267 if (name=="fact")
268 {
269 div3.setAttribute("class", "icon_color");
270 div3.setAttribute("style", "background-position:-58px -146px;");
271 }
272 else
273 {
274 div3.setAttribute("class", "icon_white");
275 div3.setAttribute("style", "background-position:-575px 50%;");
276 div3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact', z, -1); };
277 }
278
279 var sp0 = $new("span");
280 var sp1 = $new("span");
281 var sp2 = $new("span");
282 sp0.id = "ldot" +z;
283 sp1.id = "title"+z;
284 sp2.id = "rdot" +z;
285 sp1.setAttribute("style", "font-size:large;");
286 sp0.setAttribute("data-color", "3");
287 sp2.setAttribute("data-color", "3");
288 sp0.appendChild($txt(" \u2022 "));
289 sp1.appendChild($txt(title));
290 sp2.appendChild($txt(" \u2022 "));
291 if (is_cmd)
292 {
293 sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(name); this.style.backgroundColor=''; };
294 }
295 else
296 {
297 if (name!='control')
298 sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.15)'; loadPage('control', z, +1); };
299 }
300
301 div1.setAttribute("style", "font-size:small;");
302 div1.id = "reporttime"+z;
303 div1.appendChild($txt("---"));
304
305 div1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; };
306
307 htd0.appendChild(sp0);
308 htd0.appendChild(sp1);
309 htd0.appendChild(sp2);
310
311 htd1.appendChild(div1);
312 if (dz!=0/* && z+dz!=0*/)
313 htd2.appendChild(div2); // back
314 htd3.appendChild(div3); // home
315 htd4.appendChild(div4); // Warning
316
317 // -----------------------------------------------------
318
319 var tbody = $new("tbody");
320 table.appendChild(tbody);
321
322 // -----------------------------------------------------
323
324 var tf = $new("tfoot");
325 table.appendChild(tf);
326
327 var ftr = $new("tr");
328 tf.appendChild(ftr);
329
330 var ftd = $new("td");
331 ftd.setAttribute("class", "tfoot");
332 ftd.width = "100%";
333 ftd.colSpan = 3;
334 ftr.appendChild(ftd);
335
336 var ftab = $new("table");
337 ftab.width = "100%";
338 ftd.appendChild(ftab);
339
340 var ftdH = $new("td");
341 var ftd0 = $new("td");
342 var ftd1 = $new("td");
343 var ftd2 = $new("td");
344 var ftd3 = $new("td");
345 ftdH.setAttribute("width", "1px");
346 ftd2.setAttribute("width", "1px");
347 ftd3.setAttribute("width", "1px");
348
349 ftdH.setAttribute("class", "tcell1");
350 ftd0.setAttribute("class", "tcell1");
351 ftd1.setAttribute("class", "tcell2");
352 ftd2.setAttribute("class", "tcell2");
353 ftd3.setAttribute("class", "tcell2");
354
355 ftab.appendChild(ftdH);
356 ftab.appendChild(ftd0);
357 ftab.appendChild(ftd1);
358 ftab.appendChild(ftd2);
359 ftab.appendChild(ftd3);
360
361 var fdivH = $new("div");
362 var fdiv0 = $new("span");
363 var fdiv1 = $new("span");
364 var fdiv2 = $new("div");
365 var fdiv3 = $new("div");
366 ftd0.style.paddingLeft = "5px";
367 fdiv2.id="cmd"+z;
368
369 fdiv2.setAttribute("class", "icon_white");
370 fdiv3.setAttribute("class", "icon_white");
371 fdiv2.setAttribute("style", "background-position:-72px 50%;");
372 fdiv2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; };
373 if (is_cmd)
374 {
375 fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(name); this.style.backgroundColor=''; };
376 fdiv3.setAttribute("style", "background-position:-109px 50%;");
377 }
378 else
379 {
380 fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('control', z, +1); };
381 fdiv3.setAttribute("style", "background-position:-288px 50%;");
382 }
383
384 if (name.substr(0, 5)=="help-")
385 {
386 fdivH.setAttribute("class", "icon_color");
387 fdivH.setAttribute("style", "background-position:-408px -57px;");
388 //fdivH.setAttribute("style", "background-position:-13px -57px;");
389 }
390 else
391 {
392 fdivH.setAttribute("class", "icon_white");
393 fdivH.setAttribute("style", "background-position:-611px 50%;");
394 fdivH.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('help-'+name, z, +1); };
395 }
396
397
398 fdiv0.setAttribute("style", "font-size:large;");
399 fdiv1.setAttribute("style", "font-size:small;");
400 fdiv1.id = "localtime"+z;
401
402 fdiv0.appendChild($txt("logbook"));
403 fdiv1.appendChild($txt("loading..."));
404
405 ftdH.appendChild(fdivH);
406 ftd0.appendChild(fdiv0);
407 ftd1.appendChild(fdiv1);
408 ftd2.appendChild(fdiv2);
409 if (name!='control')
410 ftd3.appendChild(fdiv3);
411
412 $("body").appendChild(table);
413
414 for (var i=0; i<lines.length; i++)
415 {
416 lines[i] = trim(lines[i]);
417 if (lines[i][0] == '#')
418 lines.splice(i--, 1);
419 }
420
421 // Concatenate consecutive lines until they have at least two colons
422 for (var i=2; i<lines.length; i++)
423 {
424 if (lines[i].length==0)
425 continue;
426
427 while (i<lines.length)
428 {
429 var cols = lines[i-1].split('|');
430 if (cols.length>=3)
431 break;
432
433 lines[i-1] += lines[i].length==0 ? '<p/>' : " "+lines[i];
434 lines.splice(i,1);
435 }
436 }
437
438 var counter = 1;
439 for (var i=1; i<lines.length; i++)
440 {
441 if (lines[i].length==0)
442 continue;
443
444 var cols = lines[i].split('|');
445 if (cols.length != 3 && cols.length !=4)
446 {
447 alert("Wrong number of columns in line #"+i+" in '"+name+"': '"+lines[i]+"' N(cols)="+cols.length);
448 continue;
449 }
450
451 var check = cols[1].split("=");
452
453 if (check.length>1 && (check[0]=="camera" || check[0]=="hist"))
454 {
455 var data = cols[1].substring(check[0].length+1).split("/");
456
457 var tr = $new("tr");
458 tr.setAttribute("class", "row");
459 //tr.setAttribute("style", "margin:0;padding:0;");
460
461 var td = $new("td");
462 td.setAttribute("class", "container");
463 td.id = "container";
464 td.colSpan = 3;
465 tr.appendChild(td);
466
467 var canv = $new("canvas");
468 canv.id = "canvas"+z;
469 canv.width = "1";
470 canv.height = "1";
471 //canv.onclick = function () { save(); }
472 canv.setAttribute("data-type", check[0]);
473 canv.setAttribute("data-file", data[0]);
474 canv.setAttribute("data-data", cols[1].substring(check[0].length+data[0].length+2));
475// canv.setAttribute("style", "display:none;");
476 td.appendChild(canv);
477
478 var img = $new("img");
479 img.src = "img/dummy.png";//needed in firefox
480 img.id = "image"+z;
481 img.setAttribute("style", "width:1px;height:1px;display:none;");
482 td.appendChild(img);
483
484 tbody.appendChild(tr);
485 continue;
486 }
487
488 var tr = $new("tr");
489 tr.setAttribute("class", "row");
490 if (valid(cols[0]))
491 tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[0]+"', "+z+", -1);");
492 if (valid(cols[3]))
493 tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[3]+"', "+z+", +1);");
494
495 var td0 = $new("td");
496 td0.setAttribute("class", "tcol0");
497 tr.appendChild(td0);
498
499 if (check.length>0 && check[0]=="image")
500 {
501 var img = $new("img");
502 img.style.width="100%";
503 img.style.display="block";
504 img.src = "img/"+check[1];
505 td0.style.paddingLeft=0;
506 td0.style.border=0;
507 td0.colSpan=3;
508 td0.appendChild(img);
509
510 tbody.appendChild(tr);
511 continue;
512 }
513
514 if (valid(cols[0]))
515 {
516 var sp = $new("div");
517 sp.setAttribute("class", "icon_black");
518 sp.setAttribute("style", "background-position: -144px 50%;");
519 td0.appendChild(sp);
520 }
521
522 var td1 = $new("td");
523 td1.setAttribute("class", "tcol1");
524 td1.width = "100%";
525 tr.appendChild(td1);
526
527 var td2 = $new("td");
528 td2.setAttribute("class", "tcol2");
529 td2.width = "18px";
530
531 if (valid(cols[3]))
532 {
533 var sp = $new("div");
534 sp.setAttribute("class", "icon_black");
535 sp.setAttribute("style", "background-position: -108px 50%;");
536 td2.appendChild(sp);
537 }
538 tr.appendChild(td2);
539
540 var tab = $new("table");
541 tab.width = "100%";
542 td1.appendChild(tab);
543
544 var innertr = $new("tr");
545 tab.appendChild(innertr);
546
547 var cell1 = $new("td");
548 cell1.setAttribute("class", "tcell1");
549
550 var cell2 = $new("td");
551 cell2.setAttribute("class", valid(cols[1]) ? "tcell2" : "tcell2l");
552
553 if (check.length==0 || check[0]!="input")
554 {
555 var div = $new("div");
556 div.innerHTML = cols[1];
557 cell1.appendChild(div);
558 //cell1.appendChild($txt(cols[1]));
559
560 if (cols.length>2 && cols[2].length>0)
561 {
562 cell2.id = "data"+z+"-"+counter;
563 cell2.setAttribute("data-form", cols[2]);
564 cell2.appendChild($txt("---"));
565 counter++;
566 }
567 else
568 cell1.setAttribute("class", "description");
569 }
570 else
571 {
572 var opt = check[1].split('/');
573
574 if (opt.length<2)
575 alert("Argument name missing for'"+check[1]+"'");
576
577 var div = $new("div");
578 div.innerHTML = opt[0];
579 cell1.appendChild(div);
580 //cell1.appendChild($txt(opt[0]));
581
582 var input = $new("input");
583 input.name = opt[1];
584 input.type = "text";
585 input.maxlength = 80;
586 if (opt.length>2)
587 input.value=opt[2];
588
589 cell2.appendChild(input);
590 }
591
592 innertr.appendChild(cell1);
593 innertr.appendChild(cell2);
594
595 tbody.appendChild(tr);
596 }
597/*
598 if (true)
599 {
600 tr = $new("tr");
601 tr.setAttribute("class", "row");
602
603 td = $new("td");
604 td.colSpan = "3";
605 tr.appendChild(td);
606
607 var sp = $new("div");
608 sp.setAttribute("class", "icon_color");
609 sp.setAttribute("style", "background-position: -144px -14px;");
610 td.appendChild(sp);
611
612 sp = $new("div");
613 sp.setAttribute("class", "icon_color");
614 sp.setAttribute("style", "background-position: -56px -14px;");
615 td.appendChild(sp);
616
617 tr.appendChild(td);
618
619 tbody.appendChild(tr);
620 }
621*/
622 // ---------------------------------------
623 if (debug == true)
624 {
625 tr = $new("tr");
626 tr.setAttribute("class", "row");
627
628 td = $new("td");
629 td.id = "debug"+z;
630 td.colSpan = 3;
631 tr.appendChild(td);
632
633 tbody.appendChild(tr);
634 }
635
636 // ---------------------------------------
637
638 table.setAttribute("data-file", name);
639 doresize(z);
640}
641
642function doresize(z)
643{
644 var img = $("image"+z);
645 var canv = $("canvas"+z);
646 if (!img || !canv)
647 return;
648
649 var h = $("table"+z).offsetHeight;
650 if (h == 0)
651 return;
652
653 var fixedw = $("body").getAttribute("data-width");
654 var fixedh = $("body").getAttribute("data-height");
655
656 var W = fixedw>0 ? fixedw : window.innerWidth;
657 var H = fixedh>0 ? fixedh : window.innerHeight;
658
659 //alert(window.innerWidth+"/"+$("body").scrollWidth+"/"+$("table"+z).scrollWidth);
660
661 // wIw bSw tSw
662 // 430 / 860 / 430
663 // 429 / 430 / 430
664 // 366 / 430 / 430
665
666 // 672 / 1344 / 672
667 // 672 / 1329 / 1329
668
669 // Chrome: needs scrollbar
670 // wiW bsW tsW bcW tcW boW toW
671 // 100 200 100 84 100 84 100
672 // 100 85 85 69 85 79 85
673
674 // Chrome: does not need scrollbar
675 // 100 200 100 84 100 84 100
676 // 100 100 100 84 100 84 100
677
678 // Firefox: does not need scrollbar
679 // 100 84 100 84 100 84 100
680 // 100 84 100 84 100 84 100
681
682 // Firefox: does need scrollbar
683 // 100 84 100 84 100 84 100
684 // 100 69 85 69 85 69 85
685
686 // opera no scrollbar:
687 // 100 84 100 84 100 84 100
688 // 100 84 100 84 100 84 100
689
690 var max = $("body").getAttribute("data-max")=="yes";
691
692 var ih = max ? W : H - h + parseInt(img.style.height, 10);
693
694 // This might create the scroll bar
695 img.style.height = ih+"px";
696 canv.height = ih;
697
698 // now we can evaluate the correct view-port
699 // (-2 is the border size of the parent element 'container')
700 //var sW = (fixedw ? fixedw : $("table"+z).scrollWidth)-2;
701 var sW = fixedw ? fixedw : canv.parentNode.clientWidth;
702
703 img.style.width = sW+"px";
704 canv.width = sW;
705
706 // ------ debug -----
707 if (debug == true)
708 {
709 $('debug'+z).innerHTML = "";
710 $('debug'+z).innerHTML += "|W="+W +"/"+H;
711 $('debug'+z).innerHTML += "|H="+h+"/"+$("table"+z).offsetHeight+"/"+img.offsetHeight;
712 $('debug'+z).innerHTML += "|I="+img.style.height+"+"+H+"-"+h;
713 }
714}
715
716var intervalSlide = null;
717
718function changePage(oldz, newz)
719{
720 // No page displayed yet
721 if (oldz==newz)
722 {
723 $("table"+newz).style.left="0px";
724 $("body").setAttribute("data-visible", newz);
725
726 doresize(0);
727
728 //setInterval(refresh_text, 1000);
729 //setInterval(refresh_graphics, 5000);
730
731 refresh_text();
732
733 // first: decode the pixel mapping!
734 var codedMap = "966676:6:A;68656364626Y?\\?;A=A<AGADAN4K4i5g5h5o506W?Z?]?_?>A@A?AJAIAFACAM4J4H4f5d5e5l5m5n516X?[?^?N?P?AA1ABAVAUAKAHAEAO4L4I4G4E4c5a5b5M6j5k5V6Y6\\6_6G?J?O?Q?S?2A4A3AYAXAWAbA_AnAkAhA3404F4D4B4`5^5_5J6K6L6S6T6W6Z6]6E?H?K?M?R?T?V?5A7A6A\\A[AZAeAdAaA^AmAjAgA24o3m3C4A4?4]5[5\\5G6H6I6P6Q6R6U6X6[6^6F?I?L?<?>?U?;@=@8Ah@9AMALA]ABCACfAcA`AoAlAiA4414n3l3<4@4>425Z5X5Y5D6E6F698N6O608E8H8K8H>K>N>?>B>=???A?<@>@@@i@k@j@PAOANAECDCCC<C9CZCWCTC=3:3734313=4;4943515o4W5U5V5A6B6C6687888m7n7C8F8I8F>I>L>=>@>C>E>@?B?D??@A@C@l@n@m@SARAQAHCGCFC?C>C;C8CYCVCSC<393633303n2:4846405n4l4T5R5S5>6?6@6384858j7k7l7o7D8G8J8G>J>M>>>A>D>4>6>C?3?5?B@2@4@o@_@0ALBKBTA0CoBIC8D7D@C=C:C[CXCUC>3;3835323o2m2k27454j3m4k4i4Q5O5P5C7<6=6g71828o8h7i7S9<8?8B8Q>T>W>@=C=F=e<h<5>7>9>4?6?8?3@5@7@`@b@a@OBNBMB3C2C1C;D:D9D_D\\DQCNCKCF3C3@3>2;282Z1W1l2j2h2k3i3g3j4h4f4N5L5M5@7A7B7d7e7f7l8m8n8P9Q9:8=8@8O>R>U>>=A=D=c<f<i<k<8>:><>7?9?;?6@8@:@c@e@d@RBQBPB6C5C4C>D=D<DbDaD^D[DPCMCJCE3B3?3=2:272Y1V1T1i2g2e2h3f3d3g4e4c4K5I5J5=7>7?7a7b7c7i8j8k8M9N9O9R9;8>8A8P>S>V>?=B=E=d<g<j<Z<\\<;>k=m=:?j>l>9@i?k?f@V@g@CBBBSBgBfB7CoCnC?DSDRDcD`D]DRCOCLCG3D3A3?2<292[1X1U1S1Q1f2d2b2e3c3a3d4b4`4H5F5G5:7;7<7^7_7`7f8g8h8J9K9L97:::=:@:C:F:I:I=L=O=7=:===n<1=[<]<_<l=n=0>k>m>o>j?l?n?W@Y@X@FBEBDBjBiBhB2D1D0DVDUDTDCE@EOELEIEXEUERE5222o1l1i1f1c1`1R1P1N1c2a2_2b3`3^3a4_4]4<5:5;5778797[7\\7]7c8d8e8G9H9I94:5:8:;:>:A:D:G:G=J=M=5=8=;=l<o<2=4=^<`<b<o=1>3>n>0?2?m?o?1@Z@\\@[@IBHBGBmBlBkB5D4D3DYDXDWDFEEEBE?ENEKEHEWETEQE4212n1k1h1e1b1_1]1O1M1K1`2^2\\2_3]3[3^4\\4Z4957585475767X7Y7Z7`8a8b8D9E9F91:2:3:6:9:<:?:B:E:H:H=K=N=6=9=<=m<0=3=d;f;a<H<J<2>b=d=1?a>c>0@`?b?]@D@^@:B9BJB^B]BnBfCeC6DJDIDZDnDmDGEDEAEPEMEJEYEVESE623202m1j1g1d1a1^1\\1[0L1J1?1]2[2Y2\\3Z3X3[4Y4W4654555172737U7V7W7]8^8_8A9B9C9e9o90:n9g:j:m:L:O:R:U:X:[:];`;c;T;W;Z;7<9<e;g;i;I<K<M<c=e=g=b>d>f>a?c?e?E@G@F@=B<B;BaB`B_BiChCgCMDLDKD1E0EoD9E7E<F9F6FaE^E[EjEgEdER0O0L0I0F0C0n0l0\\0Z0X0@1>1<1Z2X2V2Y3W3U3X4V4T4E5C5D5n6o607R7S7T7Z8[8\\8>9?9@9b9c9d9l9m9e:h:k:J:M:P:S:V:Y:[;^;a;R;U;X;6<8<:<;<h;j;l;L<N<P<f=h=j=e>g>i>d?f?h?N@Q@H@@B?B>BdBcBbBlCkCjCPDODND4E3E2E;E:E8E6E;F8F5F`E]EZEiEfEcEQ0N0K0H0E0B0m0k0j0Y0W0U0=1;191W2U2S2V3T3R3U4S4Q4B5@5A5k6l6m6O7P7Q7W8X8Y8;9<9=9_9`9a9j9k9\\:_:f:i:l:K:N:Q:T:W:Z:\\;_;b;S;V;Y;C<E<G<<<m;k;1<2<O<Q<S<i=[=P=h>X>Z>g?M@O@R@U@S@J@I@AB1B0BeBTB\\CmCAD@DQDiDhD5EdD<E4F2F0F=F:F7FbE_E\\EkEhEeES0P0M0J0G0D011o0h0g0e0V0T0`0:181Q2T2R2H2S3Q3P3R4P4K3?5=5>5c6i6j6h6M7N7L7U8V8T899:9W9]9^9\\9g9h9i9]:`:c:5;2;o:>;;;8;P;M;J;G;D;A;?<A<D<F<=<><n;o;3<5<R<T<Y=Z=Q=R=Y>[>\\>^>P@T@L@K@5B4B3B2BVBUB^C]CCDBDkDjDfDeD>E=E3F1FnElE@FCFFFIFLFOF;0>0A0205080513101i0f0d0c0b0_0I1H1D1P2O2G2F2D2O3N3M3J3H3a6b6e6f6g6I7J7K7R8S8397989V9Y9Z9[9f9^:a:d:4;1;n:=;:;7;O;L;I;F;C;@;@<B<0<4<U<V<X<`=]=\\=S=U=W=]>_>`>8B7B6BZBXBWB_CaC`CFDEDDDlDgDoEmE>FAFDFGFJFMF90<0?0003060714121a0^0]0G1C1B1N2L2E2C2B2@2L3I3`6d6E7F7G7H7O8Q8192969T9U9X96;3;0;?;<;9;Q;N;K;H;E;B;W<Y<^=_=a=T=V=X=\\B[BYBdCcCbCHDGD?FBFEFHFKFNF:0=0@0104070F1E1A1M2K2J2I2A2D7L8M8N8P809495961b:";
735
736 var sum = 1036080;
737 for (var i=0; i<1440; i++)
738 {
739 var d0 = codedMap.charCodeAt([i*2]) -48;
740 var d1 = codedMap.charCodeAt([i*2+1])-48;
741
742 map[i] = d0 | (d1<<6);
743 sum -= map[i];
744 }
745 if (sum!=0)
746 alert("Pixel mapping table corrupted!");
747
748 refresh_graphics();
749 return;
750 }
751
752 var W = window.innerWidth;
753 if (W==0 || $("body").getAttribute("data-noslide")=="yes")
754 {
755 $("body").setAttribute("data-visible", newz);
756 $("body").removeChild($("table"+oldz));
757 $("table"+newz).style.left="0px";
758 return;
759 }
760
761 if (newz>oldz)
762 $("table"+newz).style.left = W+"px";
763 else
764 $("table"+newz).style.left = (-W-1)+"px";
765
766 $("body").setAttribute("data-visible", newz);
767
768 // This is needed on my mobile to ensure that te browser
769 // doesn't try to zoom during shifting
770 $("table"+newz).style.position="fixed";
771 $("table"+oldz).style.position="fixed";
772
773 intervalSlide = setInterval(function (){doShift(oldz,newz);}, 75);
774}
775
776function doShift(oldz, newz)
777{
778 var t0 = $("table"+oldz);
779 var t1 = $("table"+newz);
780
781 if (t0.style.display=="none")
782 {
783 clearInterval(intervalSlide);
784 $("body").removeChild(t0);
785
786 t1.style.position="absolute";
787
788 // Now the scroll bar might have to appear or disappear
789 doresize(newz);
790 return;
791 }
792
793 var x0 = t0.offsetLeft;
794 var x1 = t1.offsetLeft;
795
796 var W = window.innerWidth;
797
798 if (newz<oldz)
799 {
800 x0 += W/5;
801 x1 += W/5;
802 }
803
804 if (newz>oldz)
805 {
806 x0 -= W/5;
807 x1 -= W/5;
808 }
809
810 if ((newz<oldz && x1>=0) || (newz>oldz && x1<=0))
811 {
812 t0.style.display="none";
813 x1 = 0;
814 }
815
816 t0.style.left = x0+"px";
817 t1.style.left = x1+"px";
818}
819
820var timeoutText = null;
821var timeoutGraphics = null;
822
823function refresh_text()
824{
825 var z=$("body").getAttribute("data-visible");
826
827 var fname = $("table"+z).getAttribute("data-file");
828
829 var is_help = fname.substr(0,5)=="help-";
830
831 // Is sliding, no file defined or just help text?
832 if (isSliding() || !valid(fname) || is_help)
833 {
834 if (is_help)
835 {
836 setUTC($("localtime"+z), new Date());
837 $("reporttime"+z).innerHTML="";
838 }
839
840 // invalidate?
841 timeoutText = setTimeout(refresh_text, 1000);
842 return;
843 }
844
845 var xmlText = new XMLHttpRequest();
846 xmlText.open('POST', "data/"+fname+'.data', true);
847 xmlText.onload = function ()
848 {
849 if (xmlText.status!=200)
850 {
851 alert("ERROR[1] - HTTP request '"+fname+".data': "+xmlText.statusText+" ["+xmlText.status+"]");
852 timeoutText = setTimeout(refresh_text, 10000);
853 return;
854 }
855
856 if (!isSliding())
857 {
858 cycleCol($("ldot"+z));
859 update_text(fname, xmlText.responseText);
860 }
861 timeoutText = setTimeout(refresh_text, 3000);
862 };
863 xmlText.send(null);
864}
865
866var date0 = null;
867
868function update_text(fname, result)
869{
870 var z=$("body").getAttribute("data-visible");
871 var table = $("table"+z);
872
873 if (table.getAttribute("data-file") != fname)
874 return;
875
876 var tokens = result.split('\n');
877
878 // ----------------------------------------------------
879
880 var rtime = $("reporttime"+z);
881 var ltime = $("localtime"+z);
882
883 var now = new Date();
884
885 var header = tokens[0].split('\t');
886
887 // File corrupted / should we remove the date?)
888 if (header.length!=3 && header.length!=2 && header.length!=1 && header[0].length!=13)
889 {
890 // we ignore corrupted files for one minute
891 if (date0==null || date0.getTime()+60000<now.getTime())
892 rtime.style.color = "darkred";
893
894 return;
895 }
896
897 // File OK
898 date0 = now;
899
900 var stamp = new Date();
901 stamp.setTime(header[0]);
902
903 // File older than 1min
904 if (stamp.getTime()+60000<now.getTime())
905 rtime.style.color = "darkred";
906 else
907 rtime.style.color = "";
908
909 setUTC(rtime, stamp);
910 setUTC(ltime, now);
911
912 // ----------------------------------------------------
913
914 $("warn"+z).style.display = header.length>=2 && header[1]=='1' ? "" : "none";
915
916 if (header.length==3)
917 $("cmd"+z).style.backgroundColor = header[2]=='1' ? "darkgreen" : "darkred";
918
919 // ----------------------------------------------------
920
921 //var p = table.tBodies.length==3 ? 1 : 0;
922 //var tbody = table.tBodies[p];
923
924 for (var line=1; line<tokens.length; line++)
925 {
926 if (tokens[line].length==0)
927 continue;
928
929 var e = $("data"+z+"-"+line);
930 if (!e)
931 continue;
932
933 var form = e.getAttribute("data-form");
934 if (!form)
935 continue;
936
937 var cols = tokens[line].split('\t');
938 for (var col=1; col<cols.length; col++)
939 form = form.replace("\$"+(col-1), cols[col].length==0 ? "&mdash;" : cols[col]);
940
941 if (cols.length<=1)
942 form = "&mdash;";
943
944 form = form.replace(/<#(.*?)>/g, "<font color='$1'>");
945 form = form.replace(/<([\+-])>/g, "<font size='$11'>");
946 form = form.replace(/<\/([#\+-])>/g, "</font>");
947 form = form.replace(/([0-9][0-9]):([0-9][0-9]):([0-9][0-9])/g,
948 "<pre>$1</pre>:<pre>$2</pre>:<pre>$3</pre>");
949 form = form.replace(/--:--:--/g, "<pre> </pre> <pre> </pre> <pre> </pre>");
950
951 var newe = $new("div");
952 newe.innerHTML = form;
953 e.replaceChild(newe, e.lastChild);
954
955 e.parentNode.parentNode.parentNode.parentNode.style.background=cols[0];
956 }
957}
958
959// http://billmill.org/static/canvastutorial/index.html
960// http://www.netmagazine.com/tutorials/learning-basics-html5-canvas
961// http://www.alistapart.com/articles/responsive-web-design/
962
963function refresh_graphics()
964{
965 var z = $("body").getAttribute("data-visible");
966
967 var canvas = $("canvas"+z);
968
969 // Is sliding or no data file defined?
970 var fname = canvas==null ? "" : canvas.getAttribute("data-file");
971 if (isSliding() || !valid(fname))
972 {
973 // invalidate?
974 timeoutGraphics = setTimeout(refresh_graphics, 3000);
975 return;
976 }
977
978 var xmlGfx = new XMLHttpRequest();
979 xmlGfx.open('POST', "data/"+fname, true);
980 xmlGfx.onload = function ()
981 {
982 if (xmlGfx.status!=200)
983 {
984 alert("ERROR[2] - Request '"+fname+"': "+xmlGfx.statusText+" ["+xmlGfx.status+"]");
985 timeoutGraphics = setTimeout(refresh_graphics, 10000);
986 //****** invalidate ******
987 return;
988 }
989
990 if (!isSliding())
991 {
992 cycleCol($("rdot"+z));
993 process_eventdata(xmlGfx.responseText);
994 }
995 timeoutGraphics = setTimeout(refresh_graphics, 5000)
996 };
997 xmlGfx.send(null);
998}
999
1000
1001function hueToRGB(hue)
1002{
1003 hue /= 3;
1004 hue %= 6;
1005
1006 if (hue<1) return parseInt(255*hue, 10);
1007 if (hue<3) return parseInt(255, 10);
1008 if (hue<4) return parseInt(255*(4-hue), 10);
1009
1010 return 0.
1011}
1012
1013function hueToHex(flt)
1014{
1015 var s = hueToRGB(flt).toString(16);
1016 return s.length==2 ? s : "0"+s;
1017}
1018
1019function HLStoRGB(hue)
1020{
1021 hue *= 14;
1022
1023 var sr = hueToHex(20-hue);
1024 var sg = hueToHex(14-hue);
1025 var sb = hueToHex(26-hue);
1026
1027 return sr+sg+sb;
1028}
1029
1030function color(col)
1031{
1032 if (col==65533)
1033 col = 0;
1034
1035 var hue = col/128;
1036 return HLStoRGB(hue);
1037}
1038
1039function toHex(str, idx)
1040{
1041 var ch = str[idx].toString(16);
1042 return ch.length==2 ? ch : "0"+ch;
1043}
1044
1045function drawHex(ctx, x, y, col)
1046{
1047 ctx.fillStyle = "#"+color(col);
1048
1049 ctx.save();
1050
1051 ctx.translate(x, y);
1052 ctx.scale(1/2, 1/3);
1053
1054 ctx.beginPath();
1055 ctx.moveTo( 1, 1);
1056 ctx.lineTo( 0, 2);
1057 ctx.lineTo(-1, 1);
1058 ctx.lineTo(-1, -1);
1059 ctx.lineTo( 0, -2);
1060 ctx.lineTo( 1, -1);
1061 ctx.fill();
1062
1063 ctx.restore();
1064}
1065
1066function drawDisc(ctx, x, y, r, col)
1067{
1068 ctx.fillStyle = "#"+color(col);
1069
1070 ctx.save();
1071
1072 ctx.translate(x, y);
1073
1074 ctx.beginPath();
1075 ctx.arc(0, 0, r, 0, Math.PI*2, true);
1076 ctx.fill();
1077
1078 ctx.restore();
1079}
1080
1081function beginDrawCam(scale)
1082{
1083 var z = $("body").getAttribute("data-visible");
1084 var canv = $("canvas"+z);
1085
1086 var w = Math.min(canv.width/scale, canv.height/scale);
1087
1088 var ctx = canv.getContext("2d");
1089
1090 ctx.save();
1091 ctx.translate(canv.width/2, canv.height/2);
1092 ctx.scale(w*2, w*2);
1093
1094 return ctx;
1095}
1096
1097/**
1098 * @constructor
1099 */
1100function Position(s, ring, i)
1101{
1102 switch (s)
1103 {
1104 case 1: this.x = ring - i*0.5; this.y = + i; break;
1105 case 2: this.x = ring*0.5 - i; this.y = ring ; break;
1106 case 3: this.x = -ring*0.5 - i*0.5; this.y = ring - i; break;
1107 case 4: this.x = -ring + i*0.5; this.y = - i; break;
1108 case 5: this.x = -ring*0.5 + i; this.y = -ring ; break;
1109 case 0: this.x = ring*0.5 + i*0.5; this.y = -ring + i; break;
1110 }
1111 this.d = (function () { return this.x*this.x + this.y*this.y*3/4; });
1112}
1113
1114function drawFullCam(data)
1115{
1116 if (data.length!=40 && data.length!=160 && data.length!=320 && data.length!=1440)
1117 {
1118 alert("Camera - Received data has invalid size ("+data.length+"b)");
1119 return;
1120 }
1121
1122 var div = map.length/data.length;
1123 var off = data.length==320 ? 0.2 : 0;
1124
1125 var ctx = beginDrawCam(83);
1126 // ctx.rotate(Math.PI/3);
1127
1128 ctx.scale(1, Math.sqrt(3)/2);
1129 ctx.translate(-0.5, 0);
1130
1131 drawHex(ctx, 0, 0, data.charCodeAt(parseInt(map[0]/div+off, 10)));
1132
1133 var cnt = 1;
1134 for (var ring=1; ring<24; ring++)
1135 {
1136 for (var s=0; s<6; s++)
1137 {
1138 for (var i=1; i<=ring; i++)
1139 {
1140 var pos = new Position(s, ring, i);
1141 if (pos.d() - pos.x > 395.75)
1142 continue;
1143
1144 var p = parseInt(map[cnt]/div+off, 10);
1145
1146 drawHex(ctx, pos.x, pos.y, data.charCodeAt(p));
1147 cnt++;
1148 }
1149 }
1150 }
1151
1152 drawHex(ctx, 7, -22, data.charCodeAt(parseInt(map[1438]/div+off, 10)));
1153 drawHex(ctx, 7, 22, data.charCodeAt(parseInt(map[1439]/div+off, 10)));
1154
1155 ctx.restore();
1156}
1157
1158function drawCam(data)
1159{
1160 var ctx = beginDrawCam(27);
1161 ctx.rotate(Math.PI/6);
1162 ctx.scale(1, Math.sqrt(3)/2);
1163
1164 drawHex(ctx, 0, 0, data.charCodeAt(0));
1165
1166 var cnt = 1;
1167 for (var ring=1; ring<=7; ring++)
1168 {
1169 for (var s=0; s<6; s++)
1170 {
1171 for (var i=1; i<=ring; i++)
1172 {
1173 var pos = new Position(s, ring, i);
1174 if (pos.d() > 44)
1175 continue;
1176
1177 if (ring==7)
1178 {
1179 if (i==6 && (s==0 || s==3))
1180 continue;
1181 if (i==1 && (s==1 || s==4))
1182 continue;
1183 }
1184
1185 drawHex(ctx, pos.x, pos.y, data.charCodeAt(cnt++));
1186 }
1187 }
1188 }
1189
1190 ctx.restore();
1191}
1192
1193function drawCamLegend(canv, data)
1194{
1195 var unit = htmlDecode(canv.getAttribute("data-data"));
1196
1197 var umin = data[1];
1198 var umax = data[2];
1199
1200 var min = data[3]+unit
1201 var med = data[4]+unit;
1202 var max = data[5]+unit;
1203
1204 var v0 = parseFloat(umin);
1205 var v1 = parseFloat(umax);
1206
1207 var diff = v1-v0;
1208
1209 var cw = canv.width;
1210 //var ch = canv.height;
1211
1212 var ctx = canv.getContext("2d");
1213
1214 ctx.font = "8pt Arial";
1215 ctx.textAlign = "right";
1216 ctx.textBaseline = "top";
1217
1218 for (var i=0; i<11; i++)
1219 {
1220 ctx.strokeStyle = "#"+color(16*i);
1221 ctx.strokeText((v0+diff*i/10).toPrecision(3)+unit, cw-5, 125-i*12);
1222 }
1223
1224 var mw = Math.max(ctx.measureText(min).width,
1225 ctx.measureText(med).width,
1226 ctx.measureText(max).width);
1227
1228 ctx.textBaseline = "top";
1229 ctx.strokeStyle = "#000";
1230
1231 ctx.strokeText(min, 5+mw, 5+24);
1232 ctx.strokeText(med, 5+mw, 5+12);
1233 ctx.strokeText(max, 5+mw, 5);
1234}
1235
1236function drawGraph(canv, vals, data)
1237{
1238 var unit = htmlDecode(canv.getAttribute("data-data"));//.split("/");
1239
1240 var umin = vals[1]+unit;
1241 var umax = vals[2]+unit;
1242
1243 var stat = vals[3]+unit+" / "+vals[4]+unit+" / "+vals[5]+unit;
1244
1245 var cw = canv.width;
1246 var ch = canv.height;
1247
1248 var ctx = canv.getContext("2d");
1249
1250 var dw = 3; // tick width
1251 var fs = 8; // font size
1252
1253 ctx.font = fs+"pt Arial";
1254 ctx.textAlign = "right";
1255
1256 var dim0 = ctx.measureText(umin);
1257 var dim1 = ctx.measureText(umax);
1258
1259 var tw = Math.max(dim0.width, dim1.width)+dw+2;
1260
1261 var ml = 5+tw; // margin left
1262 var mr = 10; // margin right
1263
1264 var mt = 5+2*fs+4; // margin top
1265 var mb = fs/2+4; // margin bottom
1266
1267 var nx = 20;
1268 var ny = 10;
1269
1270 var w = cw-ml-mr;
1271 var h = ch-mt-mb;
1272
1273 ctx.strokeStyle = "#666";
1274
1275 // --- data ---
1276 if (data.length>1)
1277 {
1278 ctx.beginPath();
1279 ctx.moveTo(ml, ch-mb-data.charCodeAt(0)/128*h);
1280 for (var i=1; i<data.length; i++)
1281 ctx.lineTo(ml+w/(data.length-1)*i, ch-mb-data.charCodeAt(i)/128*h);
1282
1283 // --- finalize data ---
1284 ctx.lineTo(cw-mr, ch-mb);
1285 ctx.lineTo(ml, ch-mb);
1286 ctx.fillStyle = "#"+color(100);
1287 ctx.stroke();
1288 ctx.fill();
1289 }
1290
1291 ctx.beginPath();
1292
1293 // --- grid ---
1294
1295 ctx.strokeStyle = "#eee";
1296
1297 for (var i=1; i<=nx; i++)
1298 {
1299 ctx.moveTo(ml+w*i/nx, ch-mb);
1300 ctx.lineTo(ml+w*i/nx, mt);
1301 }
1302 for (var i=0; i<ny; i++)
1303 {
1304 ctx.moveTo(ml, mt+h*i/ny);
1305 ctx.lineTo(ml+w, mt+h*i/ny);
1306 }
1307 ctx.stroke();
1308 ctx.closePath();
1309 ctx.beginPath();
1310
1311 ctx.strokeStyle = "#000";
1312
1313 // --- axes ---
1314 ctx.moveTo(ml, mt);
1315 ctx.lineTo(ml, ch-mb);
1316 ctx.lineTo(cw-mr, ch-mb);
1317
1318 for (var i=1; i<=nx; i++)
1319 {
1320 ctx.moveTo(ml+w*i/nx, ch-mb-dw);
1321 ctx.lineTo(ml+w*i/nx, ch-mb+dw);
1322 }
1323 for (var i=0; i<ny; i++)
1324 {
1325 ctx.moveTo(ml-dw, mt+h*i/ny);
1326 ctx.lineTo(ml+dw, mt+h*i/ny);
1327 }
1328 ctx.stroke();
1329 ctx.closePath();
1330
1331 ctx.textBaseline = "bottom";
1332 ctx.strokeText(umin, ml-dw-2, ch-1);
1333
1334 ctx.textBaseline = mt>fs/2 ? "middle" : "top";
1335 ctx.strokeText(umax, ml-dw-2, mt);
1336
1337 ctx.textBaseline = "top";
1338 ctx.textAlign = "center";
1339 ctx.strokeText(stat, ml+w/2, 5);
1340}
1341
1342function process_eventdata(result)
1343{
1344 if (result.length==0)
1345 return;
1346
1347 var z = $("body").getAttribute("data-visible");
1348 var canv = $("canvas"+z);
1349 if (!canv)
1350 return;
1351
1352 var type = canv.getAttribute("data-type");
1353
1354 var ctx = canv.getContext("2d");
1355 ctx.clearRect(0, 0, canv.width, canv.height);
1356
1357 var data = result.split('\n');
1358 if (result.length<4)
1359 return;
1360
1361 var len = 0;
1362 for (var i=0; i<6; i++)
1363 len += data[i].length+1;
1364
1365 switch (type)
1366 {
1367 //case "camera": drawCam(result); break;
1368 case "hist":
1369 drawGraph(canv, data, result.substr(len));
1370 break;
1371 case "camera":
1372 drawFullCam(result.substr(len));
1373 drawCamLegend(canv, data);
1374 break;
1375 }
1376
1377 var now = new Date();
1378 var tm = new Date();
1379 tm.setTime(data[0]);
1380 if (tm.getTime()+60000<now.getTime())
1381 {
1382 ctx.fillStyle = "rgba(255, 255, 255, 0.75)";
1383 ctx.fillRect(0, 0, canv.width, canv.height);
1384 }
1385
1386 //$("image"+z).src = canv.toDataURL("image/png");
1387}
1388
1389function save()
1390{
1391 var z = $("body").getAttribute("data-visible");
1392
1393 var canvas = $("canvas"+z);
1394 var img = canvas.toDataURL("image/png");
1395
1396 img = img.replace("image/png", "image/octet-stream");
1397
1398 document.location.href = img;
1399}
1400
1401window['onload'] = onload;
Note: See TracBrowser for help on using the repository browser.