/* try { xmlHttp = new XMLHttpRequest(); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { alert("Your browser doesn't support dynamic reload."); return; } } } */ function $(id) { return document.getElementById(id); } function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); } function valid(str) { if (str==undefined) return false; if (str.length==0) return false; return true;} function isSliding(){ return $("table0").offsetLeft!=0 && $("table1").offsetLeft!=0; } function cycleCol(el) { var col = el.getAttribute("data-col"); col++; col %= 31; el.setAttribute("data-col", col); if (col>16) col = 31-col; var hex = col.toString(16); el.style.color = "#"+hex+"0"+hex+"0"+hex+"f"; } function onload() { /* alert("0 -- "+navigator.appCodeName+"\n"+ "1 -- "+navigator.appName+"\n"+ "2 -- "+navigator.appVersion+"\n"+ "3 -- "+navigator.platform+"\n"+ "4 -- "+navigator.userAgent); */ loadPage("fact", 0); } function onresize() { var z = $("body").getAttribute("data-visible"); doresize(z); } function loadPage(name, z) { var xmlHttp = null; try { xmlHttp = new XMLHttpRequest(); } catch(e) { alert("Your browser doesn't support dynamic reload."); return; } xmlHttp.open('POST', name+'.table', true); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4) { if (xmlHttp.status!=0 && xmlHttp.status!=200) { alert("ERROR[0] - HTTP request '"+name+".table': "+xmlHttp.statusText+" ["+xmlHttp.status+"]"); //setTimeout("loadPage('+name+')", 5000); /****** invalidate ******/ return; } buildPage(name, xmlHttp.responseText, (z+1)%2); changePage(z); //changePage(name, xmlHttp.resposeText); //slideOut(name, xmlHttp.responseText); //displayPage(name, xmlHttp.responseText); //onresize(true); } }; xmlHttp.send(null); } function buildPage(name, text, z) { var table = $("table"+z); var p = table.tBodies.length==3 ? 1 : 0; var tbody = $("table"+z).tBodies[p]; while (tbody.hasChildNodes()) tbody.removeChild(tbody.lastChild); var lines = text.split('\n'); if (lines.length>0) { /* var newe = document.createElement("span"); newe.innerHTML = lines[0]; var title = $("table"+z).tHead.rows[0].cells[0].childNodes[0].childNodes[1]; title.replaceChild(newe, title.lastChild); */ //var x = title.lastChild; //title.removeChild(title.lastChild); //title.appendChild(newe); var newe = document.createElement("span"); newe.innerHTML = lines[0]; var title = $("title"+z);//.innerHtml = lines[0]; title.replaceChild(newe, title.lastChild); } var counter = 1; for (var i=1; i")); tr.appendChild(td2); var tab = document.createElement("table"); tab.setAttribute("width", "100%"); td1.appendChild(tab); var innertr = document.createElement("tr"); tab.appendChild(innertr); var cell1 = document.createElement("td"); cell1.setAttribute("class", "tcell1"); //cell1.setAttribute("id", cols[0]+"_title"); cell1.appendChild(document.createTextNode(cols[1])); var cell2 = document.createElement("td"); cell2.setAttribute("class", "tcell2"); cell2.setAttribute("id", "data"+counter); cell2.setAttribute("data-form", cols[2]); cell2.appendChild(document.createTextNode("---")); innertr.appendChild(cell1); innertr.appendChild(cell2); tbody.appendChild(tr); counter++; } // --------------------------------------- tr = document.createElement("tr"); tr.setAttribute("class", "row"); td = document.createElement("td"); td.setAttribute("id", "debug"); td.setAttribute("colspan", "3"); tr.appendChild(td); tbody.appendChild(tr); // --------------------------------------- table.setAttribute("data-file", name); doresize(z); } function doresize(z) { var img = $("image"+z); var canv = $("canvas"+z); if (img == undefined || canv == undefined) return; var h = $("table"+z).offsetHeight; if (h == 0) return; var W = window.innerWidth; var H = window.innerHeight; var ih = img.height + H - h; img.style.width = W +"px"; img.style.height= ih+"px"; canv.width = W; canv.height = ih; // ------ debug ----- $('debug').innerHTML = ""; $('debug').innerHTML += "|W="+W +"/"+H; $('debug').innerHTML += "|H="+h+"/"+$("table"+z).offsetHeight; $('debug').innerHTML += "|I="+ih; } var intervalSlide = null; function changePage(z) { // No page displayed yet if ($("table0").style.display=="none" && $("table1").style.display=="none") { $("table0").style.display=""; $("table1").style.display=""; $("table0").style.left=window.innerWidth+"px"; $("table1").style.left="0px"; $("body").setAttribute("data-visible", "1"); doresize(1); refresh_text(); refresh_graphics(); return; } //intervalSlide = setInterval("doSlideOut("+z+")", 25); //var k = (z+1)%2; //$("table"+k).style.display=""; //$("table"+z).style.display=""; //$("table"+k).style.zIndex="0"; //$("table"+z).style.zIndex="1"; //$("table"+k).style.left=0; //$("table"+z).style.left=0; //$("table"+k).style.backgroundColor = "#ffffff"; //$("table"+z).style.backgroundColor = "#ffffff"; //doresize(k); //intervalSlide = setInterval("doSlide("+z+",1)", 50); $("body").setAttribute("data-visible", (z+1)%2); intervalSlide = setInterval("doShift("+z+")", 75); } function doShift(z) { var W = window.innerWidth; var t0 = $("table0"); var t1 = $("table1"); var x0 = t0.offsetLeft; var x1 = t1.offsetLeft; if (/*x1<0 && x0>=0 &&*/ z==0) { x0 += W/5; x1 += W/5; if (x1>=0) { x0 = W; x1 = 0; clearInterval(intervalSlide); } } if (/*x0>0 && x1<=0 &&*/ z==1) { x0 -= W/5; x1 -= W/5; if (x0<=0) { x0 = 0; x1 = -W-1; clearInterval(intervalSlide); } } t0.style.left = parseInt(x0, 10)+"px"; t1.style.left = parseInt(x1, 10)+"px"; } /* function doSlide(z, dir) { var k = (z+1)%2; var W = window.innerWidth; var tz = $("table"+z); var tk = $("table"+k); var xz = tz.offsetLeft; var xk = tk.offsetLeft; var ixz = parseInt(xz, 10); var ikz = parseInt(xk, 10); ixz += dir*W/10; ikz -= dir*W/10; tz.style.left = parseInt(ixz, 10)+"px"; tk.style.left = parseInt(ikz, 10)+"px"; if (ixz>W/2) { clearInterval(intervalSlide); $("table"+k).style.zIndex="1"; $("table"+z).style.zIndex="0"; $("body").setAttribute("data-visible", k); doresize(k); intervalSlide = setInterval("doSlide("+z+",-1)", 50); } if (ikz>0) { clearInterval(intervalSlide); tz.style.left = 0; tk.style.left = 0; tz.style.display="none"; } } function doSlideOut(z) { var table = $("table"+z); var W = window.innerWidth; var x = table.offsetLeft; var ix = parseInt(x, 10); if (ix>W) { clearInterval(intervalSlide); table.style.display="none"; z = (z+1)%2; table = $("table"+z); table.style.display=""; table.style.left = window.innerWidth+"px"; $("body").setAttribute("data-visible", z); doresize(z); intervalSlide = setInterval("doSlideIn("+z+")", 25); return; } ix += W/10; table.style.left=ix+"px"; } function doSlideIn(z) { var table = $("table"+z); var W = window.innerWidth; var x = table.offsetLeft; var ix = parseInt(x, 10); ix -= W/10; if (ix<0) ix = 0; table.style.left=ix+"px"; if (ix<=0) { clearInterval(intervalSlide); return; } } */ function refresh_text() { var z=$("body").getAttribute("data-visible"); var table = $("table"+z); // Is sliding or no file defined? var fname = table.getAttribute("data-file"); if (isSliding() || !valid(fname)) { setTimeout("refresh_text()", 1000); return; } var xmlHttp = null; try { xmlHttp = new XMLHttpRequest(); } catch(e) { alert("Your browser doesn't support dynamic reload."); return; } xmlHttp.open('POST', fname+'.txt', true); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4) { if (xmlHttp.status!=0 && xmlHttp.status!=200) { alert("ERROR[1] - HTTP request '"+fname+".txt': "+xmlHttp.statusText+" ["+xmlHttp.status+"]"); setTimeout("refresh_text()", 10000); return; } if (!isSliding()) { cycleCol($("ldot"+z)); update_text(fname, xmlHttp.responseText); } setTimeout("refresh_text()", 3000); } }; xmlHttp.send(null); } function strike(e, status) { if (!e) return; if (!status) e.style.textDecoration="line-through"; else e.style.textDecoration=""; } function gray(id, str) { var e = $(id); if (!e) return; if (valid(str)) { e.style.color="#000"; e.style.textDecoration=""; } else { e.style.color="#daa"; e.style.textDecoration="line-through"; } } var date0 = null; function update_text(fname, result) { var z=$("body").getAttribute("data-visible"); var table = $("table"+z); if (table.getAttribute("data-file") != fname) return; var tokens = result.split('\n'); // ---------------------------------------------------- var time = $("reporttime"+z); var ltime = $("localtime"+z); var date1 = new Date(); if (tokens[0].length!=13) { if (date0 != null) strike(time, date0.getTime()+60000>date1.getTime()); // FIXME: Reset display to "---" values -- no connection return; } var date2 = new Date(); date2.setTime(tokens[0]); strike(time, date2.getTime()+60000>date1.getTime()); date0 = date2; time.innerHTML = "• "+date0.toUTCString()+" •";//getUTCFullYear()+"/"+date0.getUTCMonth()+"/"+date0.getUTCDate()+" "+date0.getUTCHours()+":"+date0.getUTCMinutes()+":"+date0.getUTCSeconds()+"."+date0.getUTCMilliseconds(); ltime.innerHTML = "• "+date1.toLocaleString()+" •";//ISOlocalDateStr();//ltoString(); // ---------------------------------------------------- var p = table.tBodies.length==3 ? 1 : 0; var tbody = table.tBodies[p]; for (var line=1; line 44) continue; if (ring==7 && i==6 && s==0) continue; if (ring==7 && i==1 && s==1) continue; if (ring==7 && i==6 && s==3) continue; if (ring==7 && i==1 && s==4) continue; drawHex(ctx, x, y, data.charCodeAt(cnt++)); } } } ctx.restore(); } function drawCamLegend(canv) { var cw = canv.width; var ch = canv.height; var ctx = canv.getContext("2d"); ctx.font = "8pt Arial"; ctx.textAlign = "right"; ctx.textBaseline = "top"; ctx.strokeStyle = "#"+color(0); ctx.strokeText("-2.0V", cw-5, 135); ctx.strokeStyle = "#"+color(16); ctx.strokeText("-1.5V", cw-5, 120); ctx.strokeStyle = "#"+color(32); ctx.strokeText("-1.0V", cw-5, 105); ctx.strokeStyle = "#"+color(48); ctx.strokeText("-0.5V", cw-5, 90); ctx.strokeStyle = "#"+color(64); ctx.strokeText("0V", cw-5, 70); ctx.strokeStyle = "#"+color(80); ctx.strokeText("0.5V", cw-5, 50); ctx.strokeStyle = "#"+color(86); ctx.strokeText("1.0V", cw-5, 35); ctx.strokeStyle = "#"+color(102); ctx.strokeText("1.5V", cw-5, 20); ctx.strokeStyle = "#"+color(127); ctx.strokeText("2.0V", cw-5, 5); } function drawGraph(canv, data) { var cw = canv.width; var ch = canv.height; var ctx = canv.getContext("2d"); var dx = 15; var dy = 15; var dw = 5; var nx = 20; var ny = 10; var w = cw-2*dx; var h = ch-2*dy; ctx.strokeStyle = "#808080"; ctx.beginPath(); ctx.moveTo(dx, ch-dy-data.charCodeAt(0)/128*h); for (var i=1; i