Array.prototype.contains=function(_1){ if(Array.prototype.indexOf){ return this.indexOf(_1)!=-1; } for(var i in this){ if(this[i]==_1){ return true; } } return false; }; Array.prototype.setLength=function(_3,_4){ _4=typeof _4!="undefined"?_4:null; for(var i=0;i<_3;i++){ this[i]=_4; } return this; }; Array.prototype.addDimension=function(_6,_7){ _7=typeof _7!="undefined"?_7:null; var _8=this.length; for(var i=0;i<_8;i++){ this[i]=[].setLength(_6,_7); } return this; }; Array.prototype.first=function(){ return this[0]; }; Array.prototype.last=function(){ return this[this.length-1]; }; Array.prototype.copy=function(){ var _a=[]; var _b=this.length; for(var i=0;i<_b;i++){ if(this[i] instanceof Array){ _a[i]=this[i].copy(); }else{ _a[i]=this[i]; } } return _a; }; if(!Array.prototype.map){ Array.prototype.map=function(_d){ var _e=this.length; if(typeof _d!="function"){ throw new TypeError(); } var _f=new Array(_e); var _10=arguments[1]; for(var i=0;i<_e;i++){ if(i in this){ _f[i]=_d.call(_10,this[i],i,this); } } return _f; }; } if(!Array.prototype.filter){ Array.prototype.filter=function(fun){ var len=this.length; if(typeof fun!="function"){ throw new TypeError(); } var res=new Array(); var _15=arguments[1]; for(var i=0;i=420}; eidogo.util={byId:function(id){ return document.getElementById(id); },makeQueryString:function(_4){ var qs=""; if(_4&&typeof _4=="object"){ var _6=[]; for(var _7 in _4){ if(_4[_7]&&_4[_7].constructor==Array){ for(var i=0;i<_4[_7].length;i++){ _6.push(encodeURIComponent(_7)+"="+encodeURIComponent(_4[_7])); } }else{ _6.push(encodeURIComponent(_7)+"="+encodeURIComponent(_4[_7])); } } qs=_6.join("&").replace(/%20/g,"+"); } return qs; },ajax:function(_9,_a,_b,_c,_d,_e,_f){ _9=_9.toUpperCase(); var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest(); var qs=(_b&&typeof _b=="object"?eidogo.util.makeQueryString(_b):null); if(qs&&_9=="GET"){ _a+=(_a.match(/\?/)?"&":"?")+qs; qs=null; } xhr.open(_9,_a,true); if(qs){ xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } var _12=false; var _13=/webkit/.test(navigator.userAgent.toLowerCase()); function httpSuccess(r){ try{ return !r.status&&location.protocol=="file:"||(r.status>=200&&r.status<300)||r.status==304||_13&&r.status==undefined; } catch(e){ } return false; } function handleReadyState(_15){ if(!_12&&xhr&&(xhr.readyState==4||_15=="timeout")){ _12=true; if(_16){ clearInterval(_16); _16=null; } var _17=_15=="timeout"&&"timeout"||!httpSuccess(xhr)&&"error"||"success"; if(_17=="success"){ _c.call(_e,xhr); }else{ _d.call(_e); } xhr=null; } } var _16=setInterval(handleReadyState,13); if(_f){ setTimeout(function(){ if(xhr){ xhr.abort(); if(!_12){ handleReadyState("timeout"); } } },_f); } xhr.send(qs); return xhr; },addEventHelper:function(_18,_19,_1a){ if(_18.addEventListener){ _18.addEventListener(_19,_1a,false); }else{ if(!eidogo.util.addEventId){ eidogo.util.addEventId=1; } if(!_1a.$$guid){ _1a.$$guid=eidogo.util.addEventId++; } if(!_18.events){ _18.events={}; } var _1b=_18.events[_19]; if(!_1b){ _1b=_18.events[_19]={}; if(_18["on"+_19]){ _1b[0]=_18["on"+_19]; } } _1b[_1a.$$guid]=_1a; _18["on"+_19]=eidogo.util.handleEvent; } },handleEvent:function(_1c){ var _1d=true; _1c=_1c||((this.ownerDocument||this.document||this).parentWindow||window).event; var _1e=this.events[_1c.type]; for(var i in _1e){ this.$$handleEvent=_1e[i]; if(this.$$handleEvent(_1c)===false){ _1d=false; } } return _1d; },addEvent:function(el,_21,_22,arg,_24){ if(!el){ return; } if(_24){ _22=_22.bind(arg); }else{ if(arg){ var _25=_22; _22=function(e){ _25(e,arg); }; } } eidogo.util.addEventHelper(el,_21,_22); },onClick:function(el,_28,_29){ eidogo.util.addEvent(el,"click",_28,_29,true); },getElClickXY:function(e,el,_2c){ var doc=el.ownerDocument; if(!e.pageX){ e.pageX=e.clientX+(doc.documentElement.scrollLeft||doc.body.scrollLeft); e.pageY=e.clientY+(doc.documentElement.scrollTop||doc.body.scrollTop); } var _2e=eidogo.util.getElXY(el,_2c); return [e.pageX-_2e[0],e.pageY-_2e[1]]; },stopEvent:function(e){ if(!e){ return; } if(e.stopPropagation){ e.stopPropagation(); }else{ e.cancelBubble=true; } if(e.preventDefault){ e.preventDefault(); }else{ e.returnValue=false; } },getTarget:function(ev){ var t=ev.target||ev.srcElement; return (t&&t.nodeName&&t.nodeName.toUpperCase()=="#TEXT")?t.parentNode:t; },addClass:function(el,cls){ if(!cls){ return; } var ca=cls.split(/\s+/); for(var i=0;i1||!n._parent._parent)){ _3e.push(n.getPosition()||0); } n=n._parent; } return _3e.reverse(); },getPathMoves:function(){ var _40=[]; var cur=new eidogo.GameCursor(this.node); _40.push(cur.node.getMove()); while(cur.previous()){ var _42=cur.node.getMove(); if(_42){ _40.push(_42); } } return _40.reverse(); },getMoveNumber:function(){ var num=0,_44=this.node; while(_44){ if(_44.W||_44.B){ num++; } _44=_44._parent; } return num; },getGameRoot:function(){ if(!this.node){ return null; } var cur=new eidogo.GameCursor(this.node); if(!this.node._parent&&this.node._children.length){ return this.node._children[0]; } while(cur.previous()){ } return cur.node; }}; eidogo.SgfParser=function(){ this.init.apply(this,arguments); }; eidogo.SgfParser.prototype={init:function(_1,_2){ _2=(typeof _2=="function")?_2:null; this.sgf=_1; this.index=0; this.root={_children:[]}; this.parseTree(this.root); _2&&_2.call(this); },parseTree:function(_3){ while(this.index1?_9:_9[0]; } _8=""; _9=[]; i=0; continue; } if(c!=" "&&c!="\n"&&c!="\r"&&c!="\t"){ _8+=c; } this.index++; } return _7; },curChar:function(){ return this.sgf.charAt(this.index); }}; eidogo.Board=function(){ this.init.apply(this,arguments); }; eidogo.Board.prototype={WHITE:1,BLACK:-1,EMPTY:0,init:function(_1,_2){ this.boardSize=_2||19; this.stones=this.makeBoardArray(this.EMPTY); this.markers=this.makeBoardArray(this.EMPTY); this.captures={}; this.captures.W=0; this.captures.B=0; this.cache=[]; this.renderer=_1||new eidogo.BoardRendererHtml(); this.lastRender={stones:this.makeBoardArray(null),markers:this.makeBoardArray(null)}; },reset:function(){ this.init(this.renderer,this.boardSize); },clear:function(){ this.clearStones(); this.clearMarkers(); this.clearCaptures(); },clearStones:function(){ for(var i=0;i2000){ throw "Error initializing board"; return; } setTimeout(arguments.callee.bind(this),10); _4a+=10; return; } this.swf=swf; this.swf.init(_46.uniq,_45); this.ready=true; }.bind(this); _4b(); },showRegion:function(_4c){ },hideRegion:function(){ },clear:function(){ if(!this.swf){ return; } this.swf.clear(); },renderStone:function(pt,_4e){ if(!this.swf){ this.unrendered.push(["stone",pt,_4e]); return; } for(var i=0;i"; },renderStone:function(pt,_59){ var _5a=(this.pointWidth*this.boardSize+this.margin*2)*(pt.y*this.pointHeight+1)+(pt.x*this.pointWidth)+2; this.content=this.content.substring(0,_5a-1)+"."+this.content.substring(_5a); if(_59!="empty"){ this.content=this.content.substring(0,_5a-1)+(_59=="white"?"O":"#")+this.content.substring(_5a); } this.domNode.innerHTML="
"+this.content+"
"; },renderMarker:function(pt,_5c){ }}; eidogo.Rules=function(_1){ this.init(_1); }; eidogo.Rules.prototype={init:function(_2){ this.board=_2; this.pendingCaptures=[]; },check:function(pt,_4){ if(this.board.getStone(pt)!=this.board.EMPTY){ return false; } return true; },apply:function(pt,_6){ this.doCaptures(pt,_6); },doCaptures:function(pt,_8){ var _9=0; _9+=this.doCapture({x:pt.x-1,y:pt.y},_8); _9+=this.doCapture({x:pt.x+1,y:pt.y},_8); _9+=this.doCapture({x:pt.x,y:pt.y-1},_8); _9+=this.doCapture({x:pt.x,y:pt.y+1},_8); _9-=this.doCapture(pt,-_8); if(_9<0){ _8=-_8; _9=-_9; } _8=_8==this.board.WHITE?"W":"B"; this.board.captures[_8]+=_9; },doCapture:function(pt,_b){ this.pendingCaptures=[]; if(this.findCaptures(pt,_b)){ return 0; } var _c=this.pendingCaptures.length; while(this.pendingCaptures.length){ this.board.addStone(this.pendingCaptures.pop(),this.board.EMPTY); } return _c; },findCaptures:function(pt,_e){ if(pt.x<0||pt.y<0||pt.x>=this.board.boardSize||pt.y>=this.board.boardSize){ return 0; } if(this.board.getStone(pt)==_e){ return 0; } if(this.board.getStone(pt)==this.board.EMPTY){ return 1; } for(var i=0;i1?cfg.loadPath:[0,0]; this.gameName=cfg.gameName||""; var _17=false; if(typeof cfg.sgf=="string"){ var sgf=new eidogo.SgfParser(cfg.sgf); this.load(sgf.root); }else{ if(typeof cfg.sgf=="object"){ this.load(cfg.sgf); }else{ if(cfg.progressiveLoad&&cfg.progressiveUrl){ this.progressiveLoads=0; this.progressiveUrl=cfg.progressiveUrl; this.fetchProgressiveData(_16); _17=true; }else{ if(typeof cfg.sgfUrl=="string"||this.gameName){ if(!cfg.sgfUrl){ cfg.sgfUrl=this.sgfPath+this.gameName+".sgf"; } this.remoteLoad(cfg.sgfUrl,null,false,null,_16); _17=true; if(cfg.progressiveLoad){ this.progressiveLoads=0; this.progressiveUrl=cfg.progressiveUrl||cfg.sgfUrl.replace(/\?.+$/,""); } }else{ var _19=cfg.boardSize||"19"; var _1a={19:6.5,13:4.5,9:3.5,7:2.5}; var _1b={_children:[{SZ:_19,KM:cfg.komi||_1a[_19]||6.5,_children:[]}]}; if(cfg.opponentUrl){ this.gameName="gnugo"; this.opponentUrl=cfg.opponentUrl; this.opponentColor=cfg.opponentColor=="B"?cfg.opponentColor:"W"; this.opponentLevel=cfg.opponentLevel||7; var _1c=_1b._children[0]; _1c.PW=this.opponentColor=="B"?t["you"]:"GNU Go"; _1c.PB=this.opponentColor=="B"?"GNU Go":t["you"]; _1c.HA=parseInt(cfg.handicap,10)||0; if(_1c.HA){ var _1d={19:[["pd","dp"],["pd","dp","pp"],["pd","dp","pp","dd"],["pd","dp","pp","dd","jj"],["pd","dp","pp","dd","dj","pj"],["pd","dp","pp","dd","dj","pj","jj"],["pd","dp","pp","dd","dj","pj","jd","jp"],["pd","dp","pp","dd","dj","pj","jd","jp","jj"]],13:[["jd","dj"],["jd","dj","jj"],["jd","dj","jj","dd"],["jd","dj","jj","dd","gg"],["jd","dj","jj","dd","dg","jg"],["jd","dj","jj","dd","dg","jg","gg"],["jd","dj","jj","dd","dg","jg","gd","gj"],["jd","dj","jj","dd","dg","jg","gd","gj","gg"]],9:[["cg","gc"],["cg","gc","gg"],["cg","gc","gg","cc"],["cg","gc","gg","cc","ee"],["cg","gc","gg","cc","ce","ge"],["cg","gc","gg","cc","ce","ge","ee"],["cg","gc","gg","cc","ce","ge","ec","eg"],["cg","gc","gg","cc","ce","ge","ec","eg","ee"]]}; _1c.KM=0.5; if(_1c.HA>1){ _1c.AB=_1d[_19][_1c.HA-2]; } } } this.load(_1b); } } } } if(!_17&&typeof _16=="function"){ _16(); } },load:function(_1e,_1f){ var _20=false; if(!_1f){ _1f=new eidogo.GameNode(); this.collectionRoot=_1f; } _1f.loadJson(_1e); _1f._cached=true; this.doneLoading(); this.progressiveLoads--; if(!_1f._parent){ var _21=this.loadPath.length?parseInt(this.loadPath[0],10):0; this.initGame(_1f._children[_21||0]); _20=true; } if(this.loadPath.length){ this.goTo(this.loadPath,_20); if(!this.progressiveLoad){ this.loadPath=[0,0]; } }else{ this.refresh(); } if(_20&&this.problemMode){ if(!this.problemColor){ this.currentColor=this.problemColor=(this.cursor.getNextColor()||"B"); }else{ this.currentColor=this.problemColor; } } },remoteLoad:function(url,_23,_24,_25,_26){ _24=_24=="undefined"?true:_24; _26=(typeof _26=="function")?_26:null; if(_24){ if(!_23){ this.gameName=url; } url=this.sgfPath+url+".sgf"; } if(_25){ this.loadPath=_25; } var _27=function(req){ var _29=req.responseText.replace(/^( |\t|\r|\n)*/,""); if(_29.charAt(0)=="("){ var me=this; var sgf=new eidogo.SgfParser(_29,function(){ me.load(this.root,_23); _26&&_26(); }); }else{ if(_29.charAt(0)=="{"){ _29=eval("("+_29+")"); this.load(_29,_23); _26&&_26(); }else{ this.croak(t["invalid data"]); } } }; var _2c=function(req){ this.croak(t["error retrieving"]); }; _3("get",url,null,_27,_2c,this,30000); },initGame:function(_2e){ _2e=_2e||{}; this.handleDisplayPrefs(); var _2f=_2e.SZ||19; if(_2f!=7&&_2f!=9&&_2f!=13&&_2f!=19){ _2f=19; } if(this.shrinkToFit){ this.calcShrinkToFit(_2e,_2f); }else{ if(this.problemMode&&!this.cropParams){ this.cropParams={width:_2f,height:_2f,top:0,left:0,padding:1}; } } if(!this.board){ this.createBoard(_2f); this.rules=new eidogo.Rules(this.board); } this.unsavedChanges=false; this.resetCursor(true); this.totalMoves=0; var _30=new eidogo.GameCursor(this.cursor.node); while(_30.next()){ this.totalMoves++; } this.totalMoves--; this.showGameInfo(_2e); this.enableNavSlider(); this.selectTool(this.mode=="view"?"view":"play"); this.hook("initGame"); },handleDisplayPrefs:function(){ (this.prefs.showGameInfo||this.prefs.showPlayerInfo?_a:_b)(this.dom.info); (this.prefs.showGameInfo?_a:_b)(this.dom.infoGame); (this.prefs.showPlayerInfo?_a:_b)(this.dom.infoPlayers); (this.prefs.showTools?_a:_b)(this.dom.toolsContainer); if(!this.showingSearch){ (this.prefs.showComments?_a:_b)(this.dom.comments); } (this.prefs.showOptions?_a:_b)(this.dom.options); (this.prefs.showNavTree?_a:_b)(this.dom.navTreeContainer); },createBoard:function(_31){ _31=_31||19; if(this.board&&this.board.renderer&&this.board.boardSize==_31){ return; } try{ this.dom.boardContainer.innerHTML=""; var _32=(this.renderer=="flash"?eidogo.BoardRendererFlash:eidogo.BoardRendererHtml); var _33=new _32(this.dom.boardContainer,_31,this,this.cropParams); this.board=new eidogo.Board(_33,_31); } catch(e){ if(e=="No DOM container"){ this.croak(t["error board"]); return; } } },calcShrinkToFit:function(_34,_35){ var l=null,t=null,r=null,b=null; var _39={}; var me=this; _34.walk(function(_3b){ var _3c,i,_3e; for(_3c in _3b){ if(/^(W|B|AW|AB|LB)$/.test(_3c)){ _3e=_3b[_3c]; if(!(_3e instanceof Array)){ _3e=[_3e]; } if(_3c!="LB"){ _3e=me.expandCompressedPoints(_3e); }else{ _3e=[_3e[0].split(/:/)[0]]; } for(i=0;i<_3e.length;i++){ _39[_3e[i]]=""; } } } }); for(var key in _39){ var pt=this.sgfCoordToPoint(key); if(l==null||pt.xr){ r=pt.x; } if(t==null||pt.yb){ b=pt.y; } } this.cropParams.width=r-l+1; this.cropParams.height=b-t+1; this.cropParams.left=l; this.cropParams.top=t; var pad=this.cropParams.padding; for(var _42=pad;l-_42<0;_42--){ } if(_42){ this.cropParams.width+=_42; this.cropParams.left-=_42; } for(var _43=pad;t-_43<0;_43--){ } if(_43){ this.cropParams.height+=_43; this.cropParams.top-=_43; } for(var _44=pad;r+_44>_35;_44--){ } if(_44){ this.cropParams.width+=_44; } for(var _45=pad;b+_45>_35;_45--){ } if(_45){ this.cropParams.height+=_45; } },fetchOpponentMove:function(){ this.nowLoading(t["gnugo thinking"]); var _46=function(req){ this.doneLoading(); this.createMove(req.responseText); }; var _48=function(req){ this.croak(t["error retrieving"]); }; var _4a=this.cursor.getGameRoot(); var _4b={sgf:_4a.toSgf(),move:this.currentColor,size:_4a.SZ,level:this.opponentLevel}; _3("post",this.opponentUrl,_4b,_46,_48,this,45000); },fetchScoreEstimate:function(){ this.nowLoading(t["gnugo thinking"]); var _4c=function(req){ this.doneLoading(); var _4e=req.responseText.split("\n"); var _4f,_50=_4e[1].split(" "); for(var i=0;i<_50.length;i++){ _4f=_50[i].split(":"); if(_4f[1]){ this.addMarker(_4f[1],_4f[0]); } } this.board.render(); this.prependComment(_4e[0]); }; var _52=function(req){ this.croak(t["error retrieving"]); }; var _54=this.cursor.getGameRoot(); var _55={sgf:_54.toSgf(),move:"est",size:_54.SZ||19,komi:_54.KM||0,mn:this.moveNumber+1}; _3("post",this.scoreEstUrl,_55,_4c,_52,this,45000); },playProblemResponse:function(_56){ setTimeout(function(){ this.variation(null,_56); if(this.hooks.playProblemResponse){ this.hook("playProblemResponse"); }else{ if(!this.cursor.hasNext()){ this.prependComment(t["end of variation"]); } } }.bind(this),200); },goTo:function(_57,_58){ _58=typeof _58!="undefined"?_58:true; if(_58&&_57.length>1&&_57[0]!=this.cursor.getGameRoot().getPosition()){ this.updatedNavTree=false; } if(_58){ this.resetCursor(true); } var _59=parseInt(_57,10); if(!(_57 instanceof Array)&&!isNaN(_59)){ if(_58){ _59++; } for(var i=0;i<_59;i++){ this.variation(null,true); } this.refresh(); return; } if(!(_57 instanceof Array)||!_57.length){ alert(t["bad path"]+" "+_57); return; } var _5b; var _5c; if(isNaN(parseInt(_57[0],10))){ if(!this.cursor.node._parent){ this.variation(0,true); } while(_57.length){ if(this.progressiveLoads>0){ this.loadPath.push(_5b); return; } _5b=_57.shift(); _5c=this.getVariations(); for(var i=0;i<_5c.length;i++){ if(_5c[i].move==_5b){ this.variation(_5c[i].varNum,true); break; } } } this.refresh(); return; } var _5d=true; while(_57.length){ _5b=parseInt(_57.shift(),10); if(!_57.length){ for(var i=0;i<_5b;i++){ this.variation(0,true); } }else{ if(_57.length){ if(!_5d&&_58){ while(this.cursor.node._children.length==1){ this.variation(0,true); } } this.variation(_5b,true); } } _5d=false; } this.refresh(); },resetCursor:function(_5e,_5f){ this.board.reset(); this.resetCurrentColor(); if(_5f){ this.cursor.node=this.cursor.getGameRoot(); }else{ this.cursor.node=this.collectionRoot; } this.refresh(_5e); },resetCurrentColor:function(){ this.currentColor=(this.problemMode?this.problemColor:"B"); var _60=this.cursor.getGameRoot(); if(_60&&_60.HA>1){ this.currentColor="W"; } },refresh:function(_61){ if(this.progressiveLoads>0){ var me=this; setTimeout(function(){ me.refresh.call(me); },10); return; } this.board.revert(1); this.execNode(_61); },variation:function(_63,_64){ if(this.cursor.next(_63)){ this.execNode(_64); this.resetLastLabels(); if(this.progressiveLoads>0){ return false; } return true; } return false; },execNode:function(_65,_66){ if(!_66&&this.progressiveLoads>0){ var me=this; setTimeout(function(){ me.execNode.call(me,_65); },10); return; } if(!this.cursor.node){ return; } if(!_65){ this.dom.comments.innerHTML=""; this.board.clearMarkers(); this.moveNumber=this.cursor.getMoveNumber(); } if(this.moveNumber<1){ this.resetCurrentColor(); } var _68=this.cursor.node.getProperties(); for(var _69 in _68){ if(this.propertyHandlers[_69]){ (this.propertyHandlers[_69]).apply(this,[this.cursor.node[_69],_69,_65]); } } if(_65){ this.board.commit(); }else{ if(this.opponentUrl&&this.opponentColor==this.currentColor&&this.moveNumber==this.totalMoves){ this.fetchOpponentMove(); } this.findVariations(); this.updateControls(); this.board.commit(); this.board.render(); } if(!_66&&this.progressiveUrl){ this.fetchProgressiveData(); } if(this.problemMode&&this.currentColor&&this.currentColor!=this.problemColor&&!this.goingBack){ this.playProblemResponse(_65); } this.goingBack=false; },fetchProgressiveData:function(_6a){ var _6b=this.cursor.node||null; if(_6b&&_6b._cached){ return; } if(this.progressiveMode=="pattern"){ if(_6b&&!_6b._parent._parent){ return; } this.fetchProgressiveContinuations(_6a); }else{ var _6c=(_6b&&_6b._id)||0; this.nowLoading(); this.progressiveLoads++; var _6d=function(){ var _6e=this.cursor.getMoveNumber(); if(_6e>1){ this.cursor.node.C=""+t["show games"]+""+(this.cursor.node.C||""); } this.refresh(); if(_6a&&typeof _6a=="function"){ _6a(); } _4(_2("cont-search"),"click",function(e){ var _70=8; var _71=this.board.getRegion(0,19-_70,_70,_70); var _72=this.convertRegionPattern(_71); this.loadSearch("ne",_70+"x"+_70,this.compressPattern(_72)); _7(e); }.bind(this)); }.bind(this); var url=this.progressiveUrl+"?"+eidogo.util.makeQueryString({id:_6c,pid:this.uniq}); this.remoteLoad(url,_6b,false,null,_6d); } },fetchProgressiveContinuations:function(_74){ this.nowLoading(); this.progressiveLoads++; var _75=this.cursor.getMoveNumber(); var _76=(_75>1?11:7); var _77=19-_76-1; var _78=this.board?this.convertRegionPattern(this.board.getRegion(0,_77+1,_76,_76)):"................................................."; var _79={q:"ne",w:_76,h:_76,p:_78,a:"continuations",t:(new Date()).getTime()}; var _7a=function(req){ this.croak(t["error retrieving"]); }; var _7c=function(req){ if(!req.responseText||req.responseText=="NONE"){ this.progressiveLoads--; this.doneLoading(); this.cursor.node._cached=true; this.refresh(); return; } var _7e={LB:[],_children:[]},_7f; _7e.C=_75>1?""+t["show games"]+"":""; var _80,_81=eval("("+req.responseText+")"); if(_81.length){ _81.sort(function(a,b){ return parseInt(b.count,10)-parseInt(a.count,10); }); var _84=parseInt(_81[0].count,10); var x,y,_87,_88; _7e.C+="
"; for(var i=0;_80=_81[i];i++){ _88=parseInt(_80.count/_84*150); if(_84>20&&parseInt(_80.count,10)<10){ continue; } _7f={}; x=_77+parseInt(_80.x,10)+1; y=parseInt(_80.y,10); _87=this.pointToSgfCoord({x:x,y:y}); _7f[this.currentColor||"B"]=_87; _7e.LB.push(_87+":"+_80.label); if(_88){ _7e.C+="
"+"
"+_80.label+"
"+"
"+"
"+_80.count+"
"+"
"; } _7e._children.push(_7f); } _7e.C+="
"; if(!this.cursor.node){ _7e={_children:[_7e]}; } } this.load(_7e,this.cursor.node); _4(_2("cont-search"),"click",function(e){ this.loadSearch("ne",_76+"x"+_76,this.compressPattern(_78)); _7(e); }.bind(this)); if(_74&&typeof _74=="function"){ _74(); } }.bind(this); _3("get",this.progressiveUrl,_79,_7c,_7a,this,45000); },findVariations:function(){ this.variations=this.getVariations(); },getVariations:function(){ var _8b=[],_8c=this.cursor.node._children; for(var i=0;i<_8c.length;i++){ _8b.push({move:_8c[i].getMove(),varNum:i}); } return _8b; },back:function(e,obj,_90){ if(this.cursor.previous()){ this.board.revert(1); this.goingBack=true; this.refresh(_90); this.resetLastLabels(); } },forward:function(e,obj,_93){ this.variation(null,_93); },first:function(){ if(!this.cursor.hasPrevious()){ return; } this.resetCursor(false,true); },last:function(){ if(!this.cursor.hasNext()){ return; } while(this.variation(null,true)){ } this.refresh(); },pass:function(){ if(!this.variations){ return; } for(var i=0;i=0&&y>=0&&!this.regionBegun){ this.regionTop=y; this.regionLeft=x; this.regionBegun=true; } },handleBoardHover:function(x,y,cx,cy,e){ if(this.domLoading){ return; } if(this.mouseDown||this.regionBegun){ if(!this.boundsCheck(x,y,[0,this.board.boardSize-1])){ return; } var _9f=(x!=this.mouseDownX||y!=this.mouseDownY); var _a0=Math.abs(this.mouseDownClickX-cx)>=19||Math.abs(this.mouseDownClickY-cy)>=19; if(this.searchUrl&&!this.regionBegun&&_9f&&_a0){ this.selectTool("region"); this.regionBegun=true; this.regionTop=this.mouseDownY; this.regionLeft=this.mouseDownX; } if(this.regionBegun){ this.regionRight=x+(x>=this.regionLeft?1:0); this.regionBottom=y+(y>=this.regionTop?1:0); this.showRegion(); } _7(e); } },handleBoardMouseUp:function(x,y,e){ if(this.domLoading){ return; } this.mouseDown=false; var _a4=this.pointToSgfCoord({x:x,y:y}); if(this.mode=="view"||this.mode=="play"){ for(var i=0;i=-1&&y>=-1&&this.regionBegun){ if(this.regionTop==y&&this.regionLeft==x&&!this.regionClickSelect){ this.regionClickSelect=true; this.regionRight=x+1; this.regionBottom=y+1; this.showRegion(); }else{ this.regionBegun=false; this.regionClickSelect=false; this.regionBottom=(y<0?0:(y>=this.board.boardSize)?y:y+(y>this.regionTop?1:0)); this.regionRight=(x<0?0:(x>=this.board.boardSize)?x:x+(x>this.regionLeft?1:0)); this.showRegion(); _a(this.dom.searchButton,"inline"); _7(e); } }else{ var _ac; var _ad=this.board.getStone({x:x,y:y}); if(this.mode=="add_b"||this.mode=="add_w"){ var _ae=this.cursor.node.emptyPoint(this.pointToSgfCoord({x:x,y:y})); if(_ad!=this.board.BLACK&&this.mode=="add_b"){ _ac="AB"; }else{ if(_ad!=this.board.WHITE&&this.mode=="add_w"){ _ac="AW"; }else{ if(this.board.getStone({x:x,y:y})!=this.board.EMPTY&&!_ae){ _ac="AE"; } } } }else{ switch(this.mode){ case "tr": _ac="TR"; break; case "sq": _ac="SQ"; break; case "cr": _ac="CR"; break; case "x": _ac="MA"; break; case "dim": _ac="DD"; break; case "number": _ac="LB"; _a4=_a4+":"+this.labelLastNumber; this.labelLastNumber++; break; case "letter": _ac="LB"; _a4=_a4+":"+this.labelLastLetter; this.labelLastLetter=String.fromCharCode(this.labelLastLetter.charCodeAt(0)+1); break; case "label": _ac="LB"; _a4=_a4+":"+this.dom.labelInput.value; break; case "clear": this.cursor.node.deletePropertyValue(["TR","SQ","CR","MA","DD","LB"],new RegExp("^"+_a4)); break; } if(this.cursor.node.hasPropertyValue(_ac,_a4)){ this.cursor.node.deletePropertyValue(_ac,_a4); _ac=null; } } if(_ac){ this.cursor.node.pushProperty(_ac,_a4); } this.unsavedChanges=true; var _ae=this.checkForEmptyNode(); this.refresh(); if(_ae){ this.prependComment(t["position deleted"]); } } } },checkForEmptyNode:function(){ if(!eidogo.util.numProperties(this.cursor.node.getProperties())){ var _af=window.confirm(t["confirm delete"]); if(_af){ var id=this.cursor.node._id; var _b1=0; this.back(); this.cursor.node._children=this.cursor.node._children.filter(function(_b2,i){ if(_b2._id==id){ _b1=i; return false; }else{ return true; } }); if(_b1&&this.cursor.node._preferredChild==_b1){ this.cursor.node._preferredChild--; } return true; } } return false; },handleDocMouseUp:function(evt){ if(this.domLoading){ return true; } if(this.mode=="region"&&this.regionBegun&&!this.regionClickSelect){ this.mouseDown=false; this.regionBegun=false; _a(this.dom.searchButton,"inline"); } return true; },boundsCheck:function(x,y,_b7){ if(_b7.length==2){ _b7[3]=_b7[2]=_b7[1]; _b7[1]=_b7[0]; } return (x>=_b7[0]&&y>=_b7[1]&&x<=_b7[2]&&y<=_b7[3]); },getRegionBounds:function(){ var l=this.regionLeft; var w=this.regionRight-this.regionLeft; if(w<0){ l=this.regionRight; w=-w+1; } var t=this.regionTop; var h=this.regionBottom-this.regionTop; if(h<0){ t=this.regionBottom; h=-h+1; } return [t,l,w,h]; },showRegion:function(){ var _bc=this.getRegionBounds(); this.board.renderer.showRegion(_bc); },hideRegion:function(){ this.board.renderer.hideRegion(); },convertRegionPattern:function(_bd){ return _bd.join("").replace(new RegExp(this.board.EMPTY,"g"),".").replace(new RegExp(this.board.BLACK,"g"),"x").replace(new RegExp(this.board.WHITE,"g"),"o"); },loadSearch:function(q,dim,p,a,o){ var _c3={_children:[{SZ:this.board.boardSize,_children:[]}]}; this.load(_c3); a=a||"corner"; this.dom.searchAlgo.value=a; p=this.uncompressPattern(p); dim=dim.split("x"); var w=dim[0]; var h=dim[1]; var bs=this.board.boardSize; var l; var t; switch(q){ case "nw": l=0; t=0; break; case "ne": l=bs-w; t=0; break; case "se": l=bs-w; t=bs-h; break; case "sw": l=0; t=bs-h; break; } var c; var x; var y; for(y=0;y "+_dc.id+" "+_dc.mv+" "+_dc.pw+" "+_dc.wr+" "+_dc.pb+" "+_dc.br+" "+_dc.re+" "+_dc.dt+"
 
"; } if(_df>_e1){ _dd+=""; } _a(this.dom.searchResultsContainer); this.dom.searchResults.innerHTML=_dd+"
"; this.dom.searchCount.innerHTML=_df; this.dom.searchOffsetStart.innerHTML=_e0; this.dom.searchOffsetEnd.innerHTML=(_df<_e1?_df:_e1); this.dom.searchContainer.scrollTop=0; if(_df>_e1){ setTimeout(function(){ _4(_2("search-more"),"click",function(e){ this.loadSearch(_d7,_d0[2]+"x"+_d0[3],_d2,"corner",ret.offset+51); _7(e); }.bind(this)); }.bind(this),0); } }; var _e4=function(req){ this.croak(t["error retrieving"]); }; var _e6={q:_d7,w:_d0[2],h:_d0[3],p:_d2,a:_cf,o:_ce,t:(new Date()).getTime()}; this.progressiveLoad=false; this.progressiveUrl=null; this.prefs.markNext=false; this.prefs.showPlayerInfo=true; this.hook("searchRegion",_e6); this.nowLoading(); _3("get",this.searchUrl,_e6,_d8,_e4,this,45000); },loadSearchResult:function(e){ this.nowLoading(); var _e8=e.target||e.srcElement; if(_e8.nodeName=="SPAN"){ _e8=_e8.parentNode; } if(_e8.nodeName=="A"){ var _e9; var id; var mv; for(var i=0;_e9=_e8.childNodes[i];i++){ if(_e9.className=="id"){ id=_e9.innerHTML; } if(_e9.className=="mv"){ mv=parseInt(_e9.innerHTML,10); } } } this.remoteLoad(id,null,true,[0,mv],function(){ this.doneLoading(); this.setPermalink(); this.prefs.showOptions=true; this.handleDisplayPrefs(); }.bind(this)); _7(e); },closeSearch:function(){ this.showingSearch=false; _b(this.dom.searchContainer); _a(this.dom.comments); },compressPattern:function(_ed){ var c=null; var pc=""; var n=1; var ret=""; for(var i=0;i<_ed.length;i++){ c=_ed.charAt(i); if(c==pc){ n++; }else{ ret=ret+pc+(n>1?n:""); n=1; pc=c; } } ret=ret+pc+(n>1?n:""); return ret; },uncompressPattern:function(_f3){ var c=null; var s=null; var n=""; var ret=""; for(var i=0;i<_f3.length;i++){ c=_f3.charAt(i); if(c=="."||c=="x"||c=="o"){ if(s!=null){ n=parseInt(n,10); n=isNaN(n)?1:n; for(var j=0;j9?9:_107-1); for(var i=0;i<_108;i++){ this.forward(null,null,true); } } this.forward(); break; case 37: if(e.shiftKey){ var _108=(this.moveNumber>9?9:this.moveNumber-1); for(var i=0;i<_108;i++){ this.back(null,null,true); } } this.back(); break; case 40: this.last(); break; case 38: this.first(); break; case 192: this.pass(); break; default: stop=false; break; } if(stop){ _7(e); } },showGameInfo:function(_109){ this.hook("showGameInfo",_109); if(!_109){ return; } this.dom.infoGame.innerHTML=""; this.dom.whiteName.innerHTML=""; this.dom.blackName.innerHTML=""; var dl=document.createElement("dl"),val; for(var _10c in this.infoLabels){ if(_109[_10c] instanceof Array){ _109[_10c]=_109[_10c][0]; } if(_109[_10c]){ if(_10c=="PW"){ this.dom.whiteName.innerHTML=_109[_10c]+(_109["WR"]?", "+_109["WR"]:""); continue; }else{ if(_10c=="PB"){ this.dom.blackName.innerHTML=_109[_10c]+(_109["BR"]?", "+_109["BR"]:""); continue; } } if(_10c=="WR"||_10c=="BR"){ continue; } val=_109[_10c]; if(_10c=="DT"){ var _10d=_109[_10c].split(/[\.-]/); if(_10d.length==3){ val=_10d[2].replace(/^0+/,"")+" "+this.months[_10d[1]-1]+" "+_10d[0]; } } var dt=document.createElement("dt"); dt.innerHTML=this.infoLabels[_10c]+":"; var dd=document.createElement("dd"); dd.innerHTML=val; dl.appendChild(dt); dl.appendChild(dd); } } this.dom.infoGame.appendChild(dl); },selectTool:function(tool){ var _111; _b(this.dom.scoreEst); _b(this.dom.labelInput); if(tool=="region"){ _111="crosshair"; }else{ if(tool=="comment"){ this.startEditComment(); }else{ if(tool=="gameinfo"){ this.startEditGameInfo(); }else{ if(tool=="label"){ _a(this.dom.labelInput,"inline"); this.dom.labelInput.focus(); }else{ _111="default"; this.regionBegun=false; this.hideRegion(); _b(this.dom.searchButton); _b(this.dom.searchAlgo); if(this.searchUrl){ _a(this.dom.scoreEst,"inline"); } } } } } this.board.renderer.setCursor(_111); this.mode=tool; this.dom.toolsSelect.value=tool; },startEditComment:function(){ this.closeSearch(); var div=this.dom.commentsEdit; div.style.position="absolute"; div.style.top=this.dom.comments.offsetTop+"px"; div.style.left=this.dom.comments.offsetLeft+"px"; _a(this.dom.shade); this.dom.comments.innerHTML=""; _a(div); _a(this.dom.commentsEditDone); this.dom.commentsEditTa.value=this.cursor.node.C||""; this.dom.commentsEditTa.focus(); this.editingText=true; },finishEditComment:function(){ this.editingText=false; var oldC=this.cursor.node.C; var newC=this.dom.commentsEditTa.value; if(oldC!=newC){ this.unsavedChanges=true; this.cursor.node.C=newC; } if(!this.cursor.node.C){ delete this.cursor.node.C; } _b(this.dom.shade); _b(this.dom.commentsEdit); _a(this.dom.comments); this.selectTool("play"); var _115=this.checkForEmptyNode(); this.refresh(); if(_115){ this.prependComment(t["position deleted"]); } },startEditGameInfo:function(){ this.closeSearch(); var div=this.dom.gameInfoEdit; div.style.position="absolute"; div.style.top=this.dom.comments.offsetTop+"px"; div.style.left=this.dom.comments.offsetLeft+"px"; _a(this.dom.shade); this.dom.comments.innerHTML=""; _a(div); _a(this.dom.gameInfoEditDone); var root=this.cursor.getGameRoot(); var html=[""]; for(var prop in this.infoLabels){ html.push(""); } html.push("
"+this.infoLabels[prop]+":"+""+""+"
"); this.dom.gameInfoEditForm.innerHTML=html.join(""); setTimeout(function(){ _2("game-info-edit-field-GN").focus(); },0); this.editingText=true; },finishEditGameInfo:function(){ this.editingText=false; _b(this.dom.shade); _b(this.dom.gameInfoEdit); _a(this.dom.comments); var root=this.cursor.getGameRoot(); var _11b=null; for(var prop in this.infoLabels){ _11b=_2("game-info-edit-field-"+prop).value; if((root[prop]||"")!=_11b){ root[prop]=_11b; this.unsavedChanges=true; } } this.showGameInfo(root); this.dom.gameInfoEditForm.innerHTML=""; this.selectTool("play"); this.refresh(); },updateControls:function(){ this.dom.moveNumber.innerHTML=(this.moveNumber?(t["move"]+" "+this.moveNumber):(this.permalinkable?"permalink":"")); this.dom.whiteCaptures.innerHTML=t["captures"]+": "+this.board.captures.W+""; this.dom.blackCaptures.innerHTML=t["captures"]+": "+this.board.captures.B+""; this.dom.whiteTime.innerHTML=t["time left"]+": "+(this.timeW?this.timeW:"--")+""; this.dom.blackTime.innerHTML=t["time left"]+": "+(this.timeB?this.timeB:"--")+""; _9(this.dom.controlPass,"pass-on"); this.dom.variations.innerHTML=""; for(var i=0;i1){ var _120=this.sgfCoordToPoint(this.variations[i].move); if(this.board.getMarker(_120)!=this.board.EMPTY){ var _121=this.board.getMarker(_120); if(_121.indexOf("var:")!==0){ _11e=_121; }else{ _11f=true; } } if(this.prefs.markVariations&&!_11f){ this.board.addMarker(_120,"var:"+_11e); } } } var _122=document.createElement("div"); _122.className="variation-nav"; _122.innerHTML=_11e; _4(_122,"click",function(e,arg){ arg.me.variation(arg.varNum); },{me:this,varNum:this.variations[i].varNum}); this.dom.variations.appendChild(_122); } if(this.variations.length<2){ this.dom.variations.innerHTML="
"+t["no variations"]+"
"; } if(this.cursor.hasNext()){ _8(this.dom.controlForward,"forward-on"); _8(this.dom.controlLast,"last-on"); }else{ _9(this.dom.controlForward,"forward-on"); _9(this.dom.controlLast,"last-on"); } if(this.cursor.hasPrevious()){ _8(this.dom.controlBack,"back-on"); _8(this.dom.controlFirst,"first-on"); }else{ _9(this.dom.controlBack,"back-on"); _9(this.dom.controlFirst,"first-on"); var info=""; if(!this.prefs.showPlayerInfo){ info+=this.getGameDescription(true); } if(!this.prefs.showGameInfo){ info+=this.dom.infoGame.innerHTML; } if(info.length&&this.theme!="problem"){ this.prependComment(info,"comment-info"); } } if(!this.progressiveLoad){ this.updateNavSlider(); } if(this.prefs.showNavTree){ this.updateNavTree(); } var node=this.cursor.node,pos,html,js; if(node._parent&&!node._parent._parent&&node._parent._children.length>1){ pos=node.getPosition(); html=t["multi-game sgf"]; js="javascript:eidogo.delegate("+this.uniq+", \"goTo\", ["; if(pos){ html+=""+t["previous game"]+""; } if(node._parent._children[pos+1]){ html+=(pos?" | ":"")+""+t["next game"]+""; } this.prependComment(html,"comment-info"); } },setColor:function(_12a){ this.prependComment(_12a=="B"?t["black to play"]:t["white to play"]); this.currentColor=this.problemColor=_12a; },setMoveNumber:function(num){ this.moveNumber=num; },playMove:function(_12c,_12d,_12e){ _12d=_12d||this.currentColor; this.currentColor=(_12d=="B"?"W":"B"); _12d=_12d=="W"?this.board.WHITE:this.board.BLACK; var pt=this.sgfCoordToPoint(_12c); if((!_12c||_12c=="tt"||_12c=="")&&!_12e){ this.prependComment((_12d==this.board.WHITE?t["white"]:t["black"])+" "+t["passed"],"comment-pass"); }else{ if(_12c=="resign"){ this.prependComment((_12d==this.board.WHITE?t["white"]:t["black"])+" "+t["resigned"],"comment-resign"); }else{ if(_12c&&_12c!="tt"){ this.board.addStone(pt,_12d); this.rules.apply(pt,_12d); if(this.prefs.markCurrent&&!_12e){ this.addMarker(_12c,"current"); } } } } },addStone:function(_130,_131){ if(!(_130 instanceof Array)){ _130=[_130]; } _130=this.expandCompressedPoints(_130); for(var i=0;i<_130.length;i++){ this.board.addStone(this.sgfCoordToPoint(_130[i]),_131=="AW"?this.board.WHITE:_131=="AB"?this.board.BLACK:this.board.EMPTY); } },addMarker:function(_133,type){ if(!(_133 instanceof Array)){ _133=[_133]; } _133=this.expandCompressedPoints(_133); var _135; for(var i=0;i<_133.length;i++){ switch(type){ case "TR": _135="triangle"; break; case "SQ": _135="square"; break; case "CR": _135="circle"; break; case "MA": _135="ex"; break; case "TW": _135="territory-white"; break; case "TB": _135="territory-black"; break; case "DD": _135="dim"; break; case "LB": _135=(_133[i].split(":"))[1]; break; default: _135=type; break; } this.board.addMarker(this.sgfCoordToPoint((_133[i].split(":"))[0]),_135); } },showTime:function(_137,type){ var tp=(type=="BL"||type=="OB"?"timeB":"timeW"); if(type=="BL"||type=="WL"){ var mins=Math.floor(_137/60); var secs=(_137%60).toFixed(0); secs=(secs<10?"0":"")+secs; this[tp]=mins+":"+secs; }else{ this[tp]+=" ("+_137+")"; } },showAnnotation:function(_13c,type){ var msg; switch(type){ case "N": msg=_13c; break; case "GB": msg=(_13c>1?t["vgb"]:t["gb"]); break; case "GW": msg=(_13c>1?t["vgw"]:t["gw"]); break; case "DM": msg=(_13c>1?t["dmj"]:t["dm"]); break; case "UC": msg=t["uc"]; break; case "TE": msg=t["te"]; break; case "BM": msg=(_13c>1?t["vbm"]:t["bm"]); break; case "DO": msg=t["do"]; break; case "IT": msg=t["it"]; break; case "HO": msg=t["ho"]; break; } this.prependComment(msg); },showComments:function(_13f,junk,_141){ if(!_13f||_141){ return; } this.dom.comments.innerHTML+=_13f.replace(/^(\n|\r|\t|\s)+/,"").replace(/\n/g,"
"); },prependComment:function(_142,cls){ cls=cls||"comment-status"; this.dom.comments.innerHTML="
"+_142+"
"+this.dom.comments.innerHTML; },downloadSgf:function(evt){ _7(evt); if(this.downloadUrl){ if(this.unsavedChanges){ alert(t["unsaved changes"]); return; } location.href=this.downloadUrl+this.gameName; }else{ if(_c){ location.href="data:text/plain,"+encodeURIComponent(this.cursor.getGameRoot().toSgf()); } } },save:function(evt){ _7(evt); var _146=function(req){ this.hook("saved",[req.responseText]); }; var _148=function(req){ this.croak(t["error retrieving"]); }; var sgf=this.cursor.getGameRoot().toSgf(); _3("POST",this.saveUrl,{sgf:sgf},_146,_148,this,30000); },constructDom:function(){ this.dom.player=document.createElement("div"); this.dom.player.className="eidogo-player"+(this.theme?" theme-"+this.theme:""); this.dom.player.id="player-"+this.uniq; this.dom.container.innerHTML=""; eidogo.util.show(this.dom.container); this.dom.container.appendChild(this.dom.player); var _14b="
  • First
  • Back
  • Forward
  • Last
  • Pass
"+t["variations"]+":
"+t["done"]+"
"+t["done"]+"
"+t["close search"]+"

 "+t["matches found"]+" Showing -

"+t["white"]+" "+t["black"]+" "+t["result"]+" "+t["date"]+"
"+(this.saveUrl?""+t["save to server"]+"":"")+" "+(this.downloadUrl||_c?""+t["download sgf"]+"":"")+"
Show variations on board
Mark current move
"; _14b=_14b.replace(/ id='([^']+)'/g," id='$1-"+this.uniq+"'"); this.dom.player.innerHTML=_14b; var re=/ id='([^']+)-\d+'/g; var _14d; var id; var _14f; while(_14d=re.exec(_14b)){ id=_14d[0].replace(/'/g,"").replace(/ id=/,""); _14f=""; _14d[1].split("-").forEach(function(word,i){ word=i?word.charAt(0).toUpperCase()+word.substring(1):word; _14f+=word; }); this.dom[_14f]=_2(id); } [["moveNumber","setPermalink"],["controlFirst","first"],["controlBack","back"],["controlForward","forward"],["controlLast","last"],["controlPass","pass"],["scoreEst","fetchScoreEstimate"],["searchButton","searchRegion"],["searchResults","loadSearchResult"],["searchClose","closeSearch"],["optionDownload","downloadSgf"],["optionSave","save"],["commentsEditDone","finishEditComment"],["gameInfoEditDone","finishEditGameInfo"],["navTree","navTreeClick"]].forEach(function(eh){ if(this.dom[eh[0]]){ _5(this.dom[eh[0]],this[eh[1]],this); } }.bind(this)); _4(this.dom.toolsSelect,"change",function(e){ this.selectTool.apply(this,[(e.target||e.srcElement).value]); },this,true); },enableNavSlider:function(){ if(this.progressiveLoad){ _b(this.dom.navSliderThumb); return; } this.dom.navSlider.style.cursor="pointer"; var _154=false; var _155=null; _4(this.dom.navSlider,"mousedown",function(e){ _154=true; _7(e); },this,true); _4(document,"mousemove",function(e){ if(!_154){ return; } var xy=_6(e,this.dom.navSlider); clearTimeout(_155); _155=setTimeout(function(){ this.updateNavSlider(xy[0]); }.bind(this),10); _7(e); },this,true); _4(document,"mouseup",function(e){ if(!_154){ return true; } _154=false; var xy=_6(e,this.dom.navSlider); this.updateNavSlider(xy[0]); return true; },this,true); },updateNavSlider:function(_15b){ var _15c=this.dom.navSlider.offsetWidth-this.dom.navSliderThumb.offsetHeight; var _15d=this.totalMoves; var _15e=!!_15b; _15b=_15b||(this.moveNumber/_15d*_15c); _15b=_15b>_15c?_15c:_15b; _15b=_15b<0?0:_15b; var _15f=parseInt(_15b/_15c*_15d,10); if(_15e){ this.nowLoading(); var _160=_15f-this.cursor.getMoveNumber(); for(var i=0;i0){ this.variation(null,true); }else{ if(_160<0){ this.cursor.previous(); } } } if(_160<0){ this.board.revert(Math.abs(_160)); } this.doneLoading(); this.refresh(); } _15b=parseInt(_15f/_15d*_15c,10)||0; this.dom.navSliderThumb.style.left=_15b+"px"; },updateNavTree:function(_162){ if(!this.prefs.showNavTree){ return; } if(this.updatedNavTree){ this.showNavTreeCurrent(); return; } if(!_162){ if(this.navTreeTimeout){ clearTimeout(this.navTreeTimeout); } this.navTreeTimeout=setTimeout(function(){ this.updateNavTree(true); }.bind(this),eidogo.browser.ie?1000:500); return; } this.updatedNavTree=true; var _163=[],_164=this.cursor.getGameRoot(); path=[_164.getPosition()],cur=new eidogo.GameCursor(),maxx=0; var _166=function(node,_168,_169){ var y=_169,x=_168; var n=node,_16d=1; while(n&&n._children.length==1){ _16d++; n=n._children[0]; } while(_163[y]&&_163[y].slice(x,x+_16d+1).some(function(el){ return (typeof el!="undefined"); })){ y++; } do{ if(!_163[y]){ _163[y]=[]; } cur.node=node; node._pathStr=path.join("-")+"-"+(x-_168); _163[y][x]=node; if(x>maxx){ maxx=x; } x++; if(node._children.length!=1){ break; } node=node._children[0]; }while(node); for(var i=0;i"],node,td,cur=new eidogo.GameCursor(),x,y,_175,_176=1,LINE=2; for(x=0;x0;y--){ if(!_163[y][x]){ if(typeof _163[y][x+1]=="object"){ _163[y][x]=_176; _175=true; }else{ if(_175){ _163[y][x]=LINE; } } }else{ _175=false; } } } for(y=0;y<_163.length;y++){ html.push(""); for(x=0;x<_163[y].length;x++){ node=_163[y][x]; if(node==_176){ td="
"; }else{ if(node==LINE){ td="
"; }else{ if(node){ td=["",x,""].join(""); }else{ td="
"; } } } html.push(""); html.push(td); html.push(""); } html.push(""); } html.push(""); this.dom.navTree.innerHTML=html.join(""); setTimeout(function(){ this.showNavTreeCurrent(); }.bind(this),0); },showNavTreeCurrent:function(){ var id="navtree-node-"+this.cursor.getPath().join("-"),_179=_2(id); if(!_179){ return; } if(this.prevNavTreeCurrent){ this.prevNavTreeCurrent.className=this.prevNavTreeCurrentClass; } this.prevNavTreeCurrent=_179; this.prevNavTreeCurrentClass=_179.className; _179.className="current"; var w=_179.offsetWidth,h=_179.offsetHeight,xy=eidogo.util.getElXY(_179),_17d=eidogo.util.getElXY(this.dom.navTree),l=xy[0]-_17d[0],t=xy[1]-_17d[1],ntc=this.dom.navTreeContainer,maxl=ntc.scrollLeft,maxr=maxl+ntc.offsetWidth-100; maxt=ntc.scrollTop,maxb=maxt+ntc.offsetHeight-30; if(lmaxr){ ntc.scrollLeft+=((l+w)-maxr); } if(tmaxb){ ntc.scrollTop+=((t+h)-maxb); } },navTreeClick:function(e){ var _183=e.target||e.srcElement; if(!_183||!_183.id){ return; } var path=_183.id.replace(/^navtree-node-/,"").split("-"); this.goTo(path,true); _7(e); },resetLastLabels:function(){ this.labelLastNumber=1; this.labelLastLetter="A"; },getGameDescription:function(_185){ var root=this.cursor.getGameRoot(); if(!root){ return; } var desc=(_185?"":root.GN||this.gameName); if(root.PW&&root.PB){ var wr=root.WR?" "+root.WR:""; var br=root.BR?" "+root.BR:""; desc+=(desc.length?" - ":"")+root.PW+wr+" vs "+root.PB+br; } return desc; },sgfCoordToPoint:function(_18a){ if(!_18a||_18a=="tt"){ return {x:null,y:null}; } var _18b={a:0,b:1,c:2,d:3,e:4,f:5,g:6,h:7,i:8,j:9,k:10,l:11,m:12,n:13,o:14,p:15,q:16,r:17,s:18}; return {x:_18b[_18a.charAt(0)],y:_18b[_18a.charAt(1)]}; },pointToSgfCoord:function(pt){ if(!pt||(this.board&&!this.boundsCheck(pt.x,pt.y,[0,this.board.boardSize-1]))){ return null; } var pts={0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",15:"p",16:"q",17:"r",18:"s"}; return pts[pt.x]+pts[pt.y]; },expandCompressedPoints:function(_18e){ var _18f; var ul,lr; var x,y; var _194=[]; var hits=[]; for(var i=0;i<_18e.length;i++){ _18f=_18e[i].split(/:/); if(_18f.length>1){ ul=this.sgfCoordToPoint(_18f[0]); lr=this.sgfCoordToPoint(_18f[1]); for(x=ul.x;x<=lr.x;x++){ for(y=ul.y;y<=lr.y;y++){ _194.push(this.pointToSgfCoord({x:x,y:y})); } } hits.push(i); } } _18e=_18e.concat(_194); return _18e; },setPermalink:function(){ if(!this.permalinkable){ return true; } if(this.unsavedChanges){ alert(t["unsaved changes"]); return; } this.hook("setPermalink"); },nowLoading:function(msg){ if(this.croaked||this.problemMode){ return; } msg=msg||t["loading"]+"..."; if(_2("eidogo-loading-"+this.uniq)){ return; } this.domLoading=document.createElement("div"); this.domLoading.id="eidogo-loading-"+this.uniq; this.domLoading.className="eidogo-loading"+(this.theme?" theme-"+this.theme:""); this.domLoading.innerHTML=msg; this.dom.player.appendChild(this.domLoading); },doneLoading:function(){ if(this.domLoading&&this.domLoading!=null&&this.domLoading.parentNode){ this.domLoading.parentNode.removeChild(this.domLoading); this.domLoading=null; } },croak:function(msg){ this.doneLoading(); if(this.board){ alert(msg); }else{ if(this.problemMode){ this.prependComment(msg); }else{ this.dom.player.innerHTML+="
"+msg.replace(/\n/g,"
")+"
"; this.croaked=true; } } }}; })(); (function(){ var _1=window.eidogoConfig||{}; var _2={theme:"problem",problemMode:true,markVariations:false,markNext:false,shrinkToFit:true}; var _3=eidogo.util.getPlayerPath(); var _4=eidogo.playerPath=(_1.playerPath||_3||"player").replace(/\/$/,""); if(!_1.skipCss){ eidogo.util.addStyleSheet(_4+"/css/player.css"); if(eidogo.browser.ie&&parseInt(eidogo.browser.ver,10)<=6){ eidogo.util.addStyleSheet(_4+"/css/player-ie6.css"); } } eidogo.util.addEvent(window,"load",function(){ eidogo.autoPlayers=[]; var _5=[]; var _6=document.getElementsByTagName("div"); var _7=_6.length; for(var i=0;i<_7;i++){ if(eidogo.util.hasClass(_6[i],"eidogo-player-auto")||eidogo.util.hasClass(_6[i],"eidogo-player-problem")){ _5.push(_6[i]); } } var el; for(var i=0;el=_5[i];i++){ var _a={container:el,enableShortcuts:false,theme:"compact"}; if(eidogo.util.hasClass(el,"eidogo-player-problem")){ for(var _b in _2){ _a[_b]=_2[_b]; } } for(var _b in _1){ _a[_b]=_1[_b]; } var _c=el.getAttribute("sgf"); if(_c){ _a.sgfUrl=_c; }else{ if(el.innerHTML){ _a.sgf=el.innerHTML; } } var _d=el.getAttribute("shrink"); if(_d){ _a.shrinkToFit=(_d=="no"?false:true); } el.innerHTML=""; eidogo.util.show(el); var _e=new eidogo.Player(_a); eidogo.autoPlayers.push(_e); } }); })();