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989V9Y9Z9[9f9^:a:d:4;1;n:=;:;7;O;L;I;F;C;@;@_>`>8B7B6BZBXBWB_CaC`CFDEDDDlDgDoEmE>FAFDFGFJFMF90<0?0003060714121a0^0]0G1C1B1N2L2E2C2B2@2L3I3`6d6E7F7G7H7O8Q8192969T9U9X96;3;0;?;<;9;Q;N;K;H;E;B;W16) col = 31-col; var hex = col.toString(16); el.style.color = "#"+hex+"0"+hex+"0"+hex+"f"; } function onload() { try { var dummy = new XMLHttpRequest(); } catch(e) { // FIXME: Add a message to the body. alert("Your browser doesn't support dynamic reload."); return; } var name = location.hash.length==0 ? "fact" : location.hash.substr(1); var args = location.search.substr(1).split('&'); for (var i=0; i1) alert(xmlCmd.responseText); }; xmlCmd.send(null); } function submit(script) { var inputs = document.getElementsByTagName("input"); var args = "start="+script+".dim"; for (var i=0; i=3) break; lines[i-1] += lines[i].length==0 ? '

' : " "+lines[i]; lines.splice(i,1); } } var counter = 1; for (var i=1; i1 && (check[0]=="camera" || check[0]=="hist")) { var data = cols[1].substring(check[0].length+1).split("/"); var tr = $new("tr"); tr.setAttribute("class", "row"); //tr.setAttribute("style", "margin:0;padding:0;"); var td = $new("td"); td.setAttribute("class", "container"); td.id = "container"; td.colSpan = 3; tr.appendChild(td); var canv = $new("canvas"); canv.id = "canvas"+z; canv.width = "1"; canv.height = "1"; //canv.onclick = function () { save(); } //canv.setAttribute("data-type", check[0]); //canv.setAttribute("data-file", data[0]); //canv.setAttribute("data-data", cols[1].substring(check[0].length+data[0].length+2)); canv.dataType = check[0]; canv.fileName = data[0]; canv.dataUnit = htmlDecode(cols[1].substring(check[0].length+data[0].length+2)); // canv.setAttribute("style", "display:none;"); td.appendChild(canv); var img = $new("img"); img.src = "img/dummy.png";//needed in firefox img.id = "image"+z; img.setAttribute("style", "width:1px;height:1px;display:none;"); td.appendChild(img); tbody.appendChild(tr); continue; } var tr = $new("tr"); tr.setAttribute("class", "row"); if (valid(cols[0])) { tr.linkName = cols[0]; tr.onclick = function () { this.style.background='#ccb'; loadPage(this.linkName, z, -1); }; } if (valid(cols[3])) { tr.linkName = cols[3]; tr.onclick = function () { this.style.background='#cbb'; loadPage(this.linkName, z, +1); }; } var td0 = $new("td"); td0.setAttribute("class", "tcol0"); tr.appendChild(td0); if (check.length>0 && check[0]=="image") { var img = $new("img"); img.style.width="100%"; img.style.display="block"; img.src = "img/"+check[1]; td0.style.paddingLeft=0; td0.style.border=0; td0.colSpan=3; td0.appendChild(img); tbody.appendChild(tr); continue; } if (valid(cols[0])) { var sp = $new("div"); sp.setAttribute("class", "icon_black"); sp.setAttribute("style", "background-position: -144px 50%;"); td0.appendChild(sp); } var td1 = $new("td"); td1.setAttribute("class", "tcol1"); td1.width = "100%"; tr.appendChild(td1); var td2 = $new("td"); td2.setAttribute("class", "tcol2"); td2.width = "18px"; if (valid(cols[3])) { var sp = $new("div"); sp.setAttribute("class", "icon_black"); sp.setAttribute("style", "background-position: -108px 50%;"); td2.appendChild(sp); } tr.appendChild(td2); var tab = $new("table"); tab.width = "100%"; td1.appendChild(tab); var innertr = $new("tr"); tab.appendChild(innertr); var cell1 = $new("td"); cell1.setAttribute("class", "tcell1"); var cell2 = $new("td"); cell2.setAttribute("class", valid(cols[1]) ? "tcell2" : "tcell2l"); if (check.length>0 && check[0]=="select") { var args = check[1].split('/'); if (args.length<2) alert("Argument name missing for'"+check[1]+"'"); else { var div = $new("div"); div.innerHTML = args[0]; cell1.appendChild(div); var input = $new("SELECT"); input.name = args[1]; for (var j=2; j0 && check[0]=="input") { var opt = check[1].split('/'); if (opt.length<2) alert("Argument name missing for'"+check[1]+"'"); else { var div = $new("div"); div.innerHTML = opt[0]; cell1.appendChild(div); var input = $new("input"); input.name = opt[1]; input.type = "text"; input.maxlength = 80; input.style.textAlign = "right"; if (opt.length>2) input.value=opt[2]; cell2.appendChild(input); } } if (check.length==0 || (check[0]!="input" && check[0]!="select")) { var div = $new("div"); div.innerHTML = cols[1]; cell1.appendChild(div); if (cols.length>2 && cols[2].length>0) { cell2.id = "data"+z+"-"+counter; cell2.dataFormat = cols[2]; cell2.appendChild($txt("---")); counter++; } else cell1.setAttribute("class", "description"); } innertr.appendChild(cell1); innertr.appendChild(cell2); tbody.appendChild(tr); } // ================================================================== if (debug == true) { tr = $new("tr"); tr.setAttribute("class", "row"); td = $new("td"); td.id = "debug"+z; td.colSpan = 3; tr.appendChild(td); tbody.appendChild(tr); } // ================================================================== var table = $("table"+z); if (table) $("body").removeChild(table); table = $new("table"); table.id = "table"+z; table.border = 0; table.cellSpacing = 0; table.cellPadding = "0px"; //table.setAttribute("style", "overflow:hidden;position:fixed;top:0px;left:"+window.innerWidth+"px;") table.setAttribute("style", "position:fixed;width:100%;top:0px;"+ "left:"+window.innerWidth+"px;"); table.appendChild(th); table.appendChild(tbody); table.appendChild(tf); // ================================================================== /* var audio = $new("AUDIO"); audio.autoplay = true; audio.date = new Date(); audio.id = "audio"+z; var ogg = $new("SOURCE"); var mp3 = $new("SOURCE"); audio.appendChild(ogg); audio.appendChild(mp3); $("body").appendChild(audio); */ $("body").appendChild(table); // ================================================================== /* // Scrollbar for just the body table.style.position = "fixed"; th.style.position = "aboslute"; tf.style.position = "aboslute"; tbody.style.overflowY = "auto"; tbody.style.display = "block"; tbody.style.height = (window.innerHeight-th.clientHeight-tf.clientHeight)+"px"; tbody.id = "tbody"+z; th.id = "thead"+z; tf.id = "tfoot"+z; */ // ================================================================== table.pageName = name;//setAttribute("data-file", name); doresize(z); } function doresize(z) { var img = $("image"+z); var canv = $("canvas"+z); if (!img || !canv) return; var h = $("table"+z).offsetHeight; if (h == 0) return; // =========================================== /* var tb = $("tbody"+z); var hw = $("thead"+z).clientHeight; var fw = $("tfoot"+z).clientHeight; tb.style.height = (window.innerHeight-hw-fw)+"px"; */ // =========================================== var fixedw = $("body").displayFixedWidth;//getAttribute("data-width"); var fixedh = $("body").displayFixedHeight;//getAttribute("data-height"); var W = fixedw>0 ? fixedw : window.innerWidth; var H = fixedh>0 ? fixedh : window.innerHeight; //var max = $("body").getAttribute("data-max")=="yes"; var max = $("body").displayMax; var ih = max ? W : H - h + parseInt(img.style.height, 10); // This might create the scroll bar img.style.height = ih+"px"; canv.height = ih; // now we can evaluate the correct view-port // (-2 is the border size of the parent element 'container') //var sW = (fixedw ? fixedw : $("table"+z).scrollWidth)-2; var sW = fixedw ? fixedw : canv.parentNode.clientWidth; img.style.width = sW+"px"; canv.width = sW; // ------ debug ----- if (debug == true) { $('debug'+z).innerHTML = ""; $('debug'+z).innerHTML += "|W="+W +"/"+H; $('debug'+z).innerHTML += "|H="+h+"/"+$("table"+z).offsetHeight+"/"+img.offsetHeight; $('debug'+z).innerHTML += "|I="+img.style.height+"+"+H+"-"+h; } } var intervalSlide = null; function changePage(oldz, newz) { // No page displayed yet if (oldz==newz) { $("table"+newz).style.left="0px"; $("body").visiblePage = newz; //.setAttribute("data-visible", newz); doresize(0); //setInterval(refresh_text, 1000); //setInterval(refresh_graphics, 5000); refresh_text(); // first: decode the pixel mapping! var sum = 1036080; for (var i=0; i<1440; i++) { var d0 = codedMap.charCodeAt(i*2) -48; var d1 = codedMap.charCodeAt(i*2+1)-48; map[i] = d0 | (d1<<6); sum -= map[i]; } if (sum!=0) alert("Pixel mapping table corrupted!"); refresh_graphics(); return; } var W = window.innerWidth; if (W==0 || $("body").displayNoslide)//$("body").getAttribute("data-noslide")=="yes") { $("body").visiblePage = newz;//setAttribute("data-visible", newz); $("body").removeChild($("table"+oldz)); $("table"+newz).style.left="0px"; return; } if (newz>oldz) $("table"+newz).style.left = W+"px"; else $("table"+newz).style.left = (-W-1)+"px"; $("body").visiblePage = newz;//setAttribute("data-visible", newz); // This is needed on my mobile to ensure that te browser // doesn't try to zoom during shifting $("table"+newz).style.position="fixed"; $("table"+oldz).style.position="fixed"; intervalSlide = setInterval(function (){doShift(oldz,newz);}, 75); } function doShift(oldz, newz) { var t0 = $("table"+oldz); var t1 = $("table"+newz); if (t0.style.display=="none") { clearInterval(intervalSlide); $("body").removeChild(t0); t1.style.position="absolute"; // Now the scroll bar might have to appear or disappear doresize(newz); return; } var x0 = t0.offsetLeft; var x1 = t1.offsetLeft; var W = window.innerWidth; if (newzoldz) { x0 -= W/5; x1 -= W/5; } if ((newz=0) || (newz>oldz && x1<=0)) { t0.style.display="none"; x1 = 0; } t0.style.left = x0+"px"; t1.style.left = x1+"px"; } var timeoutText = null; var timeoutGraphics = null; function refresh_text() { var z=$("body").visiblePage;//getAttribute("data-visible"); var fname = $("table"+z).pageName;//getAttribute("data-file"); var is_help = fname.substr(0,5)=="help-"; // Is sliding, no file defined or just help text? if (isSliding() || !valid(fname) || is_help) { if (is_help) { setUTC($("localtime"+z), new Date()); $("reporttime"+z).innerHTML=""; } // invalidate? timeoutText = setTimeout(refresh_text, 1000); return; } var xmlText = new XMLHttpRequest(); xmlText.open('POST', "data/"+fname+'.data', true); xmlText.onload = function () { if (xmlText.status!=200) { alert("ERROR[1] - HTTP request '"+fname+".data': "+xmlText.statusText+" ["+xmlText.status+"]"); timeoutText = setTimeout(refresh_text, 10000); return; } if (!isSliding()) { cycleCol($("ldot"+z)); update_text(fname, xmlText.responseText); } timeoutText = setTimeout(refresh_text, 3000); }; xmlText.send(null); } var date0 = null; var test = 0; function update_text(fname, result) { var z=$("body").visiblePage;//getAttribute("data-visible"); var table = $("table"+z); if (table.pageName/*getAttribute("data-file")*/ != fname) return; var tokens = result.split('\n'); // ---------------------------------------------------- var rtime = $("reporttime"+z); var ltime = $("localtime"+z); var now = new Date(); var header = tokens[0].split('\t'); // File corrupted / should we remove the date?) if ((header.length>5 || header.length==2 || header.length==0) && header[0].length!=13) { // we ignore corrupted files for one minute if (date0==null || date0.getTime()+60000=4 && header[3]=='1' ? "" : "none"; if (header.length>=5) $("cmd"+z).style.backgroundColor = header[4]=='1' ? "darkgreen" : "darkred"; if (header.length>=3 && $("body").sound) { $("speaker"+z).style.display ="none"; var audio = $("audio"); var audio_date = new Date(); audio_date.setTime(header[1]); // Time stamp of audio file must be newer than page load // or last audio play respecitvely if (audio_date>audio.date) { audio.date = audio_date; var name_ogg = "audio/"+header[2]+".ogg"; var name_mp3 = "audio/"+header[2]+".mp3"; var ogg = $new("SOURCE"); var mp3 = $new("SOURCE"); ogg.type = "audio/ogg"; mp3.type = "audio/mp3"; ogg.src = name_ogg; mp3.src = name_mp3; if (audio.firstChild.src!=ogg.src) { audio.replaceChild(ogg, audio.firstChild); audio.replaceChild(mp3, audio.lastChild); } } } // ---------------------------------------------------- //var p = table.tBodies.length==3 ? 1 : 0; //var tbody = table.tBodies[p]; for (var line=1; line/g, ""); form = form.replace(/<([\+-])>/g, ""); form = form.replace(/<\/([#\+-])>/g, ""); form = form.replace(/([0-9][0-9]):([0-9][0-9]):([0-9][0-9])/g, "

$1
:
$2
:
$3
"); form = form.replace(/--:--:--/g, "
  
  
  
"); var newe = $new("div"); newe.innerHTML = form; e.replaceChild(newe, e.lastChild); e.parentNode.parentNode.parentNode.parentNode.style.background=cols[0]; } } // http://billmill.org/static/canvastutorial/index.html // http://www.netmagazine.com/tutorials/learning-basics-html5-canvas // http://www.alistapart.com/articles/responsive-web-design/ function refresh_graphics() { var z = $("body").visiblePage;//getAttribute("data-visible"); var canvas = $("canvas"+z); // Is sliding or no data file defined? var fname = canvas==null ? "" : canvas.fileName;//getAttribute("data-file"); if (isSliding() || !valid(fname)) { // invalidate? timeoutGraphics = setTimeout(refresh_graphics, 3000); return; } var xmlGfx = new XMLHttpRequest(); xmlGfx.open('POST', "data/"+fname, true); xmlGfx.onload = function () { if (xmlGfx.status!=200) { alert("ERROR[2] - Request '"+fname+"': "+xmlGfx.statusText+" ["+xmlGfx.status+"]"); timeoutGraphics = setTimeout(refresh_graphics, 10000); //****** invalidate ****** return; } if (!isSliding()) { cycleCol($("rdot"+z)); process_eventdata(xmlGfx.responseText); } timeoutGraphics = setTimeout(refresh_graphics, 5000) }; xmlGfx.send(null); } function hueToRGB(hue) { hue /= 3; hue %= 6; if (hue<1) return parseInt(255*hue, 10); if (hue<3) return parseInt(255, 10); if (hue<4) return parseInt(255*(4-hue), 10); return 0. } function hueToHex(flt) { var s = hueToRGB(flt).toString(16); return s.length==2 ? s : "0"+s; } function HLStoRGB(hue) { hue *= 14; var sr = hueToHex(20-hue); var sg = hueToHex(14-hue); var sb = hueToHex(26-hue); return sr+sg+sb; } function color(col) { if (col==65533) col = 0; var hue = col/128; return HLStoRGB(hue); } function toHex(str, idx) { var ch = str[idx].toString(16); return ch.length==2 ? ch : "0"+ch; } function drawHex(ctx, x, y, col) { ctx.fillStyle = "#"+color(col); ctx.save(); ctx.translate(x, y); ctx.scale(1/2, 1/3); ctx.beginPath(); ctx.moveTo( 1, 1); ctx.lineTo( 0, 2); ctx.lineTo(-1, 1); ctx.lineTo(-1, -1); ctx.lineTo( 0, -2); ctx.lineTo( 1, -1); ctx.fill(); ctx.restore(); } function drawDisc(ctx, x, y, r, col) { ctx.fillStyle = "#"+color(col); ctx.save(); ctx.translate(x, y); ctx.beginPath(); ctx.arc(0, 0, r, 0, Math.PI*2, true); ctx.fill(); ctx.restore(); } function beginDrawCam(scale) { var z = $("body").visiblePage;//getAttribute("data-visible"); var canv = $("canvas"+z); var w = Math.min(canv.width/scale, canv.height/scale); var ctx = canv.getContext("2d"); ctx.save(); ctx.translate(canv.width/2, canv.height/2); ctx.scale(w*2, w*2); return ctx; } /** * @constructor */ function Position(s, ring, i) { switch (s) { case 1: this.x = ring - i*0.5; this.y = + i; break; case 2: this.x = ring*0.5 - i; this.y = ring ; break; case 3: this.x = -ring*0.5 - i*0.5; this.y = ring - i; break; case 4: this.x = -ring + i*0.5; this.y = - i; break; case 5: this.x = -ring*0.5 + i; this.y = -ring ; break; case 0: this.x = ring*0.5 + i*0.5; this.y = -ring + i; break; } this.d = (function () { return this.x*this.x + this.y*this.y*3/4; }); } function drawFullCam(data) { if (data.length!=40 && data.length!=160 && data.length!=320 && data.length!=1440) { alert("Camera - Received data has invalid size ("+data.length+"b)"); return; } var div = map.length/data.length; var off = data.length==320 ? 0.2 : 0; var ctx = beginDrawCam(83); // ctx.rotate(Math.PI/3); ctx.scale(1, Math.sqrt(3)/2); ctx.translate(-0.5, 0); drawHex(ctx, 0, 0, data.charCodeAt(parseInt(map[0]/div+off, 10))); var cnt = 1; for (var ring=1; ring<24; ring++) { for (var s=0; s<6; s++) { for (var i=1; i<=ring; i++) { var pos = new Position(s, ring, i); if (pos.d() - pos.x > 395.75) continue; var p = parseInt(map[cnt]/div+off, 10); drawHex(ctx, pos.x, pos.y, data.charCodeAt(p)); cnt++; } } } drawHex(ctx, 7, -22, data.charCodeAt(parseInt(map[1438]/div+off, 10))); drawHex(ctx, 7, 22, data.charCodeAt(parseInt(map[1439]/div+off, 10))); ctx.restore(); } function drawCam(data) { var ctx = beginDrawCam(27); ctx.rotate(Math.PI/6); ctx.scale(1, Math.sqrt(3)/2); drawHex(ctx, 0, 0, data.charCodeAt(0)); var cnt = 1; for (var ring=1; ring<=7; ring++) { for (var s=0; s<6; s++) { for (var i=1; i<=ring; i++) { var pos = new Position(s, ring, i); if (pos.d() > 44) continue; if (ring==7) { if (i==6 && (s==0 || s==3)) continue; if (i==1 && (s==1 || s==4)) continue; } drawHex(ctx, pos.x, pos.y, data.charCodeAt(cnt++)); } } } ctx.restore(); } function drawCamLegend(canv, data) { var unit = canv.dataUnit;//htmlDecode(canv.getAttribute("data-data")); var umin = data[1]; var umax = data[2]; var min = data[3]+unit var med = data[4]+unit; var max = data[5]+unit; var v0 = parseFloat(umin); var v1 = parseFloat(umax); var diff = v1-v0; var cw = canv.width; //var ch = canv.height; var ctx = canv.getContext("2d"); ctx.font = "8pt Arial"; ctx.textAlign = "right"; ctx.textBaseline = "top"; for (var i=0; i<11; i++) { ctx.strokeStyle = "#"+color(16*i); ctx.strokeText((v0+diff*i/10).toPrecision(3)+unit, cw-5, 125-i*12); } var mw = Math.max(ctx.measureText(min).width, ctx.measureText(med).width, ctx.measureText(max).width); ctx.textBaseline = "top"; ctx.strokeStyle = "#000"; ctx.strokeText(min, 5+mw, 5+24); ctx.strokeText(med, 5+mw, 5+12); ctx.strokeText(max, 5+mw, 5); } function drawGraph(canv, vals, data) { var unit = canv.dataUnit;//htmlDecode(canv.getAttribute("data-data"));//.split("/"); var umin = vals[1]+unit; var umax = vals[2]+unit; var stat = vals[3]+unit+" / "+vals[4]+unit+" / "+vals[5]+unit; var cw = canv.width; var ch = canv.height; var ctx = canv.getContext("2d"); var dw = 3; // tick width var fs = 8; // font size ctx.font = fs+"pt Arial"; ctx.textAlign = "right"; var dim0 = ctx.measureText(umin); var dim1 = ctx.measureText(umax); var tw = Math.max(dim0.width, dim1.width)+dw+2; var ml = 5+tw; // margin left var mr = 10; // margin right var mt = 5+2*fs+4; // margin top var mb = fs/2+4; // margin bottom var nx = 20; var ny = 10; var w = cw-ml-mr; var h = ch-mt-mb; ctx.strokeStyle = "#666"; // --- data --- if (data.length>1) { ctx.beginPath(); ctx.moveTo(ml, ch-mb-data.charCodeAt(0)/128*h); for (var i=1; ifs/2 ? "middle" : "top"; ctx.strokeText(umax, ml-dw-2, mt); ctx.textBaseline = "top"; ctx.textAlign = "center"; ctx.strokeText(stat, ml+w/2, 5); } function process_eventdata(result) { if (result.length==0) return; var z = $("body").visiblePage;//getAttribute("data-visible"); var canv = $("canvas"+z); if (!canv) return; var type = canv.dataType;//getAttribute("data-type"); var ctx = canv.getContext("2d"); ctx.clearRect(0, 0, canv.width, canv.height); var data = result.split('\n'); if (result.length<4) return; var len = 0; for (var i=0; i<6; i++) len += data[i].length+1; switch (type) { //case "camera": drawCam(result); break; case "hist": drawGraph(canv, data, result.substr(len)); break; case "camera": drawFullCam(result.substr(len)); drawCamLegend(canv, data); break; } var now = new Date(); var tm = new Date(); tm.setTime(data[0]); if (tm.getTime()+60000