-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobs-app.min.js
2 lines (2 loc) · 47.1 KB
/
obs-app.min.js
1
2
function Cdraw(e,t){var n,r,a,o,i,s=e||"canvas",l="normal 16px sans-serif",c="normal 11px sans-serif",h="#000",u="globalAlpha,globalCompositeOperation,lineCap,lineJoin,miterLimit,shadowBlur,shadowColor,shadowOffsetX,shadowOffsetY";if(n=document.getElementById(s),n||(n=document.createElement("canvas"),n.id=s,n.style.top=0,n.style.left=0,t&&t.hasOwnProperty("parent")&&(i=document.getElementById(t.parent)),i||(i=document.getElementsByTagName("body")[0]),i.appendChild(n)),!n.getContext)return null;if(r=n.getContext("2d"),!r.fillText)return null;this.setheight=function(e){isNumber(e)&&(n.height=e,o=e)},this.setwidth=function(e){isNumber(e)&&(n.width=e,a=e)},this.setsize=function(e){"object"==typeof e&&e.hasOwnProperty("h")&&e.hasOwnProperty("w")&&(n.width=e.w,n.height=e.h,a=e.w,o=e.h)},this.setfont=function(e){e&&(l=e)},this.setexpfont=function(e){e&&(c=e)},this.setcolor=function(e){e&&(h=e)},this.setclip=function(e,t,n,a){r.beginPath(),r.rect(e,t,n,a),r.clip()},this.setclipcircle=function(e,t,n){r.beginPath(),r.arc(Math.round(e)+.5,Math.round(t)+.5,n,0,2*Math.PI,!0),r.clip()},this.setviewport=function(e,t){r.translate(e,t),a-=e,o-=t},this.setparam=function(e,t){-1!=u.search(e)&&(r[e]=t,this[e]=t)};this.line=function(e,t,n,a,o,i){r.strokeStyle=o||h,r.lineWidth=i||"0.5",r.beginPath(),r.moveTo(Math.round(e)+.5,Math.round(t)+.5),r.lineTo(Math.round(n)+.5,Math.round(a)+.5),r.stroke()},this.hline=function(e,t,n,r,o){var i=n||a;this.line(e,t,e+i,t,r,o)},this.vline=function(e,t,n,r,a){var i=n||o;this.line(e,t,e,t+i,r,a)},this.vtick=function(e,t,n,r,a){var o=n||4;this.line(e,t-o,e,t+o,r,a)},this.htick=function(e,t,n,r,a){var o=n||4;this.line(e-o,t,e+o,t,r,a)},this.cross=function(e,t,n,r,a){this.hline(e-n-1.5,t-.5,n,r,a),this.hline(e+.5,t-.5,n,r,a),this.vline(e-.5,t-n-1.5,n,r,a),this.vline(e-.5,t+.5,n,r,a)},this.dashline=function(e,t,n,r,a,o,i){for(var s=i||[4,4],l=Math.atan2(n-e,r-t),c=Math.sqrt(Math.pow(r-t,2)+Math.pow(n-e,2)),h=e,u=t,m=0,d=0,f=0;Math.sqrt(Math.pow(t-u,2)+Math.pow(e-h,2))<c;)m=h+Math.sin(l)*s[f],d=u+Math.cos(l)*s[f],f%2==0&&this.line(h,u,m,d,a,o),h=m,u=d,f=f==s.length-1?0:f+1},this.setdash=function(e){r.setLineDash&&(e?r.setLineDash(e):r.setLineDash([0]))},this.text=function(e,t,n,a,o,i,s){var c,u;if(e)if(e=e.toString(),r.font=a||l,r.textAlign=o||"left",r.fillStyle=i||h,r.textBaseline=s||"alphabetic",-1!=e.search(/\n/g))for(c=e.match(/[^\n]+/g),u=0;u<c.length;u++)r.fillText(c[u],Math.round(t)+.5,n+16*u);else r.fillText(e,Math.round(t)+.5,n)},this.vtext=function(e,t,n,a,o,i,s){var l;l=s?Math.PI*s/180:1.5*Math.PI,r.save(),r.translate(t,n),r.rotate(l),this.text(e,0,0,a,o,i),r.restore()},this.label=function(e,t,n,r,a,o,i){var s=i||h,l=a||"NE",c="center",u="middle",m=0,d=0,f=this.relPos(l,r);m=f.x,d=f.y,u=f.v,c=f.h,this.text(e,t+m,n+d,o,c,s,u)},this.relPos=function(e,t){var n,r=0,a=0,o="middle",i="center";if(!e||!t||!isNumber(t)||t<=1)return{x:0,y:0,h:i,v:o};switch(n=Math.round(t/2),e.toUpperCase()){case"N":a-=t+n;break;case"NE":a-=t-n,r+=t-n;break;case"E":r+=t+n;break;case"SE":a+=t-n,r+=t-n;break;case"S":a+=t+n;break;case"SW":a+=t-n,r-=t-n+2;break;case"W":r-=t+n;break;case"NW":a-=t-n,r-=t-n+2}return-1!=e.search(/N/g)&&(o="bottom"),-1!=e.search(/S/g)&&(o="top"),-1!=e.search(/E/g)&&(i="left"),-1!=e.search(/W/g)&&(i="right"),{x:r,y:a,h:i,v:o}},this.number=function(e,t,n,a,o,i){var s,l,h,u=o||"left";if(!(s=parseFloat(e).toExponential().match(/(\d*)[eE]\+?(-?\d*)/)))return void this.text(e,t,n,a,o,i);if(l=s[1],"1"!=l?l+="×10":l="10",h=s[2],"right"==u)r.font=c,this.text(l,t-r.measureText(h).width-1,n,a,u,i),this.text(h,t,n-4,c,u,i);else if("center"==u){r.font=c;var m=r.measureText(h).width;r.font=a;var d=r.measureText(l).width,f=t-(d+m)/2;this.text(l,f,n,a,"left",i),this.text(h,f+d+1,n-4,c,"left",i)}else this.text(l,t,n,a,u,i),this.text(h,t+r.measureText(l).width+1,n-5,c,u,i)},this.index=function(e,t,n,a,o,i,s){var l,h,u,m,d=o||"left";if(!(l=e.toString().match(/(.*)([<>])(.*)/)))return void this.text(l,t,n,a,o,i,s);h=l[1],u=l[3],m=l[2].search(/>/)>=0?-4:4,"right"==d?(r.font=c,this.text(h,t-r.measureText(u).width-1,n,a,d,i,s),this.text(u,t,n+m,c,d,i,s)):"center"==d?(this.text(h,t,n,a,"right",i,s),this.text(u,t,n+m,c,"left",i,s)):(this.text(h,t,n,a,d,i,s),this.text(u,t+r.measureText(h).width+1,n+m,c,d,i,s))},this.textwidth=function(e,t){return r.font=t||l,r.measureText(e).width},this.fillrect=function(e,t,n,a,o){r.fillStyle=o||h,r.fillRect(e,t,n,a)},this.strokerect=function(e,t,n,a,o,i){r.strokeStyle=o||h,r.lineWidth=i||"0.5",r.strokeRect(Math.round(e)+.5,Math.round(t)+.5,n,a)},this.filldiamond=function(e,t,n,a,o){r.fillStyle=o||h,r.beginPath(),r.moveTo(e-n,t),r.lineTo(e,t-a),r.lineTo(e+n,t),r.lineTo(e,t+a),r.closePath(),r.fill()},this.roundedrect=function(e,t,n,a,o,i,s){r.strokeStyle=i||h,r.lineWidth=s||"0.5",r.beginPath(),r.moveTo(e,t+o),r.lineTo(e,t+a-o),r.quadraticCurveTo(e,t+a,e+o,t+a),r.lineTo(e+n-o,t+a),r.quadraticCurveTo(e+n,t+a,e+n,t+a-o),r.lineTo(e+n,t+o),r.quadraticCurveTo(e+n,t,e+n-o,t),r.lineTo(e+o,t),r.quadraticCurveTo(e,t,e,t+o),r.stroke()},this.fillcircle=function(e,t,n,a){r.fillStyle=a||h,r.beginPath(),r.arc(Math.round(e)+.5,Math.round(t)+.5,n,0,2*Math.PI,!0),r.closePath(),r.fill()},this.fillellipsis=function(e,t,n,a,o){var i;r.fillStyle=o||h,i=a||1,r.save(),r.scale(1,1/i),r.beginPath(),r.arc(Math.round(e)+.5,Math.round(t*i)+.5,n,0,2*Math.PI,!0),r.closePath(),r.fill(),r.restore()},this.strokecircle=function(e,t,n,a,o){r.strokeStyle=a||h,r.lineWidth=o||"0.5",r.beginPath(),r.arc(Math.round(e)+.5,Math.round(t)+.5,n,0,2*Math.PI,!0),r.closePath(),r.stroke()},this.filltriangle=function(e,t,n,a){r.fillStyle=a||h;var o=Math.sqrt(n);r.beginPath(),r.moveTo(e,t-o),r.lineTo(e+o,t+o),r.lineTo(e-o,t+o),r.closePath(),r.fill()},this.arc=function(e,t,n,a,o,i,s,l){r.strokeStyle=s||h,r.lineWidth=l||"0.5",r.beginPath(),r.arc(e,t,n,a,o,i),r.arc(e,t,n,o,a,!i),r.closePath(),r.stroke()},this.gradient=function(e,t,n,r,a){var o=this.makegradient(e,n,t,n,a);e<t?this.fillrect(e,n,t-e,r,o):this.fillrect(t,n,e-t,r,o)},this.makegradient=function(e,t,n,a,o){var i=r.createLinearGradient(e,t,n,a);if("object"==typeof o&&o.constructor==Array)for(var s=0;s<o.length;s++)i.addColorStop(o[s].pos,o[s].col);return i},this.makeradialgradient=function(e,t,n,a,o,i,s){var l=r.createRadialGradient(e,t,n,a,o,i);if("object"==typeof s&&s.constructor==Array)for(var c=0;c<s.length;c++)l.addColorStop(s[c].pos,s[c].col);return l},this.image=function(e,t,n,a,o,i,s,l,c){var h;if(e&&-1!=(typeof e).search(/object|string/)){if(e.constructor==String)h=new Image,h.src=e;else{if(!e.src)return;h=e}i?r.drawImage(h,t,n,a,o,i,s,l,c):a?r.drawImage(h,t,n,a,o):r.drawImage(h,t,n)}},this.createpattern=function(e,t){return r.createPattern(e,t)},this.save=function(){r.save()},this.restore=function(){r.restore()},this.scale=function(e,t){r.scale(e,t)},this.rotate=function(e,t,n){var a,o,i;a=e?Math.PI*e/180:0,o=t||0,i=n||0,r.translate(o,i),r.rotate(a)},this.startp=function(e,t,n,a,o){r.fillStyle=n||h,r.strokeStyle=o||r.fillStyle,r.lineWidth=a||"0.5",r.beginPath(),r.moveTo(e,t)},this.movep=function(e,t){r.lineTo(e,t)},this.arcp=function(e,t,n,a,o,i){r.arc(e,t,n,a,o,i)},this.endp=function(e,t,n){var a=n||!1;e&&t&&r.lineTo(e,t),r.closePath(),a&&r.fill(),r.stroke()},this.termp=function(e,t){e&&t&&r.lineTo(e,t),r.stroke()},this.clear=function(){r.clearRect(0,0,a,o)},this.Width=function(){return a},this.Height=function(){return o},function(e){var t,i;for(t in e)if(e.hasOwnProperty(t))switch(i=e[t],t){case"width":isNumber(i)&&(n.width=i,a=i);break;case"height":isNumber(i)&&(n.height=i,o=i);break;case"top":case"left":n.style[t]=i;break;case"className":n.className=i;break;case"font":l=i;break;case"color":h=i;break;default:-1!=u.search(t)&&(r[t]=i,this[t]=i)}}(t),a=n.width,o=n.height}function Round(e,t){return Math.round(Math.pow(10,t)*e)/Math.pow(10,t)}function sign(e){return e?e<0?-1:1:0}function prefix(e){return SI.hasOwnProperty(e)?SI[e]:1}function w2f(e){return 299792458/e}function e2f(e){return 0xdbea334f7fe3*e}function isNumber(e){return!isNaN(parseFloat(e))&&isFinite(e)}function isArray(e){return"[object Array]"===Object.prototype.toString.call(e)}function logError(e,t){console.log(e,t)}function px(e){return e+"px"}function Diag(e,t){var n,r,a,o,i,s={lo:1e6,hi:3e26,off:6,r:20.2},l={lo:5e-8,hi:5e5,off:7.5,r:12.5},c={x:180,y:43},u=SOBS.LEGEND,m="14px 'Trebuchet MS'",d="bold 20px 'Trebuchet MS'",f=SOBS.SCALEFONT,p="bold 20px 'Trebuchet MS'",g="en",S={left:{l:0,t:"right",o:-2},right:{l:0,t:"left",o:1}};setParams=function(e){var t,a;for(t in e)switch(a=e[t],t){case"width":case"w":isNumber(a)&&(n=a);break;case"height":case"h":isNumber(a)&&(r=a);break;case"lang":g=a}},drawSpectrum=function(e,t){var n,r,o,i,s,l,c=t,h=[],m="#fff",d=SOBS.BARHEIGHT,f=SOBS.range.length-1;for(l=xscale(SOBS.range[0].f0),s=xscale(SOBS.range[f].f1)-l,n=0;n<SOBS.range.length;n++)r=xscale(SOBS.range[n].f0),o=xscale(SOBS.range[n].f1),3==n?(e.gradient(r+.5,o-.5,c,d,[{pos:0,col:SOBS.range[n].c0},{pos:.3,col:"#fc0"},{pos:.45,col:"#ff0"},{pos:.6,col:"#0f0"},{pos:.75,col:"#0cf"},{pos:1,col:SOBS.range[n].c1}]),h=h.concat([{pos:(r-l)/s,col:SOBS.range[n].c0},{pos:(r-l+2)/s,col:"#fc0"},{pos:(r-l+4)/s,col:"#ff0"},{pos:(r-l+6)/s,col:"#0f0"},{pos:(r-l+8)/s,col:"#0cf"}])):(e.gradient(r+1,o-1,c,d,[{pos:0,col:SOBS.range[n].c0},{pos:1,col:SOBS.range[n].c1}]),h.push({pos:(r-l)/s,col:SOBS.range[n].c0})),3==n?(i=d+17,m="#000"):(i=20,m="#fff"),e.text(SOBS.range[n].s,(o+r)/2,c+i,p,"center",m);e.text(SOBS.legend[g].bnd,S[u].l+30*S[u].o,c+i,SOBS.TEXTFONT,S[u].t,SOBS.TEXTCOL),a=e.makegradient(l,0,l+s,0,h)},drawXAxis=function(e,t,n,r){var a,o=t-2,i=xscale(s.lo),l=xscale(s.hi),c=SOBS.LINECOL,h=xscale(8e16);for(e.line(i,o,h-16,o,c,1.2),e.line(h+16,o,l,o,c,1.2),e.dashline(l,o,l+16,o,c,1.2,Cdraw.SDASH),e.dashline(i,o,i-16,o,c,1.2,Cdraw.SDASH),e.dashline(h-16,o,h+16,o,c,1.2,Cdraw.SDASH),a=2;a>=-8;a--)e.vline(xscale(w2f("1e"+a)),o-5,5,c,1);for(var a=3;a<=12;a++)e.vline(xscale(e2f("1e"+a)),o-5,5,c,1);for(a=0;a<SOBS.units.length;a++)"w"==SOBS.units[a].t?e.text(SOBS.units[a].n,xscale(w2f(SOBS.units[a].u)),o-10,f,"center"):e.text(SOBS.units[a].n,xscale(e2f(SOBS.units[a].u)),o-10,f,"center");for(r||e.text(SOBS.legend[g].wav,S[u].l+25*S[u].o,o-18,SOBS.TEXTFONT,S[u].t,SOBS.TEXTCOL),n&&(o+=n),e.line(i,o,l,o,c,1.2),e.dashline(l,o,l+16,o,c,1.2,Cdraw.SDASH),e.dashline(i,o,i-16,o,c,1.2,Cdraw.SDASH),a=6;a<=26;a++)e.vline(xscale("1e"+a),o,5,c,1),e.number("1e"+a,xscale("1e"+a),o+26,f,"center",SOBS.TEXTCOL);r||e.text(SOBS.legend[g].freq,S[u].l+10*S[u].o,o+25,SOBS.TEXTFONT,S[u].t,SOBS.TEXTCOL)},drawYAxis=function(t,r){var a,s,c,h,m,d,y,w=SOBS.LINECOL;if("line"==e&&(t.text(SOBS.legend[g].fut,n+32,o+12,p,"right",SOBS.TEXTCOL),t.text(SOBS.legend[g].grnd,n+32,i+34,p,"right",SOBS.TEXTCOL)),"res"==e){for(m=S[u].l,d=S[u].t,y=S[u].o,s=yscale(l.lo),c=yscale(l.hi),h=m,t.line(h,s,h,c,w,1),a=-7;a<6;a++)t.hline(h,yscale("1e"+a),5*y,w,1),t.number("1e"+a,h+7*y,yscale("1e"+a)+6,f,d);h+=35*y,"left"==u?(t.vtext("Angular Resolution [arcsec]",h-40,(c+s)/2-10,SOBS.TEXTFONT,"center",SOBS.TEXTCOL),t.text("10°",h,yscale(36e3)+6,f,d),t.hline(h+6,yscale(36e3),14,w,1),t.text(" 1°",h,yscale(3600)+6,f,d),t.hline(h+6,yscale(3600),14,w,1),t.text(" 1′",h,yscale(60)+6,f,d),t.hline(h+6,yscale(60),14,w,1),t.text(" 1″",h,yscale(1)+6,f,d),t.hline(h+6,yscale(1),14,w,1),t.text(" 1mas",h,yscale(.001)+6,f,d),t.hline(h+6,yscale(.001),10,w,1),t.text("1μas",h,yscale(1e-6)+6,f,d),t.hline(h+6,yscale(1e-6),10,w,1)):(t.vtext("Angular Resolution [arcsec]",h+70,(c+s)/2-10,SOBS.TEXTFONT,"center",SOBS.TEXTCOL),t.text("10°",h+6,yscale(36e3)+6,f,d),t.hline(h-12,yscale(36e3),14,w,1),t.text(" 1°",h+6,yscale(3600)+6,f,d),t.hline(h-12,yscale(3600),14,w,1),t.text(" 1′",h+6,yscale(60)+6,f,d),t.hline(h-12,yscale(60),14,w,1),t.text(" 1″",h+6,yscale(1)+6,f,d),t.hline(h-12,yscale(1),14,w,1),t.text(" 1mas",h+6,yscale(.001)+6,f,d),t.hline(h-12,yscale(.001),14,w,1),t.text("1μas",h+6,yscale(1e-6)+6,f,d),t.hline(h-12,yscale(1e-6),14,w,1))}},drawAbsoption=function(t,n){var r,a,o=n,i=SOBS.BARHEIGHT+4,l=xscale(s.hi)-8,c=xscale(s.lo)-2,h=t.makegradient(0,o+i,0,o,[{pos:0,col:"#c0b7df"},{pos:1,col:"#9999cc"}]);t.fillrect(c,o-1,l-c,i+2,h),h=t.makegradient(0,o+i,0,o,[{pos:0,col:"#999"},{pos:1,col:"#555"}]),t.startp(l,o+i,h),t.movep(l,o);for(var r=0;r<SOBS.absorp.length;r++)t.movep(xscale(w2f(1e-6*SOBS.absorp[r].f)),o+i*(1-SOBS.absorp[r].a));t.movep(c,o),t.movep(c,o+i),t.endp(l,o+i,!0),t.text(SOBS.legend[g].abs,S[u].l+10*S[u].o,o+14,SOBS.TEXTFONT,S[u].t,SOBS.TEXTCOL),o=o+i-6,t.text(SOBS.legend[g].ion,xscale(35e5),o,f,"center","#fff"),t.text(SOBS.legend[g].h2o,xscale(3e12),o,f,"center","#fff"),t.text(SOBS.legend[g].o23,xscale(1e20),o,f,"center","#fff"),a="line"==e?22:32,t.text("0",l+a,o+0,f,"right","","top",col),t.text("100",l+a,o-i+8,f,"right",null,null,col)},drawScope=function(e,t){var n,r,a,o,i,s=(SOBS.TEXTFONT,"#ad6");s=getColor(t),n=t.d&&t.px?drawScopeDL(e,t,s):drawScopeL(e,t,s),t.hasOwnProperty("c")&&null!=t.c&&(r="center",a=(n.x0+n.x1)/2,o=-1!=t.c.search(/b/)?n.y1:(n.y1+n.y0)/2,-1!=t.c.search(/r/)?(r="left",a=n.x1+4,o=n.y1-9):-1!=t.c.search(/l/)&&(r="right",a=n.x0-4,o=n.y0-9),-1!=t.c.search(/n/)&&(i=t.n,-1!=t.c.search(/i/)&&(i+=" "+t.i),-1!=t.c.search(/p/)&&(i=t.p),-1!=t.c.search(/v/)?-1!=t.c.search(/t/)?e.vtext(i,a+5.5,o-5.5,d,r,"#3c0",50):e.vtext(i,a-14.5,o+14.5,d,r,"#3c0",50):-1!=t.c.search(/t/)?e.text(i,a,o-2.5,d,r,"#3c0"):e.text(i,a,o+14.5,d,r,"#3c0")))},drawScopeDL=function(e,t,n){var r,a,o,i=-1,s=-1,l=-1,c=-1,h={};for(a=(t.f1-t.f0)/(xscale(t.f1)-xscale(t.f0))*3,r=t.f0;r<=t.f1;r+=a)o=getRes(t,r),i=xscale(r),s=yscale(o),r==t.f0&&(h.x0=i,h.y0=s),-1!=l&&-1!=c&&e.line(i,s,l,c,n,3.7),l=i,c=s;return h.y1=c,h.x1=l,h},drawScopeL=function(e,t,n){var r=-1,a=-1,o=-1,i=-1;return r=xscale(t.f0),o=xscale(t.f1),a=yscale(t.r0),i=t.r1?yscale(t.r1):a,e.line(r,a,o,i,n,2.5),{x0:r,y0:a,x1:o,y1:i}},drawMission=function(e,t,n){var r,a,o,i,s,l;return t.hasOwnProperty("c")&&null!=t.c?(r=xscale(t.fl),a=xscale(t.fh),i=n+SOBS.BARHEIGHT+3,-1!=t.c.search(/l/)?(l="right",o=r-16):(l="left",o=a+16),-1!=t.c.search(/n/)&&e.text(t.n,o,i+6,SOBS.TEXTFONT,l,SOBS.TEXTCOL),o=-1!=t.c.search(/l/)?a+4+t.x:r-4+t.x,t.hasOwnProperty("img")&&null!=t.img&&(s=t.hasOwnProperty("sc")&&null!=t.sc?t.sc:1,drawImg(e,t.img,s,o,n+6+t.y,l)),n+SOBS.BARHEIGHT+6):n},drawImg=function(e,t,n,r,a,o){var i,s,l=50*n;s="right"==o?4:-l-4,i=new Image,i.onload=function(t){e.image(this,r+s,a,l,this.height/this.width*l)},i.src=t},drawLine=function(e,t,n){var r,a,o;return t.hasOwnProperty("c")&&null!=t.c?(a=xscale(t.f0),r=t.f1>s.hi?xscale(s.hi):xscale(t.f1),h=n,o=getColor(t),e.line(a,h,r,h,o,4),e.vline(a,h-7,7,o,1.2),t.f1<=s.hi?e.vline(r,h-7,7,o,1.2):e.dashline(r,h,r+16,h,o,4,Cdraw.SDASH),t.hasOwnProperty("p")&&null!=t.p&&-1==t.c.search(/x/)?e.text(t.p+" "+t.i,(r+a)/2,h+4,m,"center",SOBS.TEXTCOL,"top"):t.hasOwnProperty("i")&&null!=t.i&&-1==t.c.search(/x/)&&e.text(t.i,(r+a)/2,h+4,m,"center",SOBS.TEXTCOL,"top"),-1!=t.c.search(/y/)?n+ +SOBS.BARHEIGHT:n):n},xscale=function(e){var t=e;return e>s.hi&&(t=s.hi),e<s.lo&&(t=s.lo),(Math.LOG10E*Math.log(t)-s.off)*n/s.r},yscale=function(e){var t=e;return e>l.hi&&(t=l.hi),e<l.lo&&(t=l.lo),r-(Math.LOG10E*Math.log(t)+l.off)*r/l.r},getRes=function(e,t,n){var r=75440684077500/t/e.d;return!0===n?r:Math.sqrt(r*r+Math.pow(e.px,2))},getColor=function(e){return SOBS.FUTURE&&"pl"==e.st?col="#bba":"g"==e.st?col="#778":"sol"==e.pur?col="#ff0":SOBS.mtype.hasOwnProperty(e.tp)?col=SOBS.mtype[e.tp].col:col=a,col},this.draw=function(t,a,l,h,d){var p,g,y=0,w="";if(r=d,t.setheight(d+2*c.y+18),n=h,S.left.l=xscale(s.lo),S.right.l=xscale(s.hi),t.setwidth(h+c.x+64),t.setexpfont(m),t.setfont(f),t.setcolor(SOBS.TEXTCOL),e=a,"left"==u?(t.setviewport(c.x,c.y),t.fillrect(-c.x-10,-c.y-10,n+250,r+120,SOBS.BGCOL)):(t.setviewport(30,c.y),t.fillrect(-30,-c.y-10,n+c.x+250,r+120,SOBS.BGCOL)),"res"==e){for(g=y,drawSpectrum(t,g+1),drawXAxis(t,g,r+SOBS.BARHEIGHT-6),drawYAxis(t,g),p=0;p<l.length;p++)-1!=l[p].st.search(/o|g/)&&drawScope(t,l[p]);drawAbsoption(t,r-14)}if("line"==e){for(y=10,g=y,drawSpectrum(t,g),g+=SOBS.BARHEIGHT,p=0;p<l.length;p++)-1!=l[p].st.search(/o/)&&(l[p].n!=w&&(g=drawMission(t,l[p],g),w=l[p].n),g=drawLine(t,l[p],g));for(g+=5*SOBS.BARHEIGHT,o=g,p=0;p<l.length;p++)-1!=l[p].st.search(/pl/)&&(l[p].n!=w&&(g=drawMission(t,l[p],g),w=l[p].n),g=drawLine(t,l[p],g));for(g+=2*SOBS.BARHEIGHT,drawAbsoption(t,g),g+=SOBS.BARHEIGHT+6,i=g,p=0;p<l.length;p++)-1!=l[p].st.search(/g/)&&(l[p].n!=w&&(g=drawMission(t,l[p],g),w=l[p].n),drawLine(t,l[p],g));drawXAxis(t,y,g+SOBS.BARHEIGHT-12),drawXAxis(t,o-2*SOBS.BARHEIGHT,4),drawYAxis(t,y)}}}Cdraw.SOLID=[1],Cdraw.DASH=[4,4],Cdraw.DOT=[1.5,3.5],Cdraw.LDASH=[8,8],Cdraw.SDASH=[2,4],Cdraw.DASHDOT=[4,4,1,4];var Trig={sinh:function(e){return(Math.pow(Math.E,e)-Math.pow(Math.E,-e))/2},cosh:function(e){return(Math.pow(Math.E,e)+Math.pow(Math.E,-e))/2},tanh:function(e){return 2/(1+Math.exp(-2*e))-1},asinh:function(e){return Math.log(e+Math.sqrt(e*e+1))},acosh:function(e){return Math.log(e+Math.sqrt(e*e-1))},normalize0:function(e){return(e+3*Math.PI)%(2*Math.PI)-Math.PI},normalize:function(e){return(e+2*Math.PI)%(2*Math.PI)},deg2rad:function(e){return e*Math.PI/180},hour2rad:function(e){return e*Math.PI/12},rad2deg:function(e){return 180*e/Math.PI},rad2hour:function(e){return 12*e/Math.PI},PI:Math.PI,PI2:2*Math.PI,PI_2:Math.PI/2},SI={a:1e-18,f:1e-15,p:1e-12,n:1e-9,u:1e-6,"μ":1e-6,m:.001,c:.01,k:1e3,M:1e6,G:1e9,T:1e12,P:1e15,E:1e18},UI=UI||{width:0,height:0,boxwidth:0,bevel:0,iscancelled:!1,scale:1,left:0,right:0};UI.vanish=function(e){var t,n;for(n=!1===e?document.querySelectorAll(".infoPopup"):document.querySelectorAll(".infoBox, .infoPopup"),t=0;t<n.length;t++)n[t].style.opacity=0;setTimeout(UI.shift,1e3)},UI.shift=function(){var e,t;for(t=document.querySelectorAll(".infoBox, .infoPopup"),e=0;e<t.length;e++)"0"===t[e].style.opacity&&(t[e].style.top=px(-9999))},UI.wait=function(e,t,n){var r=document.getElementById("waitmsg");r&&(e?(r.style.top=px(t),r.style.left=px(n),r.style.display="block",UI.iscancelled=!1):("block"==r.style.display&&(UI.iscancelled=!0),r.style.display="none"))},UI.cancelled=function(){return UI.iscancelled},UI.Width=function(){var e=0;return e=document.documentElement.clientWidth?document.documentElement.clientWidth:window.innerWidth,(0===e||e<700)&&(e=700),e},UI.Height=function(e){return isNumber(e)&&(UI.height+=e),UI.height},UI.show=function(e,t){var n,r,a,o=(e||window.event,UI.getBoxPos(e)),i=t||this;return r=i.offsetTop+i.clientHeight+2,n=i.id.match(/^(sbo|rings|moons|info)(.+)/),null!==n&&(a=document.getElementById(n[2]+n[1])),a||UI.cancelled()?UI.wait(!1):(UI.wait(!0,r,o.c),window.setTimeout(function(){UI.show(e,i)},500)),!!a&&(1==a.style.opacity?(UI.vanish(),parseInt(a.style.top)!=r&&window.setTimeout(function(){UI.show(e,i)},250)):(UI.vanish(),a.style.left=px(o.l),a.style.top=px(r),a.style.opacity=1,UI.Scroll.set(a)),!1)},UI.go=function(e){var t,n;null!==(t=this.id.match(/^(leg|info)(.+)/))&&(UI.vanish(),n=document.getElementById("info"+t[2]),UI.Scroll.top(n))},UI.Scroll=new function(){var e,t,n,r,a=function(){return window.pageYOffset||document.documentElement.scrollTop},o=function(){return window.innerHeight||document.documentElement.clientHeight},i=function(){return r/n},s=function(){return r+=25,e-t/2*(Math.cos(Math.PI*i())+1)},l=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;this.set=function(i){var s,c,h;i&&(h="string"==typeof i?document.getElementById(i):i,s=h.getBoundingClientRect(),c=o(),s.bottom<c||(t=s.height>c?s.top:s.bottom-c)<=0||(e=a()+t,n=25*Math.round(t/25)*2,n<25&&(n=25),r=0,l(this.move)))},this.top=function(o){var i,s;o&&(s="string"==typeof o?document.getElementById(o):o,i=s.getBoundingClientRect(),t=i.top,e=a()+t,n=25*Math.round(t/25)*2,n>2e3&&(n=25*Math.round(Math.pow(t,.85)/25)*2),n<25&&(n=25),r=0,l(this.move))},this.move=function(){var t=s();Math.abs(e-t)<1||(window.scrollTo(0,t),r<n&&l(UI.Scroll.move))}},UI.getBoxPos=function(e){var t,n,r=UI.boxwidth,a=UI.Width(),o=e||window.event;return n=o&&o.clientX?o.clientX:a/2,t=n-r/2+5,t<0&&(t=8),t>a-r-32&&(t=a-r-32),n-=99,n<8&&(n=8),n>a-232&&(n=a-232),{l:t,c:n}},UI.showBox=function(e){var t=document.getElementById(e);return t&&UI.show(null,t),!1},UI.showImg=function(e){var t,n,r,a=e||window.event;if(this.id)for(t=this.childNodes,n=0;n<t.length;n++)if("img"==t[n].nodeName.toLowerCase()){"mouseout"==a.type?t[n].style.top=px(-9999):"mouseover"==a.type&&(r=-t[n].height/2+8,t[n].style.top=px(r));break}},UI.Scale={oldsize:{w:0,h:0,t:0,l:0},dist:function(e,t){if(e.a)return parseFloat(e.a)*t},image:function(e,t){var n,r,a,o;if(a=t||1,e)return e.eqrad&&0!==e.scale?(r=e.eqrad<1?1:e.eqrad,n=5*Math.pow(r*e.scale,.9)/UI.scale*a,n<5&&(n=5),o=0===e.img.width?1:e.img.height/e.img.width,{w:n,h:n*o}):{w:e.img.width,h:e.img.height}},time:function(e,t){var n,r=t?t-UI.bevel:1;return n=Math.round((e.valueOf()-UI.left)/(UI.right-UI.left)*r),t&&(n+=UI.bevel),n},enlarge:function(e){var t,n,r,a,o=e||window.event;-1!=o.target.id.search(/pic/)?r=o.target:(n=o.target.parentNode.id,n&&""!==n||(n=o.target.parentNode.parentNode.id),n=n.replace(/line/,"pic"),r=document.getElementById(n)),r&&(a=r.height/r.width,120==parseInt(r.style.width)?(r.style.width=px(UI.Scale.oldsize.w),r.style.height=px(UI.Scale.oldsize.h),r.style.top=px(UI.Scale.oldsize.t),r.style.left=px(UI.Scale.oldsize.l),r.style.zIndex=300,UI.Scale.oldsize={w:0,h:0,t:0,l:0}):(UI.Scale.oldsize={w:parseFloat(r.style.width),h:parseFloat(r.style.height),t:parseFloat(r.style.top),l:parseFloat(r.style.left)},UI.Scale.oldsize.w<120?(r.style.cursor="url('"+Common.symbols.zoomin.src+"'), auto",r.style.width=px(120),r.style.height=px(120*a),t=UI.Scale.oldsize.t+UI.Scale.oldsize.h/2-120*a/2,t<4&&(t=4),t>244-120*a&&(t=244-120*a),r.style.top=px(t),t=UI.Scale.oldsize.l+UI.Scale.oldsize.w/2-60,t<4&&(t=4),t>UI.boxwidth-124&&(t=UI.boxwidth-124),r.style.left=px(t),r.style.zIndex=301):r.style.cursor="url('"+Common.symbols.nozoom.src+"'), auto"),n||(n=r.id.replace(/pic/,"line"),UI.showEntry(n)),o.stopPropagation())}},UI.toggle=function(e){var t=this,n=t.nextSibling;n&&("130px"!=n.style.maxHeight?(n.firstChild.style.display="inline-block",n.style.maxHeight=px(130),window.setTimeout(function(){UI.View.set(t)},600)):(n.style.maxHeight=px(0),n.firstChild.style.display="none"))},UI.showRing=function(){if(this.id){var e=this.id.replace(/pic/,"line");UI.showEntry(e)}},UI.showEntry=function(e){var t,n=document.getElementById(e);if(n)if(-1==n.style.backgroundColor.search(/rgb/))n.style.background="rgb(255, 255, 204)",n.nextSibling.firstChild.style.display="inline-block",n.nextSibling.style.maxHeight=px(120),window.setTimeout(function(){UI.View.set(n)},600);else{if(n.style.background="transparent",null!==(t=e.match(/(ring.{3}|moon.{3}|sbo.)/))&&(t="lnk"+t[1],-1!=document.getElementById(t).innerHTML.search(/Hide/)))return;n.nextSibling.firstChild.style.display="none",n.nextSibling.style.maxHeight=px(0)}},UI.View=new function(){var e,t,n,r,a,o,i=function(){return o/a},s=function(){return o+=30,t-n/2*(Math.cos(Math.PI*i())+1)};this.set=function(i){if(i){if(t=null,e=i.parentNode,r=e.firstChild.offsetTop,e.scrollHeight>e.clientHeight&&(i.offsetTop+i.clientHeight+i.nextSibling.clientHeight>e.scrollTop+e.clientHeight&&(t=i.offsetTop+i.clientHeight+i.nextSibling.clientHeight-e.clientHeight-r),i.offsetTop<e.scrollTop&&(t=i.offsetTop-r)),null===t&&e.parentNode.parentNode)return void UI.Scroll.set(e.parentNode.parentNode);n=t-e.scrollTop,a=30*Math.round(Math.abs(n)/30)*2,a<30&&(a=30),o=0,window.setTimeout(this.move,30)}},this.move=function(){var t,n=s();e.scrollTop=n,t=o>=a?0:30,t>0?window.setTimeout(UI.View.move,30):e.parentNode.parentNode&&UI.Scroll.set(e.parentNode.parentNode)}},UI.all=function(){var e,t=document.getElementsByClassName("detPanel"),n=-1==this.innerHTML.search(/Hide/),r=this.id.replace(/lnk/,""),a=null;if(n){for(e=0;e<t.length;e++)t[e].id&&-1!=t[e].id.search(r)&&(t[e].firstChild.style.display="inline-block",t[e].style.maxHeight=px(120),a=e);this.innerHTML="Hide details",a&&t[a].parentNode.parentNode.parentNode&&UI.Scroll.set(t[a].parentNode.parentNode.parentNode)}else{for(e=0;e<t.length;e++)t[e].id&&-1!=t[e].id.search(r)&&(t[e].firstChild.style.display="none",t[e].style.maxHeight=px(0));this.innerHTML="Show all details"}return!1},UI.isFullScreen=function(){return document.fullScreenElement&&null!==document.fullScreenElement||document.mozFullScreen||document.webkitIsFullScreen},UI.toggleFullScreen=function(){document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.msRequestFullscreen?document.documentElement.msRequestFullscreen():document.documentElement.mozRequestFullScreen?document.documentElement.mozRequestFullScreen():document.documentElement.webkitRequestFullscreen&&document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)};var Create={br:function(e){var t=document.createElement("br");return e&&e.appendChild(t),t},text:function(e,t){var n=document.createTextNode(t);return e&&e.appendChild(n),n},bold:function(e,t){var n=document.createElement("b");return n.appendChild(document.createTextNode(t)),e&&e.appendChild(n),n},div:function(e,t,n,r){var a=document.createElement("div");return t&&(a.className=t),n&&(a.id=n),r&&"object"==typeof r&&(r.hasOwnProperty("t")&&(a.style.top=px(r.t)),r.hasOwnProperty("l")&&(a.style.left=px(r.l)),r.hasOwnProperty("h")&&(a.style.height=px(r.h)),r.hasOwnProperty("w")&&(a.style.width=px(r.w))),e&&e.appendChild(a),a},span:function(e,t,n,r){var a,o=document.createElement("span");return n&&(o.className=n),r&&(o.id=r),t&&(a=t.n.toString(),-1!=a.search(/\d/)&&(a=this.number(a)),o.innerHTML=a,t.l&&(o.title=t.l,t.u||(o.style.cursor="help")),t.c&&(o.style.color=t.c)),e&&e.appendChild(o),o},a:function(e,t,n){var r;if(t.n||t.u)return t.u?(r=document.createElement("a"),n&&(r.className=n),this.span(r,t,n),r.href=t.u,t.t&&(r.target=t.t),e&&e.appendChild(r),r):this.span(e,t,n)},img:function(e,t,n,r){if(t&&"object"==typeof t){var a=document.createElement("img");return n&&(a.className=n),r&&(a.id=r),a.src=t.i,t.hasOwnProperty("n")&&(a.title=t.l?t.l+" ("+t.n+")":t.n),t.x&&(t.hasOwnProperty("x")&&(a.style.left=px(t.x)),t.hasOwnProperty("y")&&(a.style.top=px(t.y)),t.hasOwnProperty("h")&&(a.style.height=px(t.h)),t.hasOwnProperty("w")&&(a.style.width=px(t.w))),e&&e.appendChild(a),a}},aimg:function(e,t,n){var r;if(t){if(!t.u&&!t.i)return this.span(e,t,n);if(t.i?(r=document.createElement("img"),r.src=t.i,n&&(r.className=n),t.n||t.l||!t.u?r.title=t.l?t.l+" ("+t.n+")":t.n:r.title=t.u):r=this.span(null,t,n),t.u){var a=document.createElement("a");return a.href=t.u,t.t&&(a.target=t.t),n&&(a.className=n),a.appendChild(r),e&&e.appendChild(a),a}return e&&e.appendChild(r),r}},table:function(e,t,n){var r=document.createElement("table");return t&&(r.className=t),n&&(r.id=n),e&&e.appendChild(r),r},thead:function(e,t){var n=document.createElement("thead");return t&&(n.className=t),e&&e.appendChild(n),n},tbody:function(e,t){var n=document.createElement("tbody");return t&&(n.className=t),e&&e.appendChild(n),n},tr:function(e,t,n){var r=document.createElement("tr");return t&&(r.className=t),n&&(r.id=n),e&&e.appendChild(r),r},td:function(e,t,n){var r=document.createElement("td");return n&&(r.className=n),t&&(t.i&&this.symbol(r,t.i,"missionFlag"),this.span(r,t,n)),e&&e.appendChild(r),r},field:function(e,t,n,r,a,o,i){var s,l,c;if(!0===r&&this.br(e),t&&"-"!=t){if(!0!==r&&!1!==r&&this.br(e),this.span(e,Common.names.find("t"+n),"category"),isArray(t))for(c=a||", ",s=this.span(e,null,o,i),l=0;l<t.length;l++)l>0&&this.text(s,c),this.span(s,t[l]);else s=t.hasOwnProperty("n")?this.span(e,t,o,i):this.span(e,{n:t},o,i);return s}},closex:function(e){var t=this.a(e,{n:"x",u:"javascript:UI.vanish()"},"close");t.style.left=px(SSEH.BOXWIDTH-3),t.title="Close box"},symbol:function(e,t,n,r){var a,o,i=this.div(e,n);return o=Common.sprites[t],a=r||1,i.title=o.n,i.style.background="url("+Common.symbols.sprite.src+") "+-o.x/a+"px "+-o.y/a+"px / "+px(240/a),i},asymbol:function(e,t,n,r){var a,o,i;if(t)return Common.sprites.hasOwnProperty(t.k)?(i=t.u?this.a(e,{u:t.u,t:"_blank",n:" "},n):this.div(e,n),o=Common.sprites[t.k],a=r||1,i.title=-1!=t.k.search(/ext|tw|globe/)?t.u:o.n,i.style.background="url("+Common.symbols.sprite.src+") "+-o.x/a+"px "+-o.y/a+"px / "+px(240/a),i):this.a(e,t,n+"W")},number:function(e){var t=e.replace(/(\d)[eE]\+?(-?[\d]+)/g,"$1×10<sup>$2</sup>");return t=t.replace(/\^\+?(-?[\d]+)/g,"<sup>$1</sup>")}},Read={string:function(e,t){if(e)return 1==e.length?{n:e[0]}:e[0].length<=3&&!t?{n:e[1]+" ("+e[0]+")"}:{n:e[0],l:e[1]}},data:function(e){var t,n,r=[];if(!e)return[];if(t=e.split(";"),t.length<1)return[];for(n=0;n<t.length;n++)r[n]=t[n].split(":");return r},url:function(e,t){var n,r;if(e)return e.length>1?(n=e[1],r=Common.names.find(e[0],!1)):t?(n=e[0],r=Common.names.find(t)):(n=e[0],r=Common.names.find("More")),-1==n.search(/^[\.\/]/)&&(n="http://"+n,r.t="_blank"),r.u=n,"weather"!=e[0]&&"haz"!=e[0]||(r.k=e[0]),"tw"==e[0]&&(r.n="@"+r.u.replace(/.*\//,"")),r}};String.prototype.toCommaString=function(){var e=this.split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")},Number.prototype.toCommaString=function(){var e=this.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")},String.prototype.toScience=function(){var e,t,n="";return e=this.match(/(^\D+)/),null!==e?(n=e[1],t=parseFloat(this.substring(n.length)).toPrecision(4)):t=parseFloat(this).toPrecision(4),t=t.replace(/\.?0+[eE]/,"e"),n+t},Number.prototype.toScience=function(){var e=this.toPrecision(4);return e=e.replace(/\.?0+[eE]/,"e")},Array.prototype.unique=function(e){return function(){return this.filter(e)}}(function(e,t,n){return n.indexOf(e,t+1)<0}),Date.prototype.add=function(e,t){var n=this.valueOf();if(e){switch(t||"d"){case"y":case"yr":n+=31556926080*e;break;case"m":case"mo":n+=26298e5*e;break;case"d":case"dy":n+=864e5*e;break;case"h":case"hr":n+=36e5*e;break;case"n":case"mn":case"mon":n+=6e4*e;break;case"s":case"sec":n+=1e3*e;break;case"ms":n+=e}return new Date(n)}},Date.prototype.diff=function(e,t){var n;if(e){switch(n=e.valueOf()-this.valueOf(),t||"d"){case"y":case"yr":n/=31556926080;break;case"m":case"mo":n/=26298e5;break;case"d":case"dy":n/=864e5;break;case"h":case"hr":n/=36e5;break;case"n":case"mn":n/=6e4;break;case"s":case"sec":n/=1e3}return n}},Date.prototype.toISOString||(Date.prototype.toISOString=function(){function e(e){return e<10?"0"+e:e}return this.getUTCFullYear()+"-"+e(this.getUTCMonth()+1)+"-"+e(this.getUTCDate())}),Date.prototype.frac=function(){return(this.getHours()+this.getTimezoneOffset()/60+this.getMinutes()/60+this.getSeconds()/3600)/24};var Parse={unit:function(e){if(e)switch(e){case"kN":case"km":case"m":case"e":case"kg":return Common.SPC+e;case"au":return Common.SPC+e.toUpperCase();case"deg":case"i":return"°"}},distance:function(e,t){var n="",r=null;if(e=e.toString(),null!==(r=e.match(/([\-\d\.e\^]*\d)(mi|km|m|au|deg|i|e)?/)))switch(r[2]){case"m":n=r[1].toCommaString()+Common.SPC+"m";break;case"km":n=r[1].toCommaString()+Common.SPC+"km";break;case"mi":n=Math.round(1.609344*r[1]).toCommaString()+Common.SPC+"km";break;case"au":n=r[1]+Common.SPC+"AU";break;case"deg":case"i":n=r[1]+"°";break;case"e":n=r[1]+"";break;case void 0:var a=Common.names.findRadius(t);n=a?Math.round((r[1]-1)*a).toCommaString()+Common.SPC+"km":r[1].toCommaString();break;default:return""}return n},orbit:function(e,t){var n,r,a="",o=null;for(o=e.split("x"),
o.length>1&&-1==o[0].search(/[a-z]/i)&&-1!=o[1].search(/[a-z]/i)&&null!==(r=o[1].match(/(km|au)/))&&(o[0]+=r[1]),n=0;n<o.length;n++)""!==a&&(a+=Common.TSPC+"×"+Common.TSPC),a+=this.distance(o[n],t);return r=a.match(/(km|au)/gi),null!==r&&r.length>1&&(a=a.replace(/^(\-?\d+)\s?km|\s?au/i,"$1")),a},elements:function(e,t){var n,r,a,o,i,s,l;if(e.a)return t&&"aei"==t?(a=this.distance(e.a),e.e&&""!==e.e&&(a+=Common.TSPC+"×"+Common.TSPC+e.e),e.i&&""!==e.i&&(a+=Common.TSPC+"×"+Common.TSPC+this.distance(e.i+"i")),a):e.e?null===(l=e.a.match(/([\d\.e]+)\s?(km|au)/))?e.a:(n=this.unit(l[2]),r=-1!=n.search(/km/)?0:3,a=parseFloat(l[1]),o=parseFloat(e.e),i=Round(a*(1-o),r),s=Round(a*(1+o),r),i.toCommaString()+Common.TSPC+"×"+Common.TSPC+s.toCommaString()+n+Common.TSPC+"×"+Common.TSPC+this.distance(e.i+"i")):e.a},diameter:function(e){var t=null;if(e||""!==e)return-1!=e.search(/\//)?(t=e.split("/"),t[0].toCommaString().replace(/(km)/,Common.SPC+"$1/")+t[1]):-1!=e.search(/x/)?e.replace(/x/g,Common.TSPC+"×"+Common.TSPC).replace(/(km)/,Common.SPC+"$1"):e.toCommaString().replace(/(km)/,Common.SPC+"$1")},rad:function(e){var t,n=0,r=null;if(e||""!==e){if(-1!=e.search(/x/)){for(r=e.split("x"),t=0;t<r.length;t++)n+=parseFloat(r[t])/2;n/=r.length}else if(-1!=e.search(/\.\./)){for(r=e.split(".."),t=0;t<r.length;t++)n+=parseFloat(r[t])/2;n/=r.length}else-1!=e.search(/\//)?(r=e.split("/"),n=parseFloat(r[0])/2,n+=n*parseFloat(r[1])/4):n=parseFloat(e)/2;return n}},range:function(e){var t="",n=null;if(e||""!==e)return n=e.split(".."),t=parseFloat(n[0]).toCommaString(),n.length>1&&(t+="…"+parseFloat(n[1]).toCommaString()),t+"km"},band:function(e){var t,n,r="";if(e||""!==e)return t=e.match(/([a-zA-Z]+)/),null!==t?t[1]:"Hz",n=e.split(".."),r=parseFloat(n[0]).toCommaString(),n.length>1&&(r+="…"+parseFloat(n[1]).toCommaString()),r+"km"},thickness:function(e){var t,n="km",r="",a=null;if(e&&""!==e){for(a=e.split(".."),t=0;t<a.length;t++)t>0&&(r+="…"),parseFloat(a[t])<.1?(r+=Math.round(1e3*parseFloat(a[t])),n="m"):-1!=a[t].search(/[eE]/)?r+=a[t]:r+=parseFloat(a[t]).toCommaString();return r+Common.SPC+n}},thick:function(e){if(!e||""===e)return.001;var t,n=0,r=e.split("..");for(t=0;t<r.length;t++)n+=parseFloat(r[t]);return n/=r.length},rotation:function(e){var t;if(e&&""!==e){switch(e.toLowerCase()){case"s":t=Common.names.find("sync").n;break;case"c":t=Common.names.find("chao").n;break;default:t=Parse.time(e)}return t}},velocity:function(e){var t="",n=null;if(e){if(null!==(n=e.match(/([\d\.]+)(kms)?/)))switch(n[2]){case"kms":t=n[1]+Common.SPC+"km/s";break;case void 0:break;default:return""}return t}},position:function(e){var t=null;return null!==(t=e.match(/([\d\.]+)([NS])\,([\d\.]+)([EW])/i))?t[1]+"°"+t[2]+", "+t[3]+"°"+t[4]:null!==(t=e.match(/([\d\.]+)([EW])\,([\d\.]+)([NS])/i))?t[3]+"°"+t[4]+", "+t[1]+"°"+t[2]:(t=e.match(/([\d\.]+)([NSEW])/),null!==t?t[1]+"°"+t[2]:void 0)},pos:function(e){var t,n=null,r=null;if(e)return t=e.match(/([\d\.]+)([NS])\,([\d\.]+)([EW])/i),null!==t?(n=parseFloat(t[1]),"S"==t[2]&&(n=-n),r=parseFloat(t[3]),"W"==t[4]&&(r=-r)):null!==(t=e.match(/([\d\.]+)([EW])\,([\d\.]+)([NS])/i))&&(n=parseFloat(t[3]),"S"==t[4]&&(n=-n),r=parseFloat(t[1]),"W"==t[2]&&(r=-r)),null!==n&&null!==r?(r>180&&(r-=360),r<-180&&(r+=360),n+","+r):void 0},date:function(e,t){var n,r,a="",o=null;if(e){if(-1==e.search(/^l/)){o=e.split("..");for(var i=0;i<o.length;i++)i>0&&(a+="…"),a+=o[i]}else if(null!==(o=e.match(/^l\+([\d\.\?]+)(\w+)?/)))if(t)-1!=o[1].search(/\?/)?a="?":(r=t.add(o[1],o[2]),a=r.toISOString().slice(0,7));else{switch(o[2]){case"hr":n="hr";break;case"dy":n="dy";break;case"mo":n="mon";break;case"yr":n="yr";break;default:n=""}a="L+"+o[1]+Common.SPC+n}return a}},dt:function(e,t){var n;if(e){if(t&&-1!==e.search(/^l/i))return n=e.split(/[\+\u202f]/),t.add(n[1],n[2]);if(n=e.split("."),!(n.length<1)&&(n=n[0].split("-"),n[0]=n[0].replace(/\D/g,""),n[0]))return n[1]=n[1]?n[1].replace(/\D/g,""):"1",n[2]=n[2]?n[2].replace(/\D/g,""):"1",new Date(n[0],n[1]-1,n[2])}},comp:function(e){var t,n,r,a,o="";if(e&&""!==e){for(r=e.split("+"),t=0;t<r.length;t++)a=r[t].split(":"),"poro"==a[0]?(a[0]="Porosity",n=";"+Common.SPC):"dust"==a[0]?(a[0]="Dust",n=";"+Common.SPC):"core"==a[0]?(a[0]="Core",n=";"+Common.SPC):n=Common.SPC+"+"+Common.SPC,t>0&&(o+=n),o+=a.length>1?a[0]+":"+Common.SPC+a[1]+"%":a[0];return o}},atm:function(e){var t="";return e.atm&&""!==e.atm&&(t=this.comp(e.atm)),e.atp&&(-1==e.atp.search(/trace/)?t+=" ("+e.atp+Common.SPC+"bar)":t+=" ("+e.atp+")"),t},mag:function(e){var t="";if(e.dip&&""!==e.dip&&(t=e.dip.replace("..","…")+Common.SPC+"Gauss"),e.dipt){var n=e.dipt.split("x");t+="; Dipole:"+n[0]+this.unit("i"),n.length>1&&(t+=Common.SPC+"/"+Common.SPC+n[1]+"km")}return t},mass:function(e,t){var n,r,a;if(e)return r=e,a=e.replace(/[\d\.\-e~<,]/g,""),r=a.length<1&&t?(parseFloat(e)*t).toScience():-1!==e.search(/^\D/)?e.replace(a,""):parseFloat(e).toScience(),-1!=e.search(/\.\./)&&(n=e.split(".."),r+="…"+parseFloat(n[1]).toScience()),""===a&&(a="kg"),r+Common.SPC+a},time:function(e){if(e){var t,n="",r=null;if(null!==(r=e.match(/^([-~e\d\.\?]+)(\w+)?/))){switch(r[2]){case"s":t="s";break;case"mn":case"n":t="min";break;case"hr":case"h":t="h";break;case"dy":case"d":t="d";break;case"mo":case"m":t="mon";break;case"yr":case"y":case"a":t="a";break;default:t=r[2]}n=r[1]+Common.SPC+t}return n}},sumType:function(e){var t,n=0;for(t in e)e.hasOwnProperty(t)&&(n+=e[t]);return n},sumField:function(e,t){var n,r=0;for(n in e)e.hasOwnProperty(n)&&(r+=e[n][t]);return r}},parseObject=function(e){var t,n,r,a={},o={};r=e,o.acr=e;for(t in objects[r])objects[r].hasOwnProperty(t)&&(o[t]=objects[r][t]);if(n=o.type,a.mass=Common.names.findMass(o.par),o.img&&""!==o.img?o.img=Common.symbols[r]:o.img=null,"m"==n&&o.desig&&""!==o.desig?o.fname=o.desig+" "+o.name:"r"==n?(o.name&&-1==o.name.search(/Division|Arc|Gap/)&&(o.name+=" Ring"),o.other&&""!==o.other?o.fname=o.name+" ("+o.other+")":o.fname=o.name):"c"==n?o.desig&&""!==o.desig?o.fname=o.desig+"/"+o.name:o.fname=o.name:("a"==n||"d"==n||"t"==n)&&o.desig&&""!==o.desig?o.fname="("+o.desig+") "+o.name:o.fname=o.name,o.dia&&""!==o.dia?(o.diam=Parse.diameter(o.dia),o.eqrad=parseFloat(o.dia)/2,o.rad=Parse.rad(o.dia)):o.diam="-","r"==n&&(o.w=o.diam?o.diam:"-",o.rad||(o.rad=1),o.thick&&""!==o.thick&&(o.h=Parse.thickness(o.thick),o.th=Parse.thick(o.thick)),o.th||(o.th=.001),o.h||(o.h="-"),o.rad?o.peri=Math.round(parseFloat(o.a)-o.rad):o.peri=parseFloat(o.a),o.dist=Parse.distance(o.peri+"km"),o.len&&""!==o.len&&(o.len=Parse.distance(o.len+"i")),o.opt&&""!==o.opt&&(o.opt=o.opt.replace("..","…"))),-1!=n.search(/^(d|a|c|t)$/)&&(function(){var e,t;if(o.gr&&""!==o.gr){for(t=o.gr.split(/[\;\:]/),e=0;e<t.length;e++)t[e]=Common.names.find(t[e]).n;o.group=t.join(", ")}}(),function(){var e;o.peri&&""!==o.peri&&(e=o.peri.split(":"),o.peri=e[1],o.peri+=" ("+Parse.distance(e[0])+")")}()),-1!=n.search(/^(b)$/)&&function(){var e,t,n;if(o.cen&&""!==o.cen){for(t=o.cen.split(/\;/),e=0;e<t.length;e++)n=t[e].split(/\:/),t[e]=n[0]+": "+n[1];o.census=t.join(", ")}}(),"p"==n||"d"==n){o.nmoons=0,o.nrings=0;for(t in objects)objects[t].par==r&&("m"==objects[t].type&&o.nmoons++,"r"==objects[t].type&&o.nrings++)}return o.orbit=Parse.elements(o,"aei"),o.tilt&&(o.tilt+=Parse.unit("i")),o.per=Parse.time(o.per),o.rot=Parse.rotation(o.rot),o.dens&&""!==o.dens&&(o.dens+=Common.SPC+"g/cm^3"),o.grav&&""!==o.grav&&(o.grav+=Common.SPC+"g"),o.irad&&""!==o.irad&&(o.irad+=Common.SPC+"W/m^3"),o.sdens&&""!==o.sdens&&(o.sdens+=Common.SPC+"g/cm^2"),o.temp&&""!==o.temp&&(o.temp=o.temp.replace(/K/g,Common.SPC+"K")),o.comp=Parse.comp(o.comp),o.spec&&""!==o.spec&&(o.comp+=" ("+o.spec+"-Type)"),o.atm=Parse.atm(o),o.mag=Parse.mag(o),o.mass=Parse.mass(o.mass,a.mass),o.disc&&""!==o.disc&&""!==o.dyr&&(o.disc=o.disc+", "+o.dyr),function(){var e,t,n,r=[];if(o.url&&""!==o.url){for(t=o.url.split(/\;/),e=0;e<t.length;e++)n=t[e].split(/\:/),r.push(Read.url(n));o.url=r}}(),function(){var e,t,n;for(e=o.desc.split(";"),n=0;n<e.length;n++)switch(t=e[n].split(":"),t[0]){case"url":t.length>1&&(o.hp="http://"+t[1]);break;case"sc":o.scale=parseFloat(t[1]);break;case"scmoons":o.scmoons=parseFloat(t[1]);break;case"orb":o.orb=t[1];break;case"moon":o.moons=t[1];break;case"opa":o.opa=parseFloat(t[1]);break;case"rsize":o.rsize=t[1].split(",");break;case"x":o.x=parseInt(t[1]);break;case"y":o.y=parseInt(t[1])}if(o.scale||(o.scale=1),o.moons){for(e=o.moons.split(","),n=0;n<e.length;n++)e[n]=Common.names.find(e[n]).n;o.moons=e.join(", ")}else o.moons=""}(),o},Obs=function(e,t){var n=scopes[e],r={},a=(t?document.getElementById(t):document.body,function(e){var t,n,a={};if(e.n&&""!=e.n)for(a.name=[],t=Read.data(e.n),n=0;n<t.length;n++)a.name.push(Read.string(t[n]));for(e.ctry&&""!=e.ctry&&(a.ctry=l(e.ctry)),e.type&&""!=e.type&&(a.type=c(e.type),a.tp=e.type.split(";")),e.pur&&""!=e.pur&&(a.purpose=h(e.pur),a.pur=e.pur.split(";")),e.id&&""!=e.id&&(a.id=u(e.id)),e.url&&""!=e.url&&(a.url=m(e.id)),e.icon&&""!=e.icon?a.icon=d(e.icon,a):a.icon=r.icon,t=Read.data(e.desc),n=0;n<t.length;n++)a[t[n][0]]=s(t[n]);return!a.hasOwnProperty("ag")&&r.hasOwnProperty("ag")&&(a.ag=r.ag),!a.hasOwnProperty("lv")&&r.hasOwnProperty("lv")&&(a.lv=r.lv),!a.hasOwnProperty("fam")&&r.hasOwnProperty("fam")&&(a.fam=r.fam),!a.hasOwnProperty("m")&&r.hasOwnProperty("m")&&(a.m=r.m),a.stat=e.hasOwnProperty("stat")&&""!=e.stat?e.stat:r.stat,a}),o=function(e){var t,n,r={};if(e.pt&&""!=e.pt?r.pt=e.pt:r.pt=0,e.dt&&""!=e.dt?(r.date={n:Parse.date(e.dt)},r.dt=Parse.dt(e.dt)):r.date="?",e.tp&&""!=e.tp&&(r.tp=[Common.names.find(e.tp)]),e.loc&&""!=e.loc&&(r.loc=f(e.loc,r.tp)),e.desc&&""!=e.desc)for(n=Read.data(e.desc),t=0;t<n.length;t++)r[n[t][0]]=s(n[t]);return r},i=function(e){var t,n,r={};if(e.n&&""!=e.n)for(r.name=[],t=Read.data(e.n),n=0;n<t.length;n++)r.name.push(Read.string(t[n],!0));if(e.pt&&""!=e.pt?r.pt=e.pt:r.pt=0,t=e.tp&&""!=e.tp?e.tp:"im",r.tp=t,r.type=Common.names.find(t),e.band&&""!=e.band&&(r.band=p(e.band)),e.res&&""!=e.res&&(r.res=g(e.res)),e.d&&""!=e.d&&(r.d=parseFloat(e.d)),e.px&&""!=e.px&&(r.px=parseFloat(e.px)),e.tres&&""!=e.tres&&(r.tres=parseFloat(e.tres)),e.sres&&""!=e.sres&&(r.sres=parseFloat(e.sres)),e.sens&&""!=e.sens&&(r.sens=parseFloat(e.sens)),e.fov&&""!=e.fov&&(r.fov=parseFloat(e.fov)),e.foc&&""!=e.foc&&(r.foc=parseFloat(e.foc)),e.ea&&""!=e.ea&&(r.ea=parseFloat(e.ea)),e.url&&""!=e.url&&(r.url=m(e.id)),e.desc&&""!=e.desc)for(t=Read.data(e.desc),n=0;n<t.length;n++)r[t[n][0]]=s(t[n]);return r},s=function(e){var t,n;if(e&&!(e.length<2)){switch(e[0]){case"eom":case"pend":t=Common.names.find(e[0]);break;case"mal":case"fail":n=Common.names.find(e[0]),t=Common.names.find(e[1]),t.n=n[0]+": "+t.n;break;case"ag":t=Common.names.find(e[1]);break;case"lv":n=Common.names.findLV(e[1]),t=n?{n:e[1],id:"lnk"+n}:{n:e[1]};break;case"fam":t=Common.names.find(e[1]);break;case"m":t={n:e[1].toCommaString().replace(/kg/g,Common.SPC+"kg")};break;case"c":case"cl":case"x":case"y":case"sc":t=e[1];break;default:return}return t}},l=function(e){var t,n,r=[];for(t=Read.data(e),n=0;n<t.length;n++)Common.ctry.hasOwnProperty(t[n][0])&&r.push({n:Common.ctry[t[n][0]].name,k:t[n][0]});return r},c=function(e){var t,n,r=[];for(t=Read.data(e),n=0;n<t.length;n++)r.push(Common.names.find(t[n][0]));return r},h=function(e){var t,n,r=[];for(t=Read.data(e),n=0;n<t.length;n++)r.push(Common.names.find(t[n][0]));return r},u=function(e){var t=[];if(e&&""!=e)return t.push({n:e,u:SOBS.IDLNK+e,t:"_blank"}),t},m=function(e){var t,n,r=[];for(t=Read.data(e),n=0;n<t.length;n++)r.push(Read.url(t[n]));return r},d=function(e,t){var n,a,o,i=[];for(o=t.n&&t.n.length>0?t.n[0].n:r.name.n,n=Read.data(e),a=0;a<n.length;a++)i.push({i:SOBS.SCOPES+n[a][0],n:o});return i},f=function(e,t){var n,r,a,o=[];for(n=e.split(":"),a=n[0],r=1;r<n.length;r++)-1==n[r].search(/^\d/)?o.push(Common.names.find(n[r])):-1!=n[r].search(/x/)?o.push({n:Parse.orbit(n[r],a)}):o.push({n:Parse.distance(n[r],a)});return"l"==t&&(e=n[1],-1==SOBS.lc.search(e)&&(SOBS.lc+=e+",")),o},p=function(e){var t,n,r={};if(e||""!=e)return r.s=e,n=e.match(/([a-zA-Z]+)$/),n=null!=n?n[1]:"Hz",t=e.split(".."),r.f0=S(t[0],n),t.length>1&&(r.f1=S(t[1],n)),r.f0&&r.f1&&r.f0>r.f1&&(t=r.f0,r.f0=r.f1,r.f1=t),r},g=function(e){var t,n={};if(e&&""!=e)return t=e.split(".."),n.r0=t[0],t.length>1?n.r1=t[1]:n.r1=null,n},S=function(e,t){var n,r,a;if(e&&""!=e){if(r=-1==e.search(/[a-zA-Z]$/)?e+t:e,null==(n=r.match(/([afpnumckMGTPE]?)(eV|m|Hz)$/i)))return parseFloat(e);switch(a=prefix(n[1]),r=parseFloat(e),n[2].toLowerCase()){case"hz":return r*a;case"ev":return e2f(r*a);case"m":return w2f(r*a)}}},y=function(){var e,t,n,a,o,i,s,l,c,h=[];if(!r.inst||!r.inst[0])return null;for(e=0;e<r.inst.length;e++)t=r.inst[e],"im"!=t.tp&&"is"!=t.tp||(n=r.shortname.n,a=t.pt&&""!=t.pt?t.pt:0,t.name&&t.name.length>0&&(o=t.name[0].n),s=t.c?t.c:null,i=r.parts[a].hasOwnProperty("name")?r.parts[a].name[0].n:null,l=r.parts[a].hasOwnProperty("tp")?r.parts[a].tp[0]:null,c=r.parts[a].hasOwnProperty("pur")?r.parts[a].pur[0]:null,t.px&&t.d?h.push({tp:l,pur:c,st:r.parts[a].stat,n:n,i:o,p:i,f0:t.band.f0,f1:t.band.f1,px:t.px,d:t.d,c:s}):t.res&&h.push({tp:l,pur:c,st:r.parts[a].stat,n:n,i:o,p:i,f0:t.band.f0,f1:t.band.f1,r0:t.res.r0,r1:t.res.r1,c:s}));return h},w=function(){var e,t,n,a,o,i,s,l,c,h,u,m,d,f,p=[];if(!r.inst||!r.inst[0])return null;for(e=0;e<r.inst.length;e++)t=r.inst[e],t.band&&("im"!=t.tp&&"is"!=t.tp||(n=t.pt&&""!=t.pt?t.pt:0,a=r.shortname.n,o=t.name&&t.name.length>0?t.name[0].n:"",i=t.pt?r.parts[t.pt].name[0].n:null,s=t.cl?t.cl:t.c?t.c:null,d=r.x?parseInt(r.x):0,f=r.y?parseInt(r.y):0,l=r.parts[n].hasOwnProperty("tp")?r.parts[n].tp[0]:null,h=r.parts[n].hasOwnProperty("pur")?r.parts[0].pur[0]:null,u=r.parts[0].hasOwnProperty("icon")&&null!=r.parts[0].icon?r.parts[0].icon[0].i:null,m=r.hasOwnProperty("sc")?r.sc:1,c=r.parts[n].stat,p.push({tp:l,pur:h,st:c,n:a,i:o,p:i,img:u,sc:m,f0:t.band.f0,f1:t.band.f1,fm:(r.hi+r.lo)/2,fl:r.lo,fh:r.hi,c:s,x:d,y:f})));return p};this.Instruments=function(e){return e&&"line"!=e?y():w()},function(){var e,t;for(e=Read.data(n.name),r.name=Read.string(e[0]),r.shortname=Read.string(e[0],!0),r.url=[],e=Read.data(n.url),t=0;t<e.length;t++)r.url[t]=Read.url(e[t]);for(e=Read.data(n.icon),e&&e.length>0&&(r.icon=[{i:SOBS.SCOPES+e[0][0],n:r.name}]),e=Read.data(n.desc),t=0;t<e.length;t++)r[e[t][0]]=s(e[t]);for(r.stat=n.stat,r.parts=[],t=0;t<n.parts.length;t++)r.parts[t]=a(n.parts[t]);for(r.ev=[],t=0;t<n.ev.length;t++)r.ev[t]=o(n.ev[t]);if(n.inst)for(r.inst=[],t=0;t<n.inst.length;t++)r.inst[t]=i(n.inst[t]);if(r.lo=null,r.hi=null,r.inst)for(t=0;t<r.inst.length;t++)r.inst[t].hasOwnProperty("tp")&&-1!=r.inst[t].tp.search(/par|em|psp|msp/)||r.inst[t].hasOwnProperty("band")&&r.inst[t].band.hasOwnProperty("f0")&&((null==r.lo||r.inst[t].band.f0<r.lo)&&(r.lo=r.inst[t].band.f0),(null==r.hi||r.inst[t].band.f1>r.hi)&&(r.hi=r.inst[t].band.f1))}()},Sobs=new function(){var e,t,n,r,a={},o=function(){var e,t;e=0;for(t in scopes)a[t]=new Obs(t,r),e++},i=function(){var e,t,n={};e=0;for(t in SOBS.images)n[t]=new Image,n[t].src=SOBS.images[t],-1==SOBS.images[t].search(/\.cur/)&&e++;return numImages=e,n},s=function(){var e,t,n,r={};for(e in Common.ctry)null!=(t=Common.ctry[e].desc.match(/x\:(\d+);y\:(\d+)/))&&(r[e]={n:Common.ctry[e].name,x:t[1],y:t[2]});for(e in Common.desc)Common.desc[e].hasOwnProperty("desc")&&null!=(t=Common.desc[e].desc.match(/x\:(\d+);y\:(\d+)/))&&(n=Common.desc[e].name.split(":"),n=n.length>1?n[1]+" ("+n[0]+")":n[0],r[e]={n:n,x:t[1],y:t[2]});for(e in Common.loc)Common.loc[e].hasOwnProperty("desc")&&null!=(t=Common.loc[e].desc.match(/x\:(\d+);y\:(\d+)/))&&(n=Common.loc[e].name.split(":"),n=n.length>1?n[1]+" ("+n[0]+")":n[0],r[e]={n:n,x:t[1],y:t[2]});return r};this.load=function(){var t,r,i,s=[];o();for(i in a)null!=(t=a[i].Instruments(SOBS.TYPE))&&(s=s.concat(t));s.sort(function(e,t){return e.fm-t.fm}),r=new Diag,r.draw(n,SOBS.TYPE,s,e,height)},this.init=function(){if(cfg)for(var a in cfg)SOBS[a]=cfg[a];return e=SOBS.WIDTH,height=SOBS.HEIGHT,Common.names=new Names("SOBS"),Common.SPC=SOBS.SPC,Common.symbols=i(),Common.sprites=s(),SOBS.PARENT&&(r=document.getElementById(SOBS.PARENT)),r||(r=document.getElementsByTagName("body")[0]),t=Create.div(r,"","canvas-wrap",{w:e,h:2}),n=new Cdraw("canvas",{parent:"canvas-wrap",width:e,height:window.innerHeight}),{p:r,c:n.setheight,w:e}}};