text: var BaseLineColor="grey";function LineChart(a,b){this.parent=a,this.margin={top:30,right:10,bottom:20,left:60},this.parentRect=a.node().getBoundingClientRect(),this.internalWidth=this.parentRect.width-this.margin.left-this.margin.right,this.internalHeight=this.parentRect.height-this.margin.top-this.margin.bottom,this.shownData=[],this.hiddenData=[],this.highlightData=[],this.mode="zoom",this.x=d3.scaleLinear().range([0,this.internalWidth]),this.y=d3.scaleLinear().range([this.internalHeight,0]),this.currentX=d3.scaleLinear().range(this.x.range()),this.currentY=d3.scaleLinear().range(this.y.range()),this.idCanvasX=d3.scaleLinear().range([0,1e3]),this.idCanvasY=d3.scaleLinear().range([1e3,0]),this.xAxis=d3.axisBottom(this.x),this.yAxis=d3.axisLeft(this.y);var c=this;this.zoomBehavior=d3.zoom().scaleExtent([1,20]).on("zoom",function(){c.zoom(d3.event.transform)}),this.eraseIncludeDrag=d3.drag().on("drag",function(){c.drag(d3.event)}),this.contents=a.append("div").attr("class","lineChart"),this.xAxisSvg=this.contents.append("div").attr("class","axisWrapper").style("height",this.margin.bottom+"px").style("position","absolute").style("left",this.margin.left+"px").style("bottom",0).style("right",this.margin.right+"px").append("svg").attr("class","axis").attr("id","xAxis").call(this.xAxis),this.yAxisSvg=this.contents.append("div").attr("class","axisWrapper").style("width",this.margin.left+"px").style("position","absolute").style("top",this.margin.top+"px").style("left",0).style("bottom",this.margin.bottom+"px").append("svg").append("g").attr("class","axis").attr("id","yAxis").attr("transform","translate("+this.margin.left+",0)").call(this.yAxis),this.pixelRatio=function(){var a=document.createElement("canvas").getContext("2d"),b=window.devicePixelRatio||1,c=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1;return b/c}(),this.canvasStack=this.contents.append("div").attr("class","canvasStack").style("position","absolute").style("top",this.margin.top+"px").style("right",this.margin.right+"px").style("bottom",this.margin.bottom+"px").style("left",this.margin.left+"px"),this.hiddenCanvas=this.canvasStack.append("canvas").attr("id","hiddenCanvas"),this.hiddenCanvasContext=this.hiddenCanvas.node().getContext("2d"),this.hiddenCanvasContext.globalAlpha=.5,this.shownCanvas=this.canvasStack.append("canvas").attr("id","shownCanvas"),this.shownCanvasContext=this.shownCanvas.node().getContext("2d"),this.shownCanvasContext.globalAlpha=.2,this.highlightCanvas=this.canvasStack.append("canvas").attr("id","highlightCanvas"),this.highlightCanvasContext=this.highlightCanvas.node().getContext("2d"),this.highlightCanvasContext.lineWidth=3,this.idCanvas=this.canvasStack.append("canvas").attr("id","idCanvas").attr("width","1000px").attr("height","1000px"),this.idCanvasContext=this.idCanvas.node().getContext("2d"),this.idCanvasContext.lineWidth=4,this.eraseIncludeMask=this.contents.append("div").attr("class","eraseIncludeMask").style("position","absolute").style("top",this.margin.top+"px").style("right",this.margin.right+"px").style("bottom",this.margin.bottom+"px").style("left",this.margin.left+"px").style("display","none"),this.getData=b,this.fullDsList=[],this.loadedData={},this.extentX=[],this.extentY=[],this.selection=[],this.dispatch=d3.dispatch("mouseover","click","erase","include"),this.prevMouseOver=null,this.canvasStack.on("mousemove",function(){c.mousemove(d3.event.offsetX,d3.event.offsetY,d3.event)}).on("click",function(){c.mouseclick(d3.event.offsetX,d3.event.offsetY,d3.event)}).call(c.zoomBehavior.extent([[0,0],[c.internalWidth,c.internalHeight]]).translateExtent([[0,0],[c.internalWidth,c.internalHeight]])),this.eraseIncludeMask.call(this.eraseIncludeDrag.container(this.eraseIncludeMask.node())),this.loadIndicator=this.canvasStack.append("div").attr("class","loadIndicator").style("display","none"),this.loadIcon=this.loadIndicator.append("div").attr("class","loadIcon"),this.loadText=this.loadIndicator.append("div").attr("class","loadText").style("display","none"),this.stillDrawing=!1,this.stillLoading=!1,this.loadingPrevious=!1,this.loadIter,this.drawShownIter,this.drawHiddenIter,this.drawIdIter,setInterval(this.tick,16,this)}LineChart.prototype.tick=function(a){var b=!1,c=!1;a.loadIter&&(!a.loadingPrevious&&a.loadIter.next().done&&(a.loadIter=void 0),b=!0,c=!0);for(var d=0;25>d;d++)a.drawShownIter&&(a.drawShownIter.next().done&&(a.drawShownIter=void 0),b=!0),a.drawHiddenIter&&(a.drawHiddenIter.next().done&&(a.drawHiddenIter=void 0),b=!0);for(var d=0;10>d;d++)a.drawIdIter&&(a.drawIdIter.next().done&&(a.drawIdIter=void 0),b=!0);c!=a.stillLoading&&(a.loadText.style("display",c?"initial":"none"),a.stillLoading=c),b!=a.stillDrawing&&(a.loadIndicator.style("display",b?"initial":"none"),a.stillDrawing=b)},LineChart.prototype.updateSize=function(){this.parentRect=this.parent.node().getBoundingClientRect(),this.internalWidth=this.parentRect.width-this.margin.left-this.margin.right,this.internalHeight=this.parentRect.height-this.margin.top-this.margin.bottom;var a=this;this.canvasStack.selectAll("canvas:not(#idCanvas)").attr("width",this.internalWidth*this.pixelRatio).attr("height",this.internalHeight*this.pixelRatio).each(function(){var b=this.getContext("2d");b.scale(a.pixelRatio,a.pixelRatio)}),this.shownCanvasContext.globalAlpha=.2,this.hiddenCanvasContext.globalAlpha=.5,this.highlightCanvasContext.lineWidth=3,this.canvasStack.call(a.zoomBehavior.extent([[0,0],[a.internalWidth,a.internalHeight]]).translateExtent([[0,0],[a.internalWidth,a.internalHeight]])),this.x.range([0,this.internalWidth]),this.y.range([this.internalHeight,0]),this.currentX.range(this.x.range()),this.currentY.range(this.y.range()),this.xAxis.scale(this.currentX),this.yAxis.scale(this.currentY),this.contents.select("#xAxis").call(this.xAxis),this.contents.select("#yAxis").call(this.yAxis),this.redraw()},LineChart.prototype.redraw=function(){var a=this;this.shownCanvasContext.clearRect(0,0,this.internalWidth,this.internalHeight),this.drawShownIter=function*(b){for(var c=0;c<b.length;)a.drawLines(a.shownCanvasContext,[b[c]],BaseLineColor),yield++c}(this.shownData),this.hiddenCanvasContext.clearRect(0,0,this.internalWidth,this.internalHeight),this.drawHiddenIter=function*(b){for(var c=0;c<b.length;)a.drawLines(a.hiddenCanvasContext,[b[c]],BaseLineColor),yield++c}(this.hiddenData),this.redrawSingleContext(this.highlightCanvasContext,this.highlightData)},LineChart.prototype.redrawSingleContext=function(a,b,c){a.clearRect(0,0,this.internalWidth,this.internalHeight),0<b.length&&this.drawLines(a,b,c)},LineChart.prototype.redrawIdContext=function(){var a=this;this.idCanvasContext.clearRect(0,0,1e3,1e3),this.drawIdIter=function*(b){for(var c=0;c<b.length;)a.drawLines(a.idCanvasContext,[b[c]],"id"),yield++c}("include"==this.mode?this.hiddenData:this.shownData)},LineChart.prototype.drawLines=function(a,c,e){var f=Math.floor;for(var h in c){var i=c[h];if(!e)a.strokeStyle=i.dataSet.color;else if("id"==e){var k=i.id+1,l=f(k/256/256),b=f((k-256*(256*l))/256);a.strokeStyle="rgb("+(k-256*(256*l)-256*b)+","+b+","+l+")"}else a.strokeStyle=e;if(a.beginPath(),"id"==e)for(var g,m=0;m<i.points.length;m++)g=i.points[m],0==m?a.moveTo(this.idCanvasX(g.x),this.idCanvasY(g.y)):a.lineTo(this.idCanvasX(g.x),this.idCanvasY(g.y));else for(var g,m=0;m<i.points.length;m++)g=i.points[m],0==m?a.moveTo(this.currentX(g.x),this.currentY(g.y)):a.lineTo(this.currentX(g.x),this.currentY(g.y));a.stroke()}},LineChart.prototype.setSelection=function(a){var b=this;this.selection=a,this.shownData=[],this.hiddenData=[],a.forEach(function(a){b.loadedData[a]&&(b.shownData=b.shownData.concat(b.loadedData[a]))}),this.redraw(),this.redrawIdContext()},LineChart.prototype.setMode=function(a){"zoom"===a?(this.mode="zoom",this.eraseIncludeMask.style("display","none")):"erase"===a?(this.mode="erase",this.eraseIncludeMask.style("display","initial")):"include"===a?(this.mode="include",this.eraseIncludeMask.style("display","initial")):void 0;this.redrawIdContext()},LineChart.prototype.eraseData=function(a){var b=this;if(b.loadedData[a]){var c=this.shownData.findIndex(function(c){return c.id==b.loadedData[a][0].id});-1!=c&&(this.shownData.splice(c,2),this.hiddenData=this.hiddenData.concat(this.loadedData[a]),this.redraw(),this.redrawIdContext())}},LineChart.prototype.includeData=function(a){var b=this,c=this.hiddenData.findIndex(function(c){return c.id==b.loadedData[a][0].id});-1!=c&&(this.hiddenData.splice(c,2),this.shownData=this.shownData.concat(this.loadedData[a]),this.redraw(),this.redrawIdContext())},LineChart.prototype.setHighlight=function(a){if(this.highlightData=[],null!=a)for(var b=0;b<a.length;b++)this.loadedData[a[b]]&&(this.highlightData=this.highlightData.concat(this.loadedData[a[b]]));this.redrawSingleContext(this.highlightCanvasContext,this.highlightData)},LineChart.prototype.zoom=function(a){var b=this;this.currentX.domain([this.x.invert(-a.x/a.k),this.x.invert(b.internalWidth/a.k-a.x/a.k)]),this.currentY.domain([this.y.invert(b.internalHeight/a.k-a.y/a.k),this.y.invert(-a.y/a.k)]),this.idCanvasX.domain(this.currentX.domain()),this.idCanvasY.domain(this.currentY.domain()),this.contents.select("#xAxis").call(b.xAxis.scale(b.currentX)),this.contents.select("#yAxis").call(b.yAxis.scale(b.currentY)),this.redraw(),this.redrawIdContext(),d3.event.sourceEvent&&this.mousemove(d3.event.sourceEvent.offsetX,d3.event.sourceEvent.offsetY,d3.event)},LineChart.prototype.drag=function(a){var b=this,c=this.findDataAtPoint(a.x,a.y);null!=c&&("erase"==this.mode?this.dispatch.call("erase",this,c):"include"==this.mode&&this.dispatch.call("include",this,c))},LineChart.prototype.mousemove=function(a,b,c){var d=this,e=this.findDataAtPoint(a,b);e!=this.prevMouseOver&&(this.dispatch.call("mouseover",d,e,c),this.prevMouseOver=e)},LineChart.prototype.mouseclick=function(a,b,c){var d=this,e=this.findDataAtPoint(a,b);this.dispatch.call("click",d,e,c)},LineChart.prototype.findDataAtPoint=function(a,b){for(var c=this.idCanvasX(this.currentX.invert(a)),d=this.idCanvasY(this.currentY.invert(b)),e=this.idCanvasContext.getImageData(c-1,d-1,3,3).data,g=[],h=0;h<e.length/4;h++)g.push(e[4*h]+256*e[4*h+1]+256*(256*e[4*h+2]));g.sort();for(var i=-1,j=0,h=0;h<g.length&&!(4==j);h++)i!=g[h]&&(i=g[h],j=0),++j;for(var k="include"==this.mode?this.hiddenData:this.shownData,l=-1,m=!1,h=0;h<k.length;h++)if(k[h].id==i-1){l=h,m=!0;break}return m&&4<=j&&0<i?i-1:null};function escapeRegExp(a){return a.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function replaceAll(a,b,c){return a.replace(new RegExp(escapeRegExp(b),"g"),c)}LineChart.prototype.loadData=function(a){var b=this;this.setSelection(a),this.loadIter=function*(a){for(var c=0;c<a.length;)b.loadingPrevious=!0,b.loadSingleData(a[c],function(){b.loadingPrevious=!1}),b.loadText.text("Loading: "+(c+1)+"/"+a.length),yield++c}(a)},LineChart.prototype.loadSingleData=function(a,b){var c=this,e=a,f=[],g=this.getData(a);return null==g?(b(!1),null):void g.forEach(function(a,d){d3.text(a.file,function(h){if(h){if(" "==a.delimiter){var i=h.split("\n");h="",i=i.slice(2,i.length),i.forEach(function(a,b){0==b?h=i[b].trim():0==b%10&&(h=h+"\n"+i[b].trim())}),h=replaceAll(h,"  ","\t")}var j=d3.tsvParseRows(h).map(function(a){return a.map(function(a){return+a})}),k=[];0<=a.columnY?j.forEach(function(b,c){var d=c;0<=a.columnX&&(d=b[a.columnX]),k.push({x:d,y:b[a.columnY]})}):j.forEach(function(a){k.push({x:a[0],y:a[1]})}),f.push({dataSet:a,points:k,id:e}),c.fullDsList.push({dataSet:a,points:k,id:e});var l=c.extentX.slice(),m=c.extentY.slice(),n=d3.extent(k,function(a){return a.x}),o=d3.extent(k,function(a){return a.y});c.extentX=d3.extent(c.extentX.concat(n)),c.extentY=d3.extent(c.extentY.concat(o));var p=c.extentX[0]!=l[0]||c.extentX[1]!=l[1]||c.extentY[0]!=m[0]||c.extentY[1]!=m[1];p&&(c.x.domain(d3.extent(c.extentX,function(a){return a})),c.y.domain(d3.extent(c.extentY,function(a){return a})),c.currentX.domain(c.x.domain().slice()),c.currentY.domain(c.y.domain().slice()),c.idCanvasX.domain(c.x.domain().slice()),c.idCanvasY.domain(c.y.domain().slice()),c.updateSize(),c.redrawIdContext()),d==g.length-1&&(c.loadedData[e]=f,c.selection.includes(e)&&(c.shownData=c.shownData.concat(f),c.drawLines(c.shownCanvasContext,f,"blac"),"include"!=c.mode&&c.drawLines(c.idCanvasContext,f,"id")),b(!0))}else b(!1)})})};function TwoImageDisplay(a){this.parent=a,this.margin={top:10,right:10,bottom:10,left:10},this.parentRect=this.parent.node().getBoundingClientRect(),this.internalWidth=this.parentRect.width-this.margin.left-this.margin.right,this.internalHeight=this.parentRect.height-this.margin.top-this.margin.bottom,this.squareSize=Math.min(this.internalWidth/2,this.internalHeight);var b=this;this.zoomBehavior=d3.zoom().scaleExtent([1,20]).on("zoom",function(){b.zoom(d3.event.transform)}),this.imageWrapper=a.append("div").attr("class","twoImageDisplay").style("position","absolute").style("top",this.margin.top+"px").style("right",this.margin.right+"px").style("bottom",this.margin.bottom+"px").style("left",this.margin.left+"px").call(this.zoomBehavior.extent([[0,0],[this.squareSize,this.squareSize]]).translateExtent([[0,0],[this.squareSize,this.squareSize]])),this.leftCanvas=this.imageWrapper.append("div").attr("id","leftCanvasWrapper").attr("class","canvasWrapper").append("canvas").attr("id","leftCanvas").attr("width",this.squareSize+"px").attr("height",this.squareSize+"px"),this.leftContext=this.leftCanvas.node().getContext("2d"),this.leftImg,this.rightCanvas=this.imageWrapper.append("div").attr("id","rightCanvasWrapper").attr("class","canvasWrapper").append("canvas").attr("id","rightCanvas").attr("width",this.squareSize+"px").attr("height",this.squareSize+"px"),this.rightContext=this.rightCanvas.node().getContext("2d"),this.rightImg}TwoImageDisplay.prototype.setLeftImage=function(a){var b=this;this.leftImg=document.createElement("img"),d3.select(this.leftImg).on("load",function(){b.leftContext.drawImage(b.leftImg,0,0,b.squareSize,b.squareSize)}),this.leftImg.src=a},TwoImageDisplay.prototype.setRightImage=function(a){var b=this;this.rightImg=document.createElement("img"),d3.select(this.rightImg).on("load",function(){b.rightContext.drawImage(b.rightImg,0,0,b.squareSize,b.squareSize)}),this.rightImg.src=a},TwoImageDisplay.prototype.updateSize=function(){this.parentRect=this.parent.node().getBoundingClientRect(),this.internalWidth=this.parentRect.width-this.margin.left-this.margin.right,this.internalHeight=this.parentRect.height-this.margin.top-this.margin.bottom,this.squareSize=Math.min(this.internalWidth/2,this.internalHeight),this.imageWrapper.selectAll(".canvasWrapper canvas").attr("width",this.squareSize+"px").attr("height",this.squareSize+"px").call(this.zoomBehavior.extent([[0,0],[this.squareSize,this.squareSize]]).translateExtent([[0,0],[this.squareSize,this.squareSize]])),this.leftImg.src&&this.leftContext.drawImage(this.leftImg,0,0,this.squareSize,this.squareSize),this.rightImg.src&&this.rightContext.drawImage(this.rightImg,0,0,this.squareSize,this.squareSize)},TwoImageDisplay.prototype.zoom=function(a){this.leftContext.clearRect(0,0,this.squareSize,this.squareSize),this.leftContext.save(),this.leftContext.translate(a.x,a.y),this.leftContext.scale(a.k,a.k),this.leftImg.src&&this.leftContext.drawImage(this.leftImg,0,0,this.squareSize,this.squareSize),this.leftContext.restore(),this.rightContext.clearRect(0,0,this.squareSize,this.squareSize),this.rightContext.save(),this.rightContext.translate(a.x,a.y),this.rightContext.scale(a.k,a.k),this.rightImg.src&&this.rightContext.drawImage(this.rightImg,0,0,this.squareSize,this.squareSize),this.rightContext.restore()};var chart,diffractionChart,diffractionImageDisplay,visarChart,database,databases,db,selectedData,rtime,chartLoaded=!1,Visar_second="red",Visar_first="blue",Highlight="blue",alwaysHighlighted=[],timeout=!1,delta=200,jsonRequest=new XMLHttpRequest;jsonRequest.open("GET","databases.json",!0),jsonRequest.onreadystatechange=function(){4===jsonRequest.readyState&&(200===jsonRequest.status||0===jsonRequest.status)&&(databases=JSON.parse(jsonRequest.responseText),d3.select("#database").selectAll("option").data(databases).enter().append("option").attr("value",function(a,b){return b}).text(function(a){return a.name?a.name:a.directory}),load())},$(document).ready(function(){});function startBandit(){var a=d3.drag().on("start",function(){d3.select(this).attr("mode","dragging")}).on("drag",function(){var a=d3.select("#header").node().getBoundingClientRect();d3.select("#svgArea").style("height",d3.event.y-a.height+"px"),updateBottomHalf()}).on("end",function(){d3.select(this).attr("mode","default"),chart.updateSize(),diffractionChart&&diffractionChart.updateSize(),visarChart&&visarChart.updateSize(),diffractionImageDisplay&&diffractionImageDisplay.updateSize()});d3.select("#resizeBar").call(a),$(".socketOverlay").on("click",function(){if("filled"==$(this).attr("mode")){var a=$("#mainViewSocket .viewContainer"),b=$(this).parent().children(".viewContainer");switch(a.attr("id")){case"visarContainer":a.insertBefore("#visarSocketOverlay"),$("#visarSocketOverlay").attr("mode","filled"),visarChart.updateSize();break;case"diffractionContainer":a.insertBefore("#diffractionSocketOverlay"),$("#diffractionSocketOverlay").attr("mode","filled"),diffractionChart.updateSize();break;case"diffractionImageContainer":a.insertBefore("#diffractionImageSocketOverlay"),$("#diffractionImageSocketOverlay").attr("mode","filled"),diffractionImageDisplay.updateSize();}switch($("#mainViewSocket").append(b),$(this).attr("mode","empty"),b.attr("id")){case"visarContainer":visarChart.updateSize();break;case"diffractionContainer":diffractionChart.updateSize();break;case"diffractionImageContainer":$("#toolbar").slideUp(500),$("#resultsArea").animate({top:"5px"},callback=function(){diffractionImageDisplay.updateSize()});}}}),$(".tool").on("click",function(){if("unselected"==$(this).attr("mode"))switch($(".tool[mode=\"selected\"]").attr("mode","unselected"),$(this).attr("mode","selected"),$(this).attr("id")){case"zoomTool":visarChart&&visarChart.setMode("zoom"),diffractionChart&&diffractionChart.setMode("zoom"),$("#tooltip").text("Scroll to zoom, click-and-drag to pan.");break;case"eraseTool":visarChart&&visarChart.setMode("erase"),diffractionChart&&diffractionChart.setMode("erase"),$("#tooltip").text("Drag over results to grey them out.");break;case"includeTool":visarChart&&visarChart.setMode("include"),diffractionChart&&diffractionChart.setMode("include"),$("#tooltip").text("Drag over erased results to see them again");}}),$(window).resize(function(){rtime=new Date,!1===timeout&&(timeout=!0,setTimeout(resizeend,delta))}),updateBottomHalf(),jsonRequest.send(null)}function load(){chartLoaded=!1,$("#svgContainer").html(""),$("#visarContainer").html(""),$("#diffractionContainer").html(""),$("#diffractionImageContainer").html(""),$("#toolbar").slideUp(500),$("#diffractionSocketOverlay").attr("mode","disabled"),$("#visarSocketOverlay").attr("mode","disabled"),$("#diffractionImageSocketOverlay").attr("mode","disabled");var a=$("#mainViewSocket .viewContainer");switch(a.attr("id")){case"visarContainer":a.insertBefore("#visarSocketOverlay");break;case"diffractionContainer":a.insertBefore("#diffractionSocketOverlay");break;case"diffractionImageContainer":a.insertBefore("#diffractionImageSocketOverlay");}"selected"!=$("#zoomTool").attr("mode")&&($(".tool[mode=\"selected\"]").attr("mode","unselected"),$("#zoomTool").attr("mode","selected")),alwaysHighlighted=[],selectedData=null,db=databases[$("#database").get(0).value],console.log(db.name);database=new CINEMA_COMPONENTS.Database(db.directory,doneLoading,null,onDatabaseUpdate)}function doneLoading(){chartLoaded=!0,chart=new CINEMA_COMPONENTS.PcoordSVG($("#svgContainer")[0],database,/visar*|diffraction*/),chart.results=database.data,chart.dispatch.on("selectionchange",onSelectionChange),chart.dispatch.on("mouseover",onMouseOverChange),chart.dispatch.on("click",onMouseClick);var a=Array.apply(null,Array(chart.results.length)).map(function(a,b){return b});(chart.results[0].visar_file||chart.results[0].visar_file1||chart.results[0].visar_file2)&&(visarChart=new LineChart(d3.select("#visarContainer"),getVisarData),visarChart.loadData(a),visarChart.dispatch.on("mouseover",onMouseOverChange),visarChart.dispatch.on("click",onMouseClick),visarChart.dispatch.on("erase",onErase),visarChart.dispatch.on("include",onInclude),$("#visarSocketOverlay").attr("mode","filled")),(chart.results[0].diffraction_file||chart.results[0].diffraction_file1||chart.results[0].diffraction_file2)&&(diffractionChart=new LineChart(d3.select("#diffractionContainer"),getDiffData),diffractionChart.loadData(a),diffractionChart.updateSize(),diffractionChart.dispatch.on("mouseover",onMouseOverChange),diffractionChart.dispatch.on("click",onMouseClick),diffractionChart.dispatch.on("erase",onErase),diffractionChart.dispatch.on("include",onInclude),$("#diffractionSocketOverlay").attr("mode","filled")),(chart.results[0].diffraction_image||chart.results[0].diffraction_image1||chart.results[0].diffraction_image2)&&(diffractionImageDisplay=new TwoImageDisplay(d3.select("#diffractionImageContainer")),$("#diffractionImageSocketOverlay").attr("mode","filled"))}function onDatabaseUpdate(a){0<a.added.length&&(visarChart.loadData(a.added),diffractionChart.loadData(a.added),chart.updateSelection(!0))}function resizeend(){new Date-rtime<delta?setTimeout(resizeend,delta):(timeout=!1,chart.updateSize(),diffractionChart&&diffractionChart.updateSize(),visarChart&&visarChart.updateSize(),diffractionImageDisplay&&diffractionImageDisplay.updateSize())}function onSelectionChange(a){visarChart&&visarChart.setSelection(a),diffractionChart&&diffractionChart.setSelection(a)}function onErase(a){visarChart&&visarChart.eraseData(a),diffractionChart&&diffractionChart.eraseData(a),$(".pCoordChart .resultPaths path[index=\""+a+"\"]").attr("mode","erased")}function onInclude(a){visarChart&&visarChart.includeData(a),diffractionChart&&diffractionChart.includeData(a),$(".pCoordChart .resultPaths path[index=\""+a+"\"]").attr("mode","active")}function onMouseOverChange(a){var b=[];if(a&&(b=b.concat([a])),selectedData&&(b=b.concat([selectedData])),chartLoaded&&chart.setHighlightedPaths(b),null!=a){if(diffractionChart&&diffractionChart.setHighlight([selectedData].concat([a].concat(alwaysHighlighted))),visarChart&&visarChart.setHighlight([selectedData].concat([a].concat(alwaysHighlighted))),diffractionImageDisplay){var c=getImages(a);diffractionImageDisplay.setLeftImage(c[0]),diffractionImageDisplay.setRightImage(c[1])}}else if(diffractionChart&&diffractionChart.setHighlight([selectedData].concat(alwaysHighlighted)),visarChart&&visarChart.setHighlight([selectedData].concat(alwaysHighlighted)),null!=selectedData&&diffractionImageDisplay){var c=getImages(selectedData);diffractionImageDisplay.setLeftImage(c[0]),diffractionImageDisplay.setRightImage(c[1])}}function onMouseClick(a){selectedData=a,diffractionChart&&diffractionChart.setHighlight([selectedData].concat(alwaysHighlighted)),visarChart&&visarChart.setHighlight([selectedData].concat(alwaysHighlighted)),chart.overlayPathData=null==a?[]:[{data:chart.results[a]}],chart.setHighlightedPaths([a])}function updateBottomHalf(){var a=$("#topHalf").get(0).getBoundingClientRect();$("#bottomHalf").css("top",a.height+"px")}function pad(a,b){return("000000000"+a).substr(-b)}function getDiffData(a){if(chartLoaded){var b=chart.results[a],c=[];return b.diffraction_file?c.push({file:db.directory+"/"+b.diffraction_file,color:Highlight,columnX:b.diffraction_xCol,columnY:b.diffraction_yCol,delimiter:b.diffraction_delimiter}):b.diffraction_file1&&c.push({file:db.directory+"/"+b.diffraction_file1,color:Visar_first,columnX:b.diffraction1_xCol,columnY:b.diffraction1_yCol,delimiter:b.diffraction_delimiter}),b.diffraction_file2&&c.push({file:db.directory+"/"+b.diffraction_file2,color:Visar_second,columnX:b.diffraction2_xCol,columnY:b.diffraction2_yCol,delimiter:b.diffraction_delimiter}),c}return null}function getVisarData(a){if(chartLoaded){var b=chart.results[a],c=[];return b.visar_file?c.push({file:db.directory+"/"+b.visar_file,color:Highlight,columnX:b.visar_xCol,columnY:b.visar_yCol,delimiter:b.visar_delimiter}):b.visar_file1&&c.push({file:db.directory+"/"+b.visar_file1,color:Visar_first,columnX:b.visar1_xCol,columnY:b.visar1_yCol,delimiter:b.visar_delimiter}),b.visar_file2&&c.push({file:db.directory+"/"+b.visar_file2,color:Visar_second,columnX:b.visar2_xCol,columnY:b.visar2_yCol,delimiter:b.visar_delimiter}),c}return null}function getImages(a){if(chartLoaded){var b,c,d=chart.results[a];return d.diffraction_image?b=db.directory+"/"+d.diffraction_image:d.diffraction_image1&&(b=db.directory+"/"+d.diffraction_image1),d.diffraction_image2&&(c=db.directory+"/"+d.diffraction_image2),[b,c]}}