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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 xmlLoad = new XMLHttpRequest(); xmlLoad.open('POST', "index.php?load", true); xmlLoad.setRequestHeader("Cache-Control", "no-cache"); xmlLoad.setRequestHeader("If-Match", "*"); xmlLoad.onload = function() { if (xmlLoad.status==401) login(""); if (xmlLoad.status!=200) { //alert("ERROR[0] - HTTP request '"+xmlLoad.statusText+" ["+xmlLoad.status+"]"); //return; } if (xmlLoad.status==200) login(xmlLoad.responseText); }; xmlLoad.send(null); } 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); else alert("Command submitted."); }; xmlCmd.send(null); } function submit(script, isIrq) { var inputs = document.getElementsByTagName("input"); var args = isIrq ? "interrupt="+script : "start="+script+".js"; for (var i=0; i=1 ? script[0].substr(1) : title.substr(1); script = script.length>=1 ? script[1] : name; } // ================================================================== var th = $new("thead"); th.colSpan = 3; th.width = "100%"; var htr = $new("tr"); th.appendChild(htr); var htd = $new("td"); htd.setAttribute("class", "thead"); htd.colSpan = 3; htd.width = "100%"; htr.appendChild(htd); // ------------- var htab = $new("table"); htab.width = "100%"; htd.appendChild(htab); var hhtr = $new("tr"); htab.appendChild(hhtr); var htd0 = $new("td"); var htd1 = $new("td"); var htd2 = $new("td"); var htd3 = $new("td"); var htd4 = $new("td"); var htd5 = $new("td"); var htd6 = $new("td"); htd0.setAttribute("class", "tcell1"); htd1.setAttribute("class", "tcell2"); htd2.setAttribute("class", "tcell1"); htd2.setAttribute("width", "1px"); htd3.setAttribute("class", "tcell1"); htd3.setAttribute("width", "1px"); htd4.setAttribute("width", "1px"); htd5.setAttribute("width", "1px"); htd6.setAttribute("width", "1px"); hhtr.appendChild(htd6); hhtr.appendChild(htd4); hhtr.appendChild(htd3); hhtr.appendChild(htd0); hhtr.appendChild(htd1); hhtr.appendChild(htd2); hhtr.appendChild(htd5); var div0 = $new("div"); var div1 = $new("div"); var div2 = $new("div"); var div3 = $new("div"); var div4 = $new("div"); var div5 = $new("div"); div0.id = "login"+z; div0.alt = $("body").user; div4.id = "warn"+z; div5.id = "speaker"+z; div0.setAttribute("class", "icon_login"); div2.setAttribute("class", "icon_white"); div4.setAttribute("class", "icon_color"); div5.setAttribute("class", "icon_color"); div0.setAttribute("style", "background-position:-"+($("body").user?"720":"755")+"px 50%;"); div2.setAttribute("style", "background-position:-396px 50%;"); div4.setAttribute("style", "background-position:-12px -13px;display:none;"); div5.setAttribute("style", "background-position:-189px -57px;"); div0.onclick = function () { sendCommand("logout"); }; div2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage(fname, z, -dz); }; div4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('error', z, +1); }; if (name=="fact") { div3.setAttribute("class", "icon_color"); div3.setAttribute("style", "background-position:-58px -146px;"); } else { div3.setAttribute("class", "icon_white"); div3.setAttribute("style", "background-position:-575px 50%;"); div3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact', z, -1); }; } var sp0 = $new("span"); var sp1 = $new("span"); var sp2 = $new("span"); sp0.id = "ldot" +z; sp1.id = "title"+z; sp2.id = "rdot" +z; sp1.setAttribute("style", "font-size:large;"); //sp0.setAttribute("data-color", "3"); //sp2.setAttribute("data-color", "3"); sp0.dotColor = 3; sp2.dotColor = 3; sp0.appendChild($txt(" \u2022 ")); sp1.appendChild($txt(title)); sp2.appendChild($txt(" \u2022 ")); if (is_cmd) { sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(script, is_irq); this.style.backgroundColor=''; }; } else { if (name!='control') sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.15)'; loadPage('control', z, +1); }; } div1.setAttribute("style", "font-size:small;"); div1.id = "reporttime"+z; div1.appendChild($txt("---")); div1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; }; htd0.appendChild(sp0); htd0.appendChild(sp1); htd0.appendChild(sp2); htd6.appendChild(div0); // Login htd1.appendChild(div1); if (dz!=0/* && z+dz!=0*/) htd2.appendChild(div2); // back htd3.appendChild(div3); // home htd4.appendChild(div4); // Warning htd5.appendChild(div5); // Speaker // ================================================================== var tf = $new("tfoot"); var ftr = $new("tr"); tf.appendChild(ftr); var ftd = $new("td"); ftd.setAttribute("class", "tfoot"); ftd.width = "100%"; ftd.colSpan = 3; ftr.appendChild(ftd); var ftab = $new("table"); ftab.width = "100%"; ftd.appendChild(ftab); var ftdH = $new("td"); var ftd0 = $new("td"); var ftd1 = $new("td"); var ftd2 = $new("td"); var ftd3 = $new("td"); var ftd4 = $new("td"); ftdH.setAttribute("width", "1px"); ftd2.setAttribute("width", "1px"); ftd3.setAttribute("width", "1px"); ftd4.setAttribute("width", "1px"); ftdH.setAttribute("class", "tcell1"); ftd0.setAttribute("class", "tcell1"); ftd1.setAttribute("class", "tcell2"); ftd2.setAttribute("class", "tcell2"); ftd3.setAttribute("class", "tcell2"); ftd4.setAttribute("class", "tcell2"); ftab.appendChild(ftdH); ftab.appendChild(ftd0); ftab.appendChild(ftd1); ftab.appendChild(ftd2); ftab.appendChild(ftd3); ftab.appendChild(ftd4); var fdivH = $new("div"); var fdiv0 = $new("span"); var fdiv1 = $new("span"); var fdiv2 = $new("div"); var fdiv3 = $new("div"); var fdiv4 = $new("div"); ftd0.style.paddingLeft = "5px"; fdiv4.id="cmd"+z; fdiv2.setAttribute("class", "icon_white"); fdiv3.setAttribute("class", "icon_white"); fdiv4.setAttribute("class", "icon_white"); fdiv2.setAttribute("style", "background-position:-72px 50%;"); fdiv4.setAttribute("style", "background-position:-432px 50%;"); fdiv2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; }; if (is_cmd) { fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(script, is_irq); this.style.backgroundColor=''; }; fdiv3.setAttribute("style", "background-position:-109px 50%;"); } else { fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('control', z, +1); }; fdiv3.setAttribute("style", "background-position:-289px 50%;"); } if (name.substr(0, 5)=="help-") { fdivH.setAttribute("class", "icon_color"); fdivH.setAttribute("style", "background-position:-408px -57px;"); //fdivH.setAttribute("style", "background-position:-13px -57px;"); } else { fdivH.setAttribute("class", "icon_white"); fdivH.setAttribute("style", "background-position:-611px 50%;"); fdivH.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('help-'+name, z, +1); }; } fdiv4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('scriptlog', z, +1); }; fdiv0.setAttribute("style", "font-size:large;"); fdiv1.setAttribute("style", "font-size:small;"); fdiv1.id = "localtime"+z; fdiv0.onclick = function () { window.location='https://www.fact-project.org/logbook/misc.php?action=mobile'; } fdiv0.appendChild($txt("logbook")); fdiv1.appendChild($txt("loading...")); ftdH.appendChild(fdivH); ftd0.appendChild(fdiv0); ftd1.appendChild(fdiv1); ftd2.appendChild(fdiv2); if (is_cmd || name!='control') ftd3.appendChild(fdiv3); if (name!='scriptlog') ftd4.appendChild(fdiv4); // ================================================================== var tbody = $new("tbody"); 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:15px;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"; input.style.width = "100%"; if (opt.length>2) input.value=opt[2]; cell2.appendChild(input); } } if (check.length>0 && check[0]=="checkbox") { var opt = check[1].split('/'); var div = $new("div"); div.innerHTML = opt[0]; cell1.appendChild(div); var input = $new("input"); input.type = "checkbox"; input.name = opt[1]; input.onclick = function() { this.value=this.checked; }; var c = opt.length>2 && opt[2]=="1"; input.checked = c; input.value = c; cell2.appendChild(input); } if (check.length==0 || (check[0]!="input" && check[0]!="select" && check[0]!="checkbox")) { 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); $("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); table.counter = counter; // This is needed so that the page is extended in height // _before_ the sliding (in case it contains graphics 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 if (img.style.height!=ih+"px") img.style.height = ih+"px"; if (canv.height!=ih) 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; if (img.style.width!=sW+"px") img.style.width = sW+"px"; if (canv.width!=sW) 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) { var tab = $("table"+newz); tab.style.left="0px"; tab.style.position="absolute"; $("body").visiblePage = newz; //.setAttribute("data-visible", newz); doresize(newz); //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; var test_counter = 0; function refresh_text() { var z=$("body").visiblePage;//getAttribute("data-visible"); var fname = $("table"+z).pageName;//getAttribute("data-file"); var counter = $("table"+z).counter;//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('GET', "data/"+fname+'.data', true); xmlText.setRequestHeader("Cache-Control", "no-cache"); xmlText.setRequestHeader("If-Match", "*"); xmlText.onload = function () { // if (xmlText.status==412) // { // timeoutText = setTimeout(refresh_text, 3000); // return; // } if (counter>1 && xmlText.status!=200 && xmlText.status!=412) { alert("ERROR[2] - HTTP request '"+fname+".data': "+xmlText.statusText+" ["+xmlText.status+"]"); timeoutText = setTimeout(refresh_text, 10000); return; } if (!isSliding()) { cycleCol($("ldot"+z)); update_text(fname, counter>1 ? xmlText.responseText : undefined); doresize(z); } 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 now = new Date(); var ltime = $("localtime"+z); setUTC(ltime, now); if (!result) return; var rtime = $("reporttime"+z); var tokens = result.split('\n'); 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 && header[2].length>0) { var name = "audio/"+header[2]; var mp3 = $new("SOURCE"); var ogg = $new("SOURCE"); mp3.src = name+".mp3"; ogg.src = name+".ogg"; mp3.type = "audio/mp3"; ogg.type = "audio/ogg"; audio.replaceChild(mp3, audio.firstChild); audio.replaceChild(ogg, audio.lastChild); audio.load(); audio.play(); audio.date = audio_date; } } // ---------------------------------------------------- //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(/<\/([#\+-])>/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('GET', "data/"+fname, true); xmlGfx.setRequestHeader("Cache-Control", "no-cache"); xmlGfx.setRequestHeader("If-Match", "*"); xmlGfx.onload = function () { // if (xmlGfx.status==412) // { // timeoutGraphics = setTimeout(refresh_graphics, 5000); // return; // } if (xmlGfx.status!=200 && xmlGfx.status!=412) { alert("ERROR[3] - 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) return HLStoRGB(0); var hue = col/126; 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(126*i/10); 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.length==4 ? vals[3] : 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"; ctx.fillStyle = "#"+color(100); // --- data --- var cnt = 0; for (var j=1; jfs/2 ? "middle" : "top"; ctx.strokeText(umax, ml-dw-2, mt); ctx.textBaseline = "top"; ctx.textAlign = "center"; ctx.strokeText(stat, ml+w/2, 5); } function invalidateCanvas(canv) { var ctx = canv.getContext("2d"); ctx.fillStyle = "rgba(255, 255, 255, 0.5)"; ctx.fillRect(0, 0, canv.width, canv.height); } function processGraphicsData(canv, result) { if (result.length==0) return false; var ctx = canv.getContext("2d"); ctx.clearRect(0, 0, canv.width, canv.height); var data = result.split('\x7f'); if (data.length<2) return false; var header = data[0].split('\n'); if (header.length<4) return false; switch (canv.dataType) { //case "camera": drawCam(result); break; case "hist": drawGraph(canv, header, data); break; case "camera": drawFullCam(data[1]); drawCamLegend(canv, header); break; } var now = new Date(); var tm = new Date(); tm.setTime(header[0]); if (tm.getTime()+60000