Object.extend(String.English,{});Papercube=SC.Object.create({server:SC.Server.create({prefix:["Papercube"]}),FIXTURES:[]});Papercube.pluralizeString=function(a,b){return(b)+a+((b!=1)?"s":"")};var NODE=0;var EDGE=1;var TEXT=2;var EDGETEXT=4;var REL=3;var NODEGRAPH_DEFAULT_SCALE=10;var NODEGRAPH_USE_CHILDREN_OFFSET=YES;var NODEGRAPH_OFFSET_PERCENT=0.4;var YEARLINE=5;var YEARTEXT=6;var PERYEAR_DEFAULT_SCALE=20;require("core");Papercube.DragPanMixin={_xPos:0,_yPos:0,_mouseDragTime:0,_canDrag:NO,mouseUp:function(a){if(this._canDrag){Papercube.canvasController.panToCoordinates((Event.pointerX(a)-this._xPos),(Event.pointerY(a)-this._yPos),YES);this._yPos=0;this._xPos=0;this.removeClassName("is-dragging");this.removeClassName("can-drag")}this._canDrag=NO},mouseDragged:function(b){if(this._canDrag){this.removeClassName("can-drag");this.addClassName("is-dragging");var a=Event.pointerX(b);var c=Event.pointerY(b);if((Date.now()-this._mouseDragTime)>200){Papercube.canvasController.panToCoordinates((a-this._xPos),(c-this._yPos));this._xPos=a;this._yPos=c;this._mouseDragTime=Date.now()}}},handleMouseDownDrag:function(a){this.addClassName("can-drag");this._yPos=Event.pointerY(a);this._xPos=Event.pointerX(a);this._canDrag=YES;this._mouseDragTime=Date.now();return YES}};require("core");require("views/dragpan");Papercube.NodeGraphView=SC.View.extend(Papercube.DragPanMixin,{depth:1,_cached_depth:1,linkThreshold:1,_cached_linkThreshold:1,_displayRefs:YES,nodeColor:"#FFCB2F",nodeColorSel:"yellow",nodeBorderColor:"#EAA400",nodeBorderColorSel:"#FFB60B",nodeTextColor:"#666",nodeDefaultRadius:25,nodeBorderWidth:1,nodeXYRatio:1.5,edgeColor:"#333",edgeColorSel:"red",edgeTextColor:"#666",edgeMinWidth:1,nodeTextRatio:2,edgeTextPosOffset:0.3,nodeOpacity:1,edgeOpacity:0.2,edgeOpacitySel:0.5,showEdgeLabel:YES,useEdgeWeightWidth:YES,showEdges:YES,defaultTitleKey:"title",contentTypeViewing:"Paper",viewName:"none",metaDataBoxHeightSmall:120,metaDataBoxWidthSmall:400,metaDataClassName:"",setDefaultTitle:function(a){var b="";if(a){b=a.get(this.defaultTitleKey)}this.graphTitle.innerHTML=b},findCustomObject:function(a){return null},findCustomObjectAttr:function(a){return[]},getGuidForRelation:function(a){return""},setBindingDefaults:function(){},findCustomObjectLabel:function(){},calcRelationWeight:function(){return 1},performCustomRequest:function(b,a){},relationMeetsCustomThreshold:function(a){return(this.calcRelationWeight(a)>=this._cached_linkThreshold)},displayPropertiesBinding:"Papercube.canvasController.displayProperties",outlets:["metaDataView","graphTitle"],metaDataView:".meta-data?",graphTitle:".graph-title?",_canvasWidth:800,_canvasHeight:600,_h:0,_w:0,_x:0,_y:0,_foundGuid:null,svgCanvas:null,_deepest:0,_linesPinned:NO,_visited:{},_positioned:{},_nodes:{},_svgNodesCache:{},_svgEdgesTextCache:{},_svgEdgesCache:{},_svgTextCache:{},_lBound:0,_rBound:0,_tBound:0,_bBound:0,_offset:0,_radius:0,_lastDeepest:0,_last_nodeBorderWidth:1,displayPropertiesDidChange:function(a){if(!this.get("isVisible")||!this.displayProperties){return NO}var f=this.displayProperties.height-20;var k=this.displayProperties.width;var j=this.displayProperties.left;var i=this.displayProperties.top;var g=this.displayProperties.zoomValue;var b=this.displayProperties.portalWidth;var l=this.displayProperties.portalHeight;var e=this.depth;var d=this.linkThreshold;this._linesPinned=NO;this.setStyle({height:(l-20)+"px",width:b+"px",left:"20px",top:"20px"});this._frame={height:(l-20),width:b,x:20,y:20};this.svgCanvas.setAttributeNS(null,"height",l);this.svgCanvas.setAttributeNS(null,"width",b);this._canvasHeight=f;this._canvasWidth=k;var c=(((this._h!=f||this._w!=k))&&this._z==g||e!=this._cached_depth||d!=this._cached_linkThreshold);if(this._cachedLinkThreshold!=d){this._hideExistingLines()}this._h=f;this._w=k;this._x=j;this._y=i;this._z=g;this._zI=g/NODEGRAPH_DEFAULT_SCALE;this._pH=l;this._pW=b;this._cached_depth=e;this._cached_linkThreshold=d;this._hideMetaData();if(this.svgGroup){this.svgGroup.setAttributeNS(null,"transform","scale("+this._zI+") translate("+(this._x/this._zI)+","+(this._y/this._zI)+")")}if(c&&typeof a!="boolean"&&this._cachedContent){this._foundGuid=null;this._render()}}.observes("displayProperties","depth","linkThreshold"),redrawParamsDidChange:function(){var a=this.get("content");if(!this.get("isVisible")||!a){return NO}Papercube.canvasController.set("zoomValueMax",NODEGRAPH_DEFAULT_SCALE);Papercube.canvasController.set("zoomStep",0.5);if(this.metaDataClassName!=""){this.metaDataView.addClassName(this.metaDataClassName)}if(!this._cachedContent||this._cachedContent.get("guid")!==a.get("guid")){this._hideMetaData();this._svgNodesCache={};this._svgEdgesTextCache={};this._svgEdgesCache={};this._svgTextCache={};this._svgRels={};this._clearSVG();Papercube.canvasController.zoomOutFull();this._lastDeepest=null;this.setDefaultTitle(a)}if(!this._cachedContent){this.setBindingDefaults()}this._foundGuid=null;this._cachedContent=a;this.displayPropertiesDidChange(YES);this._deepest=0;this._render()}.observes("content","isVisible"),mouseMoved:function(l){var j=l.target.getAttribute("guid");if(j){if(this._foundGuid!=j&&!this._linesPinned){this._hideExistingLines();this._foundGuid=j;var b=this.findCustomObject(j);var h=(this._svgNodesCache[j])?this._svgNodesCache[j].elm:null;if(h){h.setAttributeNS(null,"fill",this.nodeColorSel);h.setAttributeNS(null,"stroke",this.nodeBorderColorSel)}if(b){var k=this.findCustomObjectAttr(b)}var f=k.length;for(var c=0;c<f;c++){var e=this.getGuidForRelation(k[c]);var a=(this._svgEdgesCache[this._foundGuid+e]||this._svgEdgesCache[e+this._foundGuid]);if(a){var d=a.elm;if(d){d.setAttributeNS(null,"stroke",this.edgeColorSel);d.setAttributeNS(null,"stroke-opacity",this.edgeOpacitySel)}}}}this._showMetaData({x:Event.pointerX(l),y:Event.pointerY(l)},j)}else{this._hideMetaData()}},_hideExistingLines:function(){if(this._foundGuid&&this._svgNodesCache[this._foundGuid]){var d=this.findCustomObject(this._foundGuid);if(d){var c=this.findCustomObjectAttr(d)}var j=this._svgNodesCache[this._foundGuid].elm;if(j){j.removeAttributeNS(null,"fill");j.removeAttributeNS(null,"stroke")}var b=c.length;for(var e=0;e<b;e++){var h=this.getGuidForRelation(c[e]);var f=(this._svgEdgesCache[this._foundGuid+h]||this._svgEdgesCache[h+this._foundGuid]);if(f){var a=f.elm;if(a){a.removeAttributeNS(null,"stroke");a.removeAttributeNS(null,"stroke-opacity")}}}}this._foundGuid=null},mouseExited:function(a){this._hideMetaData()},mouseDown:function(a){var b=a.target.getAttribute("guid");var c=a.target.getAttribute("fanType");if(b&&c){this._mouseDownGUID=b;Papercube.canvasController.showFan(Event.pointerX(a),Event.pointerY(a),this.viewName,(c+"Fan"));return YES}else{return this.handleMouseDownDrag(a)}return NO},pinLinesForObj:function(){this._linesPinned=!this._linesPinned},_hideMetaData:function(){this.metaDataView.removeClassName("show-meta-data-small")},_showMetaData:function(e,b){if(!e){return NO}var a=e.x+10;var f=e.y-20;var d=Papercube.canvasController.windowHeight()-30;var c=Papercube.canvasController.windowWidth()-10;if(f<30){f=30}if(a<20){a=20}if(f>(d-this.metaDataBoxHeightSmall)){f=(d-this.metaDataBoxHeightSmall)-30}if(a>(c-this.metaDataBoxWidthSmall)){a=(c-this.metaDataBoxWidthSmall)+1}this.metaDataView.style.top=f+"px";this.metaDataView.style.left=a+"px";this.metaDataView.addClassName("show-meta-data-small");this.generateCustomMetaData(b)},_render:function(){this._guidsNeeded=[];this._nodes={};this._visited={};this._positioned={};this._checkForData(this._cachedContent.get("guid"),0);var v=1;for(var q in this._visited){if(this._visited[q].level>v){v=this._visited[q].level}}this._deepest=v;this._radius=this._h/this.nodeDefaultRadius/v*NODEGRAPH_DEFAULT_SCALE/this._z;this._offset=(this._h/2-(this._h/2*0.2))/this._deepest*NODEGRAPH_DEFAULT_SCALE/this._z;var o=this._cachedContent.get("guid");this._lBound=1000000;this._rBound=0;this._tBound=1000000;this._bBound=0;var s=this._w/2*NODEGRAPH_DEFAULT_SCALE/this._z;var r=this._h/2*NODEGRAPH_DEFAULT_SCALE/this._z;this._positioned[o]=1;this._nodes[o]={guid:o,level:0,radius:this._radius,sx:s,sy:r,ex:s,ey:r,isMain:YES,content:this._cachedContent};this._generateDataCoords(this._cachedContent.get("guid"),0,s,r,360,360);if(this._guidsNeeded.length>0){console.log("retrieving "+this._guidsNeeded.length+" objects");Papercube.searchController.set("showRequestSpinner",YES);var j=function(){this.redrawParamsDidChange()}.bind(this,this.get("content"));this.performCustomRequest(this._guidsNeeded,j)}else{Papercube.searchController.set("showRequestSpinner",NO)}var k=this._radius*2;var i=this._w*NODEGRAPH_DEFAULT_SCALE/this._z-this._radius*4;var l=this._radius;var f=this._h*NODEGRAPH_DEFAULT_SCALE/this._z-this._radius;var m=(f-l);var n=(i-k);var c=this._lBound-this._radius;var u=this._rBound+this._radius;var d=this._tBound-this._radius;var t=this._bBound+this._radius;var h=(t-d);var p=(u-c);if(this._lastDeepest!=v){var e=Math.min(n/p,m/h);e=e-e%0.5;var b=(1-(n-p/2-c)/n);var a=(1-(m-h/2-d)/m);Papercube.canvasController.zoomToLocation(b,a,e)}this._renderGraph();this._lastDeepest=v},_renderGraph:function(){var V=this._nodes;var B=[];var j=NODEGRAPH_DEFAULT_SCALE/this._deepest;var aq=this.showEdgeLabel;var u=this.edgeMinWidth;var z=this.useEdgeWeightWidth;var H=this.edgeTextPosOffset;var al=1-this.edgeTextPosOffset;var an=this.nodeTextRatio;var p=this.nodeXYRatio;var K=4*j;var aj=this.nodeBorderWidth*j;if(aj!=this._last_nodeBorderWidth){B.push({elm:this.svgNodes,props:{"stroke-width":{start:this._last_nodeBorderWidth,end:aj}},duration:250,isSVG:YES});this._last_nodeBorderWidth=aj}var J=[];var e=[];var S=[];var o=[];var am=this._svgNodesCache;var M=this._svgEdgesCache;var F=this._svgTextCache;var D=this._svgEdgesTextCache;for(var A in V){var E=V[A];var aa=E.content;if(!aa){continue}var h=this.findCustomObjectAttr(aa);var g=E.sx;var f=E.sy;var Z=E.ex;var X=E.ey;var N=E.radius;var O=N*p;var w=N/an;var v=N/an;var q=(!am[A]);var Y=!q?Z:g;var W=(!q?X:f);var b={cx:Y,cy:W,ry:N,rx:O,fanType:"unfocused",guid:A};var R={x:Y,y:W,"font-size":w,fanType:"unfocused",guid:A};if(!q){var L=am[A].params;var n=am[A].elm;var af=F[A].elm;var U={};var ae={};var ac=NO;if(L.cx!=Y){U.cx={start:L.cx,end:Y};ae.x={start:L.cx,end:Y};ac=YES}if(L.cy!=W){v=L.ry/2;U.cy={start:L.cy,end:W};ae.y={start:L.cy,end:W};ac=YES}if(L.ry!=N){U.rx={start:L.rx,end:O};U.ry={start:L.ry,end:N};ae["font-size"]={start:v,end:w};ac=YES}if(ac){B.push({elm:n,props:U,duration:250,isSVG:YES});B.push({elm:af,props:ae,duration:250,isSVG:YES})}}else{am[A]={elm:this._createSVGElement("ellipse",b,{},NODE),params:b};F[A]={elm:this._createSVGElement("text",R,{},TEXT),params:R};F[A].elm.appendChild(document.createTextNode(this.findCustomObjectLabel(aa)));B.push({elm:am[A].elm,props:{cx:{start:Y,end:Z},cy:{start:W,end:X},ry:{start:K,end:N},rx:{start:K,end:O}},duration:250,isSVG:YES});B.push({elm:F[A].elm,props:{x:{start:Y,end:Z},y:{start:W,end:X}},duration:250,isSVG:YES})}am[A].params.rx=O;am[A].params.ry=N;F[A].params.x=Z-2*j;F[A].params.y=X-2*j;J.push(A);o.push(A);if(this.showEdges){var P=h.length;for(var ak=0;ak<P;ak++){var ai=this.getGuidForRelation(h[ak]);var C=V[ai];var m=ai+A;var l=A+ai;if(C){var d=C.sx;var c=C.sy;var T=C.ex;var Q=C.ey;if(z){var ad=this.calcRelationWeight(h[ak]);var a=Math.max(u,Math.min(Math.floor(ad/5+2),6))*j}else{var a=u*j}var t=(q)?g:Z;var ap=(q)?f:X;var s=(!am[ai])?d:T;var ao=(!am[ai])?c:Q;if(aq){var I=(Z*al+T*(H));var G=(X*al+Q*(H))+j*3}var b={x1:t,y1:ap,x2:s,y2:ao,"stroke-width":a};if((M[m]||M[l])&&e.indexOf(m)==-1&&e.indexOf(l)==-1){var L=M[m].params;var ab=M[m].elm;var U={};var ac=NO;if(L.x1!=t){U.x1={start:L.x1,end:t};ac=YES}if(L.x2!=s){U.x2={start:L.x2,end:s};ac=YES}if(L.y1!=ap){U.y1={start:L.y1,end:ap};ac=YES}if(L.y2!=ao){U.y2={start:L.y2,end:ao};ac=YES}ab.setAttributeNS(null,"stroke-width",a);if(ac){B.push({elm:ab,props:U,duration:250,isSVG:YES});if(aq){B.push({elm:D[m].elm,props:{x:{start:(L.x1*al+L.x2*(H)),end:I},y:{start:(L.y1*al+L.y2*(H))+3*j,end:G},"font-size":{start:v,end:w}},duration:250,isSVG:YES})}}M[m].params.x1=M[l].params.x1=t;M[m].params.y1=M[l].params.y1=ap;M[m].params.x2=M[l].params.x2=s;M[m].params.y2=M[l].params.y2=ao}else{if(e.indexOf(m)==-1&&e.indexOf(l)==-1){t=(q)?g:am[A].params.cx;ap=(q)?f:am[A].params.cy;if(aq){var ah=(t*al+s*(H));var ag=(ap*al+ao*(H))+3*j;var r={x:ah,y:ag,"font-size":w};D[m]=D[l]={elm:this._createSVGElement("text",r,{},EDGETEXT),params:b};D[m].elm.appendChild(document.createTextNode(ad))}M[m]=M[l]={elm:this._createSVGElement("line",b,{},EDGE),params:b};var U={};var ac=NO;if(Z!=t){U.x1={start:t,end:Z};ac=YES}if(X!=ap){U.y1={start:ap,end:X};ac=YES}if(T!=s){U.x2={start:s,end:T};ac=YES}if(Q!=ao){U.y2={start:ao,end:Q};ac=YES}if(ac){B.push({elm:M[m].elm,props:U,duration:250,isSVG:YES});if(aq){B.push({elm:D[m].elm,props:{x:{start:ah,end:I},y:{start:ag,end:G},"font-size":{start:v,end:w}},duration:250,isSVG:YES})}}M[m].params.x1=M[l].params.x1=Z;M[m].params.y1=M[l].params.y1=X;M[m].params.x2=M[l].params.x2=T;M[m].params.y2=M[l].params.y2=Q}}if(aq){D[m].params.x=D[l].params.x=I;D[m].params.y=D[l].params.y=G}e.push(l);e.push(m);if(aq){S.push(l);S.push(m)}}}}am[A].params.cx=Z;am[A].params.cy=X}Papercube.animationController.addSubjects(B,this.svgCanvas,this._pH);this._clearSVGElms(am,J,this.svgNodes);this._clearSVGElms(M,e,this.svgEdges);this._clearSVGElms(F,o,this.svgText);this._clearSVGElms(D,S,this.svgEdgesText);this._svgTextCache=F;this._svgEdgesTextCache=D;this._svgEdgesCache=M;this._svgNodesCache=am},_checkForData:function(d,h){var c=this.findCustomObject(d);if(c&&(!this._visited[d]||this._visited[d].level>h)){var b=this.findCustomObjectAttr(c);var a=b.length;var g=h+1;if(!this._visited[d]){this._visited[d]={level:h,count:1,childCount:a}}else{var f=this._visited[d].level;this._visited[d].level=(h<f)?h:f;this._visited[d].count++}if(g<=this._cached_depth){for(var e=0;e<a;e++){if(this.relationMeetsCustomThreshold(b[e])){this._checkForData(this.getGuidForRelation(b[e]),g)}}}}else{if(this._visited[d]){this._visited[d].count++}else{this._guidsNeeded.push(d)}}},_generateDataCoords:function(D,a,t,s,L,p){var N=this.findCustomObject(D);var B=this._nodes[D];if(N&&B){B.content=N;var P=a+1;var z=this.findCustomObjectAttr(N);var d=[];var m=[];var G=0;var v=0;var b=z.length;for(var H=0;H<b;H++){var c=z[H];var J=this.getGuidForRelation(c);if(this._visited[J]&&!this._positioned[J]){if(this._visited[J].childCount>v){v=this._visited[J].childCount}var u=this.calcRelationWeight(c);if(u>G){G=u}d.push([J,u])}}var I=d.length;if(I>0){var E=(a==0)?L/I:L/(I-1);var l=(a==0||I==1)?p:p-L/2;var O=l;var k=this._offset;var h=Math.min(this._radius,(2*Math.PI*k)*(L/360)/I/4);var q=Math.PI/180;var M=this._deepest;var j=(k*NODEGRAPH_OFFSET_PERCENT);for(var H=0;H<I;H++){m[H]=[];var J=d[H][0];var F=this._visited[J].level;if(F==P&&!this._positioned[J]){var A=(F!=M)?j*(1-this._visited[J].childCount/v):0;var C=(NODEGRAPH_USE_CHILDREN_OFFSET)?(k-A):k;var K=l*q;var f=t+C*Math.cos(K);var e=s+C*Math.sin(K);if(f<this._lBound){this._lBound=f}if(f>this._rBound){this._rBound=f}if(e<this._tBound){this._tBound=e}if(e>this._bBound){this._bBound=e}this._nodes[J]={guid:J,level:F,ex:f,ey:e,sx:t,sy:s,radius:h};this._positioned[J]=YES;m[H]=[f,e];l+=E}}if(P<=this._cached_depth){for(var H=0;H<I;H++){this._generateDataCoords(d[H][0],P,m[H][0],m[H][1],Math.min(E%360*1.5,90),O%360);O+=E}}}}},_clearSVG:function(){var a=this.svgNodes;while(a.firstChild){a.removeChild(a.firstChild)}var a=this.svgEdges;while(a.firstChild){a.removeChild(a.firstChild)}var a=this.svgText;while(a.firstChild){a.removeChild(a.firstChild)}var a=this.svgEdgesText;while(a.firstChild){a.removeChild(a.firstChild)}},_createSVGElement:function(e,a,c,d){var f=document.createElementNS("http://www.w3.org/2000/svg",e);if(a){for(var b in a){if(isNaN(a[b])||b.indexOf("opacity")!=-1){f.setAttributeNS(null,b,a[b])}else{f.setAttributeNS(null,b,Math.floor(a[b]))}}}switch(d){case NODE:this.svgNodes.appendChild(f);break;case EDGE:this.svgEdges.appendChild(f);break;case TEXT:this.svgText.appendChild(f);break;case EDGETEXT:this.svgEdgesText.appendChild(f);break;default:break}return f},_clearSVGElms:function(d,f,a){for(var b in d){if(f.indexOf(b)==-1){try{a.removeChild(d[b].elm);delete d[b].elm;delete d[b].params;delete d[b]}catch(c){try{delete d[b]}catch(c){}}}}},init:function(){arguments.callee.base.apply(this,arguments);this.svgCanvas=document.createElementNS("http://www.w3.org/2000/svg","svg");this.rootElement.appendChild(this.svgCanvas);this.svgFitGroup=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgCanvas.appendChild(this.svgFitGroup);this.svgGroup=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgFitGroup.appendChild(this.svgGroup);this.svgEdges=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgEdges);this.svgEdges.setAttributeNS(null,"stroke",this.edgeColor);if(this.edgeOpacity!=1){this.svgEdges.setAttributeNS(null,"stroke-opacity",this.edgeOpacity)}this.svgEdgesText=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgEdgesText);this.svgEdgesText.setAttributeNS(null,"fill",this.edgeTextColor);this.svgEdgesText.setAttributeNS(null,"text-anchor","middle");this.svgEdgesText.setAttributeNS(null,"style","cursor: default");this.svgNodes=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgNodes);this.svgNodes.setAttributeNS(null,"fill",this.nodeColor);this.svgNodes.setAttributeNS(null,"stroke",this.nodeBorderColor);this._last_nodeBorderWidth=this.nodeBorderWidth*NODEGRAPH_DEFAULT_SCALE;this.svgNodes.setAttributeNS(null,"stroke-width",this._last_nodeBorderWidth);if(this.nodeOpacity!=1){this.svgNodes.setAttributeNS(null,"opacity",this.nodeOpacity)}this.svgText=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgText);this.svgText.setAttributeNS(null,"fill",this.nodeTextColor);this.svgText.setAttributeNS(null,"text-anchor","middle");this.svgText.setAttributeNS(null,"style","cursor: default");var f=function(g){Papercube.viewController.setContentToViewFromGUID(this._mouseDownGUID,this.contentTypeViewing,NO)}.bind(this);var c=function(g){window.open(Papercube.Paper.find(this._mouseDownGUID).get("url"))}.bind(this);var e=function(g){Papercube.viewController.saveObject(this._mouseDownGUID,this.contentTypeViewing)}.bind(this);var a=function(g){Papercube.canvasController.setZoomToPointerLocation(Event.pointerX(g),Event.pointerY(g),NO)}.bind(this);var b=function(g){Papercube.canvasController.setZoomToPointerLocation(Event.pointerX(g),Event.pointerY(g),YES)}.bind(this);var d=function(g){this.pinLinesForObj()}.bind(this);if(this.get("showEdges")){Papercube.canvasController.registerFans(this.viewName,{focusedFan:{CiteSeer:c,Save:e,"Pin Lines":d,"Zoom +":b,"Zoom -":a},unfocusedFan:{CiteSeer:c,Save:e,"Pin Lines":d,Refocus:f,"Zoom +":b,"Zoom -":a}})}else{Papercube.canvasController.registerFans(this.viewName,{focusedFan:{CiteSeer:c,Save:e,"Zoom +":b,"Zoom -":a},unfocusedFan:{CiteSeer:c,Save:e,Refocus:f,"Zoom +":b,"Zoom -":a}})}}});require("core");Papercube.canvasController=SC.Object.create({zoomValue:1,zoomStep:1,zoomValueMin:1,zoomValueMax:30,isZooming:NO,shouldShowCanvas:NO,canvasHeight:0,canvasWidth:0,canvasTop:0,canvasLeft:0,portalHeight:0,portalWidth:0,percentageX:0.5,percentageY:0.5,displayProperties:{height:0,width:0,left:0,top:0,zoomValue:0,portalWidth:0,portalHeight:0},fanDiv:null,fanSVGRoot:null,fanSVG:null,fans:{},leftViewShowing:NO,_scrollCoolDown:0,_scrollCoolDownAmount:200,zoomOutFull:function(){this.set("zoomValue",this.get("zoomValueMin"))},zoomOut:function(){this.set("zoomValue",Math.max(this.get("zoomValueMin"),(this.get("zoomValue")-this.get("zoomStep"))))},zoomIn:function(){this.set("zoomValue",Math.min(this.get("zoomValueMax"),(this.get("zoomValue")+this.get("zoomStep"))))},scrollZoom:function(a){if((Date.now()-this._scrollCoolDown)<this._scrollCoolDownAmount||Papercube.viewController.savedPanelViewShowing){return}this._scrollCoolDown=Date.now();this.setZoomToPointerLocation(Event.pointerX(a),Event.pointerY(a),((a.detail?a.detail*-1:a.wheelDelta)>0))},setZoomToPointerLocation:function(f,d,e){var g=e?this.zoomStep:-this.zoomStep;var a=this.zoomValue+g;if(a<this.zoomValueMin||a>this.zoomValueMax||this.leftViewShowing){return NO}this.set("zoomValue",a);var i=f-this.canvasLeft+30*a;var h=d-30-this.canvasTop;var c=1-(this.canvasWidth-i)/this.canvasWidth;var b=1-(this.canvasHeight-h)/this.canvasHeight;SC.page.canvas.zoomView.setParams(c,b)},panToCoordinates:function(h,c,f){var e=this.get("zoomValue");if(e===this.zoomValueMin||this.leftViewShowing){return NO}var g=this.percentageX*this.canvasWidth-h;var d=this.percentageY*this.canvasHeight-c;var b=Math.max(1-(this.canvasWidth-g)/this.canvasWidth,0);var a=Math.max(1-(this.canvasHeight-d)/this.canvasHeight,0);this.set("percentageX",b);this.set("percentageY",a);if(f){SC.page.canvas.zoomView._zoomDirty=YES;SC.page.canvas.zoomView.updatePreviewBox(b,a)}},zoomToLocation:function(b,a,c){if(c<this.zoomValueMin||c>this.zoomValueMax||this.leftViewShowing){return NO}SC.page.canvas.zoomView._zoomDirty=YES;this.beginPropertyChanges();this.set("zoomValue",c);this.set("percentageX",b/2);this.set("percentageY",a/2);this.endPropertyChanges()},windowHeight:function(){var a=window;return a.innerHeight||(a.document.documentElement.clientHeight||a.document.body.clientHeight)||0},windowWidth:function(){var a=window;return a.innerWidth||(a.document.documentElement.clientWidth||a.document.body.clientWidth)||0},getWindowProperties:function(){var a=this.windowHeight();var b=this.windowWidth();this.fanSVGRoot.setAttributeNS(null,"height",a);this.fanSVGRoot.setAttributeNS(null,"width",b);this.set("portalHeight",(a-30));this.set("portalWidth",b);this.repositionCanvasDidChange()},repositionCanvasDidChange:function(){this.canvasHeight=parseInt(this.portalHeight*this.zoomValue,0);this.canvasWidth=parseInt(this.portalWidth*this.zoomValue,0);var a=0;var b=0;if(this.zoomValue!=this.zoomValueMin){var a=-(this.percentageY*this.canvasHeight);var b=-(this.percentageX*this.canvasWidth)}this.canvasTop=a;this.canvasLeft=b;this.set("displayProperties",{height:this.canvasHeight,width:this.canvasWidth,top:this.canvasTop,left:this.canvasLeft,zoomValue:this.zoomValue,portalWidth:this.portalWidth,portalHeight:this.portalHeight});this.hideFan();this.set("isZooming",this.get("zoomValue")!=1)}.observes("percentageX","percentageY","zoomValue"),showFan:function(a,d,b,c){if(this.fanSVG.childNodes.length!=0){this.hideFan()}if(!this.fans[b]){console.log("Fan Error: You need to register your fan views!");return NO}else{if(!this.fans[b].svg[c]){console.log("Fan Notice: Fan "+b+"-"+c+" has not been created, creating now.");this.createFan(b,c)}}this.fanSVG.appendChild(this.fans[b].svg[c]);this.fanSVG.setAttributeNS(null,"x",a-37);this.fanSVG.setAttributeNS(null,"y",d-157);this.fanSVGRoot.style.cssText="position: relative; z-index: 1001;"},hideFan:function(){if(this.fanSVG&&this.fanSVGRoot&&this.fanSVG.firstChild){this.fanSVG.removeChild(this.fanSVG.firstChild);this.fanSVGRoot.style.cssText=""}},svgMouseOver:function(a){this._highlightFan(a,"#555")},svgMouseOut:function(a){this._highlightFan(a,"#222")},svgMouseDown:function(a){this._highlightFan(a,"#222")},svgMouseUp:function(a){if(a.target.nodeName=="path"){a.target.setAttributeNS(null,"fill","#222")}this.hideFan();var b=this._getSVGParams(a);if(b){this.fans[b.name].opts[b.fanType][b.action](a)}},circleMouseUp:function(a){this.hideFan()},registerFans:function(a,b){this.fans[a]={name:a,opts:b,svg:{},slices:{}}},createFan:function(D,o){var A=this._createSVGElement("g",{},{});var n=this.fans[D].opts[o];var a=[];var f=[];for(var C in n){f.push(C)}var t=25;var e=11;var c=150;var p=150;var y=f.length;var B=(Math.PI/2)/y;var j=(Math.PI/4);this._createSVGElement("circle",{cx:e+20,cy:c,r:p*2,opacity:"0.0"},{mouseover:this.circleMouseUp.bind(this)},A);for(var w=0;w<y;w++){var h=j+B;var l=e+20+t*Math.sin(j);var v=c-t*Math.cos(j);var k=e+20+t*Math.sin(h);var u=c-t*Math.cos(h);var z=e+(p-t)*Math.sin(j);var d=c-(p-t)*Math.cos(j);var x=e+(p-t)*Math.sin(h);var b=c-(p-t)*Math.cos(h);var s="M "+k+","+u+" A "+t+","+t+" 0 0 0 "+l+","+v+" L "+z+","+d+" A "+p+","+p+" 0 0 1 "+x+","+b+" Z";a.push(this._createSVGElement("path",{d:s,fill:"#222",stroke:"#555","stroke-width":1,opacity:"0.8",fanType:o,name:D,action:f[w],index:w},{mouseout:this.svgMouseOut.bind(this),mousemove:this.svgMouseOver.bind(this),mousedown:this.svgMouseDown.bind(this),mouseup:this.svgMouseUp.bind(this)},A));j=h}var B=90/y;var j=-45;for(var w=0;w<y;w++){var h=j+B;var m=this._createSVGElement("text",{x:90,y:c+5,fill:"white","text-anchor":"right","font-size":10,transform:"rotate("+(((j+h)/2))+" "+(20)+", 160)",fanType:o,name:D,action:f[w],index:w},{mouseout:this.svgMouseOut.bind(this),mousemove:this.svgMouseOver.bind(this),mousedown:this.svgMouseDown.bind(this),mouseup:this.svgMouseUp.bind(this)},A);var q=document.createTextNode(f[w]);m.appendChild(q);j=h}this._createSVGElement("circle",{cx:e+20,cy:c,r:t,fill:"#000",stroke:"none","stroke-width":1,opacity:"0.3",index:-1},{mouseup:this.circleMouseUp.bind(this)},A);this.fans[D].svg[o]=A;this.fans[D].slices[o]=a},_highlightFan:function(a,b){var c=this._getSVGParams(a);if(c){this.fans[c.name].slices[c.fanType][c.index].setAttributeNS(null,"fill",b)}else{this.hideFan()}},_getSVGParams:function(a){var f=a.target;var c=f.getAttribute("index");var b=f.getAttribute("name");var e=f.getAttribute("fanType");var d=f.getAttribute("action");if(c&&b&&e&&d){return{index:c,name:b,fanType:e,action:d}}return NO},_createSVGElement:function(e,b,d,a){var f=document.createElementNS("http://www.w3.org/2000/svg",e);if(b){for(var c in b){f.setAttributeNS(null,c,b[c])}}if(d){for(var c in d){f.addEventListener(c,d[c],NO)}}if(a){a.appendChild(f)}return f},init:function(){Event.observe(window,"resize",this.getWindowProperties.bind(this));if(SC.isFireFox()){Element.observe(document.body,"DOMMouseScroll",this.scrollZoom.bind(this))}else{Element.observe(document.body,"mousewheel",this.scrollZoom.bind(this))}this.fanDiv=$("fan-container");this.fanSVGRoot=document.createElementNS("http://www.w3.org/2000/svg","svg");this.fanSVGRoot.setAttributeNS(null,"height",1);this.fanSVGRoot.setAttributeNS(null,"width",1);this.fanDiv.appendChild(this.fanSVGRoot);this.fanSVG=document.createElementNS("http://www.w3.org/2000/svg","svg");this.fanSVG.setAttributeNS(null,"height",300);this.fanSVG.setAttributeNS(null,"width",300);this.fanSVGRoot.appendChild(this.fanSVG);this.getWindowProperties();arguments.callee.base.apply(this,arguments)}});require("core");require("controllers/canvas");Papercube.ZoomView=SC.View.extend({heightBinding:"Papercube.canvasController.portalHeight",widthBinding:"Papercube.canvasController.portalWidth",zoomValueBinding:"Papercube.canvasController.zoomValue",isZoomingBinding:"Papercube.canvasController.isZooming",percentageXBinding:"Papercube.canvasController.percentageX",percentageYBinding:"Papercube.canvasController.percentageY",isVisible:NO,_zoomDirty:NO,_bounds:{x:0,y:0,height:0,width:0},_actionType:"",_ptrXOffset:0,_ptrYOffset:0,percentageX:0.5,percentageY:0.5,outlets:["canvasPreview","portalPreview"],canvasPreview:".canvas-preview?",portalPreview:".portal-preview?",isZoomingDidChange:function(){this.set("isVisible",this.get("isZooming"));setTimeout(this.applyZoomTransition.bind(this),5);if(!this.get("isZooming")){this._zoomDirty=NO}}.observes("isZooming"),redrawParamsDidChange:function(){if(!this.get("isVisible")){return NO}var m=this.get("height");var c=this.get("width");var j=140;var d=140;var b=this.get("zoomValue");if(m>c){d=parseInt(j*(c/m),0)}else{j=parseInt(d*(m/c),0)}var f=(j+10);var k=(d+20);this.setStyle({height:f+"px",width:k+"px"});this._frame=null;this.get("frame");this._frame.height=f;this._frame.width=k;this.canvasPreview.style.right="10px";this.canvasPreview.style.width=d+"px";this.canvasPreview.style.height=j+"px";var e=(d/b);var l=(j/b);var a={x:(this._frame.x+8),y:30,height:j,width:d,previewWidth:e,previewHeight:l};this._bounds=a;var n=NO;if(this._zoomDirty&&(this._lastHeight!=m||this._lastWidth!=c)){var i=a.x+this.get("percentageX")*d+e/2;var g=a.y+this.get("percentageY")*j+l/2}else{if(this._zoomDirty&&this._lastZoomValue!=b){var i=this._lastPrevX;var g=this._lastPrevY;n=YES}else{var i=a.x+d/2;var g=a.y+j/2;n=YES}}this._setPreviewPosition(i,g);if(n){this._setPercentage()}this._lastHeight=m;this._lastWidth=c;this._lastZoomValue=b}.observes("height","width","zoomValue"),applyZoomTransition:function(){this.setClassName("zoom-view-visible",this.get("isZooming"))},setParams:function(b,a){var c=this._bounds;this._setPreviewPosition((c.x+c.width*b),(c.y+c.height*a));this._setPercentage()},updatePreviewBox:function(b,a){var c=this._bounds;this._setPreviewPosition(parseInt((c.x+c.width*b+c.previewWidth/2),0),parseInt((c.y+c.height*a+c.previewHeight/2),0))},positionPreviewBox:function(b,d,a,c){this.portalPreview.style.top=d+"px";this.portalPreview.style.left=b+"px";this.portalPreview.style.width=c+"px";this.portalPreview.style.height=a+"px";this._bounds.previewX=b;this._bounds.previewY=d},_setPreviewPosition:function(a,e){this._lastPrevX=a;this._lastPrevY=e;var c=this._bounds;a=a-c.previewWidth/2;e=e-c.previewHeight/2;if(e<c.y){e=c.y}if(e>((c.y+c.height)-c.previewHeight)){e=((c.y+c.height)-c.previewHeight)}if(a<c.x){a=c.x}if(a>((c.x+c.width)-c.previewWidth)){a=((c.x+c.width)-c.previewWidth)+1}var b=e-c.y;var d=a-c.x;this._bounds.previewX=Math.min(d+1,c.width-c.previewWidth+1);this._bounds.previewY=b+1;this._bounds.ly=b;this._bounds.lx=d;this.positionPreviewBox(this._bounds.previewX,this._bounds.previewY,c.previewHeight,c.previewWidth)},_setPercentage:function(){var a=this._bounds;this.set("percentageX",1-(a.width-a.lx)/a.width);this.set("percentageY",1-(a.height-a.ly)/a.height)},mouseDown:function(a){if(Element.hasClassName(a.target,"canvas-preview")){this._actionType="click"}else{if(Element.hasClassName(a.target,"portal-preview")){this._ptrXOffset=parseInt(Event.pointerX(a)-(this._bounds.x+this._bounds.previewX+this._bounds.previewWidth/2),0);this._ptrYOffset=parseInt(Event.pointerY(a)-(this._bounds.y+this._bounds.previewY+this._bounds.previewHeight/2),0);this._actionType="drag";this.portalPreview.className="portal-preview grabbing"}else{this._actionType="";return NO}}return YES},mouseDragged:function(a){if(this._actionType==""||this._actionType=="click"){return NO}this._setPreviewPosition(Event.pointerX(a)-this._ptrXOffset,Event.pointerY(a)-this._ptrYOffset);return YES},mouseUp:function(a){this._zoomDirty=YES;this.portalPreview.className="portal-preview";if(this._actionType=="drag"){this._setPreviewPosition(Event.pointerX(a)-this._ptrXOffset,Event.pointerY(a)-this._ptrYOffset)}else{this._setPreviewPosition(Event.pointerX(a),Event.pointerY(a))}this._setPercentage();this._actionType="";return YES}});require("core");Papercube.PaperTreeView=SC.View.extend(Papercube.DragPanMixin,{displayPropertiesBinding:"Papercube.canvasController.displayProperties",viewDirectionBinding:"Papercube.viewController.viewDirection",citeThresholdBinding:"Papercube.paperTreeController.citeThreshold",_cached_citeThreshold:1,refThresholdBinding:"Papercube.paperTreeController.refThreshold",_cached_refThreshold:1,depthBinding:"Papercube.paperTreeController.depth",_cached_depth:15,_displayRefs:YES,_canvasWidth:800,_canvasHeight:600,_h:0,_w:0,_x:0,_y:0,_rowHeight:1,_deepestLevel:1,_renderTree:{},_paperDOMMap:{},_foundGuid:null,_metaDataBoxWidthSmall:400,_metaDataBoxHeightSmall:120,_styleSheet:null,_deepest:0,_guidsNeeded:{},_node:null,_textNode:null,outlets:["canvas","metaDataView"],canvas:".canvas?",metaDataView:".meta-data?",_hideMetaData:function(){this.metaDataView.removeClassName("show-meta-data-small");this.removeHighlight()},_showMetaData:function(i,d){var g=Event.pointerX(i)+10;var e=Event.pointerY(i)-20;var c=Papercube.canvasController.windowHeight();var a=Papercube.canvasController.windowWidth();if(e<30){e=30}if(g<20){g=20}if(e>(c-this._metaDataBoxHeightSmall)){e=(c-this._metaDataBoxHeightSmall)-30}if(g>(a-this._metaDataBoxWidthSmall)){g=(a-this._metaDataBoxWidthSmall)+1}this.metaDataView.style.top=e+"px";this.metaDataView.style.left=g+"px";this.metaDataView.addClassName("show-meta-data-small");if(d.indexOf("--1")==-1){var b=Papercube.Paper.find(d);if(!b){return}this.metaDataView.childNodes[0].innerHTML=b.get("title");var f=b.get("authorNames").join(", ");var h=f.length;this.metaDataView.childNodes[1].innerHTML=(h>150)?(f.substr(0,150)+"&hellip;"):f;this.metaDataView.childNodes[2].innerHTML=(b.get("publisher"))?b.get("publisher"):"";this.metaDataView.childNodes[3].innerHTML="<strong>Publication Date: </strong> "+b.get("year");this.metaDataView.childNodes[4].innerHTML=Papercube.pluralizeString(" reference",b.get("refCount"));this.metaDataView.childNodes[5].innerHTML=Papercube.pluralizeString(" citation",b.get("citeCount"))}},mouseMoved:function(a){if(a&&a.target&&a.target.id&&Element.hasClassName(a.target,"item")||Element.hasClassName(a.target,"item-text")){var c=a.target.id;if(c.substr(0,2)!="-1"){if(c!=this._foundGuid){this.removeHighlight()}this._showMetaData(a,c);this._foundGuid=c;var b=this._paperDOMMap[this._foundGuid];if(b){for(var d=0;d<b.length;d++){b[d].addClassName("highlight")}}}else{this._hideMetaData()}}else{this._hideMetaData()}},removeHighlight:function(){var a=this._paperDOMMap[this._foundGuid];if(!a){return}for(var b=0;b<a.length;b++){a[b].removeClassName("highlight")}},mouseExited:function(a){this._hideMetaData()},mouseDown:function(a){if(a&&a.target&&a.target.id){var b=a.target.id;if(b.substr(0,2)=="--1"){Papercube.viewController.setContentToViewFromGUID(b.substr(3,b.length-3),"Paper")}else{this._mouseDownGUID=b;var c=(Element.hasClassName(a.target,"level0")||(Element.hasClassName(a.target,"item-text")&&Element.hasClassName(a.target.parentNode,"level0")))?"focused":"unfocused";Papercube.canvasController.showFan(Event.pointerX(a),Event.pointerY(a),"papertree",(c+"Fan"));return YES}}else{return this.handleMouseDownDrag(a)}return NO},redrawParamsDidChange:function(){var b=this.get("content");if(!this.get("isVisible")||!b){return NO}Papercube.canvasController.set("zoomValueMax",5);Papercube.canvasController.set("zoomStep",0.5);this._hideMetaData();if(!this._cachedContent||this._cachedContent.get("guid")!==b.get("guid")){this._deepest=1;Papercube.canvasController.zoomOut();Papercube.paperTreeController.setDefaults()}this._displayRefs=(this.get("viewDirection")=="References");this.setClassName("citations",!this._displayRefs);this.setClassName("references",this._displayRefs);var a=this.get("citeThreshold");var c=this.get("refThreshold");this._cached_citeThreshold=a;this._cached_refThreshold=c;this._cached_depth=this.get("depth");this._cachedContent=b;this.displayPropertiesDidChange()}.observes("content","isVisible","viewDirection","refThreshold","depth","citeThreshold"),displayPropertiesDidChange:function(){if(!this.get("isVisible")||!this._cachedContent){return NO}var c=this.displayProperties.height-20;var b=this.displayProperties.width-20;var a=this.displayProperties.left+20;var e=this.displayProperties.top;var d=this.displayProperties.zoomValue;this.setStyle({height:c+"px",width:b+"px",left:a+"px",top:e+"px"});this._frame={height:c,width:b,x:a,y:e};this.canvas.style.height=c+"px";this.canvas.style.width=b+"px";this.canvas.style.left=a+"px";this.canvas.style.top=e+"px";this._canvasHeight=c;this._canvasWidth=b;this._h=c;this._w=b;this._x=a;this._y=e;this._z=d;this._render()}.observes("displayProperties"),_render:function(){this._guidsNeeded={};this._renderTree={};this._deepest=0;this._paperDOMMap={};var b=this._buildLevel(this._cachedContent.get("guid"),0,this._w,0,0);this._rowHeight=Math.floor(this._h/((Math.min(this._deepest+1,this.get("depth")))));if(this._displayRefs){this._styleSheet.cssRules[0].style.top=this._rowHeight+"px";this._styleSheet.cssRules[0].style.bottom=""}else{this._styleSheet.cssRules[0].style.top="";this._styleSheet.cssRules[0].style.bottom=this._rowHeight+"px"}this._styleSheet.cssRules[0].style.height=this._rowHeight+"px";this._styleSheet.cssRules[1].style.height=(this._rowHeight-10)+"px";if(this.canvas.childNodes.length){this.canvas.removeChild(this.canvas.childNodes[0])}if(b){this.canvas.appendChild(b)}var d=[];for(var a in this._guidsNeeded){if(d.indexOf(a)==-1){d.push(a)}}if(d.length>0){Papercube.searchController.set("showRequestSpinner",YES);var c=function(){this.redrawParamsDidChange()}.bind(this,this.get("content"));Papercube.adaptor.getPaperDetails(d,c);this._cachedContent.set((this._displayRefs?"maxRefLevel":"maxCiteLevel"),this._deepest)}else{Papercube.searchController.set("showRequestSpinner",NO)}},_buildLevel:function(u,b,o,g,r){if(this._cached_depth<b){return null}var n=Papercube.Paper.find(u);var d=[];var j=this._displayRefs;if(n){d=(j)?n._attributes.references:n._attributes.citations}if(this._deepest<b){this._deepest=b}if(n){var l=n.get("refCount");var m=n.get("citeCount");var v=this._node.cloneNode(YES);v.className="item level"+b;v.id=u;if(b!==0){v.style.left=(g-1)+"px"}v.style.width=(o-1)+"px";if(!this._paperDOMMap[u]){this._paperDOMMap[u]=[]}this._paperDOMMap[u].push(v);if(o>20&&n){var t=this._textNode.cloneNode(YES);t.id=u;t.innerHTML=n._attributes.title+"<br/><br/> ["+Papercube.pluralizeString(" ref",l)+"] ["+Papercube.pluralizeString(" cite",m)+"]";v.appendChild(t)}if(!this._renderTree[u]){this._renderTree[u]=0}this._renderTree[u]++;var y=d.length;var s=[];for(var x=0;x<y;x++){var a=d[x];var h=Papercube.Paper.find(a);if(h){if(this._cached_citeThreshold<=h.get("citeCount")&&this._cached_refThreshold<=h.get("refCount")){s.push(a)}}else{this._guidsNeeded[a]=1}}y=s.length;d=s;var f=Math.floor(o/y);if(f>=1&&this._renderTree[u]==1){var q=o-(f*y);var e=0;var z=b+1;for(var x=0;x<y;x++){var c=d[x];var k=f;if(q!=0&&x<q){k=f+1}var p=this._buildLevel(c,z,k,e,x);if(p){v.appendChild(p)}this._renderTree[c]=1;e+=k}}else{if(this._renderTree[u]!=1&&f<=1){var v=this._node.cloneNode(YES);v.className="item stub level"+b;v.id="--1_"+u;v.style.width=(o-1)+"px"}}}else{if(this._renderTree[u]!=1&&f<=1){var v=this._node.cloneNode(YES);v.className="item stub level"+b;v.id="--1_"+u;v.style.width=(o-1)+"px"}}return v},init:function(){var f=function(g){Papercube.viewController.setContentToViewFromGUID(this._mouseDownGUID,"Paper",NO)}.bind(this);var d=function(g){window.open(Papercube.Paper.find(this._mouseDownGUID).get("url"))}.bind(this);var e=function(g){Papercube.viewController.saveObject(this._mouseDownGUID,"Paper")}.bind(this);var a=function(g){Papercube.canvasController.setZoomToPointerLocation(Event.pointerX(g),Event.pointerY(g),NO)}.bind(this);var b=function(g){Papercube.canvasController.setZoomToPointerLocation(Event.pointerX(g),Event.pointerY(g),YES)}.bind(this);Papercube.canvasController.registerFans("papertree",{focusedFan:{CiteSeer:d,Save:e,"Zoom +":b,"Zoom -":a},unfocusedFan:{CiteSeer:d,Save:e,Refocus:f,"Zoom +":b,"Zoom -":a}});for(var c=0;c<document.styleSheets.length;c++){if(document.styleSheets[c].cssRules[0].cssText.substr(0,11)==".paper_tree"){this._styleSheet=document.styleSheets[c]}}this._node=document.createElement("div");this._textNode=document.createElement("div");this._textNode.className="item-text";arguments.callee.base.apply(this,arguments)}});require("core");Papercube.AuthorPaperView=Papercube.NodeGraphView.extend({_year:new Date().getFullYear(),depth:1,linkThresholdBinding:"Papercube.authorPaperController.refThreshold",_cached_linkThreshold:1,citeThresholdBinding:"Papercube.authorPaperController.citeThreshold",_cached_citeThreshold:1,startYearThresholdBinding:"Papercube.authorPaperController.startYearThreshold",_cached_startYearThreshold:1960,endYearThresholdBinding:"Papercube.authorPaperController.endYearThreshold",_cached_endYearThreshold:new Date().getFullYear(),nodeColor:"#B0BDC5",nodeColorSel:"#D2E2EC",nodeBorderColor:"#727C81",nodeBorderColorSel:"#727C81",nodeTextColor:"#111",viewName:"authorpaper",contentTypeViewing:"Paper",defaultTitleKey:"name",nodeTextRatio:3,showEdgeLabel:NO,useEdgeWeightWidth:NO,showEdges:NO,edgeTextPosOffset:0.4,performCustomRequest:function(b,a){Papercube.adaptor.getPaperDetails(b,a)},generateCustomMetaData:function(c){var d=Papercube.Paper.find(c);if(!d){var d=Papercube.Author.find(c);if(!d){return NO}this.metaDataView.childNodes[0].innerHTML=d.get("name");this.metaDataView.childNodes[1].innerHTML="<strong>Number of Collaborators:</strong> "+Papercube.pluralizeString(" author",d.get("collaborators").length);this.metaDataView.childNodes[2].innerHTML="<strong>Author references:</strong> "+Papercube.pluralizeString(" other author",d.get("refAuthors").length);this.metaDataView.childNodes[3].innerHTML="<strong>Author is cited by:</strong> "+Papercube.pluralizeString(" other author",d.get("citeAuthors").length);this.metaDataView.childNodes[4].innerHTML="<strong>Papers Published:</strong> "+Papercube.pluralizeString(" paper",d.get("paperCount"));this.metaDataView.childNodes[5].innerHTML="";return NO}this.metaDataView.childNodes[0].innerHTML=d.get("title");var b=d.get("authorNames").join(", ");var a=b.length;this.metaDataView.childNodes[1].innerHTML=(a>150)?(b.substr(0,150)+"&hellip;"):b;this.metaDataView.childNodes[2].innerHTML=(d.get("publisher"))?d.get("publisher"):"";this.metaDataView.childNodes[3].innerHTML="<strong>Publication Date: </strong> "+d.get("year");this.metaDataView.childNodes[4].innerHTML=Papercube.pluralizeString(" reference",d.get("refCount"));this.metaDataView.childNodes[5].innerHTML=Papercube.pluralizeString(" citation",d.get("citeCount"))},findCustomObject:function(a){var b=Papercube.Paper.find(a);if(!b){b=Papercube.Author.find(a)}return b},findCustomObjectAttr:function(a){if(a){if(a._type=="Papercube.Author"){return a._attributes.papers}return[]}else{return[]}},getGuidForRelation:function(a){if(a){return a}},calcRelationWeight:function(a){return 1},findCustomObjectLabel:function(c){if(c){if(c._type=="Papercube.Author"){var b="";var e=c._attributes.name.split(" ");var a=e.length;for(var d=0;d<a;d++){if(d<a-1){b+=e[d].substr(0,1).toUpperCase()+" "}else{b+=e[d].substr(0,6)}}return b}return c._attributes.title.substr(0,20)}return"?"},setBindingDefaults:function(){Papercube.authorPaperController.setDefaults()},relationMeetsCustomThreshold:function(a){if(this._cached_linkThreshold===0&&this._cached_citeThreshold===0&&this._cached_startYearThreshold===1960&&this._cached_endYearThreshold===this._year){return YES}var b=Papercube.Paper.find(a);if(b){console.log("check:"+this._cached_startYearThreshold);return(b.get("refCount")>=this._cached_linkThreshold&&b.get("citeCount")>=this._cached_citeThreshold&&b.get("year")>=this._cached_startYearThreshold&&b.get("year")<=this._cached_endYearThreshold)}return NO},citeThresholdDidChange:function(){var b=this.get("content");if(!this.get("isVisible")||!b){return}var a=this.get("citeThreshold");if(a!=this._cached_citeThreshold){this._hideExistingLines();this._cached_citeThreshold=a;this._render()}}.observes("citeThreshold"),startYearThresholdDidChange:function(){var b=this.get("content");if(!this.get("isVisible")||!b){return}var a=this.get("startYearThreshold");if(a!=this._cached_startYearThreshold){this._hideExistingLines();this._cached_startYearThreshold=a;this._render()}}.observes("startYearThreshold"),endYearThresholdDidChange:function(){var b=this.get("content");if(!this.get("isVisible")||!b){return}var a=this.get("endYearThreshold");if(a!=this._cached_endYearThreshold){this._hideExistingLines();this._cached_endYearThreshold=a;this._render()}}.observes("endYearThreshold")});require("core");Papercube.DropDownView=SC.View.extend({emptyElement:['<div class="button">',"</div>",'<div class="list">',"<div>"].join(""),outlets:["button","list"],list:".list?",button:".button?",showingList:NO,isButton:NO,buttonLabel:"Button",buttonAction:null,selectionAction:null,lazyListGenFuncFunc:null,funcScope:this,value:"generic",orientationDown:YES,isEnabled:YES,_mouseDownHappened:NO,choices:["default1","default2"],isEnabledDidChange:function(){this.setClassName("disabled",!this.get("isEnabled"))}.observes("isEnabled"),valueDidChange:function(){if(!this.isButton){this.button.innerHTML=this.get("value")}}.observes("value"),mouseDown:function(a){if(!this.get("isEnabled")){return}if(!this.isButton){if(a.target.hasClassName("button")&&!this.button.hasClassName("active")){this.button.addClassName("active");this.showList()}else{if(a.target.hasClassName("button")&&this.button.hasClassName("active")){this.mouseExited(a)}}}else{this.button.addClassName("active");this._mouseDownHappened=YES;setTimeout(this._showList.bind(this),800)}},mouseUp:function(a){if(!this.get("isEnabled")){return}if(!this.isButton){if(a.target.hasClassName("list-item")){this.selectItem(a.target.innerHTML)}}else{if(a.target.hasClassName("button")&&!this._showingList){this._mouseDownHappened=NO;if(this.buttonAction){this.buttonAction.bind(this.funcScope)()}}else{if(a.target.hasClassName("list-item")){this.selectItem(a.target.innerHTML);this._mouseDownHappened=NO}}}},mouseExited:function(a){this.list.style.display="none";this._showingList=NO;this.button.removeClassName("active");this._mouseDownHappened=NO},_showList:function(){if(this._mouseDownHappened){this._showingList=YES;this.showList()}},selectItem:function(a){if(this.selectAction){this.selectAction.bind(this.funcScope,a)()}else{this.set("value",a)}this._showingList=NO;this.list.style.display="none"},showList:function(){this.list.innerHTML="";var a=[];if(this.lazyListGenFunc){a=this.lazyListGenFunc.bind(this.funcScope)()}else{a=this.get("choices")}var c=[];for(var b=0;b<a.length;b++){c.push('<div class="list-item">'+a[b]+"</div>")}this.list.innerHTML=c.join("");if(!this.get("orientationDown")){this.list.style.top=-((a.length+1)*18)+"px"}this._showingList=YES;if(a.length>0){this.list.style.display="block"}},init:function(){this.set("innerHTML",this.emptyElement);this.addClassName("drop-down");this.setClassName("down-orientation",this.get("orientationDown")&&!this.get("isButton"));this.setClassName("up-orientation",!this.get("orientationDown")&&!this.get("isButton"));arguments.callee.base.apply(this,arguments);this.list.style.display="none";if(this.isButton){this.button.innerHTML=this.buttonLabel}}});require("core");require("views/dropdown");Papercube.ViewSelectView=Papercube.DropDownView.extend({isViewingModeSelector:NO,viewingModeDidChange:function(){if(this.isViewingModeSelector){this.button.innerHTML=this.get("viewingMode")}}.observes("viewingMode"),viewChoiceDidChange:function(){if(!this.isViewingModeSelector){this.button.innerHTML=this.get("viewChoice")}}.observes("viewChoice"),mouseDown:function(a){if(a.target.hasClassName("button")&&!this.button.hasClassName("active")){this.button.addClassName("active");this.showList()}else{if(a.target.hasClassName("button")&&this.button.hasClassName("active")){this.mouseExited(a)}}},selectItem:function(a){if(this.isViewingModeSelector){Papercube.viewController.setViewingMode(a)}else{Papercube.viewController.setViewChoice(a)}arguments.callee.base.apply(this,arguments)},showList:function(){this.list.innerHTML="";if(this.isViewingModeSelector){var a=Papercube.viewController.get("viewingModes")}else{var a=Papercube.viewController.get("viewChoices")[Papercube.viewController.get("viewingMode")]}this.set("choices",a);arguments.callee.base.apply(this,arguments)}});require("core");Papercube.collaboratorController=SC.Object.create({depthStep:1,depthValueMax:5,depthValueMin:1,depth:1,defaultDepth:1,collabThresholdStep:1,collabThresholdValueMax:30,collabThresholdValueMin:1,collabThreshold:30,defaultCollabThreshold:1,paperThresholdStep:1,paperThresholdValueMax:30,paperThresholdValueMin:1,paperThreshold:30,defaultPaperThreshold:1,maxStrength:function(a){if(a){this.maxPaperStrength()}else{this.maxCollabStrength()}},minStrength:function(a){if(a){this.minPaperStrength()}else{this.minCollabStrength()}},maxCollabStrength:function(){if(this.get("collabThreshold")<this.get("collabThresholdValueMax")){this.set("collabThreshold",this.get("collabThreshold")+1)}},minCollabStrength:function(){if(this.get("collabThreshold")>this.get("collabThresholdValueMin")){this.set("collabThreshold",this.get("collabThreshold")-1)}},maxPaperStrength:function(){if(this.get("paperThreshold")<this.get("paperThresholdValueMax")){this.set("paperThreshold",this.get("paperThreshold")+1)}},minPaperStrength:function(){if(this.get("paperThreshold")>this.get("paperThresholdValueMin")){this.set("paperThreshold",this.get("paperThreshold")-1)}},maxDepth:function(){if(this.get("depth")<this.get("depthValueMax")){this.set("depth",this.get("depth")+1)}},minDepth:function(){if(this.get("depth")>this.get("depthValueMin")){this.set("depth",this.get("depth")-1)}},setDefaults:function(){this.set("depth",this.get("defaultDepth"));this.set("collabThreshold",this.get("defaultCollabThreshold"));this.set("paperThreshold",this.get("defaultPaperThreshold"))}});require("core");Papercube.ZoomButtonView=SC.View.extend({emptyElement:"<div></div>",zoomOut:YES,mouseDown:function(){if(this.get("zoomOut")){Papercube.canvasController.zoomOut()}else{Papercube.canvasController.zoomIn()}}});require("core");Papercube.paperGraphController=SC.Object.create({depthStep:1,depthValueMax:15,depthValueMin:1,depth:1,defaultDepth:1,refThresholdStep:1,refThresholdValueMax:30,refThresholdValueMin:0,refThreshold:0,defaultRefThreshold:0,citeThresholdStep:1,citeThresholdValueMax:30,citeThresholdValueMin:0,citeThreshold:0,defaultCiteThreshold:0,maxStrength:function(a){if(a){this.maxRefStrength()}else{this.maxCiteStrength()}},minStrength:function(a){if(a){this.minRefStrength()}else{this.minCiteStrength()}},maxRefStrength:function(){if(this.get("refThreshold")<this.get("refThresholdValueMax")){this.set("refThreshold",this.get("refThreshold")+1)}},minRefStrength:function(){if(this.get("refThreshold")>this.get("refThresholdValueMin")){this.set("refThreshold",this.get("refThreshold")-1)}},maxCiteStrength:function(){if(this.get("citeThreshold")<this.get("citeThresholdValueMax")){this.set("citeThreshold",this.get("citeThreshold")+1)}},minCiteStrength:function(){if(this.get("citeThreshold")>this.get("citeThresholdValueMin")){this.set("citeThreshold",this.get("citeThreshold")-1)}},maxDepth:function(){if(this.get("depth")<this.get("depthValueMax")){this.set("depth",this.get("depth")+1)}},minDepth:function(){if(this.get("depth")>this.get("depthValueMin")){this.set("depth",this.get("depth")-1)}},setDefaults:function(){this.set("refThreshold",this.get("defaultRefThreshold"));this.set("citeThreshold",this.get("defaultCiteThreshold"));this.set("depth",this.get("defaultDepth"))}});require("core");Papercube.paperStatController=SC.Object.create({citationSortOrder:"Title",citationSortOrderChoices:["Title","Date","Num Refs","Num Cites","Num Authors"],referenceSortOrder:"Title",referenceSortOrderChoices:["Title","Date","Num Refs","Num Cites","Num Authors"],authorSortOrder:"Name",authorSortOrderChoices:["Name","Num Papers","Num Collabs","Cite Count"]});require("core");Papercube.DepthButtonView=SC.View.extend({emptyElement:"<div></div>",maxDepth:YES,controller:null,mouseDown:function(){var a=this.get("controller");if(a){if(this.get("maxDepth")){a.maxDepth()}else{a.minDepth()}}}});require("core");Papercube.LeftView=SC.View.extend({mouseMoved:function(a){Papercube.canvasController.leftViewShowing=YES;this.addClassName("left-view-visible")},mouseExited:function(a){Papercube.canvasController.leftViewShowing=NO;this.removeClassName("left-view-visible")}});require("core");require("views/nodegraph");Papercube.CiteRefView=Papercube.NodeGraphView.extend({depth:1,linkThresholdBinding:"Papercube.citeRefController.linkThreshold",viewDirectionBinding:"Papercube.viewController.viewDirection",viewName:"citeref",contentTypeViewing:"Author",defaultTitleKey:"name",metaDataBoxHeightSmall:100,metaDataBoxWidthSmall:200,metaDataClassName:"author",performCustomRequest:function(b,a){Papercube.adaptor.getAuthorDetails(b,a)},generateCustomMetaData:function(a){var b=Papercube.Author.find(a);if(!b){return}this.metaDataView.childNodes[0].innerHTML=b.get("name");this.metaDataView.childNodes[1].innerHTML="<strong>Papers Published:</strong> "+Papercube.pluralizeString(" paper",b.get("paperCount"));this.metaDataView.childNodes[2].innerHTML="<strong>Number of Collaborators:</strong> "+Papercube.pluralizeString(" author",b.get("collaborators").length);this.metaDataView.childNodes[3].innerHTML="<strong>Author references:</strong> "+Papercube.pluralizeString(" other author",b.get("refAuthors").length);this.metaDataView.childNodes[4].innerHTML="<strong>Author is cited by:</strong> "+Papercube.pluralizeString(" other author",b.get("citeAuthors").length)},findCustomObject:function(a){return Papercube.Author.find(a)},findCustomObjectAttr:function(a){if(a){if(this._displayRefs){return a._attributes.refAuthors}return a._attributes.citeAuthors}},getGuidForRelation:function(a){if(a){return a[0]}},calcRelationWeight:function(a){return a[1]},findCustomObjectLabel:function(c){var b="";if(c){var e=c._attributes.name.split(" ");var a=e.length;for(var d=0;d<a;d++){if(d<a-1){b+=e[d].substr(0,1).toUpperCase()+" "}else{b+=e[d].substr(0,6)}}}return b},setBindingDefaults:function(){Papercube.citeRefController.setDefaults()},viewDirectionDidChange:function(){var a=this.get("content");Papercube.citeRefController.setPrompt();if(!this.get("isVisible")||!a){return}var b=this.get("viewDirection");if(b!=this._cached_viewDirection){this._hideExistingLines();this._cached_viewDirection=b;this._displayRefs=(b=="References");this._render()}}.observes("viewDirection")});require("core");Papercube.PapersPerYearView=SC.View.extend(Papercube.DragPanMixin,{displayPropertiesBinding:"Papercube.canvasController.displayProperties",viewDirectionBinding:"Papercube.viewController.viewDirection",citeThresholdBinding:"Papercube.papersPerYearController.citeThreshold",_cached_citeThreshold:1,refThresholdBinding:"Papercube.papersPerYearController.refThreshold",_cached_refThreshold:1,depthBinding:"Papercube.papersPerYearController.depth",hideBogusYearsBinding:"Papercube.papersPerYearController.hideBogusYears",_cached_hideBogusYears:false,_cached_depth:8,_displayRefs:YES,_canvasWidth:800,_canvasHeight:600,_h:0,_w:0,_x:0,_y:0,_rowHeight:1,_deepest:0,_renderTree:{},_foundGuid:null,_metaDataBoxWidthSmall:400,_metaDataBoxHeightSmall:120,outlets:["metaDataView"],svgCanvas:null,metaDataView:".meta-data?",_selection:null,_svgNodesCache:{},_svgYearTextCache:{},_svgYearLinesCache:{},_svgTextCache:{},_guidsNeeded:{},_papersPerYear:{},_shouldAnimate:NO,_shouldAnimateYears:NO,_hideMetaData:function(){this.metaDataView.removeClassName("show-meta-data-small")},_showMetaData:function(h,d){if(!h){return NO}var g=h.x+10;var e=h.y-20;var c=Papercube.canvasController.windowHeight()-30;var a=Papercube.canvasController.windowWidth()-10;if(e<30){e=30}if(g<20){g=20}if(e>(c-this._metaDataBoxHeightSmall)){e=(c-this._metaDataBoxHeightSmall)-30}if(g>(a-this._metaDataBoxWidthSmall)){g=(a-this._metaDataBoxWidthSmall)+1}this.metaDataView.style.top=e+"px";this.metaDataView.style.left=g+"px";this.metaDataView.addClassName("show-meta-data-small");var b=Papercube.Paper.find(d);if(!b){return}this.metaDataView.childNodes[0].innerHTML=b.get("title");var f=b.get("authorNames").join(", ");var i=f.length;this.metaDataView.childNodes[1].innerHTML=(i>150)?(f.substr(0,150)+"&hellip;"):f;this.metaDataView.childNodes[2].innerHTML=(b.get("publisher"))?b.get("publisher"):"";this.metaDataView.childNodes[3].innerHTML="<strong>Publication Date: </strong> "+b.get("year");this.metaDataView.childNodes[4].innerHTML=Papercube.pluralizeString(" reference",b.get("refCount"));this.metaDataView.childNodes[5].innerHTML=Papercube.pluralizeString(" citation",b.get("citeCount"))},_linesPinned:NO,nodeColor:"#FFCB2F",nodeColorSel:"yellow",nodeBorderColor:"#EAA400",nodeBorderColorSel:"#FFB60B",nodeTextColor:"#666",nodeOpacitySel:1,nodeOpacity:0.5,nodeBorderWidth:1,edgeRefColor:"blue",edgeCiteColor:"red",edgeWidth:1,yearLineWidth:1,nodeTextRatio:5,yearLineColor:"#666",yearTextColor:"#555",mouseMoved:function(o){var k=o.target.getAttribute("guid");if(k){if(this._foundGuid!=k&&!this._linesPinned){if(this._foundGuid){var c=Papercube.Paper.find(this._foundGuid);if(c){var l=c._attributes.references;var b=c._attributes.citations}var h=this._svgNodesCache[this._foundGuid].elm;if(h){h.removeAttributeNS(null,"fill-opacity");h.removeAttributeNS(null,"fill");h.removeAttributeNS(null,"stroke-width");h.removeAttributeNS(null,"stroke")}var g=l.length;for(var e=0;e<g;e++){var h=(this._svgNodesCache[l[e]])?this._svgNodesCache[l[e]].elm:null;if(h){h.removeAttributeNS(null,"fill-opacity");h.removeAttributeNS(null,"stroke-width");h.removeAttributeNS(null,"stroke")}}var g=b.length;for(var e=0;e<g;e++){var h=(this._svgNodesCache[b[e]])?this._svgNodesCache[b[e]].elm:null;if(h){h.removeAttributeNS(null,"fill-opacity");h.removeAttributeNS(null,"stroke-width");h.removeAttributeNS(null,"stroke")}}}this._removeEdges();this._foundGuid=k;var c=Papercube.Paper.find(k);var b=[];var l=[];if(c){l=c._attributes.references;b=c._attributes.citations}var h=this._svgNodesCache[k].elm;if(h){h.setAttributeNS(null,"fill",this.nodeColorSel);h.setAttributeNS(null,"fill-opacity",this.nodeOpacitySel);h.setAttributeNS(null,"stroke-width",this.nodeBorderWidth*(PERYEAR_DEFAULT_SCALE-this._z));h.setAttributeNS(null,"stroke",this.nodeBorderColorSel)}var f=parseInt(h.attributes[0].nodeValue,0);var j=parseInt(h.attributes[2].nodeValue,0);var d=parseInt(h.attributes[1].nodeValue,0)+((this._displayRefs)?j:-j);var a=this.edgeWidth*(PERYEAR_DEFAULT_SCALE-this._z);var g=l.length;for(var e=0;e<g;e++){var h=(this._svgNodesCache[l[e]])?this._svgNodesCache[l[e]].elm:null;if(h){var q=parseInt(h.attributes[0].nodeValue,0);var p=parseInt(h.attributes[1].nodeValue,0)-((this._displayRefs)?parseInt(h.attributes[2].nodeValue,0):-parseInt(h.attributes[2].nodeValue,0));var n=f;var m=(d+p)/2;this._createSVGElement("path",{d:("M"+f+" "+d+" Q "+n+" "+m+" "+q+" "+p),fill:"none",stroke:"blue","stroke-width":a},{},EDGE);h.setAttributeNS(null,"fill-opacity",this.nodeOpacitySel);h.setAttributeNS(null,"stroke-width",a);h.setAttributeNS(null,"stroke",this.edgeRefColor)}}var g=b.length;for(var e=0;e<g;e++){var h=(this._svgNodesCache[b[e]])?this._svgNodesCache[b[e]].elm:null;if(h){var q=parseInt(h.attributes[0].nodeValue,0);var p=parseInt(h.attributes[1].nodeValue,0)-((this._displayRefs)?parseInt(h.attributes[2].nodeValue,0):-parseInt(h.attributes[2].nodeValue,0));var n=f;var m=(d+p)/2;this._createSVGElement("path",{d:("M"+f+" "+d+" Q "+n+" "+m+" "+q+" "+p),fill:"none",stroke:"red","stroke-width":a},{},EDGE);h.setAttributeNS(null,"fill-opacity",this.nodeOpacitySel);h.setAttributeNS(null,"stroke-width",a);h.setAttributeNS(null,"stroke",this.edgeCiteColor)}}if(SC.isSafari()){this.svgCanvas.setAttributeNS(null,"width",this._pW+1);this.svgCanvas.setAttributeNS(null,"width",this._pW)}}this._showMetaData({x:Event.pointerX(o),y:Event.pointerY(o)},k)}else{this._hideMetaData()}},mouseExited:function(a){this._hideMetaData()},mouseDown:function(a){var b=a.target.getAttribute("guid");var c=a.target.getAttribute("fanType");if(b&&c){this._mouseDownGUID=b;Papercube.canvasController.showFan(Event.pointerX(a),Event.pointerY(a),"papersperyear",(c+"Fan"));return YES}else{return this.handleMouseDownDrag(a)}return NO},pinLinesForPaper:function(){this._linesPinned=!this._linesPinned},displayPropertiesDidChange:function(a){if(!this.get("isVisible")){return NO}var e=this.get("displayProperties");var d=e.height-20;var j=e.width;var i=e.left;var g=e.top;var f=e.zoomValue;var b=e.portalWidth;var k=e.portalHeight;this._linesPinned=NO;this.setStyle({height:(k-20)+"px",width:b+"px",left:"20px",top:"20px"});this._frame={height:k-20,width:b,x:20,y:20};this.svgCanvas.setAttributeNS(null,"height",k);this.svgCanvas.setAttributeNS(null,"width",b);this._canvasHeight=d;this._canvasWidth=j;var c=(((this._h!=d||this._w!=j))&&this._z==f);this._h=d;this._w=j;this._x=i;this._y=g;this._z=f;this._pH=k-20;this._pW=b;this._zI=f/PERYEAR_DEFAULT_SCALE;this._hideMetaData();if(this.svgGroup){this.svgGroup.setAttributeNS(null,"transform","scale("+this._zI+") translate("+(this._x/this._zI)+","+(this._y/this._zI)+")")}if(c&&typeof a!="boolean"&&this._cachedContent){Papercube.canvasController.zoomOutFull();this._deepest=1;this._foundGuid=null;this._render()}}.observes("displayProperties"),redrawParamsDidChange:function(){var b=this.get("content");if(!this.get("isVisible")||!b){return NO}Papercube.canvasController.set("zoomValueMax",20);Papercube.canvasController.set("zoomStep",1);this._displayRefs=(this.get("viewDirection")=="References");this.setClassName("citations",!this._displayRefs);this.setClassName("references",this._displayRefs);if(!this._cachedContent||this._cachedContent.get("guid")!==b.get("guid")){this._hideMetaData();Papercube.canvasController.zoomOutFull();this._svgNodesCache={};this._svgTextCache={};this._svgYearTextCache={};this._svgYearLinesCache={};this._svgRels={};this._clearSVG();Papercube.papersPerYearController.setDefaults()}this._deepest=1;this._foundGuid=null;this._cachedContent=b;var d=this.get("depth");var a=this.get("citeThreshold");var c=this.get("refThreshold");var e=this.get("hideBogusYears");if((this._cached_citeThreshold!=a||this._cached_citeThreshold!=c||this._cached_hideBogusYears!=e||this._cached_depth!=d)&&this.get("displayProperties").zoomValue!=1){this._cached_citeThreshold=a;this._cached_refThreshold=c;this._cached_depth=d;this._cached_hideBogusYears=e;Papercube.canvasController.zoomOutFull();return}this._cached_citeThreshold=a;this._cached_refThreshold=c;this._cached_depth=d;this._cached_hideBogusYears=e;this.displayPropertiesDidChange(YES);this._render()}.observes("content","isVisible","viewDirection","refThreshold","depth","citeThreshold","hideBogusYears"),_render:function(){this._guidsNeeded={};this._renderTree={};this._papersPerYear={};this._checkForData(this._cachedContent.get("guid"),0);this._removeEdges();var j=PERYEAR_DEFAULT_SCALE/this._z;this.svgYearLines.setAttributeNS(null,"stroke-width",this.yearLineWidth*j);var C=[];var q=[];var v=[];var l=[];this._subjectArr=[];var aa=this.nodeTextRatio;if(this._deepest<this._cached_depth){var R=[];for(var o in this._guidsNeeded){if(R.indexOf(o)==-1){R.push(o)}}if(R.length>0){console.log("retrieving "+R.length+" papers");Papercube.searchController.set("showRequestSpinner",YES);var D=function(){this.redrawParamsDidChange()}.bind(this,this.get("content"));setTimeout(this._waitToCallServer.bind(this,R,D),500);this._cachedContent.set((this._displayRefs?"maxRefLevel":"maxCiteLevel"),this._deepest)}else{Papercube.searchController.set("showRequestSpinner",NO)}}else{Papercube.searchController.set("showRequestSpinner",NO)}var K=[];var G=0;var Z=0;var E=0;for(var o in this._papersPerYear){var f=this._papersPerYear[o];f.sort(function(i,h){var r=i.get("year");var k=h.get("year");if(r==k){return i._attributes.title<h._attributes.title}if(r<k){return -1}return 1});K.push(f);E+=f.length;if(f.length>Z){Z=f.length}G++}K.sort(function(i,h){if(!i[0]||!h[0]){return 1}var r=i[0].get("year");var k=h[0].get("year");if(r>k){return -1}return 1});var Y=this._displayRefs;this._shouldAnimate=(E<40);this._shouldAnimateYears=(E<100);var N=(this._w-120)*j;var W=this._h/(G+1)*j;var L=(Y)?W/2:this._h*j-W/2;var u=this._cachedContent._attributes.guid;var p=K.length;var g=this._cachedContent.get("year");var P=(W/4);var M=(N/2)+70*j;var c={cx:M,cy:L,r:P,fanType:"focused",guid:u};var Q={"font-size":(W/4)/aa,x:M,y:L,guid:u};var z=30*PERYEAR_DEFAULT_SCALE;var e=(this._w-30)*PERYEAR_DEFAULT_SCALE;var t=this._w*PERYEAR_DEFAULT_SCALE;var X=12*j;var A={x1:z,y1:(L-W/2),x2:t,y2:(L-W/2)};var I={x:z,y:L,"text-anchor":"left","font-size":X};var J={x:e,y:L,"text-anchor":"right","font-size":X};var F=this._cachedContent._attributes.title.substr(0,80);if(!this._svgNodesCache[u]){this._createNode(u,c,Q,F);this._createYearLine(u,A);this._createYearText(("L"+u),I,(g+" - '"+F+"'"));this._createYearText(("R"+u),J,g)}else{this._handleLinesTransition(u,A,I,J);this._handleNodeTransition(u,c,Q)}C.push(("L"+u));C.push(("R"+u));q.push(u);v.push(u);l.push(u);L+=(Y)?W:-W;var B=5*j;var m=15*j;for(var T=0;T<p;T++){var f=K[T];var d=f.length;var g=f[0].get("year");var H=N/(d);var P=Math.min(W/4,H/3);var n=P/aa;var M=70*j+H/2;var s=(L-W/2);var A={x1:z,y1:s,x2:t,y2:s};var I={x:z,y:s+m,"text-anchor":"left","font-size":X};var J={x:e,y:s+m,"text-anchor":"right","font-size":X};var a=g.toString();if(!this._svgYearLinesCache[a]){this._createYearLine(a,A);this._createYearText(("L"+g),I,g);this._createYearText(("R"+g),J,g)}else{this._handleLinesTransition(a,A,I,J)}C.push(("L"+g));C.push(("R"+g));q.push(a);if(d/300<1){var V=L;for(var U=0;U<d;U++){var b=f[U];var S=b._attributes.guid;if(S!=u){var c={cx:M,cy:V,r:P,fanType:"unfocused",guid:S};var Q={"font-size":n,x:M,y:V,guid:S};if(!this._svgNodesCache[S]){this._createNode(S,c,Q,b._attributes.title)}else{this._handleNodeTransition(S,c,Q)}v.push(S);l.push(S);M+=H}}}else{var o="ERR_"+g;var O={x:(N/2)+70,y:L+5,fill:"#777","text-anchor":"middle","font-size":14};this._handleErrorText(o,O,svgText);l.push(o)}L+=(Y)?W:-W}Papercube.animationController.addSubjects(this._subjectArr,this.svgCanvas,this._pH);this._clearSVGElms(this._svgNodesCache,v,this.svgNodes);this._clearSVGElms(this._svgTextCache,l,this.svgText);this._clearSVGElms(this._svgYearLinesCache,q,this.svgYearLines);this._clearSVGElms(this._svgYearTextCache,C,this.svgYearText)},_waitToCallServer:function(b,a){Papercube.adaptor.getPaperDetails(b,a)},_handleErrorParams:function(b,f){if(!this._svgTextCache[b]){this._svgTextCache[b]={elm:this._createSVGElement("text",f,{},TEXT)};this._svgTextCache[b].elm.appendChild(document.createTextNode("{ There are more than 300 papers for this year! That's too many to display. }"))}else{var d=this._svgTextCache[b].elm;var e=this._svgTextCache[b].params;var a=NO;var c={};if(e.x!=f.x){a=YES;c.x={start:e.x,end:f.x}}if(e.y!=f.y){a=YES;c.y={start:e.y,end:f.y}}if(a){this._subjectArr.push({elm:svgText[b].elm,props:c,duration:250,isSVG:YES})}}},_handleNodeTransition:function(h,c,e){var a=this._svgNodesCache[h].elm;var j=this._svgTextCache[h].elm;var g=this._svgTextCache[h].params;var d=this._svgNodesCache[h].params;a.removeAttributeNS(null,"fill-opacity");a.removeAttributeNS(null,"fill");a.removeAttributeNS(null,"stroke-width");a.removeAttributeNS(null,"stroke");if(this._shouldAnimate){var i=NO;var b={};var f={};if(d.cx!=c.cx){b.cx={start:d.cx,end:c.cx};f.x={start:g.x,end:e.x};i=YES}if(d.cy!=c.cy){b.cy={start:d.cy,end:c.cy};f.y={start:g.y,end:e.y};i=YES}if(d.r!=c.r){b.r={start:d.r,end:c.r};f["font-size"]={start:g["font-size"],end:e["font-size"]};i=YES}if(i){this._subjectArr.push({elm:a,props:b,duration:250,isSVG:YES});this._subjectArr.push({elm:j,props:f,duration:250,isSVG:YES})}}else{if(d.cx!=c.cx){a.setAttributeNS(null,"cx",Math.floor(c.cx));j.setAttributeNS(null,"x",Math.floor(c.cx))}if(d.cy!=c.cy){a.setAttributeNS(null,"cy",Math.floor(c.cy));j.setAttributeNS(null,"y",Math.floor(c.cy))}if(d.r!=c.r){a.setAttributeNS(null,"r",Math.floor(c.r));j.setAttributeNS(null,"font-size",Math.floor(e["font-size"]))}}this._svgNodesCache[h].params=c;this._svgTextCache[h].params=e},_handleLinesTransition:function(k,f,b,i){var g=NO;var n=NO;var c=NO;var h={};var p={};var o={};var j=this._svgYearLinesCache[k].elm;var m=this._svgYearLinesCache[k].params;var l=this._svgYearTextCache["L"+k].elm;var a=this._svgYearTextCache["L"+k].params;var e=this._svgYearTextCache["R"+k].elm;var d=this._svgYearTextCache["R"+k].params;if(this._shouldAnimateYears){if(m.x1!=f.x1){o.x1={start:m.x1,end:f.x1};c=YES}if(m.x2!=f.x2){o.x2={start:m.x2,end:f.x2};c=YES}if(m.y1!=f.y1){o.y1={start:m.y1,end:f.y1};c=YES}if(m.y2!=f.y2){o.y2={start:m.y2,end:f.y2};c=YES}if(a.x!=b.x){h.x={start:a.x,end:b.x};g=YES}if(a.y!=b.y){h.y={start:a.y,end:b.y};g=YES}if(d.x!=i.x){p.x={start:d.x,end:i.x};n=YES}if(d.y!=i.y){p.y={start:d.y,end:i.y};n=YES}if(c){this._subjectArr.push({elm:j,props:o,duration:250,isSVG:YES})}if(g){this._subjectArr.push({elm:l,props:h,duration:250,isSVG:YES})}if(n){this._subjectArr.push({elm:e,props:p,duration:250,isSVG:YES})}}else{if(m.x1!=f.x1){j.setAttributeNS(null,"x1",Math.floor(f.x1))}if(m.x2!=f.x2){j.setAttributeNS(null,"x2",Math.floor(f.x2))}if(m.y1!=f.y1){j.setAttributeNS(null,"y1",Math.floor(f.y1))}if(m.y2!=f.y2){j.setAttributeNS(null,"y2",Math.floor(f.y2))}if(a.x!=b.x){l.setAttributeNS(null,"x",Math.floor(b.x))}if(a.y!=b.y){l.setAttributeNS(null,"y",Math.floor(b.y))}if(d.x!=i.x){e.setAttributeNS(null,"x",Math.floor(i.x))}if(d.y!=i.y){e.setAttributeNS(null,"y",Math.floor(i.y))}}this._svgYearLinesCache[k].params=f;this._svgYearTextCache["R"+k].params=i;this._svgYearTextCache["L"+k].params=b},_createNode:function(a,d,b,c){this._svgNodesCache[a]={elm:this._createSVGElement("circle",d,{},NODE),params:d};this._svgTextCache[a]={elm:this._createSVGElement("text",b,{},TEXT),params:b};this._svgTextCache[a].elm.appendChild(document.createTextNode(c.substr(0,20)))},_createYearLine:function(a,b){this._svgYearLinesCache[a]={elm:this._createSVGElement("line",b,{},YEARLINE),params:b}},_createYearText:function(a,c,b){this._svgYearTextCache[a]={elm:this._createSVGElement("text",c,{},YEARTEXT),params:c};this._svgYearTextCache[a].elm.appendChild(document.createTextNode(b))},_checkForData:function(l,a){var c=Papercube.Paper.find(l);var j=[];if(c&&this._renderTree[l]!=1){if(!this._renderTree[l]){this._renderTree[l]=0}this._renderTree[l]++;j=(this._displayRefs)?c._attributes.references:c._attributes.citations;var e=j.length;var d=[];for(var f=0;f<e;f++){var g=j[f];var b=Papercube.Paper.find(g);if(b&&(!this._cached_hideBogusYears||(this._cached_hideBogusYears&&b._attributes.fixedyear==="1"))){if(this._cached_citeThreshold<=b.get("citeCount")&&this._cached_refThreshold<=b.get("refCount")){d.push(g)}}else{if(!this._cached_hideBogusYears){this._guidsNeeded[g]=1}}}var k=c.get("year");if(this._cachedContent._attributes.guid!=l){if(!this._papersPerYear[k]){this._papersPerYear[k]=[]}this._papersPerYear[k].push(c)}e=d.length;j=d}if(this._deepest<a){this._deepest=a}var e=j.length;var h=a+1;if(this._renderTree[l]==1&&a<this._cached_depth){for(var f=0;f<e;f++){var m=j[f];this._checkForData(m,h)}}},_removeEdges:function(){var a=this.svgEdges;while(a.firstChild){a.removeChild(a.firstChild)}},_clearSVG:function(){var a=this.svgNodes;while(a.firstChild){a.removeChild(a.firstChild)}var a=this.svgEdges;while(a.firstChild){a.removeChild(a.firstChild)}var a=this.svgText;while(a.firstChild){a.removeChild(a.firstChild)}var a=this.svgYearLines;while(a.firstChild){a.removeChild(a.firstChild)}var a=this.svgYearText;while(a.firstChild){a.removeChild(a.firstChild)}},_createSVGElement:function(e,a,c,d){var f=document.createElementNS("http://www.w3.org/2000/svg",e);if(a){for(var b in a){if(isNaN(a[b])||b.indexOf("opacity")!=-1){f.setAttributeNS(null,b,a[b])}else{f.setAttributeNS(null,b,Math.floor(a[b]))}}}switch(d){case NODE:this.svgNodes.appendChild(f);break;case EDGE:this.svgEdges.appendChild(f);break;case TEXT:this.svgText.appendChild(f);break;case YEARLINE:this.svgYearLines.appendChild(f);break;case YEARTEXT:this.svgYearText.appendChild(f);break;default:break}return f},_clearSVGElms:function(d,f,a){for(var b in d){if(f.indexOf(b)==-1){try{a.removeChild(d[b].elm);delete d[b].elm;delete d[b].params;delete d[b]}catch(c){try{delete d[b]}catch(c){}}}}},init:function(){arguments.callee.base.apply(this,arguments);this.svgCanvas=document.createElementNS("http://www.w3.org/2000/svg","svg");this.rootElement.appendChild(this.svgCanvas);this.svgGroup=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgCanvas.appendChild(this.svgGroup);this.svgNodes=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgNodes);this.svgText=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgText);this.svgText.setAttributeNS(null,"fill",this.nodeTextColor);this.svgText.setAttributeNS(null,"text-anchor","middle");this.svgText.setAttributeNS(null,"style","cursor: default");this.svgNodes.setAttributeNS(null,"fill",this.nodeColor);this.svgNodes.setAttributeNS(null,"fill-opacity",this.nodeOpacity);this.svgYearText=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgYearText);this.svgYearText.setAttributeNS(null,"fill",this.yearTextColor);this.svgYearLines=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgYearLines);this.svgYearLines.setAttributeNS(null,"stroke",this.yearLineColor);this.svgEdges=document.createElementNS("http://www.w3.org/2000/svg","g");this.svgGroup.appendChild(this.svgEdges);var f=function(g){Papercube.viewController.setContentToViewFromGUID(this._mouseDownGUID,"Paper",NO)}.bind(this);var c=function(g){window.open(Papercube.Paper.find(this._mouseDownGUID).get("url"))}.bind(this);var e=function(g){Papercube.viewController.saveObject(this._mouseDownGUID,"Paper")}.bind(this);var a=function(g){Papercube.canvasController.setZoomToPointerLocation(Event.pointerX(g),Event.pointerY(g),NO)}.bind(this);var b=function(g){Papercube.canvasController.setZoomToPointerLocation(Event.pointerX(g),Event.pointerY(g),YES)}.bind(this);var d=function(g){this.pinLinesForPaper()}.bind(this);Papercube.canvasController.registerFans("papersperyear",{focusedFan:{CiteSeer:c,Save:e,"Pin Lines":d,"Zoom +":b,"Zoom -":a},unfocusedFan:{CiteSeer:c,Save:e,"Pin Lines":d,Refocus:f,"Zoom +":b,"Zoom -":a}})}});require("core");Papercube.PaperstatListView=SC.View.extend({emptyElement:"<div></div>",isAuthorList:NO,subView:SC.View.extend({emptyElement:"<div></div>",contentDidChange:function(){var d=this.get("content");if(!d){return}var a=d.get("guid");if(this.owner.isAuthorList){var b="<strong>Papers Published:</strong> "+Papercube.pluralizeString(" paper",d.get("paperCount"))+"<br/>";b+="<strong>Number of Collaborators:</strong> "+Papercube.pluralizeString(" author",d.get("collaborators").length)+"<br/>";b+="<strong>Author references:</strong> "+Papercube.pluralizeString(" other author",d.get("refAuthors").length)+"<br/>";b+="<strong>Author is cited by:</strong> "+Papercube.pluralizeString(" other author",d.get("citeAuthors").length);var f=['<div class="title" fanType="author" guid="'+a+'">',d.get("name"),"</div>",'<div class="bottom" fanType="author" guid="'+a+'">','<div class="stats" fanType="author" guid="'+a+'">',b,"</div>","</div>"]}else{var e=d.get("title");e=e.substr(0,80)+((e.length>80)?"&hellip;":"")+" ("+d.get("year")+")";var c=Papercube.pluralizeString(" ref",d.get("refCount"))+", "+Papercube.pluralizeString(" cite",d.get("citeCount"));var f=['<div class="title" fanType="paper" guid="'+a+'">',e,"</div>",'<div class="bottom" fanType="paper" guid="'+a+'">','<div class="authors" fanType="paper" guid="'+a+'">',d.get("authorNames").join(", ").substr(0,100),"</div>",'<div class="info" fanType="paper" guid="'+a+'">','<div class="left" fanType="paper" guid="'+a+'">',c,"</div>","</div>","</div>"]}this.set("innerHTML",f.join(""))}.observes("content"),mouseExited:function(a){this.rootElement.childNodes[0].className="title";this.rootElement.childNodes[1].className="bottom"},mouseOver:function(a){this.rootElement.childNodes[0].className="title sel";this.rootElement.childNodes[1].className="bottom show"}}),contentDidChange:function(){var c=this.get("content");var d=this.get("childNodes");for(var b=0;b<d.length;b++){this.removeChild(d[b])}for(var b=0;b<c.length;b++){var a=this.subView.create({owner:this});a.set("content",c[b]);this.appendChild(a)}}.observes("content")});require("core");require("views/paperstatlist");Papercube.PaperstatView=SC.View.extend({authorSortOrderBinding:"Papercube.paperStatController.authorSortOrder",referenceSortOrderBinding:"Papercube.paperStatController.referenceSortOrder",citationSortOrderBinding:"Papercube.paperStatController.citationSortOrder",_mouseDownGUID:null,_direction:0,outlets:["titleLabel","abstractTxt","sourceURL","citeseerURL","sourceType","refCount","citeCount","citeList","refList","papersPerYear","graph","refButton","citeButton","stats","authorCount","authorList"],titleLabel:".title?",abstractTxt:".abstract?",sourceURL:".source-url?",sourceType:".source-type?",citeseerURL:".citeseer-url?",refCount:".ref-count?",citeCount:".cite-count?",authorCount:".author-count?",papersPerYear:".papersperyear?",graph:".data?",stats:".stats?",refButton:SC.ButtonView.extend({action:function(){this.owner._direction=0;this.rootElement.className="refs-button sel";this.owner.citeButton.rootElement.className="refs-button";this.owner._renderGraph()}}).outletFor(".refs-button?"),citeButton:SC.ButtonView.extend({action:function(){this.owner._direction=1;this.rootElement.className="cites-button sel";this.owner.refButton.rootElement.className="cites-button";this.owner._renderGraph()}}).outletFor(".cites-button?"),refList:Papercube.PaperstatListView.outletFor(".references-list?"),citeList:Papercube.PaperstatListView.outletFor(".citations-list?"),authorList:Papercube.PaperstatListView.extend({isAuthorList:YES}).outletFor(".author-list?"),contentDidChange:function(){var j=this.get("content");if(!this.get("isVisible")||!j){return NO}this.stats.style.display="";if(!this._cachedContent||this._cachedContent.get("guid")!=j.get("guid")){this.papersPerYear.className="papersperyear";this.papersPerYear.className="papersperyear show";this.abstractTxt.className="abstract";this.abstractTxt.className="abstract show";this._cachedContent=j;this._clearGraph()}var g=function(){this.contentDidChange()}.bind(this);if(!j.get("allDataRetrieved")){Papercube.adaptor.getAllDataForPaper(j.get("guid"),g);var f=Papercube.viewController.collectNeededPaperGUIDs([].concat(j.get("references"),j.get("citations")),[]);if(f.guids.length>0){Papercube.adaptor.getPaperDetails(f.guids,g);this._renderList("refs",YES);this._renderList("cites",YES);this._clearGraph()}}else{this._renderList("refs",NO);this._renderList("cites",NO);this.refButton.action()}var d=[];var e=j.get("authors");for(var h=0;h<e.length;h++){var k=Papercube.Author.find(e[h].guid);if(!k){d.push(e[h].guid)}}if(d.length>0){Papercube.adaptor.getAuthorDetails(d,g);this._renderList("authors",YES)}else{this._renderList("authors",NO)}Papercube.canvasController.set("zoomValueMax",1);Papercube.canvasController.set("zoomStep",1);this.titleLabel.innerHTML=j.get("title").escapeHTML()+" ("+j.get("year")+")";this.abstractTxt.innerHTML=j.get("abstract").escapeHTML();var b=j.get("source");if(b){this.sourceURL.innerHTML=b;this.sourceURL.onmousedown=function(){window.open(b)}}else{this.sourceURL.innerHTML="";this.sourceURL.onmousedown=null}var l=j.get("format");if(l){this.sourceType.innerHTML=l}else{this.sourceType.innerHTML=""}var c=j.get("url");if(c){this.citeseerURL.innerHTML=c;this.citeseerURL.onmousedown=function(){window.open(c)}}else{this.citeseerURL.innerHTML="";this.citeseerURL.onmousedown=null}}.observes("content","isVisible","referenceSortOrder","citationSortOrder","authorSortOrder"),_renderList:function(h,f){var g=this.get("content");if(!g){if(h=="refs"){this.refList.set("content",[])}else{if(h=="cites"){this.citeList.set("content",[])}else{if(h=="authors"){this.authorList.set("content",[])}}}return}if(h!="authors"){var k=(h=="refs")?g.get("references"):g.get("citations");var l=[];for(var e=0;e<k.length;e++){var b=Papercube.Paper.find(k[e]);if(b){l.push(b)}}var d=(h=="refs")?this.get("referenceSortOrder"):this.get("citationSortOrder");switch(d){case"Title":l.sort(function(m,i){var o=m._attributes.title.toLowerCase();var n=i._attributes.title.toLowerCase();if(o==n){return 0}if(o<n){return -1}return 1});break;case"Date":l.sort(function(m,i){var o=m.get("year");var n=i.get("year");if(o==n){return m._attributes.title.toLowerCase()<i._attributes.title.toLowerCase()}if(o>n){return -1}return 1});break;case"Num Refs":l.sort(function(m,i){var o=m.get("refCount");var n=i.get("refCount");if(o==n){return 0}if(o>n){return -1}return 1});break;case"Num Cites":l.sort(function(m,i){var o=m.get("citeCount");var n=i.get("citeCount");if(o==n){return 0}if(o>n){return -1}return 1});break;case"Num Authors":l.sort(function(m,i){var o=m.get("authorCount");var n=i.get("authorCount");if(o==n){return 0}if(o>n){return -1}return 1});break}if(h=="refs"){this.refCount.innerHTML=" ("+l.length+")";this.refList.set("content",l);this.refList.setClassName("show",(l.length!=0))}else{this.citeCount.innerHTML=" ("+l.length+")";this.citeList.set("content",l);this.citeList.setClassName("show",(l.length!=0))}}else{var a=g.get("authors");var j=[];for(var e=0;e<a.length;e++){var c=Papercube.Author.find(a[e].guid);if(c){j.push(c)}}var d=this.get("authorSortOrder");switch(d){case"Name":j.sort(function(m,i){var o=m._attributes.name.toLowerCase();var n=i._attributes.name.toLowerCase();if(o==n){return 0}if(o<n){return -1}return 1});break;case"Num Papers":j.sort(function(m,i){var o=m.get("paperCount");var n=i.get("paperCount");if(o==n){return 0}if(o>n){return -1}return 1});break;case"Num Collabs":j.sort(function(m,i){var o=m.get("collaborators").length;var n=i.get("collaborators").length;if(o==n){return 0}if(o>n){return -1}return 1});break;case"Cite Count":j.sort(function(m,i){var o=m.get("citeAuthors").length;var n=i.get("citeAuthors").length;if(o==n){return 0}if(o>n){return -1}return 1});break}this.authorCount.innerHTML=" ("+j.length+")";this.authorList.set("content",j);this.authorList.setClassName("show",(j.length!=0))}},_renderGraph:function(){this._clearGraph();var b=(this._direction)?this._cachedContent.get("citations"):this._cachedContent.get("references");var h=135;var j=300;var d={};var l=0;var g=0;for(var p=0;p<b.length;p++){var f=Papercube.Paper.find(b[p]);var o="?";if(f){o=f.get("year")}if(!d[o]){l++;d[o]=0}d[o]++;if(d[o]>g){g=d[o]}}var m=[];for(var s in d){m.push([s,d[s]])}m.sort(function(t,i){if(t[0]<i[0]){return 1}return -1});var e="";var a=h/l;var q=j/g;var n=(a-2*a/3);var r=((n/2)-12/2);for(var p=0;p<m.length;p++){var c=m[p][1];var k=(c*q>50)?Papercube.pluralizeString(" Paper",c)+"&nbsp;":"";e+='<div class="row" style="height:'+a+'px;"><div class="year" style="margin-top:'+((a/2)-11/2)+"px; height:"+(a-2*a/3)+'px;">'+m[p][0]+'</div><div class="bar" style="padding-top: '+r+"px; margin-top:"+(a-2*a/3)+"px; width:"+(c*q)+"px; height:"+n+'px;">'+k+"</div></div>"}this.graph.innerHTML=e},_clearGraph:function(){this.graph.innerHTML=""},mouseDown:function(a){var b=a.target.getAttribute("guid");var c=a.target.getAttribute("fanType");if(b){this._mouseDownGUID=b;Papercube.canvasController.showFan(Event.pointerX(a),Event.pointerY(a),"paperstat",(c+"Fan"));return YES}return NO},init:function(){arguments.callee.base.apply(this,arguments);var e=function(f){Papercube.viewController.setContentToViewFromGUID(this._mouseDownGUID,"Paper",NO)}.bind(this);var b=function(f){Papercube.viewController.viewAuthor(this._mouseDownGUID)}.bind(this);var c=function(f){window.open(Papercube.Paper.find(this._mouseDownGUID).get("url"))}.bind(this);var d=function(f){Papercube.viewController.saveObject(this._mouseDownGUID,"Paper")}.bind(this);var a=function(f){Papercube.viewController.saveObject(this._mouseDownGUID,"Author")}.bind(this);Papercube.canvasController.registerFans("paperstat",{authorFan:{Save:a,Refocus:b},paperFan:{CiteSeer:c,Save:d,Refocus:e}})}});require("core");require("views/nodegraph");Papercube.CollaboratorView=Papercube.NodeGraphView.extend({depthBinding:"Papercube.collaboratorController.depth",linkThresholdBinding:"Papercube.collaboratorController.collabThreshold",paperThresholdBinding:"Papercube.collaboratorController.paperThreshold",_cached_paperThreshold:0,nodeColor:"#BCE510",nodeColorSel:"#E7F738",nodeBorderColor:"#ACD20E",nodeBorderColorSel:"#CCDA31",nodeTextColor:"#7E6C53",viewName:"collaborator",contentTypeViewing:"Author",defaultTitleKey:"name",edgeTextPosOffset:0.4,metaDataBoxHeightSmall:100,metaDataBoxWidthSmall:100,metaDataClassName:"author",performCustomRequest:function(b,a){Papercube.adaptor.getAuthorDetails(b,a)},generateCustomMetaData:function(a){var b=Papercube.Author.find(a);if(!b){return}this.metaDataView.childNodes[0].innerHTML=b.get("name");this.metaDataView.childNodes[1].innerHTML="<strong>Papers Published:</strong> "+Papercube.pluralizeString(" paper",b.get("paperCount"));this.metaDataView.childNodes[2].innerHTML="<strong>Number of Collaborators:</strong> "+Papercube.pluralizeString(" author",b.get("collaborators").length);this.metaDataView.childNodes[3].innerHTML="<strong>Author references:</strong> "+Papercube.pluralizeString(" other author",b.get("refAuthors").length);this.metaDataView.childNodes[4].innerHTML="<strong>Author is cited by:</strong> "+Papercube.pluralizeString(" other author",b.get("citeAuthors").length)},findCustomObject:function(a){return Papercube.Author.find(a)},findCustomObjectAttr:function(a){if(a){return a._attributes.collaborators}},getGuidForRelation:function(a){if(a){return a[0]}},calcRelationWeight:function(a){return a[1]},findCustomObjectLabel:function(c){var b="";if(c){var e=c._attributes.name.split(" ");var a=e.length;for(var d=0;d<a;d++){if(d<a-1){b+=e[d].substr(0,1).toUpperCase()+" "}else{b+=e[d].substr(0,6)}}}return b},setBindingDefaults:function(){Papercube.collaboratorController.setDefaults()},relationMeetsCustomThreshold:function(a){if(a[1]>=this._cached_linkThreshold){if(this._cached_paperThreshold!=0){var b=Papercube.Author.find(a[0]);if(b){return(b._attributes.papers.length>=this._cached_paperThreshold)}}return YES}return NO},paperThresholdDidChange:function(){var b=this.get("content");if(!this.get("isVisible")||!b){return}var a=this.get("paperThreshold");if(a!=this._cached_paperThreshold){this._hideExistingLines();this._cached_paperThreshold=a;this._render()}}.observes("paperThreshold")});require("core");Papercube.adaptor=SC.Server.create({base:"/beta/api/request.php",prefix:["Papercube"],requestIndex:0,requests:{searchPapers:{action:"searchPapers",onSuccess:"Papercube.adaptor.searchPapersSuccess",onError:"Papercube.adaptor.handleError",onFailure:"Papercube.adaptor.handleFailure"},getPaperDetails:{action:"getPaperDetails",onSuccess:"Papercube.adaptor.getPaperDetailsSuccess",onError:"Papercube.adaptor.handleError",onFailure:"Papercube.adaptor.handleFailure"},getAllDataForPaper:{action:"getAllDataForPaper",onSuccess:"Papercube.adaptor.getPaperDetailsSuccess",onError:"Papercube.adaptor.handleError",onFailure:"Papercube.adaptor.handleFailure"},searchAuthors:{action:"searchAuthors",onSuccess:"Papercube.adaptor.searchAuthorsSuccess",onError:"Papercube.adaptor.handleError",onFailure:"Papercube.adaptor.handleFailure"},getAuthorDetails:{action:"getAuthorDetails",onSuccess:"Papercube.adaptor.getAuthorDetailsSuccess",onError:"Papercube.adaptor.handleError",onFailure:"Papercube.adaptor.handleFailure"}},searchPapers:function(d,c,e,f,a){console.log("searchPapers@Papercube.adaptor");if(d==null){console.log("No searchKey specified, aborting!");return NO}var b="searchKey="+encodeURIComponent(d)+"&searchValue="+encodeURIComponent(c)+"&queryStart="+f+"&queryLimit="+a+"&sc="+e;this.request(this.requests.searchPapers,b)},searchPapersSuccess:function(a){console.log("searchPapersSuccess@Papercube.adaptor");Papercube.searchController.displayResults()},_getPaperDetailsCallback:null,getPaperDetails:function(a,b){console.log("getPaperDetails@Papercube.adaptor");Papercube.adaptor._getPaperDetailsCallback=b;a=this._handleMult(a);this.request(this.requests.getPaperDetails,"",{guid:a})},getAllDataForPaper:function(a,b){console.log("getAllDataForPaper@Papercube.adaptor");Papercube.adaptor._getPaperDetailsCallback=b;a=this._handleMult(a);this.request(this.requests.getAllDataForPaper,"",{guid:a})},getPaperDetailsSuccess:function(a){if(Papercube.adaptor._getPaperDetailsCallback){Papercube.adaptor._getPaperDetailsCallback()}},searchAuthors:function(d,c,e,f,a){console.log("searchAuthors@Papercube.adaptor");var b="";if(d==null){console.log("No searchKey specified, aborting!");return NO}b="searchKey="+encodeURIComponent(d)+"&searchValue="+encodeURIComponent(c)+"&queryStart="+f+"&queryLimit="+a+"&sc="+e;this.request(this.requests.searchAuthors,b)},searchAuthorsSuccess:function(a){console.log("searchAuthorsSuccess@Papercube.adaptor");Papercube.searchController.displayResults()},_getAuthorDetailsCallBack:null,getAuthorDetails:function(a,c){console.log("getAuthorDetails@Papercube.adaptor");Papercube.adaptor._getAuthorDetailsCallBack=c;a=this._handleMult(a);var b="guid="+a;this.request(this.requests.getAuthorDetails,b)},getAuthorDetailsSuccess:function(a){if(Papercube.adaptor._getAuthorDetailsCallBack){Papercube.adaptor._getAuthorDetailsCallBack()}},_handleMult:function(a){if(typeof a=="object"){a=a.join(",")}return a},request:function(b,a,d){var c=this.base+"?action="+b.action+"&"+a;console.log(c);new Ajax.Request(c,{parameters:d,method:"post",onSuccess:Papercube.adaptor.requestSuccess.bind(Papercube.adaptor,b),onError:Papercube.adaptor.requestError.bind(Papercube.adaptor,b),onFailure:Papercube.adaptor.requestFailure.bind(Papercube.adaptor,b)})},requestSuccess:function(requestHash,transport){var resultText=transport.responseText;var s=new Date().getTime();var json=eval("("+resultText.replace(/[\n\r\t]/g)+")");console.log("eval time: "+(new Date().getTime()-s));if(!this.evaluateStatus(json)){return NO}if(requestHash.action=="searchPapers"||requestHash.action=="searchAuthors"){var dLen=json.data.length;var sc=Papercube.searchController._sc;for(var i=0;i<dLen;i++){json.data[i].sc=sc}}var s=new Date().getTime();this.importRecords(json.data);console.log("import time: "+(new Date().getTime()-s));eval(requestHash.onSuccess)(json.data)},requestError:function(transport,requestHash){var resultText=transport.responseText;var json=eval("("+string.replace(/[\n\r\t]/g)+")");if(!this.evaluateStatus(json)){return NO}eval(requestHash.onError)(json);Papercube.searchController.set("showRequestSpinner",NO)},handleError:function(b,a){console.log("Server ERROR")},requestFailure:function(requestHash,transport){var resultText=transport.responseText;var json=eval("("+string.replace(/[\n\r\t]/g)+")");if(!this.evaluateStatus(json)){return NO}eval(requestHash.onFailure)(json)},handleFailure:function(b,a){console.log("Server FAILURE")},evaluateStatus:function(a){switch(a.status){case 0:console.log("API request error: "+a.error[0]+" - "+a.error[1]);return NO;default:console.log("Success: "+a.status);break}return YES},importRecords:function(a){if(a&&a.length>0){console.log("Importing "+a.length+" records");this.refreshRecordsWithData(a,SC.Record,null,NO)}}});require("core");Papercube.papersPerYearController=SC.Object.create({depthStep:1,depthValueMax:15,depthValueMin:1,depth:8,defaultDepth:8,refThresholdStep:1,refThresholdValueMax:30,refThresholdValueMin:0,refThreshold:0,defaultRefThreshold:0,citeThresholdStep:1,citeThresholdValueMax:30,citeThresholdValueMin:0,citeThreshold:0,defaultCiteThreshold:0,hideBogusYears:false,maxStrength:function(a){if(a){this.maxRefStrength()}else{this.maxCiteStrength()}},minStrength:function(a){if(a){this.minRefStrength()}else{this.minCiteStrength()}},maxRefStrength:function(){if(this.get("refThreshold")<this.get("refThresholdValueMax")){this.set("refThreshold",this.get("refThreshold")+1)}},minRefStrength:function(){if(this.get("refThreshold")>this.get("refThresholdValueMin")){this.set("refThreshold",this.get("refThreshold")-1)}},maxCiteStrength:function(){if(this.get("citeThreshold")<this.get("citeThresholdValueMax")){this.set("citeThreshold",this.get("citeThreshold")+1)}},minCiteStrength:function(){if(this.get("citeThreshold")>this.get("citeThresholdValueMin")){this.set("citeThreshold",this.get("citeThreshold")-1)}},maxDepth:function(){if(this.get("depth")<this.get("depthValueMax")){this.set("depth",this.get("depth")+1)}},minDepth:function(){if(this.get("depth")>this.get("depthValueMin")){this.set("depth",this.get("depth")-1)}},setDefaults:function(){this.set("refThreshold",this.get("defaultRefThreshold"));this.set("citeThreshold",this.get("defaultCiteThreshold"));this.set("depth",this.get("defaultDepth"))}});require("core");Papercube.Author=SC.Record.extend({_cached_paperCount:null,paperCount:function(){if(!this._cached_paperCount){var a=this.get("papers");if(a&&a.length){this._cached_paperCount=a.length}else{this._cached_paperCount=0}}return this._cached_paperCount}.property(),label:function(){return this.get("name")}.property()});require("core");Papercube.searchController=SC.Object.create({viewingModeBinding:"Papercube.viewController.viewingMode",showRequestSpinner:NO,_searchHeadings:{Authors:"Search for authors",Papers:"Search for papers"},searchHeading:"",searchKeys:[{order:1,name:"Paper Title",key:"title"},{order:2,name:"Paper Abstract",key:"abstract"},{order:2,name:"Paper Subject",key:"subject"},{order:3,name:"Paper Publication Year",key:"pubyear"},{order:4,name:"Author Name",key:"name"},],_sc:0,_searchStart:0,_searchLimit:50,showMoreAllowed:NO,searchKey:"",searchValue:"",searchCount:"",searchResults:null,viewingModeDidChange:function(){var a=this.get("viewingMode");switch(a){case"Authors":this.set("searchHeading",this._searchHeadings.Authors);break;default:this.set("searchHeading",this._searchHeadings.Papers);break}this.set("searchResults",[]);this.set("searchCounnt",0);this.performSearch()}.observes("viewingMode"),selectionDidChange:function(){var a=this.get("selection");if(a&&a[0]){Papercube.viewController.setContentToView(a[0])}}.observes("selection"),performSearch:function(){var b=this.get("searchKey");var a=this.get("searchValue");if(a==""){return}Papercube.canvasController.hideFan();Papercube.searchController.set("showRequestSpinner",YES);this._sc++;Papercube.viewController.setContentToView(null);if(!b){b="title"}this._searchStart=0;if(Papercube.viewController.get("viewingMode")=="Papers"){Papercube.adaptor.searchPapers(b,a,this._sc,0,this._searchLimit)}else{Papercube.adaptor.searchAuthors(b,a,this._sc,0,this._searchLimit)}},showMoreFromSearch:function(){Papercube.canvasController.hideFan();Papercube.searchController.set("showRequestSpinner",YES);var b=this.get("searchKey");var a=this.get("searchValue");if(!b){b="title"}this._searchStart+=this._searchLimit;if(Papercube.viewController.get("viewingMode")=="Papers"){Papercube.adaptor.searchPapers(b,a,this._sc,this._searchStart,this._searchLimit)}else{Papercube.adaptor.searchAuthors(b,a,this._sc,this._searchStart,this._searchLimit)}},displayResults:function(){if(Papercube.viewController.get("viewingMode")=="Papers"){var a=Papercube.Paper.findAll({sc:this._sc});this.set("searchCount",Papercube.pluralizeString(" Paper",a.length))}else{var a=Papercube.Author.findAll({sc:this._sc});this.set("searchCount",Papercube.pluralizeString(" Author",a.length))}this.set("showMoreAllowed",(a.length!=0));this.set("searchResults",a);Papercube.searchController.set("showRequestSpinner",NO)},init:function(){arguments.callee.base.apply(this,arguments);this.set("searchHeading",this._searchHeadings.Papers)}});require("core");Papercube.citeRefController=SC.Object.create({linkThresholdStep:1,linkThresholdValueMax:30,linkThresholdValueMin:1,linkThreshold:1,defaultLinkThreshold:1,strengthPrompt:"",refPrompt:"Hide authors who were referenced by focused author less than ",citePrompt:"Hide authors who referenced the focused author less than ",setPrompt:function(){if(Papercube.viewController.get("viewDirection")=="References"){Papercube.citeRefController.set("strengthPrompt",this.get("refPrompt"))}else{Papercube.citeRefController.set("strengthPrompt",this.get("citePrompt"))}},maxStrength:function(){if(this.get("linkThreshold")<this.get("linkThresholdValueMax")){this.set("linkThreshold",this.get("linkThreshold")+1)}},minStrength:function(){if(this.get("linkThreshold")>this.get("linkThresholdValueMin")){this.set("linkThreshold",this.get("linkThreshold")-1)}},setDefaults:function(){this.set("linkThreshold",this.get("defaultLinkThreshold"));this.setPrompt()}});require("core");Papercube.SearchResultsCollectionView=SC.CollectionView.extend({resizeWithOldParentSize:function(a){this.set("frame",{height:Papercube.canvasController.windowHeight()-194})},init:function(){arguments.callee.base.apply(this,arguments);this.resizeWithOldParentSize()}});require("core");Papercube.viewController=SC.Object.create({viewingModes:["Papers","Authors"],viewChoices:{Authors:["Author Detail","Papers","Collaborators","Author's Cites"],Papers:["Paper Detail","Circle View","Tree Map","Per Year","Paper Graph"]},viewingMode:"Papers",viewChoice:"Paper Detail",paperViewChoice:"Paper Detail",authorViewChoice:"Author Detail",_viewVisibilities:{"Circle View":"circleView","Per Year":"papersPerYearView","Paper Detail":"paperStatView","Tree Map":"paperTreeView","Paper Graph":"paperGraphView",Papers:"authorPaperView",Collaborators:"collaboratorView","Author's Cites":"citeRefView","Author Detail":"authorStatView"},viewDirectionChoices:["References","Citations"],viewDirection:"References",circleViewShowing:NO,paperTreeViewShowing:NO,papersPerYearViewShowing:NO,paperStatViewShowing:NO,paperGraphViewShowing:NO,authorPaperViewShowing:NO,authorStatViewShowing:NO,collaboratorViewShowing:NO,citeRefViewShowing:NO,showIntroView:NO,shouldNotShowAgain:YES,savedPanelViewShowing:NO,nowShowing:"noContent",_saved:[],_savedGuids:{},savedContent:[],showVideo:function(){var e="papercubevideo=";var b=document.cookie.split(";");var a="";for(var d=0;d<b.length;d++){var f=b[d];while(f.charAt(0)==" "){f=f.substring(1,f.length)}if(f.indexOf(e)==0){a=f.substring(e.length,f.length)}}if(!a){$("video").innerHTML='<object width="640" height="360"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5661651&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=eeeeee&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5661651&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=eeeeee&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="360"></embed></object>';this.set("showIntroView",YES)}},hideVideo:function(){this.set("showIntroView",NO);$("video").innerHTML="";if(this.get("shouldNotShowAgain")===YES){document.cookie="papercubevideo=1; expires="+(Date.now()+8640000000)+"; path=/"}},showSaved:function(){var f=this._saved;var h=[];var c=[];var a=[];for(var d=0;d<f.length;d++){var e=null;var b=f[d].guid;if(f[d].type=="Author"){e=Papercube.Author.find(f[d].guid);if(!e&&!f[d].retrieving){c.push(b);f[d].retrieving=true}}else{e=Papercube.Paper.find(b);if(!e&&!f[d].retrieving){a.push(b);f[d].retrieving=true}}if(e){h.push(e)}}var g=function(){this.doneRetrievingSaved()}.bind(this);if(a.length>0){Papercube.searchController.set("showRequestSpinner",YES);Papercube.adaptor.getPaperDetails(a,g)}if(c.length>0){Papercube.searchController.set("showRequestSpinner",YES);Papercube.adaptor.getAuthorDetails(c,g)}this.set("savedContent",h);this.set("savedPanelShowing",YES)},hideSaved:function(){this.set("savedPanelShowing",NO)},clearSaved:function(){this._saved=[];this._savedGuids={};this.set("savedContent",[]);this._eraseCookie()},saveObject:function(a,b){if(!this._savedGuids[a]){this._saved.push({type:b,guid:a});this._savedGuids[a]=1;this._saveCookie()}},readSavedItemsCookie:function(){var nameEQ="papercube=";var ca=document.cookie.split(";");var result="";for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length)}if(c.indexOf(nameEQ)==0){result=c.substring(nameEQ.length,c.length)}}if(result==""){return NO}var saved=eval(unescape(result));this._saved=saved},_saveCookie:function(){document.cookie="papercube="+escape(this._saved.toJSON())+"; expires="+(Date.now()+8640000000)+"; path=/"},_eraseCookie:function(){document.cookie="papercube=; expires=-1; path=/"},doneRetrievingSaved:function(){Papercube.searchController.set("showRequestSpinner",NO);if(this.get("savedPanelShowing")){this.showSaved()}},_history:[],_historyIdx:-1,_timer:null,addToHistory:function(b,c,a){var d=this._history.splice(0,this._historyIdx+1);var e={guid:b,type:c,label:a,viewChoice:this.get("viewChoice"),viewDirection:this.get("viewDirection"),viewingMode:this.get("viewingMode")};d.push(e);this._history=d;this._historyIdx++;this._setHistoryLocation()},_showHistoryItem:function(a){var b=this._history[a];this.setViewingMode(b.viewingMode,YES);this.setViewChoice(b.viewChoice,YES);this.setViewDirection(b.viewDirection,YES);this.setContentToViewFromGUID(b.guid,b.type,YES);this._setHistoryLocation()},_lastHash:"",parseHash:function(){var e=NO;if(window.location.hash!==""){var f=window.location.hash.substr(1).split("/");if(f.length===5){var b=f[0]=="Authors";var a=f[0]=="Papers";if(b){this.setViewingMode(f[0])}var d=f[1].replace("_"," ");if(b&&this.viewChoices.Authors.indexOf(d)){this.setViewChoice(d)}else{if(a&&this.viewChoices.Papers.indexOf(d)){this.setViewChoice(d)}}if(f[2]=="1"){this.setViewDirection("Citations")}var c=(a)?"PAPER-%@".fmt(f[3]):"AUTHOR-%@".fmt(f[3]);this._lastHash=window.location.hash;if(a){Papercube.adaptor.getPaperDetails(c,function(g){this.viewPaper(g)}.bind(this,c))}else{if(b){Papercube.adaptor.getAuthorDetails(c,function(g){this.viewAuthor(g)}.bind(this,c))}}e=YES}else{window.location.hash=""}}setInterval("Papercube.viewController.checkLocation()",1000);return e},_setHistoryLocation:function(){var a=this._historyIdx;var b=this._history[a];window.location.hash=this._lastHash="%@/%@/%@/%@/%@".fmt(b.viewingMode,b.viewChoice.replace(" ","_"),(b.viewDirection=="References")?"0":"1",(b.type=="Paper")?b.guid.substr(6):b.guid.substr(7),a);if(b){document.title="PaperCube - "+b.label.substr(0,40)+" - "+b.viewChoice+" - "+b.viewingMode}},checkLocation:function(){if(this._lastHash!=window.location.hash){var b=window.location.hash.split("/");var a=parseInt(b[b.length-1],10);if(a!==this._historyIdx){this._historyIdx=a;this._showHistoryItem(a)}}},showDefaultView:function(){this.setViewChoice(this.viewChoice,NO)},setViewDirection:function(b,a){if(this.paperForView&&!a){this.addToHistory(this.paperForView.get("guid"),this.paperForView.get("type"),this.paperForView.get("label"))}this.set("viewDirection",b)},setViewChoice:function(c,b){if(this.viewChoices[this.viewingMode].indexOf(c)==-1){console.log("error: '"+c+"' is not a valid view choice.");return NO}var a=this._viewVisibilities;for(var d in a){this.setIfChanged(a[d]+"Showing",(d==c))}this.set("viewChoice",c);this.set("nowShowing",this._viewVisibilities[c]);if(this.get("viewingMode")=="Papers"){this.set("paperViewChoice",c)}if(this.get("viewingMode")=="Authors"){this.set("authorViewChoice",c)}if(this.contentForView&&!b){this.addToHistory(this.contentForView.get("guid"),this.contentForView.get("type"),this.contentForView.get("label"))}},setViewingMode:function(a,b){if(this.viewingModes.indexOf(a)==-1){console.log("error: '"+a+"' is not a valid view mode.");return NO}this.set("viewingMode",a);if(this.contentForView&&!b){this.addToHistory(this.contentForView.get("guid"),this.contentForView.get("type"),this.contentForView.get("label"))}if(this.viewChoices[a].indexOf(this.get("viewChoice"))==-1){this.setViewChoice(this.viewChoices[a][0])}},paperForView:null,authorForView:null,contentForView:null,noContentForView:YES,noContentForViewDidChange:function(){this.set("noContentForView",!this.get("contentForView"))}.observes("contentForView"),collectNeededPaperGUIDs:function(a,c){if(!c){c=[]}var e=[];for(var b=0;b<a.length;b++){var d=Papercube.Paper.find(a[b]);if(!d){c.push(a[b])}else{e.push(d)}}return{papers:e,guids:c}},setContentToView:function(b,a){if(b){if(!a){this.addToHistory(b.get("guid"),b.get("type"),b.get("label"))}this.set("contentForView",b);if(b.get("type")=="Author"){this.set("authorForView",b)}if(b.get("type")=="Paper"){this.set("paperForView",b)}}Papercube.canvasController.hideFan()},setContentToViewFromGUID:function(b,c,a){var d=null;if(c=="Paper"){d=Papercube.Paper.find(b)}if(c=="Author"){d=Papercube.Author.find(b)}if(d){this.setContentToView(d,a)}Papercube.canvasController.hideFan()},viewAuthor:function(a){var b=Papercube.Author.find(a);if(b){this.set("viewingMode","Authors");this.setViewChoice(this.authorViewChoice,NO);this.setContentToView(b,NO)}},viewPaper:function(a){var b=Papercube.Paper.find(a);if(b){this.set("viewingMode","Papers");this.setViewChoice(this.paperViewChoice,NO);this.setContentToView(b,NO)}}});require("core");Papercube.authorPaperController=SC.Object.create({refThresholdStep:1,refThresholdValueMax:30,refThresholdValueMin:0,refThreshold:0,defaultRefThreshold:0,citeThresholdStep:1,citeThresholdValueMax:30,citeThresholdValueMin:0,citeThreshold:0,defaultCiteThreshold:0,startYearThresholdStep:1,startYearThresholdValueMax:(new Date().getFullYear()-1960),startYearThresholdValueMin:0,startYearThreshold:1960,startYearThresholdValue:0,defaultStartYearThreshold:0,endYearThresholdStep:1,endYearThresholdValueMax:(new Date().getFullYear()-1960),endYearThresholdValueMin:0,endYearThresholdValue:(new Date().getFullYear()-1960),endYearThreshold:new Date().getFullYear(),defaultEndYearThreshold:(new Date().getFullYear()-1960),maxStrength:function(a){if(a===YES){this.maxRefStrength()}else{if(a===2){this.maxEndYearStrength()}else{if(a===3){this.maxStartYearStrength()}else{this.maxCiteStrength()}}}},minStrength:function(a){if(a===YES){this.minRefStrength()}else{if(a===2){this.minEndYearStrength()}else{if(a===3){this.minStartYearStrength()}else{this.minCiteStrength()}}}},maxRefStrength:function(){if(this.get("refThreshold")<this.get("refThresholdValueMax")){this.set("refThreshold",this.get("refThreshold")+1)}},minRefStrength:function(){if(this.get("refThreshold")>this.get("refThresholdValueMin")){this.set("refThreshold",this.get("refThreshold")-1)}},maxCiteStrength:function(){if(this.get("citeThreshold")<this.get("citeThresholdValueMax")){this.set("citeThreshold",this.get("citeThreshold")+1)}},minCiteStrength:function(){if(this.get("citeThreshold")>this.get("citeThresholdValueMin")){this.set("citeThreshold",this.get("citeThreshold")-1)}},maxStartYearStrength:function(){if(this.get("startYearThresholdValue")<this.get("startYearThresholdValueMax")){this.set("startYearThresholdValue",this.get("startYearThresholdValue")+1)}},minStartYearStrength:function(){if(this.get("startYearThresholdValue")>this.get("startYearThresholdValueMin")){this.set("startYearThresholdValue",this.get("startYearThresholdValue")-1)}},maxEndYearStrength:function(){if(this.get("endYearThresholdValue")<this.get("endYearThresholdValueMax")){this.set("endYearThresholdValue",this.get("endYearThresholdValue")+1)}},minEndYearStrength:function(){if(this.get("endYearThresholdValue")>this.get("endYearThresholdValueMin")){this.set("endYearThresholdValue",this.get("endYearThresholdValue")-1)}},setDefaults:function(){this.set("refThreshold",this.get("defaultRefThreshold"));this.set("citeThreshold",this.get("defaultCiteThreshold"));this.set("startYearThresholdValue",this.get("defaultStartYearThreshold"));this.set("endYearThresholdValue",this.get("defaultEndYearThreshold"))},startYearThresholdValueDidChange:function(){this.set("startYearThreshold",1960+this.get("startYearThresholdValue"))}.observes("startYearThresholdValue"),endYearThresholdValueDidChange:function(){this.set("endYearThreshold",1960+this.get("endYearThresholdValue"))}.observes("endYearThresholdValue")});require("core");Papercube.LinkStrengthButtonView=SC.View.extend({emptyElement:"<div></div>",maxStrength:YES,controller:null,option:NO,mouseDown:function(){var a=this.get("controller");if(a){if(this.get("maxStrength")){a.maxStrength(this.get("option"))}else{a.minStrength(this.get("option"))}}}});require("core");Papercube.CircleViewHTML=SC.View.extend(Papercube.DragPanMixin,{displayPropertiesBinding:"Papercube.canvasController.displayProperties",viewDirectionBinding:"Papercube.viewController.viewDirection",citeThresholdBinding:"Papercube.circleViewController.citeThreshold",_cached_citeThreshold:1,refThresholdBinding:"Papercube.circleViewController.refThreshold",_cached_refThreshold:1,_displayRefs:YES,_showingMetaData:NO,_canvasWidth:800,_canvasHeight:600,_h:0,_w:0,_x:0,_y:0,_numberOfFirstRefs:0,_numberOfFirstCites:0,_numberOfFirstCircles:0,_rotatingLeft:NO,_rotatingRight:NO,_xC:0,_yC:0,_sAngle:-25,_rotationSpeed:1,_tAIncr:null,_isAnimating:NO,_detailGUID:null,_rotateToGUID:null,_rotateFromGUID:null,_minRefs:0,_minCites:0,_maxRefs:0,_maxCites:0,_lastContentGUID:null,_cachedContent:null,_isAnimatingToMiddle:NO,_animateSrcD:0,_animateSrcX:0,_animateSrcY:0,_animatePosDeltaD:0,_animatePosDeltaX:0,_animatePosDeltaY:0,_animateElm:null,_animateOpacity:100,_twoPI:Math.PI*2,_mouseDownGUID:null,_mouseDownCircle:null,_guidCache:{},_htmlCache:{},_lineColorCache:{},_selection:null,_filteredRefs:{},_filteredCites:{},_styleSheet:null,outlets:["canvas","divCanvas","fan","rotateLeftButton","rotateRightButton","metaDataView"],canvas:".canvas?",divCanvas:".div-canvas?",metaDataView:".meta-data?",rotateLeftButton:SC.ButtonView.extend({action:function(){this.owner._rotateFromGUID=this.owner._detailGUID;this.owner._cRotationSpeed();this.owner.rotateLeft(NO)}}).outletFor(".rotate-left?"),rotateRightButton:SC.ButtonView.extend({action:function(){this.owner._rotateFromGUID=this.owner._detailGUID;this.owner._cRotationSpeed();this.owner.rotateRight(NO)}}).outletFor(".rotate-right?"),_cRotationSpeed:function(d){var b=(this._displayRefs)?this._numberOfFirstRefs:this._numberOfFirstCites;var c=360/b;if(d){c=c*(d/2)}this._stopRotation=NO;this._rotationSpeed=Math.max(2,Math.min(4,c/20))},animateToMiddle:function(b){var g=this._mouseDownCircle;if(!g){return NO}var a=parseInt(g.style.left,0);var f=parseInt(g.style.top,0);var d=0;this._animateElm=g;if(Element.hasClassName(g,"small")||Element.hasClassName(g,"s")){d=this._smallCRadius}else{if(Element.hasClassName(g,"detail")||Element.hasClassName(g,"d")){d=this._detailCRadius}else{if(Element.hasClassName(g,"medium")||Element.hasClassName(g,"m")){d=this._mediumCRadius}}}this._ctx.clearRect(0,0,this._canvasWidth,this._canvasHeight);this._animateSrcX=a;this._animateSrcY=f;this._animateSrcD=d*2;this._animatePosDeltaD=(this._largeCRadius*2-d*2)/30;var e=(this._xC-this._largeCRadius);var c=(this._yC-this._largeCRadius);this._animatePosDeltaX=(e-a)/30;this._animatePosDeltaY=(c-f)/30;this._animateOpacity=100;g.innerHTML="";setTimeout(this.doAnimateToMiddle.bind(this,0),100)},doAnimateToMiddle:function(d){if(d==31){this.divCanvas.innerHTML="";var c=Papercube.Paper.find(this._selection);Papercube.viewController.setContentToView(c);this._isAnimatingToMiddle=NO;this._render();return}if(this._animateOpacity>5){this._animateOpacity-=15}var a=parseFloat(this._animateOpacity/100,0);for(var b in this._htmlCache){if(b!=this._mouseDownGUID){this._htmlCache[b].style.opacity=a}}this._animateElm.style.opacity="1.0";this._animateSrcX+=this._animatePosDeltaX;this._animateSrcY+=this._animatePosDeltaY;this._animateSrcD+=this._animatePosDeltaD;this._animateElm.style.left=this._animateSrcX+"px";this._animateElm.style.top=this._animateSrcY+"px";this._animateElm.style.width=this._animateSrcD+"px";this._animateElm.style.height=this._animateSrcD+"px";this._animateElm.style["-webkit-border-radius"]=(Math.floor(this._animateSrcD/2))+"px";this._animateElm.className="large sel";d++;setTimeout(this.doAnimateToMiddle.bind(this,d),15)},mouseDown:function(a){if(!this.get("isVisible")){return NO}var b=a.target.getAttribute("objguid");if(!b){return this.handleMouseDownDrag(a)}this._mouseDownGUID=b;var c="large";if(Element.hasClassName(a.target,"small")||Element.hasClassName(a.target,"s")){c="small"}else{if(Element.hasClassName(a.target,"detail")||Element.hasClassName(a.target,"d")||(Element.hasClassName(a.target,"m")&&(Element.hasClassName(a.target.parentNode,"detail")||Element.hasClassName(a.target.parentNode.parentNode,"detail")))){c="detail"}else{if(Element.hasClassName(a.target,"medium")||Element.hasClassName(a.target,"m")||(Element.hasClassName(a.target,"m")&&Element.hasClassName(a.target.parentNode,"medium"))){c="medium"}}}if(Element.hasClassName(a.target,"d")||Element.hasClassName(a.target,"s")||Element.hasClassName(a.target,"m")){if(Element.hasClassName(a.target,"title")||Element.hasClassName(a.target,"authors")||Element.hasClassName(a.target,"rels")){this._mouseDownCircle=a.target.parentNode.parentNode}else{this._mouseDownCircle=a.target.parentNode}}else{this._mouseDownCircle=a.target}Papercube.canvasController.showFan(Event.pointerX(a),Event.pointerY(a),"circleview",(c+"Fan"));return YES},mouseMoved:function(a){if(!this.get("isVisible")){return}var c=a.target.getAttribute("objguid");if(!c){return NO}if(c==this._selection){return}var b=this._htmlCache[this._selection];if(b){var e=b.length;for(var d=0;d<e;d++){Element.removeClassName(b[d],"sel")}}var b=this._htmlCache[c];if(b){var e=b.length;for(var d=0;d<e;d++){Element.addClassName(b[d],"sel")}}this._selection=c;this._render();this._showMetaData()},_hideMetaData:function(){this._showingMetaData=NO;this.metaDataView.removeClassName("show-meta-data")},_showMetaData:function(){this._showingMetaData=YES;var b=Papercube.Paper.find(this._selection);if(!b){return NO}this.metaDataView.childNodes[0].innerHTML=b.get("title");var a=b.get("authorNames");var c=a.join(", ");this.metaDataView.childNodes[1].innerHTML=c;this.metaDataView.childNodes[2].innerHTML="<em>"+b.get("abstract").substring(0,200)+"</em>";this.metaDataView.childNodes[3].innerHTML="<strong>Publication Date: </strong> "+b.get("year");this.metaDataView.childNodes[4].innerHTML=Papercube.pluralizeString(" reference",b.get("refCount"));this.metaDataView.childNodes[5].innerHTML=Papercube.pluralizeString(" citation",b.get("citeCount"));this.metaDataView.addClassName("show-meta-data")},_render:function(){if(!this.get("isVisible")){return NO}this._ctx.lineWidth=this._lineWidth;this._ctx.clearRect(0,0,this._canvasWidth,this._canvasHeight);this._renderOneDepth();this._renderZeroDepth()},_lineColor:function(c,a){var b=Math.min(255,parseInt(((c/(a?this._maxRefs:this._maxCites))*180+75),0)).toString(16);return"#"+((b.length==1)?"0":"")+b+"2d2d"},_genCircle:function(c,b,a,d){var e=document.createElement("div");e.setAttribute("objGuid",b);e.style.borderColor=d;if(c){e.appendChild(c)}this.divCanvas.appendChild(e);if(!this._guidCache[b]){this._guidCache[b]=[]}this._guidCache[b].push(e);this._htmlCache[a]=e;return e},_setProperties:function(b,f,d,c,a,e){e.className=c;e.style.top=(f-d)+"px";e.style.left=(b-d)+"px";e.style.borderWidth=(a*this._z)+"px";e.style.borderStyle="solid"},_renderZeroDepth:function(){var c=this._cachedContent;if(!c){return NO}var b=c.get("guid");var a=b+b;if(!this._htmlCache[a]){if(this._displayRefs){var d=this._lineColor(c.get("references").length,YES)}else{var d=this._lineColor(c.get("citations").length,NO)}this._genCircle(this._createLargeText(c,"large"),b,a,d)}this._setProperties(this._xC,this._yC,this._largeCRadius,((this._selection==b)?"large sel":"large"),1,this._htmlCache[a])},_filterByRels:function(h,b){if(!h){return[]}var k=h._attributes.guid;var a=(this._displayRefs&&!b);if(this._cached_citeThreshold>0||this._cached_refThreshold>0){if(a&&this._filteredRefs[k]){return this._filteredRefs[k]}else{if(this._filteredCites[k]){return this._filteredCites[k]}}var j=(a)?h._attributes.references:h._attributes.citations;var e=j.length;var d=[];for(var f=0;f<e;f++){var g=j[f];var c=Papercube.Paper.find(g);if(c){if(this._cached_citeThreshold<=c.get("citeCount")&&this._cached_refThreshold<=c.get("refCount")){d.push(g)}}}if(a){this._filteredRefs[k]=d}else{this._filteredCites[k]=d}return d}return(a)?h._attributes.references:h._attributes.citations},_renderOneDepth:function(){var k=this._cachedContent;if(!k){return NO}var s=k._attributes.guid;var F=this._displayRefs;var z=this._filterByRels(k);var g=(1/z.length);this._tAIncr=g;var o=this._mR*3.5;var u=this._sAngle/360;var B=z.length;for(var C=0;C<B;C++){var G=NO;var h=NO;var w=0;var v=0;var f=z[C];var e=this._twoPI*u;var L=parseInt((u*360)%360);var l=0;if((L<=-24&&L>=-26)||(L>=334&&L<=336)&&(!this._rotateTo||(this._rotateTo&&f==this._rotateToGUID))){G=YES;h=YES;this._detailGUID=f;l=1}var D=(this._selection==f)?"sel ":"";if(l==1){this._stopRotation=YES;D+="detail";w=this._xC+(o)*Math.cos(e);v=this._yC+(o)*Math.sin(e)}else{D+="medium";if(B<=30){var K=0}else{if(B>30&&B<50){var K=(C%2==0)?this._mR/4:0}else{if(B>50&&B<70){var K=(C%4==0)?this._mR/2:(C%4==1||C%4==3)?this._mR/4:0}else{var K=(C%6==0)?this._mR/3:(C%6==1||C%6==5)?this._mR/6:(C%6==2||C%6==4)?this._mR/9:0}}}var J=this._mR+this._mR+K;w=this._xC+(J)*Math.cos(e);v=this._yC+(J)*Math.sin(e)}var y=Papercube.Paper.find(f);if(!y){var n=[];var t=[]}else{var n=y._attributes.references;var t=y._attributes.citations}if(!this._lineColorCache[f]){if(F){this._lineColorCache[f]=this._lineColor(t.length,NO)}else{this._lineColorCache[f]=this._lineColor(n.length,YES)}}this._ctx.strokeStyle=this._lineColorCache[f];this._ctx.beginPath();this._ctx.moveTo(this._xC,this._yC);this._ctx.lineTo(w,v);this._ctx.stroke();var q=s+f;if(!this._htmlCache[q]){var r=1;if(F){var I=this._lineColor(n.length,YES)}else{var I=this._lineColor(t.length,NO)}this._genCircle(this._createLargeText(y,((G)?"detail":"medium")),f,q,I)}this._setProperties(w,v,((G)?this._detailCRadius:this._mediumCRadius),D,r,this._htmlCache[q]);var c=(G)?this._detailCRadius:this._mediumCRadius;c+=(this._z*7);var x=this._filterByRels(y);if(x&&(z.length<20||G&&!this._isAnimating)&&(!this._isAnimating||(x.length<20&&!G&&!this._isAnimating)||G)){var H=(1/x.length);var M=u;var m=x.length;for(var A=0;A<m;A++){var p=this._twoPI*M;var d=w+c*Math.cos(p);var b=v+c*Math.sin(p);M+=H;var E=x[A];var q=f+E;if(!this._htmlCache[q]){var r=1;if(F){var I=this._lineColor(n.length,YES)}else{var I=this._lineColor(t.length,NO)}this._genCircle(this._createSmallText(Papercube.Paper.find(E)),E,q,I)}var D=(this._selection==E)?"small sel ":"small";this._setProperties(d,b,this._smallCRadius,D,r,this._htmlCache[q])}}else{this._setPaperRefVisibilty(NO,f)}u+=g}},_createSmallText:function(b){if(!b){return}var d=b.get("authorNames");var e="";var c=d.length;for(var f=0;f<c;f++){var a=d[f].split(" ");e+=a[a.length-1].substr(0,1)}if(e.length>2){e=e.substr(0,2)+"+"}var g=document.createElement("div");g.setAttribute("objGuid",b._attributes.guid);g.className="s";g.innerHTML=e;return g},_createLargeText:function(g,h){if(!g){return NO}var j=g._attributes.guid;var a=document.createElement("div");a.setAttribute("objGuid",j);a.className=h.substr(0,1);var c=document.createElement("div");c.setAttribute("objGuid",j);c.setAttribute("type",h);c.className="title "+h.substr(0,1);c.innerHTML=g.get("title");var e=document.createElement("div");e.setAttribute("objGuid",j);e.className="authors "+h.substr(0,1);var k=g.get("authorNames");var d=k.length;for(var f=0;f<d;f++){e.innerHTML+=k[f]+"<br/>"}var b=document.createElement("div");b.setAttribute("objGuid",j);b.className="rels "+h.substr(0,1);b.innerHTML=g.get("formattedReferenceCount")+"<br/>"+g.get("formattedCitationCount");a.appendChild(c);a.appendChild(e);a.appendChild(b);return a},rotateTo:function(c){this._setSecondLevelVisibility(NO);this._rotateTo=YES;this._isAnimating=YES;this._rotateToGUID=c;var a=this._filterByRels(this._cachedContent);var b=a.length;var h=a.indexOf(this._detailGUID);var e=a.indexOf(c);var f=NO;var d=NO;var g=0;if(e>h){if(e-h>=(b-e)+h){g=(b-e)+h;d=YES}else{g=e-h;f=YES}}else{if(h-e>=(b-h)+e){g=(b-h)+e;f=YES}else{g=h-e;d=YES}}this._cRotationSpeed(g);if(f){this.rotateLeft(YES)}else{this.rotateRight(YES)}},_setSecondLevelVisibility:function(k){if(!this._cachedContent){return}var l=this._filterByRels(this._cachedContent);var g=l.length;for(var d=0;d<g;d++){var b=Papercube.Paper.find(l[d]);if(b){var f=l[d];var h=this._filterByRels(b);var a=h.length;for(var c=0;c<a;c++){var e=f+h[c];if(this._htmlCache[e]){this._htmlCache[e].style.display=(k)?"":"none"}}}}},_setPaperRefVisibilty:function(c,e){var g=Papercube.Paper.find(e);if(!g){return}var a=this._filterByRels(g);var b=a.length;for(var f=0;f<b;f++){var d=e+a[f];if(this._htmlCache[d]){this._htmlCache[d].style.display=(c)?"":"none"}}},rotateLeft:function(d){if(!this._stopRotation){if(!d){var b=this._filterByRels(this._cachedContent);var a=b.indexOf(this._detailGUID);var c="";if(a==b.length-1){c=b[0]}else{c=b[a+1]}this.rotateTo(c)}else{if(this._rotatingRight){this.stopRotation()}this._rotatingLeft=YES;this._isAnimating=YES;this._sAngle-=this._rotationSpeed;this._sAngle=this._sAngle%360;this._render();this._rotationTimeout=setTimeout(this.rotateLeft.bind(this,YES),30)}}else{this.stopRotation();this._stopRotation=NO;this._rotateTo=NO;this._isAnimating=NO}},rotateRight:function(d){if(!this._stopRotation){if(!d){var b=this._filterByRels(this._cachedContent);var a=b.indexOf(this._detailGUID);var c="";if(a==0){c=b[b.length-1]}else{c=b[a-1]}this.rotateTo(c)}else{if(this._rotatingLeft){this.stopRotation()}this._rotatingRight=YES;this._isAnimating=YES;this._sAngle+=(this._slowRotation==YES)?this._slowRotationSpeed:this._rotationSpeed;this._sAngle=this._sAngle%360;this._render();this._rotationTimeout=setTimeout(this.rotateRight.bind(this,YES),30)}}else{this.stopRotation();this._stopRotation=NO;this._rotateTo=NO;this._isAnimating=NO}},stopRotation:function(a){this._setSecondLevelVisibility(YES);this._rotatingLeft=NO;this._rotatingRight=NO;this._isAnimating=NO;clearTimeout(this._rotationTimeout);if(!a){this._render()}},displayPropertiesDidChange:function(a){if(!this.get("isVisible")){return NO}var f=this.displayProperties.height;var o=this.displayProperties.width;var m=this.displayProperties.left;var l=this.displayProperties.top;var j=this.displayProperties.zoomValue;var d=NO;if(f==this._h&&o==this._w&&this._z==j){if((m!=this._x||l!=this._y)){d=YES}}if(a){d=NO}this._h=f;this._w=o;this._x=m;this._y=l;this._z=j;this.setStyle({height:f+"px",width:o+"px",left:m+"px",top:l+"px"});this._frame={height:f,width:o,x:m,y:l};this.canvas.style.left=m+"px";this.canvas.style.top=l+"px";this.divCanvas.style.left=m+"px";this.divCanvas.style.top=l+"px";this.stopRotation(YES);if(d){return}this.divCanvas.style.height=f+"px";this.divCanvas.style.width=o+"px";this.canvas.height=f;this.canvas.width=o;this._canvasHeight=f;this._canvasWidth=o;this._lineColorCache={};this._sAngle=-25;this._xC=(this._canvasWidth/2)-(this._canvasWidth/8);this._yC=(this._canvasHeight/2);this._mR=Math.min((this._canvasWidth/9),(this._canvasHeight/6));this._largeCRadius=this._mR*1.2;this._detailCRadius=this._mR*1.1;this._mediumCRadius=this._mR/(2+0.08*this._numberOfFirstCircles);this._smallCRadius=this._mR/(8+0.12*this._numberOfFirstCircles);this._lineWidth=3*this._z;if(!SC.isChrome&&SC.isSafari()){var c=(2*this._z);var b=(2*this._z);var g=c+"px "+c+"px "+b+"px #222";this._styleSheet.cssRules[1].style["-webkit-box-shadow"]=g;this._styleSheet.cssRules[2].style["-webkit-box-shadow"]=g;this._styleSheet.cssRules[3].style["-webkit-box-shadow"]=g}var n=(this._smallCRadius*2)+"px";var e=(this._mediumCRadius*2)+"px";var k=(this._largeCRadius*2)+"px";var i=(this._detailCRadius*2)+"px";var q=(10*this._z)+"px";this._styleSheet.cssRules[10].style.fontSize=q;this._styleSheet.cssRules[10].style.lineHeight=q;this._styleSheet.cssRules[0].style.width=n;this._styleSheet.cssRules[0].style.height=n;this._styleSheet.cssRules[0].style["-webkit-border-radius"]=(this._smallCRadius)+"px";this._styleSheet.cssRules[1].style.width=e;this._styleSheet.cssRules[1].style.height=e;this._styleSheet.cssRules[1].style["-webkit-border-radius"]=(this._mediumCRadius)+"px";this._styleSheet.cssRules[2].style.width=k;this._styleSheet.cssRules[2].style.height=k;this._styleSheet.cssRules[2].style["-webkit-border-radius"]=(this._largeCRadius)+"px";this._styleSheet.cssRules[3].style.width=i;this._styleSheet.cssRules[3].style.height=i;this._styleSheet.cssRules[3].style["-webkit-border-radius"]=(this._detailCRadius)+"px";var q=this._smallCRadius-(4*this._z)+"px";this._styleSheet.cssRules[4].style.fontSize=q;this._styleSheet.cssRules[4].style.lineHeight=q;this._styleSheet.cssRules[5].style.marginTop=(this._smallCRadius/2)+(2*this._z)+"px";this._styleSheet.cssRules[6].style.marginTop=(this._mediumCRadius-15*this._z)+"px";this._styleSheet.cssRules[6].style.marginLeft=(5*this._z)+"px";this._styleSheet.cssRules[6].style.marginRight=(5*this._z)+"px";this._styleSheet.cssRules[7].style.marginTop=(10*this._z)+"px";this._styleSheet.cssRules[8].style.marginTop=(this._detailCRadius*0.7)+"px";this._styleSheet.cssRules[8].style.marginLeft=(5*this._z)+"px";this._styleSheet.cssRules[8].style.marginRight=(5*this._z)+"px";this._styleSheet.cssRules[9].style.marginTop=(20*this._z)+"px";this._styleSheet.cssRules[9].style.marginLeft=(5*this._z)+"px";this._styleSheet.cssRules[9].style.marginRight=(5*this._z)+"px";this._styleSheet.cssRules[9].style.fontSize=q;var p=this._yC+(this._mR*3)*Math.sin(this._twoPI*(-25/360));this.rotateLeftButton.setStyle({left:(this._xC+this._mR*4.5)+"px",top:(p-20-this._mR)+"px"});this.rotateRightButton.setStyle({left:(this._xC+this._mR*4.5)+"px",top:(p-20+this._mR/2)+"px"});if(!this._isAnimatingToMiddle){this._render()}}.observes("displayProperties"),redrawParamsDidChange:function(){var h=this.get("content");if(!this.get("isVisible")||!h){return NO}var d=(this._displayRefs!=(this.get("viewDirection")=="References"));this._displayRefs=(this.get("viewDirection")=="References");var e=this.get("citeThreshold");var a=this.get("refThreshold");if(this._cached_citeThreshold!=e||this._cached_refThreshold!=a||d){this._filteredRefs={};this._filteredCites={};this._selection=[]}this._cached_citeThreshold=e;this._cached_refThreshold=a;Papercube.canvasController.set("zoomValueMax",2);Papercube.canvasController.set("zoomStep",0.5);this._hideMetaData();this.divCanvas.innerHTML="";this._guidCache={};this._htmlCache={};var l=this._filterByRels(h);if((this._displayRefs&&h.get("maxRefLevel")<2)||(!this._displayRefs&&h.get("maxCiteLevel")<2)){Papercube.searchController.set("showRequestSpinner",YES);this._retrieveRecords(h,l)}else{Papercube.searchController.set("showRequestSpinner",NO)}this._minRefs=0;this._minCites=0;this._maxRefs=0;this._maxCites=0;this._lastContentGUID=h.get("guid");var g=l.length;for(var f=0;f<g;f++){var j=Papercube.Paper.find(l[f]);if(j){var k=this._filterByRels(j).length;var b=this._filterByRels(j,YES).length;if(k<this._minRefs){this._minRefs=k}if(k>this._maxRefs){this._maxRefs=k}if(b<this._minCites){this._minCites=b}if(b>this._maxCites){this._maxCites=b}}}this._numberOfFirstRefs=this._filterByRels(h).length;this._numberOfFirstCites=this._filterByRels(h,YES).length;this._numberOfFirstCircles=(this._displayRefs)?this._numberOfFirstRefs:this._numberOfFirstCites;if((this._displayRefs&&this._numberOfFirstRefs>0)||(!this._displayRefs&&this._numberOfFirstCites>0)){this.rotateLeftButton.set("isVisible",YES);this.rotateRightButton.set("isVisible",YES)}if(!this._cachedContent||this._cachedContent.get("guid")!=h.get("guid")){Papercube.circleViewController.setDefaults();this._cachedContent=h}this.stopRotation(YES);this._sAngle=-25;this.displayPropertiesDidChange(YES)}.observes("content","isVisible","viewDirection","refThreshold","citeThreshold"),retrieveLevelDone:function(){var a=this.get("content");if(!a){return NO}var b=a.get((this._displayRefs?"maxRefLevel":"maxCiteLevel"));a.set((this._displayRefs?"maxRefLevel":"maxCiteLevel"),b++);this.redrawParamsDidChange();Papercube.searchController.set("showRequestSpinner",NO)},_retrieveRecords:function(e,a){var b=Papercube.viewController.collectNeededPaperGUIDs(a,[]);var f=function(){this.retrieveLevelDone()}.bind(this);if(b.guids.length>0){Papercube.adaptor.getPaperDetails(b.guids,f)}else{var h=b.papers;var g=[];for(var c=0;c<h.length;c++){var d=Papercube.viewController.collectNeededPaperGUIDs((this._displayRefs)?h[c].get("references"):h[c].get("citations"),g);g=d.guids}if(g.length>0){Papercube.adaptor.getPaperDetails(g,f)}}},init:function(){arguments.callee.base.apply(this,arguments);this._ctx=this.canvas.getContext("2d");this.rotateLeftButton.set("isVisible",NO);this.rotateRightButton.set("isVisible",NO);var c=function(i){this.animateToMiddle(this._mouseDownGUID)}.bind(this);var h=function(i){this.animateToMiddle(this._mouseDownGUID)}.bind(this);var e=function(i){window.open(Papercube.Paper.find(this._mouseDownGUID).get("url"))}.bind(this);var g=function(i){Papercube.viewController.saveObject(this._mouseDownGUID,"Paper")}.bind(this);var a=function(i){Papercube.canvasController.setZoomToPointerLocation(Event.pointerX(i),Event.pointerY(i),NO)}.bind(this);var b=function(i){Papercube.canvasController.setZoomToPointerLocation(Event.pointerX(i),Event.pointerY(i),YES)}.bind(this);var f=function(i){this._rotateFromGUID=this._detailGUID;this.rotateTo(this._mouseDownGUID)}.bind(this);Papercube.canvasController.registerFans("circleview",{smallFan:{CiteSeer:e,Save:g,Refocus:h,"Zoom +":b,"Zoom -":a},mediumFan:{CiteSeer:e,Save:g,Refocus:h,Detail:f,"Zoom +":b,"Zoom -":a},largeFan:{CiteSeer:e,Save:g,"Zoom +":b,"Zoom -":a},detailFan:{CiteSeer:e,Save:g,Refocus:c,"Zoom +":b,"Zoom -":a}});for(var d=0;d<document.styleSheets.length;d++){if(document.styleSheets[d].cssRules[0].cssText.substr(0,12)==".circle_view"){this._styleSheet=document.styleSheets[d]}}}});require("core");Papercube.authorStatController=SC.Object.create({paperSortOrder:"Title",paperSortOrderChoices:["Title","Date","Num Refs","Num Cites","Num Authors"],collaboratorSortOrder:"Name",refAuthorSortOrder:"Name",citeAuthorSortOrder:"Name",authorSortOrderChoices:["Name","Num Papers","Num Collabs","Cite Count"]});require("core");Papercube.paperTreeController=SC.Object.create({depthStep:1,depthValueMax:15,depthValueMin:1,depth:8,defaultDepth:8,refThresholdStep:1,refThresholdValueMax:15,refThresholdValueMin:0,refThreshold:0,defaultRefThreshold:0,citeThresholdStep:1,citeThresholdValueMax:15,citeThresholdValueMin:0,citeThreshold:0,defaultCiteThreshold:0,maxStrength:function(a){if(a){this.maxRefStrength()}else{this.maxCiteStrength()}},minStrength:function(a){if(a){this.minRefStrength()}else{this.minCiteStrength()}},maxRefStrength:function(){if(this.get("refThreshold")<this.get("refThresholdValueMax")){this.set("refThreshold",this.get("refThreshold")+1)}},minRefStrength:function(){if(this.get("refThreshold")>this.get("refThresholdValueMin")){this.set("refThreshold",this.get("refThreshold")-1)}},maxCiteStrength:function(){if(this.get("citeThreshold")<this.get("citeThresholdValueMax")){this.set("citeThreshold",this.get("citeThreshold")+1)}},minCiteStrength:function(){if(this.get("citeThreshold")>this.get("citeThresholdValueMin")){this.set("citeThreshold",this.get("citeThreshold")-1)}},maxDepth:function(){if(this.get("depth")<this.get("depthValueMax")){this.set("depth",this.get("depth")+1)}},minDepth:function(){if(this.get("depth")>this.get("depthValueMin")){this.set("depth",this.get("depth")-1)}},setDefaults:function(){this.set("refThreshold",this.get("defaultRefThreshold"));this.set("citeThreshold",this.get("defaultCiteThreshold"));this.set("depth",this.get("defaultDepth"))}});require("core");Papercube.SavedItemsItemView=SC.View.extend({emptyElement:"<div></div>",isSelected:NO,isSelectedDidChange:function(){this.setClassName("sel",this.get("isSelected"))}.observes("isSelected"),_contentIsPaper:NO,contentDidChange:function(){var b=this.get("content");if(!b){return}var e=[];if(b._type=="Papercube.Author"){this._contentIsPaper=NO;var a=Papercube.pluralizeString(" paper",b.get("paperCount"))+" published, "+Papercube.pluralizeString(" collaboration",b.get("collaborators").length)+" with others, references "+Papercube.pluralizeString(" author",b.get("refAuthors").length)+", cited by "+Papercube.pluralizeString(" author",b.get("citeAuthors").length);e=['<div class="title">',b.get("name"),"</div>",'<div class="num">',b.get("affiliation"),"</div>",'<div class="subtitle">',a,"</div>"]}else{this._contentIsPaper=YES;var c=b.get("authorNames").join(", ");if(c.length>100){c=c.substr(0,99)+"&hellip;"}var d=titleStr=b.get("title");if(d.length>70){d=d.substr(0,69)+"&hellip"}e=['<div class="title" title="'+titleStr+'">',d,"</div>",'<div class="num">',Papercube.pluralizeString(" ref",b.get("refCount"))+", "+Papercube.pluralizeString(" cite",b.get("citeCount")),"</div>",'<div class="subtitle">',c,"</div>"]}this.set("innerHTML",e.join(""))}.observes("content"),mouseDown:function(a){var b=this.get("content");Papercube.viewController.set("savedPanelShowing",NO);if(!this._contentIsPaper&&b){Papercube.viewController.viewAuthor(b.get("guid"))}if(this._contentIsPaper&&b){Papercube.viewController.viewPaper(b.get("guid"))}}});require("core");require("views/paperstatlist");Papercube.AuthorStatView=SC.View.extend({collaboratorSortOrderBinding:"Papercube.authorStatController.collaboratorSortOrder",paperSortOrderBinding:"Papercube.authorStatController.paperSortOrder",refAuthorSortOrderBinding:"Papercube.authorStatController.refAuthorSortOrder",citeAuthorSortOrderBinding:"Papercube.authorStatController.citeAuthorSortOrder",outlets:["nameLabel","collaboratorCount","paperCount","refAuthorCount","citeAuthorCount","collaboratorList","paperList","refAuthorList","citeAuthorList","papersPerYear","graph","stats"],nameLabel:".name?",collaboratorCount:".collaborator-count?",paperCount:".paper-count?",refAuthorCount:".refauthor-count?",citeAuthorCount:".citeauthor-count?",papersPerYear:".papersperyear?",graph:".data?",stats:".stats?",paperList:Papercube.PaperstatListView.outletFor(".paper-list?"),collaboratorList:Papercube.PaperstatListView.extend({isAuthorList:YES}).outletFor(".collaborator-list?"),refAuthorList:Papercube.PaperstatListView.extend({isAuthorList:YES}).outletFor(".refauthor-list?"),citeAuthorList:Papercube.PaperstatListView.extend({isAuthorList:YES}).outletFor(".citeauthor-list?"),_mouseDownGUID:null,_calledForAuthors:NO,_calledForPapers:NO,contentDidChange:function(){var c=this.get("content");if(!this.get("isVisible")||!c){return}this.stats.style.display="";if(!this._cachedContent||this._cachedContent.get("guid")!=c.get("guid")){this.papersPerYear.className="papersperyear";this.papersPerYear.className="papersperyear show";this._cachedContent=c;this._calledForAuthors=NO;this._calledForPapers=NO;this._clearGraph()}var d=function(){this.contentDidChange()}.bind(this);if(!this._calledForAuthors){var f=[];f=f.concat(this._collectAuthors(c.get("collaborators")));f=f.concat(this._collectAuthors(c.get("refAuthors")));f=f.concat(this._collectAuthors(c.get("citeAuthors")));if(f.length>0){Papercube.adaptor.getAuthorDetails(f,d)}this._calledForAuthors=YES}this._renderList("collaborators");this._renderList("refAuthors");this._renderList("citeAuthors");var h=NO;if(!this._calledForPapers){var b=[];var g=c.get("papers");for(var a=0;a<g.length;a++){var e=Papercube.Paper.find(g[a]);if(!e){b.push(g[a])}}var h=(b.length>0);if(h){Papercube.adaptor.getPaperDetails(b,d)}this._calledForPapers=YES}if(!h){this._renderGraph()}this._renderList("papers");Papercube.canvasController.set("zoomValueMax",1);Papercube.canvasController.set("zoomStep",1);this.nameLabel.innerHTML=c.get("name").escapeHTML()}.observes("content","isVisible","paperSortOrder","collaboratorSortOrder","refAuthorSortOrder","citeAuthorSortOrder"),_collectAuthors:function(c){var e=[];for(var d=0;d<c.length;d++){var b=Papercube.Author.find(c[d][0]);if(!b){e.push(c[d][0])}}return e},_renderList:function(h){var g=this.get("content");if(!g){if(h=="collaborators"){this.collaboratorList.set("content",[])}else{if(h=="papers"){this.paperList.set("content",[])}else{if(h=="refAuthors"){this.refAuthorList.set("content",[])}else{if(h=="citeAuthors"){this.citeAuthorList.set("content",[])}}}}return NO}if(h=="papers"){var k=g.get("papers");var l=[];for(var f=0;f<k.length;f++){var b=Papercube.Paper.find(k[f]);if(b){l.push(b)}}var e=this.get("paperSortOrder");switch(e){case"Title":l.sort(function(m,i){var o=m._attributes.title.toLowerCase();var n=i._attributes.title.toLowerCase();if(o==n){return 0}if(o<n){return -1}return 1});break;case"Date":l.sort(function(m,i){var o=m.get("year");var n=i.get("year");if(o==n){return m._attributes.title.toLowerCase()<i._attributes.title.toLowerCase()}if(o>n){return -1}return 1});break;case"Num Refs":case"Num Cites":case"Num Authors":var c=(e=="Num Refs")?"refCount":(e=="Num Cites")?"citeCount":"authorCount";l.sort(function(m,i){var o=m.get(c);var n=i.get(c);if(o==n){return 0}if(o>n){return -1}return 1});break}this.paperCount.innerHTML=" ("+l.length+")";this.paperList.set("content",l);this.paperList.setClassName("show",(l.length!=0))}else{var a=g.get(h);var j=[];for(var f=0;f<a.length;f++){var d=Papercube.Author.find(a[f][0]);if(d){j.push(d)}}var e=(h=="collaborators")?this.get("collaboratorSortOrder"):(h=="refAuthors")?this.get("refAuthorSortOrder"):this.get("citeAuthorSortOrder");switch(e){case"Name":j.sort(function(m,i){var o=m._attributes.name.toLowerCase();var n=i._attributes.name.toLowerCase();if(o==n){return 0}if(o<n){return -1}return 1});break;case"Num Papers":j.sort(function(m,i){var o=m.get("paperCount");var n=i.get("paperCount");if(o==n){return 0}if(o>n){return -1}return 1});break;case"Num Collabs":case"Cite Count":var c=(e=="Num Collabs")?"collaborators":"citeAuthors";j.sort(function(m,i){var o=m.get(c).length;var n=i.get(c).length;if(o==n){return 0}if(o>n){return -1}return 1});break}if(h=="collaborators"){this.collaboratorCount.innerHTML=" ("+j.length+")";this.collaboratorList.set("content",j);this.collaboratorList.setClassName("show",(j.length!=0))}else{if(h=="refAuthors"){this.refAuthorCount.innerHTML=" ("+j.length+")";this.refAuthorList.set("content",j);this.refAuthorList.setClassName("show",(j.length!=0))}else{this.citeAuthorCount.innerHTML=" ("+j.length+")";this.citeAuthorList.set("content",j);this.citeAuthorList.setClassName("show",(j.length!=0))}}}},_renderGraph:function(){this._clearGraph();var b=this._cachedContent.get("papers");var d={};var l=0;var g=0;for(var p=0;p<b.length;p++){var f=Papercube.Paper.find(b[p]);var o="?";if(f){o=f.get("year")}if(!d[o]){l++;d[o]=0}d[o]++;if(d[o]>g){g=d[o]}}var m=[];for(var s in d){m.push([s,d[s]])}m.sort(function(t,i){if(t[0]<i[0]){return 1}return -1});var e="";var h=135;var j=500;var a=h/l;var q=j/g;var n=(a-2*a/3);var r=((n/2)-12/2);for(var p=0;p<m.length;p++){var c=m[p][1];var k=(c*q>50)?Papercube.pluralizeString(" Paper",c)+"&nbsp;":"";e+='<div class="row" style="height:'+a+'px;"><div class="year" style="margin-top:'+((a/2)-11/2)+"px; height:"+(a-2*a/3)+'px;">'+m[p][0]+'</div><div class="bar" style="padding-top: '+r+"px; margin-top:"+(a-2*a/3)+"px; width:"+(c*q)+"px; height:"+n+'px;">'+k+"</div></div>"}this.graph.innerHTML=e},_clearGraph:function(){this.graph.innerHTML=""},mouseDown:function(a){var b=a.target.getAttribute("guid");var c=a.target.getAttribute("fanType");if(b){this._mouseDownGUID=b;Papercube.canvasController.showFan(Event.pointerX(a),Event.pointerY(a),"paperstat",(c+"Fan"));return YES}return NO},init:function(){arguments.callee.base.apply(this,arguments);var e=function(f){Papercube.viewController.setContentToViewFromGUID(this._mouseDownGUID,"Paper",NO)}.bind(this);var b=function(f){Papercube.viewController.viewAuthor(this._mouseDownGUID)}.bind(this);var c=function(f){window.open(Papercube.Paper.find(this._mouseDownGUID).get("url"))}.bind(this);var d=function(f){Papercube.viewController.saveObject(this._mouseDownGUID,"Paper")}.bind(this);var a=function(f){Papercube.viewController.saveObject(this._mouseDownGUID,"Author")}.bind(this);Papercube.canvasController.registerFans("authorstat",{authorFan:{Save:a,Refocus:b},paperFan:{CiteSeer:c,Save:d,Refocus:e}})}});require("core");Papercube.Paper=SC.Record.extend({maxRefLevel:0,maxCiteLevel:0,_cached_citeCount:null,citeCount:function(){if(!this._cached_citeCount){var a=this.get("citations");if(a&&a.length){this._cached_citeCount=a.length}else{this._cached_citeCount=0}}return this._cached_citeCount}.property(),_cached_refCount:null,refCount:function(){if(!this._cached_refCount){var a=this.get("references");if(a&&a.length){this._cached_refCount=a.length}else{this._cached_refCount=0}}return this._cached_refCount}.property(),_cached_authorCount:null,authorCount:function(){if(!this._cached_authorCount){var b=this.get("authors");if(b&&b.length){this._cached_authorCount=b.length}else{this._cached_authorCount=0}}return this._cached_authorCount}.property(),_cached_formattedReferenceCount:null,formattedReferenceCount:function(){if(!this._cached_formattedReferenceCount){this._cached_formattedReferenceCount="["+Papercube.pluralizeString(" ref",this.get("refCount"))+"]"}return this._cached_formattedReferenceCount}.property(),_cached_formattedCitationCount:null,formattedCitationCount:function(){if(!this._cached_formattedCitationCount){this._cached_formattedCitationCount="["+Papercube.pluralizeString(" cite",this.get("citeCount"))+"]"}return this._cached_formattedCitationCount}.property(),_cached_authorNames:null,authorNames:function(){if(!this._cached_authorNames){var b=[];var a=this.get("authors");for(var c=0;c<a.length;c++){b.push(a[c].name)}if(b.length==0){b=["unknown"]}this._cached_authorNames=b}return this._cached_authorNames}.property(),label:function(){return this.get("title")}.property(),url:function(){return"http://citeseer.ist.psu.edu/"+this.get("guid").split("-")[1]+".html"}.property()});require("core");Papercube.animationController=SC.Object.create({_queue:[],_svgMain:null,_svgMainHeight:0,addSubjects:function(b,a,f){this._svgMain=a;this._svgMainHeight=f;var c=b.length;for(var e=0;e<c;e++){var d=b[e];this.addSubject(d.elm,d.props,d.duration,d.isSVG)}},addSubject:function(h,c,e,f){var d={};for(var b in c){if(b.indexOf("opacity")==-1){d[b]={start:Math.floor(c[b].start),end:Math.floor(c[b].end)}}else{d[b]={start:c[b].start,end:c[b].end}}}var g=Date.now();var a={isCompleted:NO};a.animate=function(){var m=Math.min(100,parseInt((100*(Date.now()-g)/e),0));var i=NO;if(m>=100){i=YES;this.isCompleted=YES}for(var k in c){var l=d[k].start;var n=d[k].end;var j=(i)?n:Math.floor(l+(n-l)*m/100);if(f){h.setAttributeNS(null,k,j)}else{if(k=="opacity"){h.style.opacity=j}else{h.style[k]=j+"px"}}}};this._queue.push(a)},runAnimation:function(){var d=this._queue;if(!d){return NO}var e=d.length;if(e==0){return NO}var c=[];var a=[];for(var b=0;b<e;b++){d[b].animate();if(!d[b].isCompleted){c.push(d[b])}else{a.push(d[b])}}e=a.length;for(var b=0;b<e;b++){delete a[b]}if(this._svgMain){this._svgMain.setAttributeNS(null,"height",this._svgMainHeight+1);this._svgMain.setAttributeNS(null,"height",this._svgMainHeight)}this._queue=c}});require("core");Papercube.SearchResultsItemView=SC.View.extend({emptyElement:"<div></div>",isSelected:NO,isSelectedDidChange:function(){this.setClassName("sel",this.get("isSelected"))}.observes("isSelected"),contentDidChange:function(){var b=this.get("content");if(!b){return}var e=[];if(Papercube.viewController.get("viewingMode")=="Authors"){var a=Papercube.pluralizeString(" paper",b.get("paperCount"))+", "+Papercube.pluralizeString(" collab",b.get("collaborators").length)+", references "+b.get("refAuthors").length+", cited by "+b.get("citeAuthors").length;e=['<div class="title">',b.get("name"),"</div>",'<div class="num">',b.get("affiliation"),"</div>",'<div class="subtitle">',a,"</div>"]}else{var c=b.get("authorNames").join(", ");if(c.length>50){c=c.substr(0,50)+"&hellip;"}var d=titleStr=(b.get("title"))?b.get("title"):"Untitled";if(d.length>35){d=d.substr(0,33)+"&hellip"}e=['<div class="title" title="'+titleStr+'">',d,"</div>",'<div class="num">',Papercube.pluralizeString(" ref",b.get("refCount"))+", "+Papercube.pluralizeString(" cite",b.get("citeCount")),"</div>",'<div class="subtitle">',c,"</div>"]}this.set("innerHTML",e.join(""))}.observes("content")});require("core");Papercube.circleViewController=SC.Object.create({refThresholdStep:1,refThresholdValueMax:30,refThresholdValueMin:0,refThreshold:0,defaultRefThreshold:0,citeThresholdStep:1,citeThresholdValueMax:30,citeThresholdValueMin:0,citeThreshold:0,defaultCiteThreshold:0,maxStrength:function(a){if(a){this.maxRefStrength()}else{this.maxCiteStrength()}},minStrength:function(a){if(a){this.minRefStrength()}else{this.minCiteStrength()}},maxRefStrength:function(){if(this.get("refThreshold")<this.get("refThresholdValueMax")){this.set("refThreshold",this.get("refThreshold")+1)}},minRefStrength:function(){if(this.get("refThreshold")>this.get("refThresholdValueMin")){this.set("refThreshold",this.get("refThreshold")-1)}},maxCiteStrength:function(){if(this.get("citeThreshold")<this.get("citeThresholdValueMax")){this.set("citeThreshold",this.get("citeThreshold")+1)}},minCiteStrength:function(){if(this.get("citeThreshold")>this.get("citeThresholdValueMin")){this.set("citeThreshold",this.get("citeThreshold")-1)}},setDefaults:function(){this.set("refThreshold",this.get("defaultRefThreshold"));this.set("citeThreshold",this.get("defaultCiteThreshold"))}});require("core");Papercube.SavedItemsCollectionView=SC.CollectionView.extend({resizeWithOldParentSize:function(a){this.set("frame",{height:420})},init:function(){arguments.callee.base.apply(this,arguments);this.resizeWithOldParentSize()}});require("core");require("views/nodegraph");Papercube.PaperGraphView=Papercube.NodeGraphView.extend({depthBinding:"Papercube.paperGraphController.depth",linkThresholdBinding:"Papercube.paperGraphController.refThreshold",citeThresholdBinding:"Papercube.paperGraphController.citeThreshold",viewDirectionBinding:"Papercube.viewController.viewDirection",_cached_citeThreshold:1,viewName:"papergraph",contentTypeViewing:"Paper",_cached_viewDirection:null,defaultTitleKey:"title",nodeTextRatio:3,nodeXYRatio:1.7,edgeTextPosOffset:0.4,nodeColor:"#F3D15C",nodeColorSel:"#FFF594",nodeBorderColor:"#DF7E05",nodeBorderColorSel:"#FFB60B",nodeTextColor:"#6D3D03",performCustomRequest:function(b,a){Papercube.adaptor.getPaperDetails(b,a)},generateCustomMetaData:function(c){var d=Papercube.Paper.find(c);if(!d){return}this.metaDataView.childNodes[0].innerHTML=d.get("title");var b=d.get("authorNames").join(", ");var a=b.length;this.metaDataView.childNodes[1].innerHTML=(a>150)?(b.substr(0,150)+"&hellip;"):b;this.metaDataView.childNodes[2].innerHTML=(d.get("publisher"))?d.get("publisher"):"";this.metaDataView.childNodes[3].innerHTML="<strong>Publication Date: </strong> "+d.get("year");this.metaDataView.childNodes[4].innerHTML=Papercube.pluralizeString(" reference",d.get("refCount"));this.metaDataView.childNodes[5].innerHTML=Papercube.pluralizeString(" citation",d.get("citeCount"))},findCustomObject:function(a){return Papercube.Paper.find(a)},findCustomObjectAttr:function(a){if(a){if(this._displayRefs){return a._attributes.references}return a._attributes.citations}else{return null}},getGuidForRelation:function(a){if(a){return a}},calcRelationWeight:function(a){var b=Papercube.Paper.find(a);if(b){if(this._displayRefs){return b.get("citeCount")}return b.get("refCount")}return 1},findCustomObjectLabel:function(a){if(a){return a._attributes.title.substr(0,20)}return"?"},setBindingDefaults:function(){Papercube.paperGraphController.setDefaults()},viewDirectionDidChange:function(){var a=this.get("content");if(!this.get("isVisible")||!a){return}var b=this.get("viewDirection");if(b!=this._cached_viewDirection){this._cached_viewDirection=b;this._displayRefs=(b=="References");this._render()}}.observes("viewDirection"),relationMeetsCustomThreshold:function(a){if(this._cached_linkThreshold==0&&this._cached_citeThreshold==0){return YES}var b=Papercube.Paper.find(a);if(b){return(b.get("refCount")>=this._cached_linkThreshold&&b.get("citeCount")>=this._cached_citeThreshold)}return NO},citeThresholdDidChange:function(){var b=this.get("content");if(!this.get("isVisible")||!b){return}var a=this.get("citeThreshold");if(a!=this._cached_citeThreshold){this._hideExistingLines();this._cached_citeThreshold=a;this._render()}}.observes("citeThreshold")});function main(){if(SC.isIE()){alert("Papercube is currently not compatible with Internet Explorer.\n\nPlease use Firefox 3+, Safari 3+, Webkit, or Google Chrome.");return}if(SC.isFireFox()&&SC.Platform.Firefox<3){alert("To get the best user experience possible, please upgrade your browser.\n\nPlease use Firefox 3+, Safari 3+, Webkit, or Google Chrome.")}if(navigator.userAgent.indexOf("Chrome")!=-1){SC.isChrome=YES}SC.page.awake();if(!Papercube.viewController.parseHash()){setTimeout("fadeLoadingDiv()",1000)}else{Papercube.set("stillLoading",NO);$("bottom").addClassName("bottom-view-visible");SC.page.topView.addClassName("top-view-visible");SC.page.leftView.removeClassName("left-view-hidden")}Papercube.viewController.readSavedItemsCookie();setInterval("Papercube.animationController.runAnimation()",50);document.title="PaperCube - Peter Bergström";document.body.oncontextmenu=function(){return false};if(navigator.userAgent.indexOf("Chrome")!=-1){var b="";var d=document.body.className.split(" ");for(var a=0;a<d.length;a++){if(d[a]==="webkit"){b+="chrome "}else{b+=d[a]+" "}}document.body.className=b;SC.isChrome=YES}}function fadeLoadingDiv(){SC.page.loadingView.addClassName("faded");$("bottom").addClassName("bottom-view-visible");SC.page.topView.addClassName("top-view-visible");SC.page.leftView.removeClassName("left-view-hidden");SC.page.leftView.addClassName("left-view-visible");setTimeout("hideLoadingDiv()",1200)}function hideLoadingDiv(){SC.page.canvas.removeClassName("faded");SC.page.canvas.noContent.addClassName("show");Papercube.set("stillLoading",NO);Papercube.viewController.showDefaultView();Papercube.viewController.showVideo()};
