source: trunk/FACT++/www/index.js@ 13554

Last change on this file since 13554 was 13526, checked in by tbretz, 13 years ago
Added cycling color of dots; moved some code to isSliding; new simplified sliding algorithm; simplified doresize
File size: 21.4 KB
Line 
1/*
2 try { xmlHttp = new XMLHttpRequest(); }
3 catch(e)
4 {
5 try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
6 catch(e)
7 {
8 try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
9 catch(e)
10 {
11 alert("Your browser doesn't support dynamic reload.");
12 return;
13 }
14 }
15 }
16 */
17
18function $(id) { return document.getElementById(id); }
19function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); }
20function valid(str) { if (str==undefined) return false; if (str.length==0) return false; return true;}
21function isSliding(){ return $("table0").offsetLeft!=0 && $("table1").offsetLeft!=0; }
22function cycleCol(el)
23{
24 var col = el.getAttribute("data-col");
25 col++;
26 col %= 31;
27 el.setAttribute("data-col", col);
28 if (col>16)
29 col = 31-col;
30 var hex = col.toString(16);
31 el.style.color = "#"+hex+"0"+hex+"0"+hex+"f";
32}
33
34function onload()
35{
36 /*
37 alert("0 -- "+navigator.appCodeName+"\n"+
38 "1 -- "+navigator.appName+"\n"+
39 "2 -- "+navigator.appVersion+"\n"+
40 "3 -- "+navigator.platform+"\n"+
41 "4 -- "+navigator.userAgent);
42 */
43 loadPage("fact", 0);
44}
45
46function onresize()
47{
48 var z = $("body").getAttribute("data-visible");
49 doresize(z);
50}
51
52function loadPage(name, z)
53{
54 var xmlHttp = null;
55
56 try { xmlHttp = new XMLHttpRequest(); }
57 catch(e)
58 {
59 alert("Your browser doesn't support dynamic reload.");
60 return;
61 }
62
63 xmlHttp.open('POST', name+'.table', true);
64
65 xmlHttp.onreadystatechange =
66 function ()
67 {
68 if (xmlHttp.readyState == 4)
69 {
70 if (xmlHttp.status!=0 && xmlHttp.status!=200)
71 {
72 alert("ERROR[0] - HTTP request '"+name+".table': "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
73 //setTimeout("loadPage('+name+')", 5000);
74 /****** invalidate ******/
75 return;
76 }
77
78 buildPage(name, xmlHttp.responseText, (z+1)%2);
79 changePage(z);
80
81 //changePage(name, xmlHttp.resposeText);
82 //slideOut(name, xmlHttp.responseText);
83 //displayPage(name, xmlHttp.responseText);
84 //onresize(true);
85 }
86 };
87
88 xmlHttp.send(null);
89}
90
91
92function buildPage(name, text, z)
93{
94 var table = $("table"+z);
95 var p = table.tBodies.length==3 ? 1 : 0;
96
97 var tbody = $("table"+z).tBodies[p];
98
99 while (tbody.hasChildNodes())
100 tbody.removeChild(tbody.lastChild);
101
102 var lines = text.split('\n');
103
104 if (lines.length>0)
105 {
106 /*
107 var newe = document.createElement("span");
108 newe.innerHTML = lines[0];
109 var title = $("table"+z).tHead.rows[0].cells[0].childNodes[0].childNodes[1];
110 title.replaceChild(newe, title.lastChild);
111 */
112
113 //var x = title.lastChild;
114 //title.removeChild(title.lastChild);
115 //title.appendChild(newe);
116
117 var newe = document.createElement("span");
118 newe.innerHTML = lines[0];
119 var title = $("title"+z);//.innerHtml = lines[0];
120 title.replaceChild(newe, title.lastChild);
121 }
122
123 var counter = 1;
124 for (var i=1; i<lines.length; i++)
125 {
126 lines[i] = trim(lines[i]);
127
128 if (lines[i].length==0 || lines[i][0] == '#')
129 continue;
130
131 var cols = lines[i].split(':');
132 if (cols.length != 3 && cols.length !=4)
133 {
134 alert("Size mismatch #"+i+": '"+lines[i]+"' N(cols)="+cols.length);
135 continue;
136 }
137
138 if (cols[1].substring(0, 7)=="canvas=")
139 {
140 var tr = document.createElement("tr");
141 tr.setAttribute("class", "row");
142 tr.setAttribute("style", "margin:0;padding:0;");
143
144 var td = document.createElement("td");
145 td.setAttribute("class", "container");
146 td.setAttribute("id", "container");
147 //td.setAttribute("onclick", "save();");
148 td.setAttribute("colspan", "3");
149 tr.appendChild(td);
150
151 var canv = document.createElement("canvas");
152 canv.setAttribute("id", "canvas"+z);
153 canv.setAttribute("width", "1");
154 canv.setAttribute("height", "1");
155 canv.setAttribute("data-file", cols[1].substring(7));
156 canv.setAttribute("style", "display:none;");
157 td.appendChild(canv);
158
159 var img = document.createElement("img");
160 img.setAttribute("id", "image"+z);
161 img.setAttribute("width", "1");
162 img.setAttribute("height", "1");
163 td.appendChild(img);
164
165 tbody.appendChild(tr);
166 continue;
167 }
168
169 var tr = document.createElement("tr");
170 tr.setAttribute("class", "row");
171 if (valid(cols[0]))
172 tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[0]+"',"+z+");");
173 if (valid(cols[3]))
174 tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[3]+"',"+z+");");
175 //tr.setAttribute("id", cols[0]+"_row");
176
177 var td0 = document.createElement("td");
178 td0.setAttribute("class", "tcol0");
179 if (valid(cols[0]))
180 td0.appendChild(document.createTextNode("<"));
181 tr.appendChild(td0);
182
183 var td1 = document.createElement("td");
184 td1.setAttribute("class", "tcol1");
185 td1.setAttribute("width", "100%");
186 tr.appendChild(td1);
187
188 var td2 = document.createElement("td");
189 td2.setAttribute("class", "tcol2");
190 if (valid(cols[3]))
191 td2.appendChild(document.createTextNode(">"));
192 tr.appendChild(td2);
193
194 var tab = document.createElement("table");
195 tab.setAttribute("width", "100%");
196 td1.appendChild(tab);
197
198 var innertr = document.createElement("tr");
199 tab.appendChild(innertr);
200
201 var cell1 = document.createElement("td");
202 cell1.setAttribute("class", "tcell1");
203 //cell1.setAttribute("id", cols[0]+"_title");
204 cell1.appendChild(document.createTextNode(cols[1]));
205
206 var cell2 = document.createElement("td");
207 cell2.setAttribute("class", "tcell2");
208 cell2.setAttribute("id", "data"+counter);
209 cell2.setAttribute("data-form", cols[2]);
210 cell2.appendChild(document.createTextNode("---"));
211
212 innertr.appendChild(cell1);
213 innertr.appendChild(cell2);
214
215 tbody.appendChild(tr);
216
217 counter++;
218 }
219
220 // ---------------------------------------
221
222 tr = document.createElement("tr");
223 tr.setAttribute("class", "row");
224
225 td = document.createElement("td");
226 td.setAttribute("id", "debug");
227 td.setAttribute("colspan", "3");
228 tr.appendChild(td);
229
230 tbody.appendChild(tr);
231
232 // ---------------------------------------
233
234 table.setAttribute("data-file", name);
235 doresize(z);
236}
237
238function doresize(z)
239{
240 var img = $("image"+z);
241 var canv = $("canvas"+z);
242 if (img == undefined || canv == undefined)
243 return;
244
245 var W = window.innerWidth;
246 var H = window.innerHeight;
247
248 //img.width = 1;
249 //img.height = 1;
250
251 var h = $("table"+z).offsetHeight;
252
253 //alert(img.height+"/"+img.offsetHeight+"/"+img.parentNode.offsetHeight);
254
255 // Be aware that this is recursive!
256 img.width = W;
257 img.height += H - h;
258
259 canv.width = img.width;
260 canv.height = img.height;
261
262 // ------ debug -----
263 $('debug').innerHTML = "";
264 $('debug').innerHTML += "|W="+W +"/"+H;
265 $('debug').innerHTML += "|H="+h+"/"+$("table"+z).offsetHeight;
266}
267
268var intervalSlide = null;
269
270function changePage(z)
271{
272 // No page displayed yet
273 if ($("table0").style.display=="none" && $("table1").style.display=="none")
274 {
275 $("table0").style.display="";
276 $("table1").style.display="";
277
278 $("table0").style.left=window.innerWidth+"px";
279 $("table1").style.left="0px";
280
281 $("body").setAttribute("data-visible", "1");
282
283 doresize(1);
284
285 refresh_text();
286 refresh_graphics();
287 return;
288 }
289
290 //intervalSlide = setInterval("doSlideOut("+z+")", 25);
291
292 //var k = (z+1)%2;
293 //$("table"+k).style.display="";
294 //$("table"+z).style.display="";
295 //$("table"+k).style.zIndex="0";
296 //$("table"+z).style.zIndex="1";
297 //$("table"+k).style.left=0;
298 //$("table"+z).style.left=0;
299 //$("table"+k).style.backgroundColor = "#ffffff";
300 //$("table"+z).style.backgroundColor = "#ffffff";
301 //doresize(k);
302 //intervalSlide = setInterval("doSlide("+z+",1)", 50);
303
304 $("body").setAttribute("data-visible", (z+1)%2);
305 intervalSlide = setInterval("doShift("+z+")", 75);
306}
307
308function doShift(z)
309{
310 var W = window.innerWidth;
311
312 var t0 = $("table0");
313 var t1 = $("table1");
314
315 var x0 = t0.offsetLeft;
316 var x1 = t1.offsetLeft;
317
318 if (/*x1<0 && x0>=0 &&*/ z==0)
319 {
320 x0 += W/5;
321 x1 += W/5;
322
323 if (x1>=0)
324 {
325 x0 = W;
326 x1 = 0;
327
328 clearInterval(intervalSlide);
329 }
330 }
331
332 if (/*x0>0 && x1<=0 &&*/ z==1)
333 {
334 x0 -= W/5;
335 x1 -= W/5;
336
337 if (x0<=0)
338 {
339 x0 = 0;
340 x1 = -W-1;
341
342 clearInterval(intervalSlide);
343 }
344 }
345
346 t0.style.left = parseInt(x0, 10)+"px";
347 t1.style.left = parseInt(x1, 10)+"px";
348}
349
350/*
351function doSlide(z, dir)
352{
353 var k = (z+1)%2;
354
355 var W = window.innerWidth;
356
357 var tz = $("table"+z);
358 var tk = $("table"+k);
359
360 var xz = tz.offsetLeft;
361 var xk = tk.offsetLeft;
362
363 var ixz = parseInt(xz, 10);
364 var ikz = parseInt(xk, 10);
365
366 ixz += dir*W/10;
367 ikz -= dir*W/10;
368
369 tz.style.left = parseInt(ixz, 10)+"px";
370 tk.style.left = parseInt(ikz, 10)+"px";
371
372 if (ixz>W/2)
373 {
374 clearInterval(intervalSlide);
375
376 $("table"+k).style.zIndex="1";
377 $("table"+z).style.zIndex="0";
378
379 $("body").setAttribute("data-visible", k);
380 doresize(k);
381
382 intervalSlide = setInterval("doSlide("+z+",-1)", 50);
383 }
384 if (ikz>0)
385 {
386 clearInterval(intervalSlide);
387
388 tz.style.left = 0;
389 tk.style.left = 0;
390
391 tz.style.display="none";
392 }
393}
394
395
396function doSlideOut(z)
397{
398 var table = $("table"+z);
399
400 var W = window.innerWidth;
401 var x = table.offsetLeft;
402
403 var ix = parseInt(x, 10);
404 if (ix>W)
405 {
406 clearInterval(intervalSlide);
407
408 table.style.display="none";
409
410 z = (z+1)%2;
411 table = $("table"+z);
412
413 table.style.display="";
414 table.style.left = window.innerWidth+"px";
415
416 $("body").setAttribute("data-visible", z);
417 doresize(z);
418
419 intervalSlide = setInterval("doSlideIn("+z+")", 25);
420 return;
421 }
422
423 ix += W/10;
424 table.style.left=ix+"px";
425}
426
427function doSlideIn(z)
428{
429 var table = $("table"+z);
430
431 var W = window.innerWidth;
432 var x = table.offsetLeft;
433
434 var ix = parseInt(x, 10);
435
436 ix -= W/10;
437 if (ix<0)
438 ix = 0;
439
440 table.style.left=ix+"px";
441
442 if (ix<=0)
443 {
444 clearInterval(intervalSlide);
445 return;
446 }
447}
448*/
449
450function refresh_text()
451{
452 var z=$("body").getAttribute("data-visible");
453 var table = $("table"+z);
454
455 // Is sliding or no file defined?
456 var fname = table.getAttribute("data-file");
457 if (isSliding() || !valid(fname))
458 {
459 setTimeout("refresh_text()", 1000);
460 return;
461 }
462
463 var xmlHttp = null;
464
465 try { xmlHttp = new XMLHttpRequest(); }
466 catch(e)
467 {
468 alert("Your browser doesn't support dynamic reload.");
469 return;
470 }
471
472 xmlHttp.open('POST', fname+'.txt', true);
473
474 xmlHttp.onreadystatechange =
475 function ()
476 {
477 if (xmlHttp.readyState == 4)
478 {
479 if (xmlHttp.status!=0 && xmlHttp.status!=200)
480 {
481 alert("ERROR[1] - HTTP request '"+fname+".txt': "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
482 setTimeout("refresh_text()", 10000);
483 return;
484 }
485
486 if (!isSliding())
487 {
488 cycleCol($("ldot"+z));
489 update_text(fname, xmlHttp.responseText);
490 }
491 setTimeout("refresh_text()", 3000);
492 }
493 };
494
495 xmlHttp.send(null);
496}
497
498function strike(e, status)
499{
500 if (!e)
501 return;
502
503 if (!status)
504 e.style.textDecoration="line-through";
505 else
506 e.style.textDecoration="";
507}
508
509function gray(id, str)
510{
511 var e = $(id);
512 if (!e)
513 return;
514
515 if (valid(str))
516 {
517 e.style.color="#000";
518 e.style.textDecoration="";
519 }
520 else
521 {
522 e.style.color="#daa";
523 e.style.textDecoration="line-through";
524 }
525
526}
527
528var date0 = null;
529
530function update_text(fname, result)
531{
532 var z=$("body").getAttribute("data-visible");
533 var table = $("table"+z);
534
535 if (table.getAttribute("data-file") != fname)
536 return;
537
538 var tokens = result.split('\n');
539
540 // ----------------------------------------------------
541
542 var time = $("reporttime"+z);
543 var ltime = $("localtime"+z);
544
545 var date1 = new Date();
546
547 if (tokens[0].length!=13)
548 {
549 if (date0 != null)
550 strike(time, date0.getTime()+60000>date1.getTime());
551 // FIXME: Reset display to "---" values -- no connection
552 return;
553 }
554
555 var date2 = new Date();
556 date2.setTime(tokens[0]);
557
558 strike(time, date2.getTime()+60000>date1.getTime());
559
560 date0 = date2;
561
562 time.innerHTML =
563 "&#8226;&nbsp;"+date0.toUTCString()+"&nbsp;&#8226;";//getUTCFullYear()+"/"+date0.getUTCMonth()+"/"+date0.getUTCDate()+" "+date0.getUTCHours()+":"+date0.getUTCMinutes()+":"+date0.getUTCSeconds()+"."+date0.getUTCMilliseconds();
564 ltime.innerHTML =
565 "&#8226;&nbsp;"+date1.toLocaleString()+"&nbsp;&#8226;";//ISOlocalDateStr();//ltoString();
566
567 // ----------------------------------------------------
568
569 var p = table.tBodies.length==3 ? 1 : 0;
570 var tbody = table.tBodies[p];
571
572 for (var line=1; line<tokens.length; line++)
573 {
574 var c = tbody.rows[line-1].cells[1];
575 if (c == undefined)
576 continue;
577
578 var e = c.childNodes[0].rows[0].cells[1];
579 if (e == undefined)
580 continue;
581
582 var form = e.getAttribute("data-form");
583 if (form==undefined)
584 continue;
585
586 var cols = tokens[line].split('\t');
587 for (var col=1; col<cols.length; col++)
588 form = form.replace("\$"+(col-1), cols[col].length==0 ? "--" : cols[col]);
589
590 if (cols.length<=1)
591 form = "---";
592
593 var newe = document.createElement("div");
594 newe.innerHTML = form;
595 e.replaceChild(newe, e.lastChild);
596
597 e.parentNode.parentNode.parentNode.parentNode.style.background=cols[0];
598 }
599}
600
601// http://billmill.org/static/canvastutorial/index.html
602// http://www.netmagazine.com/tutorials/learning-basics-html5-canvas
603// http://www.alistapart.com/articles/responsive-web-design/
604
605function refresh_graphics()
606{
607 var z = $("body").getAttribute("data-visible");
608
609 var canvas = $("canvas"+z);
610
611 // Is sliding or no data file defined?
612 var fname = canvas==null ? "" : canvas.getAttribute("data-file");
613 if (isSliding() || !valid(fname))
614 {
615 setTimeout("refresh_graphics()", 1000);
616 return;
617 }
618
619 var xmlHttp = null;
620
621 try { xmlHttp = new XMLHttpRequest(); }
622 catch(e)
623 {
624 alert("Your browser doesn't support dynamic reload.");
625 return;
626 }
627
628 xmlHttp.open('POST', fname, true);
629 xmlHttp.onload =
630 function ()
631 {
632 if (xmlHttp.readyState == 4)
633 {
634 if (xmlHttp.status!=0 && xmlHttp.status!=200)
635 {
636 alert("ERROR[2] - Request '"+fname+"': "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
637 setTimeout("refresh_text()", 10000);
638 //****** invalidate ******
639 return;
640 }
641
642 if (!isSliding())
643 {
644 cycleCol($("rdot"+z));
645 process_eventdata(xmlHttp.responseText);
646 }
647 setTimeout("refresh_graphics()", 5000)
648 }
649 };
650
651 xmlHttp.send(null);
652}
653
654
655function hueToRGB(hue)
656{
657 hue /= 3;
658 hue %= 6;
659
660 if (hue<1) return parseInt(255*hue, 10);
661 if (hue<3) return parseInt(255, 10);
662 if (hue<4) return parseInt(255*(4-hue), 10);
663
664/*
665 if (hue<1*5/4) return parseInt(255*hue*4/5);
666 if (hue<2*5/4) return parseInt(255);
667 if (hue<3*5/4) return parseInt(255*(3*5/4-hue)*4/5);
668*/
669/*
670 if (hue<1.5) return parseInt(255*hue/1.5);
671 if (hue<3.0) return parseInt(255);
672 if (hue<4.5) return parseInt(255*(4.5-hue)/1.5);
673*/
674 return 0.
675}
676
677function hueToHex(flt)
678{
679 var s = hueToRGB(flt).toString(16);
680 return s.length==2 ? s : "0"+s;
681}
682
683function HLStoRGB(hue)
684{
685 hue *= 14;
686
687 var sr = hueToHex(20-hue);
688 var sg = hueToHex(14-hue);
689 var sb = hueToHex(26-hue);
690
691 return sr+sg+sb;
692}
693
694
695function color(col)
696{
697 if (col==65533)
698 col = 0;
699
700 var hue = col/128;
701 return HLStoRGB(hue);
702}
703
704function toHex(str, idx)
705{
706 var ch = str[idx].toString(16);
707 return ch.length==2 ? ch : "0"+ch;
708}
709
710function drawPix(x, y, col)
711{
712 var z = $("body").getAttribute("data-visible");
713 var canv = $("canvas"+z);
714
715 var cw = canv.width;
716 var ch = canv.height;
717
718 var w = Math.min(cw/28, ch/28);
719
720 var ctx = canv.getContext("2d");
721
722 ctx.beginPath();
723 ctx.arc(x*w*2+cw/2, y*w*2+ch/2, w, 0, Math.PI*2, true);
724 ctx.lineWidth = 0;
725 ctx.fillStyle = "#"+color(col);
726 ctx.fill();
727 ctx.closePath();
728}
729function drawCam(data)
730{
731 drawPix(0, 0, data.charCodeAt(0));
732
733 var gsSin60 = Math.sqrt(3)/2;
734
735 var cnt = 1;
736 for (var ring=1; ring<=7; ring++)
737 {
738 for (var s=0; s<6; s++)
739 {
740 for (var i=1; i<=ring; i++)
741 {
742 var x=0.;
743 var y=0.;
744
745 switch (s)
746 {
747 case 0: x = ring-i*0.5; y = i*gsSin60; break;
748 case 1: x = ring*0.5-i; y = ring*gsSin60; break;
749 case 2: x = -(ring+i)*0.5; y = (ring-i)*gsSin60; break;
750 case 3: x = 0.5*i-ring; y = -i*gsSin60; break;
751 case 4: x = i-ring*0.5; y = -ring*gsSin60; break;
752 case 5: x = (ring+i)*0.5; y = (-ring+i)*gsSin60; break;
753 }
754
755 if (Math.sqrt(x*x+y*y)>6.7)
756 continue;
757 if (ring==7 && i==6 && s==0)
758 continue;
759 if (ring==7 && i==1 && s==1)
760 continue;
761 if (ring==7 && i==6 && s==3)
762 continue;
763 if (ring==7 && i==1 && s==4)
764 continue;
765
766 // Rotate by 60deg
767 var px = gsSin60*x - 0.5*y;
768 var py = gsSin60*y + 0.5*x;
769
770 drawPix(px, py, data.charCodeAt(cnt));
771 cnt++;
772 }
773 }
774 }
775}
776
777function drawCamLegend(canv)
778{
779 var cw = canv.width;
780 var ch = canv.height;
781
782 var ctx = canv.getContext("2d");
783
784 ctx.font = "8pt Arial";
785 ctx.textAlign = "right";
786 ctx.textBaseline = "top";
787
788 ctx.strokeStyle = "#"+color(0);
789 ctx.strokeText("-2.0V", cw-5, 135);
790
791 ctx.strokeStyle = "#"+color(16);
792 ctx.strokeText("-1.5V", cw-5, 120);
793
794 ctx.strokeStyle = "#"+color(32);
795 ctx.strokeText("-1.0V", cw-5, 105);
796
797 ctx.strokeStyle = "#"+color(48);
798 ctx.strokeText("-0.5V", cw-5, 90);
799
800 ctx.strokeStyle = "#"+color(64);
801 ctx.strokeText("0V", cw-5, 70);
802
803 ctx.strokeStyle = "#"+color(80);
804 ctx.strokeText("0.5V", cw-5, 50);
805
806 ctx.strokeStyle = "#"+color(86);
807 ctx.strokeText("1.0V", cw-5, 35);
808
809 ctx.strokeStyle = "#"+color(102);
810 ctx.strokeText("1.5V", cw-5, 20);
811
812 ctx.strokeStyle = "#"+color(127);
813 ctx.strokeText("2.0V", cw-5, 5);
814}
815
816function drawGraph(canv, data)
817{
818 var cw = canv.width;
819 var ch = canv.height;
820
821 var ctx = canv.getContext("2d");
822
823 var dx = 15;
824 var dy = 15;
825
826 var dw = 5;
827
828 var nx = 20;
829 var ny = 10;
830
831 var w = cw-2*dx;
832 var h = ch-2*dy;
833
834 ctx.strokeStyle = "#808080";
835
836 ctx.beginPath();
837 ctx.moveTo(dx, ch-dy-data.charCodeAt(0)/128*h);
838 for (var i=1; i<data.length; i++)
839 ctx.lineTo(dx+w/data.length*i, ch-dy-data.charCodeAt(i)/128*h);
840 ctx.lineTo(dx+w, ch-dy);
841 ctx.lineTo(dx, ch-dy);
842 ctx.fillStyle = "#"+color(100);
843 ctx.fill();
844 ctx.stroke();
845 ctx.closePath();
846
847 ctx.strokeStyle = "#000000";
848
849 ctx.beginPath();
850
851 ctx.moveTo(dx, dy);
852 ctx.lineTo(dx, ch-dy);
853 ctx.lineTo(cw-dx, ch-dy);
854
855 for (var i=0; i<nx; i++)
856 {
857 ctx.moveTo(dx+w/nx*i, ch-dy-dw);
858 ctx.lineTo(dx+w/nx*i, ch-dy+dw);
859 }
860 for (var i=0; i<ny; i++)
861 {
862 ctx.moveTo(dx-dw, dy+h/ny*i);
863 ctx.lineTo(dx+dw, dy+h/ny*i);
864 }
865 ctx.stroke();
866 ctx.closePath();
867}
868
869function process_eventdata(result)
870{
871 if (result.length!=160)
872 return;
873
874 var z = $("body").getAttribute("data-visible");
875 var canv = $("canvas"+z);
876 if (canv == undefined)
877 return;
878
879 var ctx = canv.getContext("2d");
880 ctx.clearRect(0, 0, canv.width, canv.height);
881
882 drawGraph(canv, result);
883
884 drawCam(result);
885 drawCamLegend(canv);
886
887 $("image"+z).src = canv.toDataURL("image/png");
888}
889
890/*
891function save()
892{
893 var z = $("body").getAttribute("data-visible");
894
895 var canvas = $("canvas"+z);
896 var img = canvas.toDataURL("image/png");
897
898 img = img.replace("image/png", "image/octet-stream");
899
900 document.location.href = img;
901}
902*/
903window['onload'] = onload;
Note: See TracBrowser for help on using the repository browser.