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<len;i++){ if(i in this){ var val=this[i]; if(fun.call(_15,val,i,this)){ res.push(val); } } } return res; }; } if(!Array.prototype.forEach){ Array.prototype.forEach=function(fun){ var len=this.length; if(typeof fun!="function"){ throw new TypeError(); } var _1a=arguments[1]; for(var i=0;i<len;i++){ if(i in this){ fun.call(_1a,this[i],i,this); } } }; } if(!Array.prototype.every){ Array.prototype.every=function(fun){ var len=this.length; if(typeof fun!="function"){ throw new TypeError(); } var _1e=arguments[1]; for(var i=0;i<len;i++){ if(i in this&&!fun.call(_1e,this[i],i,this)){ return false; } } return true; }; } if(!Array.prototype.some){ Array.prototype.some=function(fun){ var len=this.length; if(typeof fun!="function"){ throw new TypeError(); } var _22=arguments[1]; for(var i=0;i<len;i++){ if(i in this&&fun.call(_22,this[i],i,this)){ return true; } } return false; }; } Array.from=function(it){ var arr=[]; for(var i=0;i<it.length;i++){ arr[i]=it[i]; } return arr; }; Function.prototype.bind=function(_27){ var _28=this; var _29=Array.from(arguments).slice(1); return function(){ return _28.apply(_27,_29.concat(Array.from(arguments))); }; }; eidogo=window.eidogo||{}; (function(){ var ua=navigator.userAgent.toLowerCase(); var _2=(ua.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1]; eidogo.browser={ua:ua,ver:_2,ie:/msie/.test(ua)&&!/opera/.test(ua),moz:/mozilla/.test(ua)&&!/(compatible|webkit)/.test(ua),safari3:/webkit/.test(ua)&&parseInt(_2,10)>=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;i<ca.length;i++){ if(!eidogo.util.hasClass(el,ca[i])){ el.className+=(el.className?" ":"")+ca[i]; } } },removeClass:function(el,cls){ var ca=el.className.split(/\s+/); var nc=[]; for(var i=0;i<ca.length;i++){ if(ca[i]!=cls){ nc.push(ca[i]); } } el.className=nc.join(" "); },hasClass:function(el,cls){ var ca=el.className.split(/\s+/); for(var i=0;i<ca.length;i++){ if(ca[i]==cls){ return true; } } return false; },show:function(el,_40){ _40=_40||"block"; if(typeof el=="string"){ el=eidogo.util.byId(el); } if(!el){ return; } el.style.display=_40; },hide:function(el){ if(typeof el=="string"){ el=eidogo.util.byId(el); } if(!el){ return; } el.style.display="none"; },getElXY:function(el,_43){ var _44=el,elX=0,elY=0,_47=el.parentNode,sx=0,sy=0,doc=el.ownerDocument; if(el.getBoundingClientRect){ var _4b=el.getBoundingClientRect(); elX=_4b.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft); elY=_4b.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop); }else{ while(_44){ elX+=_44.offsetLeft; elY+=_44.offsetTop; _44=_44.offsetParent?_44.offsetParent:null; } while(!_43&&_47&&_47.tagName&&!/^body|html$/i.test(_47.tagName)){ sx+=_47.scrollLeft; sy+=_47.scrollTop; elX-=_47.scrollLeft; elY-=_47.scrollTop; _47=_47.parentNode; } } return [elX,elY,sx,sy]; },getElX:function(el){ return this.getElXY(el)[0]; },getElY:function(el){ return this.getElXY(el)[1]; },addStyleSheet:function(_4e){ if(document.createStyleSheet){ document.createStyleSheet(_4e); }else{ var _4f=document.createElement("link"); _4f.rel="stylesheet"; _4f.type="text/css"; _4f.href=_4e; document.getElementsByTagName("head")[0].appendChild(_4f); } },getPlayerPath:function(){ var _50=document.getElementsByTagName("script"); var _51; var _52; for(var i=0;_52=_50[i];i++){ if(/(all\.compressed\.js|eidogo\.js)/.test(_52.src)){ _51=_52.src.replace(/\/js\/[^\/]+$/,""); } } return _51; },numProperties:function(obj){ var _55=0; for(var i in obj){ _55++; } return _55; }}; })(); eidogo=window.eidogo||{}; eidogo.i18n=eidogo.i18n||{"move":"Move","loading":"Loading","passed":"passed","resigned":"resigned","variations":"Variations","no variations":"none","tool":"Tool","view":"Jump to Move","play":"Play","region":"Select Region","add_b":"Black Stone","add_w":"White Stone","edit comment":"Edit Comment","edit game info":"Edit Game Info","done":"Done","triangle":"Triangle","square":"Square","circle":"Circle","x":"X","letter":"Letter","number":"Number","label":"Custom Label","dim":"Dim","clear":"Clear Marker","score":"Score","score est":"Score Estimate","search":"Search","search corner":"Corner Search","search center":"Center Search","region info":"Click and drag to select a region.","two stones":"Please select at least two stones to search for.","two edges":"For corner searches, your selection must touch two adjacent edges of the board.","no search url":"No search URL provided.","close search":"close search","matches found":"matches found.","show games":"Show pro games with this position","save to server":"Save to Server","download sgf":"Download SGF","multi-game sgf":"Multi-game SGF: ","next game":"Next Game","previous game":"Previous Game","end of variation":"End of variation","white":"White","white rank":"White rank","white team":"White team","black":"Black","black rank":"Black rank","black team":"Black team","captures":"captures","time left":"time left","you":"You","game":"Game","handicap":"Handicap","komi":"Komi","result":"Result","date":"Date","info":"Info","place":"Place","event":"Event","round":"Round","overtime":"Overtime","opening":"Openning","ruleset":"Ruleset","annotator":"Annotator","copyright":"Copyright","source":"Source","time limit":"Time limit","transcriber":"Transcriber","created with":"Created with","january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December","gw":"Good for White","vgw":"Very good for White","gb":"Good for Black","vgb":"Very good for Black","dm":"Even position","dmj":"Even position (joseki)","uc":"Unclear position","te":"Tesuji","bm":"Bad move","vbm":"Very bad move","do":"Doubtful move","it":"Interesting move","black to play":"Black to play","white to play":"White to play","ho":"Hotspot","confirm delete":"You've removed all properties from this position.\n\nDelete this position and all sub-positions?","position deleted":"Position deleted","dom error":"Error finding DOM container","error retrieving":"There was a problem retrieving the game data.","invalid data":"Received invalid game data","error board":"Error loading board container","unsaved changes":"There are unsaved changes in this game. You must save before you can permalink or download.","bad path":"Don't know how to get to path: ","gnugo thinking":"GNU Go is thinking..."}; eidogo.gameNodeIdCounter=100000; eidogo.GameNode=function(){ this.init.apply(this,arguments); }; eidogo.GameNode.prototype={init:function(_1,_2,id){ this._id=(typeof id!="undefined"?id:eidogo.gameNodeIdCounter++); this._parent=_1||null; this._children=[]; this._preferredChild=0; if(_2){ this.loadJson(_2); } },pushProperty:function(_4,_5){ if(this[_4]){ if(!(this[_4] instanceof Array)){ this[_4]=[this[_4]]; } if(!this[_4].contains(_5)){ this[_4].push(_5); } }else{ this[_4]=_5; } },hasPropertyValue:function(_6,_7){ if(!this[_6]){ return false; } var _8=(this[_6] instanceof Array?this[_6]:[this[_6]]); return _8.contains(_7); },deletePropertyValue:function(_9,_a){ var _b=(_a instanceof RegExp)?function(v){ return _a.test(v); }:function(v){ return _a==v; }; var _e=(_9 instanceof Array?_9:[_9]); for(var i=0;_9=_e[i];i++){ if(this[_9] instanceof Array){ this[_9]=this[_9].filter(function(v){ return !_b(v); }); if(!this[_9].length){ delete this[_9]; } }else{ if(_b(this.prop)){ delete this[_9]; } } } },loadJson:function(_11){ var _12=[_11],_13=[this]; var _14,_15; var i,len; while(_12.length){ _14=_12.pop(); _15=_13.pop(); _15.loadJsonNode(_14); len=(_14._children?_14._children.length:0); for(i=0;i<len;i++){ _12.push(_14._children[i]); if(!_15._children[i]){ _15._children[i]=new eidogo.GameNode(_15); } _13.push(_15._children[i]); } } },loadJsonNode:function(_18){ for(var _19 in _18){ if(_19=="_id"){ this[_19]=_18[_19].toString(); eidogo.gameNodeIdCounter=Math.max(eidogo.gameNodeIdCounter,parseInt(_18[_19],10)); continue; } if(_19.charAt(0)!="_"){ this[_19]=_18[_19]; } } },appendChild:function(_1a){ _1a._parent=this; this._children.push(_1a); },getProperties:function(){ var _1b={},_1c,_1d,_1e,_1f; for(_1c in this){ isPrivate=(_1c.charAt(0)=="_"); _1e=(typeof this[_1c]=="string"); _1f=(this[_1c] instanceof Array); if(!isPrivate&&(_1e||_1f)){ _1b[_1c]=this[_1c]; } } return _1b; },walk:function(fn,_21){ var _22=[this]; var _23; var i,len; while(_22.length){ _23=_22.pop(); fn.call(_21||this,_23); len=(_23._children?_23._children.length:0); for(i=0;i<len;i++){ _22.push(_23._children[i]); } } },getMove:function(){ if(typeof this.W!="undefined"){ return this.W; }else{ if(typeof this.B!="undefined"){ return this.B; } } return null; },emptyPoint:function(_26){ var _27=this.getProperties(); var _28=null; for(var _29 in _27){ if(_29=="AW"||_29=="AB"||_29=="AE"){ if(!(this[_29] instanceof Array)){ this[_29]=[this[_29]]; } this[_29]=this[_29].filter(function(val){ if(val==_26){ _28=val; return false; } return true; }); if(!this[_29].length){ delete this[_29]; } }else{ if((_29=="B"||_29=="W")&&this[_29]==_26){ _28=this[_29]; delete this[_29]; } } } return _28; },getPosition:function(){ if(!this._parent){ return null; } var _2b=this._parent._children; for(var i=0;i<_2b.length;i++){ if(_2b[i]._id==this._id){ return i; } } return null; },toSgf:function(){ var sgf=(this._parent?"(":""); var _2e=this; function propsToSgf(_2f){ if(!_2f){ return ""; } var sgf=";",key,val; for(key in _2f){ if(_2f[key] instanceof Array){ val=_2f[key].map(function(val){ return val.toString().replace(/\]/g,"\\]"); }).join("]["); }else{ val=_2f[key].toString().replace(/\]/g,"\\]"); } sgf+=key+"["+val+"]"; } return sgf; } sgf+=propsToSgf(_2e.getProperties()); while(_2e._children.length==1){ _2e=_2e._children[0]; sgf+=propsToSgf(_2e.getProperties()); } for(var i=0;i<_2e._children.length;i++){ sgf+=_2e._children[i].toSgf(); } sgf+=(this._parent?")":""); return sgf; }}; eidogo.GameCursor=function(){ this.init.apply(this,arguments); }; eidogo.GameCursor.prototype={init:function(_35){ this.node=_35; },next:function(_36){ if(!this.hasNext()){ return false; } _36=(typeof _36=="undefined"||_36==null?this.node._preferredChild:_36); this.node._preferredChild=_36; this.node=this.node._children[_36]; return true; },previous:function(){ if(!this.hasPrevious()){ return false; } this.node=this.node._parent; return true; },hasNext:function(){ return this.node&&this.node._children.length; },hasPrevious:function(){ return this.node&&this.node._parent&&this.node._parent._parent; },getNextMoves:function(){ if(!this.hasNext()){ return null; } var _37={}; var i,_39; for(i=0;_39=this.node._children[i];i++){ _37[_39.getMove()]=i; } return _37; },getNextColor:function(){ if(!this.hasNext()){ return null; } var i,_3b; for(var i=0;_3b=this.node._children[i];i++){ if(_3b.W||_3b.B){ return _3b.W?"W":"B"; } } return null; },getNextNodeWithVariations:function(){ var _3c=this.node; while(_3c._children.length==1){ _3c=_3c._children[0]; } return _3c; },getPath:function(){ var n=this.node,_3e=[],mn=0; while(n&&n._parent&&n._parent._children.length==1&&n._parent._parent){ mn++; n=n._parent; } _3e.push(mn); while(n){ if(n._parent&&(n._parent._children.length>1||!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.index<this.sgf.length){ var c=this.curChar(); this.index++; switch(c){ case ";": _3=this.parseNode(_3); break; case "(": this.parseTree(_3); break; case ")": return; break; } } },parseNode:function(_5){ var _6={_children:[]}; if(_5){ _5._children.push(_6); }else{ this.root=_6; } _6=this.parseProperties(_6); return _6; },parseProperties:function(_7){ var _8=""; var _9=[]; var i=0; while(this.index<this.sgf.length){ var c=this.curChar(); if(c==";"||c=="("||c==")"){ break; } if(this.curChar()=="["){ while(this.curChar()=="["){ this.index++; _9[i]=""; while(this.curChar()!="]"&&this.index<this.sgf.length){ if(this.curChar()=="\\"){ this.index++; while(this.curChar()=="\r"||this.curChar()=="\n"){ this.index++; } } _9[i]+=this.curChar(); this.index++; } i++; while(this.curChar()=="]"||this.curChar()=="\n"||this.curChar()=="\r"){ this.index++; } } if(_7[_8]){ if(!(_7[_8] instanceof Array)){ _7[_8]=[_7[_8]]; } _7[_8]=_7[_8].concat(_9); }else{ _7[_8]=_9.length>1?_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;i<this.stones.length;i++){ this.stones[i]=this.EMPTY; } },clearMarkers:function(){ for(var i=0;i<this.markers.length;i++){ this.markers[i]=this.EMPTY; } },clearCaptures:function(){ this.captures.W=0; this.captures.B=0; },makeBoardArray:function(_5){ return [].setLength(this.boardSize*this.boardSize,_5); },commit:function(){ this.cache.push({stones:this.stones.concat(),captures:{W:this.captures.W,B:this.captures.B}}); },rollback:function(){ if(this.cache.last()){ this.stones=this.cache.last().stones.concat(); this.captures.W=this.cache.last().captures.W; this.captures.B=this.cache.last().captures.B; }else{ this.clear(); } },revert:function(_6){ _6=_6||1; this.rollback(); for(var i=0;i<_6;i++){ this.cache.pop(); } this.rollback(); },addStone:function(pt,_9){ this.stones[pt.y*this.boardSize+pt.x]=_9; },getStone:function(pt){ return this.stones[pt.y*this.boardSize+pt.x]; },getRegion:function(t,l,w,h){ var _f=[].setLength(w*h,this.EMPTY); var _10; for(var y=t;y<t+h;y++){ for(var x=l;x<l+w;x++){ _10=(y-t)*w+(x-l); _f[_10]=this.getStone({x:x,y:y}); } } return _f; },addMarker:function(pt,_14){ this.markers[pt.y*this.boardSize+pt.x]=_14; },getMarker:function(pt){ return this.markers[pt.y*this.boardSize+pt.x]; },render:function(_16){ var _17=this.makeBoardArray(null); var _18=this.makeBoardArray(null); var _19,_1a; var len; if(!_16&&this.cache.last()){ var _1c=this.cache.last(); len=this.stones.length; for(var i=0;i<len;i++){ if(_1c.stones[i]!=this.lastRender.stones[i]){ _17[i]=_1c.stones[i]; } } _18=this.markers; }else{ _17=this.stones; _18=this.markers; } var _1e; for(var x=0;x<this.boardSize;x++){ for(var y=0;y<this.boardSize;y++){ _1e=y*this.boardSize+x; if(_18[_1e]!=null){ this.renderer.renderMarker({x:x,y:y},_18[_1e]); this.lastRender.markers[_1e]=_18[_1e]; } if(_17[_1e]==null){ continue; }else{ if(_17[_1e]==this.EMPTY){ _19="empty"; }else{ _19=(_17[_1e]==this.WHITE?"white":"black"); } } this.renderer.renderStone({x:x,y:y},_19); this.lastRender.stones[_1e]=_17[_1e]; } } }}; eidogo.BoardRendererHtml=function(){ this.init.apply(this,arguments); }; eidogo.BoardRendererHtml.prototype={init:function(_21,_22,_23,_24){ if(!_21){ throw "No DOM container"; return; } this.boardSize=_22||19; var _25=document.createElement("div"); _25.className="board-gutter"+(this.boardSize==19?" with-coords":""); _21.appendChild(_25); var _26=document.createElement("div"); _26.className="board size"+this.boardSize; _26.style.position=(_24&&eidogo.browser.ie?"static":"relative"); _25.appendChild(_26); this.domNode=_26; this.domGutter=_25; this.domContainer=_21; this.player=_23; this.uniq=_21.id+"-"; this.renderCache={stones:[].setLength(this.boardSize,0).addDimension(this.boardSize,0),markers:[].setLength(this.boardSize,0).addDimension(this.boardSize,0)}; this.pointWidth=0; this.pointHeight=0; this.margin=0; var _27=this.renderStone({x:0,y:0},"black"); this.pointWidth=this.pointHeight=_27.offsetWidth; this.renderStone({x:0,y:0},"white"); this.renderMarker({x:0,y:0},"current"); this.clear(); this.margin=(this.domNode.offsetWidth-(this.boardSize*this.pointWidth))/2; this.scrollX=0; this.scrollY=0; if(_24){ this.crop(_24); if(eidogo.browser.ie){ var _28=this.domNode.parentNode; while(_28&&_28.tagName&&!/^body|html$/i.test(_28.tagName)){ this.scrollX+=_28.scrollLeft; this.scrollY+=_28.scrollTop; _28=_28.parentNode; } } } this.dom={}; this.dom.searchRegion=document.createElement("div"); this.dom.searchRegion.id=this.uniq+"search-region"; this.dom.searchRegion.className="search-region"; this.domNode.appendChild(this.dom.searchRegion); eidogo.util.addEvent(this.domNode,"mousemove",this.handleHover,this,true); eidogo.util.addEvent(this.domNode,"mousedown",this.handleMouseDown,this,true); eidogo.util.addEvent(this.domNode,"mouseup",this.handleMouseUp,this,true); },showRegion:function(_29){ this.dom.searchRegion.style.top=(this.margin+this.pointHeight*_29[0])+"px"; this.dom.searchRegion.style.left=(this.margin+this.pointWidth*_29[1])+"px"; this.dom.searchRegion.style.width=this.pointWidth*_29[2]+"px"; this.dom.searchRegion.style.height=this.pointHeight*_29[3]+"px"; eidogo.util.show(this.dom.searchRegion); },hideRegion:function(){ eidogo.util.hide(this.dom.searchRegion); },clear:function(){ this.domNode.innerHTML=""; },renderStone:function(pt,_2b){ var _2c=document.getElementById(this.uniq+"stone-"+pt.x+"-"+pt.y); if(_2c){ _2c.parentNode.removeChild(_2c); } if(_2b!="empty"){ var div=document.createElement("div"); div.id=this.uniq+"stone-"+pt.x+"-"+pt.y; div.className="point stone "+_2b; try{ div.style.left=(pt.x*this.pointWidth+this.margin-this.scrollX)+"px"; div.style.top=(pt.y*this.pointHeight+this.margin-this.scrollY)+"px"; } catch(e){ } this.domNode.appendChild(div); return div; } return null; },renderMarker:function(pt,_2f){ if(this.renderCache.markers[pt.x][pt.y]){ var _30=document.getElementById(this.uniq+"marker-"+pt.x+"-"+pt.y); if(_30){ _30.parentNode.removeChild(_30); } } if(_2f=="empty"||!_2f){ this.renderCache.markers[pt.x][pt.y]=0; return null; } this.renderCache.markers[pt.x][pt.y]=1; if(_2f){ var _31=""; switch(_2f){ case "triangle": case "square": case "circle": case "ex": case "territory-white": case "territory-black": case "dim": case "current": break; default: if(_2f.indexOf("var:")==0){ _31=_2f.substring(4); _2f="variation"; }else{ _31=_2f; _2f="label"; } break; } var div=document.createElement("div"); div.id=this.uniq+"marker-"+pt.x+"-"+pt.y; div.className="point marker "+_2f; try{ div.style.left=(pt.x*this.pointWidth+this.margin-this.scrollX)+"px"; div.style.top=(pt.y*this.pointHeight+this.margin-this.scrollY)+"px"; } catch(e){ } div.appendChild(document.createTextNode(_31)); this.domNode.appendChild(div); return div; } return null; },setCursor:function(_33){ this.domNode.style.cursor=_33; },handleHover:function(e){ var xy=this.getXY(e); this.player.handleBoardHover(xy[0],xy[1],xy[2],xy[3],e); },handleMouseDown:function(e){ var xy=this.getXY(e); this.player.handleBoardMouseDown(xy[0],xy[1],xy[2],xy[3],e); },handleMouseUp:function(e){ var xy=this.getXY(e); this.player.handleBoardMouseUp(xy[0],xy[1]); },getXY:function(e){ var _3b=eidogo.util.getElClickXY(e,this.domNode); var m=this.margin; var pw=this.pointWidth; var ph=this.pointHeight; var x=Math.round((_3b[0]-m-(pw/2))/pw); var y=Math.round((_3b[1]-m-(ph/2))/ph); return [x,y,_3b[0],_3b[1]]; },crop:function(_41){ eidogo.util.addClass(this.domContainer,"shrunk"); this.domGutter.style.overflow="hidden"; var _42=_41.width*this.pointWidth+(this.margin*2); var _43=_41.height*this.pointHeight+(this.margin*2); this.domGutter.style.width=_42+"px"; this.domGutter.style.height=_43+"px"; this.player.dom.player.style.width=_42+"px"; this.domGutter.scrollLeft=_41.left*this.pointWidth; this.domGutter.scrollTop=_41.top*this.pointHeight; }}; eidogo.BoardRendererFlash=function(){ this.init.apply(this,arguments); }; eidogo.BoardRendererFlash.prototype={init:function(_44,_45,_46,_47){ if(!_44){ throw "No DOM container"; return; } this.ready=false; this.swf=null; this.unrendered=[]; var _48=_44.id+"-board"; var so=new SWFObject(eidogo.playerPath+"/swf/board.swf",_48,"421","421","8","#665544"); so.addParam("allowScriptAccess","sameDomain"); so.write(_44); var _4a=0; var _4b=function(){ swf=eidogo.util.byId(_48); if(!swf||!swf.init){ if(_4a>2000){ 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<this.unrendered.length;i++){ if(this.unrendered[i][0]=="stone"){ this.swf.renderStone(this.unrendered[i][1],this.unrendered[i][2]); } } this.unrendered=[]; this.swf.renderStone(pt,_4e); },renderMarker:function(pt,_51){ if(!_51){ return; } if(!this.swf){ this.unrendered.push(["marker",pt,_51]); return; } for(var i=0;i<this.unrendered.length;i++){ if(this.unrendered[i][0]=="marker"){ this.swf.renderMarker(this.unrendered[i][1],this.unrendered[i][2]); } } this.unrendered=[]; this.swf.renderMarker(pt,_51); },setCursor:function(_53){ },crop:function(){ }}; eidogo.BoardRendererAscii=function(_54,_55){ this.init(_54,_55); }; eidogo.BoardRendererAscii.prototype={pointWidth:2,pointHeight:1,margin:1,blankBoard:"+-------------------------------------+\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"+-------------------------------------+",init:function(_56,_57){ this.domNode=_56||null; this.boardSize=_57||19; this.content=this.blankBoard; },clear:function(){ this.content=this.blankBoard; this.domNode.innerHTML="<pre>"+this.content+"</pre>"; },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="<pre>"+this.content+"</pre>"; },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;i<this.pendingCaptures.length;i++){ if(this.pendingCaptures[i].x==pt.x&&this.pendingCaptures[i].y==pt.y){ return 0; } } this.pendingCaptures.push(pt); if(this.findCaptures({x:pt.x-1,y:pt.y},_e)){ return 1; } if(this.findCaptures({x:pt.x+1,y:pt.y},_e)){ return 1; } if(this.findCaptures({x:pt.x,y:pt.y-1},_e)){ return 1; } if(this.findCaptures({x:pt.x,y:pt.y+1},_e)){ return 1; } return 0; }}; (function(){ var t=eidogo.i18n,_2=eidogo.util.byId,_3=eidogo.util.ajax,_4=eidogo.util.addEvent,_5=eidogo.util.onClick,_6=eidogo.util.getElClickXY,_7=eidogo.util.stopEvent,_8=eidogo.util.addClass,_9=eidogo.util.removeClass,_a=eidogo.util.show,_b=eidogo.util.hide,_c=eidogo.browser.moz,_d=eidogo.util.getPlayerPath(); eidogo.players=eidogo.players||{}; eidogo.delegate=function(_e,fn){ var _10=eidogo.players[_e]; _10[fn].apply(_10,Array.from(arguments).slice(2)); }; eidogo.Player=function(){ this.init.apply(this,arguments); }; eidogo.Player.prototype={init:function(cfg){ cfg=cfg||{}; this.mode=cfg.mode?cfg.mode:"play"; this.dom={}; this.dom.container=(typeof cfg.container=="string"?_2(cfg.container):cfg.container); if(!this.dom.container){ alert(t["dom error"]); return; } this.uniq=(new Date()).getTime(); eidogo.players[this.uniq]=this; this.sgfPath=cfg.sgfPath; this.searchUrl=cfg.searchUrl; this.showingSearch=false; this.saveUrl=cfg.saveUrl; this.downloadUrl=cfg.downloadUrl; this.scoreEstUrl=cfg.scoreEstUrl; this.hooks=cfg.hooks||{}; this.permalinkable=!!this.hooks.setPermalink; this.propertyHandlers={W:this.playMove,B:this.playMove,KO:this.playMove,MN:this.setMoveNumber,AW:this.addStone,AB:this.addStone,AE:this.addStone,CR:this.addMarker,LB:this.addMarker,TR:this.addMarker,MA:this.addMarker,SQ:this.addMarker,TW:this.addMarker,TB:this.addMarker,DD:this.addMarker,PL:this.setColor,C:this.showComments,N:this.showAnnotation,GB:this.showAnnotation,GW:this.showAnnotation,DM:this.showAnnotation,HO:this.showAnnotation,UC:this.showAnnotation,V:this.showAnnotation,BM:this.showAnnotation,DO:this.showAnnotation,IT:this.showAnnotation,TE:this.showAnnotation,BL:this.showTime,OB:this.showTime,WL:this.showTime,OW:this.showTime}; this.infoLabels={GN:t["game"],PW:t["white"],WR:t["white rank"],WT:t["white team"],PB:t["black"],BR:t["black rank"],BT:t["black team"],HA:t["handicap"],KM:t["komi"],RE:t["result"],DT:t["date"],GC:t["info"],PC:t["place"],EV:t["event"],RO:t["round"],OT:t["overtime"],ON:t["opening"],RU:t["ruleset"],AN:t["annotator"],CP:t["copyright"],SO:t["source"],TM:t["time limit"],US:t["transcriber"],AP:t["created with"]}; this.months=[t["january"],t["february"],t["march"],t["april"],t["may"],t["june"],t["july"],t["august"],t["september"],t["october"],t["november"],t["december"]]; this.theme=cfg.theme; this.reset(cfg); this.renderer=cfg.renderer||"html"; this.cropParams=null; this.shrinkToFit=cfg.shrinkToFit; if(this.shrinkToFit||cfg.cropWidth||cfg.cropHeight){ this.cropParams={}; this.cropParams.width=cfg.cropWidth; this.cropParams.height=cfg.cropHeight; this.cropParams.left=cfg.cropLeft; this.cropParams.top=cfg.cropTop; this.cropParams.padding=cfg.cropPadding||1; } this.constructDom(); if(cfg.enableShortcuts){ _4(document,_c?"keypress":"keydown",this.handleKeypress,this,true); } _4(document,"mouseup",this.handleDocMouseUp,this,true); if(cfg.sgf||cfg.sgfUrl||(cfg.sgfPath&&cfg.gameName)){ this.loadSgf(cfg); } this.hook("initDone"); },hook:function(_12,_13){ if(_12 in this.hooks){ return this.hooks[_12].bind(this)(_13); } },reset:function(cfg){ this.gameName=""; this.collectionRoot=new eidogo.GameNode(); this.cursor=new eidogo.GameCursor(); this.progressiveLoad=cfg.progressiveLoad?true:false; this.progressiveLoads=null; this.progressiveUrl=null; this.progressiveMode=cfg.progressiveLoad&&cfg.progressiveMode||"id"; this.opponentUrl=null; this.opponentColor=null; this.opponentLevel=null; this.board=null; this.rules=null; this.currentColor=null; this.moveNumber=null; this.totalMoves=null; this.variations=null; this.timeB=""; this.timeW=""; this.regionTop=null; this.regionLeft=null; this.regionWidth=null; this.regionHeight=null; this.regionBegun=null; this.regionClickSelect=null; this.mouseDown=null; this.mouseDownX=null; this.mouseDownY=null; this.mouseDownClickX=null; this.mouseDownClickY=null; this.labelLastLetter=null; this.labelLastNumber=null; this.resetLastLabels(); this.unsavedChanges=false; this.updatedNavTree=false; this.navTreeTimeout=null; this.searching=false; this.editingText=false; this.goingBack=false; this.problemMode=cfg.problemMode; this.problemColor=cfg.problemColor; this.prefs={}; this.prefs.markCurrent=typeof cfg.markCurrent!="undefined"?!!cfg.markCurrent:true; this.prefs.markNext=typeof cfg.markNext!="undefined"?cfg.markNext:false; this.prefs.markVariations=typeof cfg.markVariations!="undefined"?!!cfg.markVariations:true; this.prefs.showGameInfo=!!cfg.showGameInfo; this.prefs.showPlayerInfo=!!cfg.showPlayerInfo; this.prefs.showTools=!!cfg.showTools; this.prefs.showComments=typeof cfg.showComments!="undefined"?!!cfg.showComments:true; this.prefs.showOptions=!!cfg.showOptions; this.prefs.showNavTree=!this.progressiveLoad&&typeof cfg.showNavTree!="undefined"?!!cfg.showNavTree:false; },loadSgf:function(cfg,_16){ cfg=cfg||{}; this.nowLoading(); this.reset(cfg); this.sgfPath=cfg.sgfPath||this.sgfPath; this.loadPath=cfg.loadPath&&cfg.loadPath.length>1?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.x<l){ l=pt.x; } if(r==null||pt.x>r){ r=pt.x; } if(t==null||pt.y<t){ t=pt.y; } if(b==null||pt.y>b){ 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="<a id='cont-search' href='#'>"+t["show games"]+"</a>"+(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?"<a id='cont-search' href='#'>"+t["show games"]+"</a>":""; 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+="<div class='continuations'>"; 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+="<div class='continuation'>"+"<div class='cont-label'>"+_80.label+"</div>"+"<div class='cont-bar' style='width: "+_88+"px'></div>"+"<div class='cont-count'>"+_80.count+"</div>"+"</div>"; } _7e._children.push(_7f); } _7e.C+="</div>"; 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<this.variations.length;i++){ if(!this.variations[i].move||this.variations[i].move=="tt"){ this.variation(this.variations[i].varNum); return; } } this.createMove("tt"); },handleBoardMouseDown:function(x,y,cx,cy,e){ if(this.domLoading){ return; } if(!this.boundsCheck(x,y,[0,this.board.boardSize-1])){ return; } this.mouseDown=true; this.mouseDownX=x; this.mouseDownY=y; this.mouseDownClickX=cx; this.mouseDownClickY=cy; if(this.mode=="region"&&x>=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<this.variations.length;i++){ var _a6=this.sgfCoordToPoint(this.variations[i].move); if(_a6.x==x&&_a6.y==y){ this.variation(this.variations[i].varNum); _7(e); return; } } } if(this.mode=="view"){ var _a7=this.cursor.getGameRoot(),_a8=[0,_a7.getPosition()],mn=0,_aa=_a7._children[0]; while(_aa){ if(_aa.getMove()==_a4){ _a8.push(mn); this.goTo(_a8); break; } mn++; _aa=_aa._children[0]; } return; } if(this.mode=="play"){ if(!this.rules.check({x:x,y:y},this.currentColor)){ return; } if(_a4){ var _ab=this.cursor.getNextMoves(); if(_ab&&_a4 in _ab){ this.variation(_ab[_a4]); }else{ this.createMove(_a4); } } }else{ if(this.mode=="region"&&x>=-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<h;y++){ for(x=0;x<w;x++){ c=p.charAt(y*w+x); if(c=="o"){ c="AW"; }else{ if(c=="x"){ c="AB"; }else{ c=""; } } this.cursor.node.pushProperty(c,this.pointToSgfCoord({x:l+x,y:t+y})); } } this.refresh(); this.regionLeft=l; this.regionTop=t; this.regionRight=l+x; this.regionBottom=t+y; var b=this.getRegionBounds(); var r=[b[1],b[0],b[1]+b[2],b[0]+b[3]-1]; for(y=0;y<this.board.boardSize;y++){ for(x=0;x<this.board.boardSize;x++){ if(!this.boundsCheck(x,y,r)){ this.board.renderer.renderMarker({x:x,y:y},"dim"); } } } this.searchRegion(o); },searchRegion:function(_ce){ if(this.searching){ return; } this.searching=true; if(!this.searchUrl){ _a(this.dom.comments); _b(this.dom.searchContainer); this.prependComment(t["no search url"]); return; } var _ce=parseInt(_ce,10)||0; var _cf=this.dom.searchAlgo.value; var _d0=this.getRegionBounds(); var _d1=this.board.getRegion(_d0[0],_d0[1],_d0[2],_d0[3]); var _d2=this.convertRegionPattern(_d1); var _d3=/^\.*$/.test(_d2); var _d4=/^\.*o\.*$/.test(_d2); var _d5=/^\.*x\.*$/.test(_d2); if(_d3||_d4||_d5){ this.searching=false; _a(this.dom.comments); _b(this.dom.searchContainer); this.prependComment(t["two stones"]); return; } var _d6=[]; if(_d0[0]==0){ _d6.push("n"); } if(_d0[1]==0){ _d6.push("w"); } if(_d0[0]+_d0[3]==this.board.boardSize){ _d6.push("s"); } if(_d0[1]+_d0[2]==this.board.boardSize){ _d6.push("e"); } if(_cf=="corner"&&!(_d6.length==2&&((_d6.contains("n")&&_d6.contains("e"))||(_d6.contains("n")&&_d6.contains("w"))||(_d6.contains("s")&&_d6.contains("e"))||(_d6.contains("s")&&_d6.contains("w"))))){ this.searching=false; _a(this.dom.comments); _b(this.dom.searchContainer); this.prependComment(t["two edges"]); return; } var _d7=(_d6.contains("n")?"n":"s"); _d7+=(_d6.contains("w")?"w":"e"); this.showComments(""); this.gameName="search"; var _d8=function(req){ this.searching=false; this.doneLoading(); _b(this.dom.comments); _a(this.dom.searchContainer); this.showingSearch=true; if(req.responseText=="ERROR"){ this.croak(t["error retrieving"]); return; }else{ if(req.responseText=="NONE"){ _b(this.dom.searchResultsContainer); this.dom.searchCount.innerHTML="No"; return; } } var ret=eval("("+req.responseText+")"); var _db=ret.results,_dc,_dd="",odd,_df=parseInt(ret.total,10),_e0=parseInt(ret.offset,10)+1,_e1=parseInt(ret.offset,10)+50; for(var i=0;_dc=_db[i];i++){ odd=odd?false:true; _dd+="<a class='search-result"+(odd?" odd":"")+"' href='#'> <span class='id'>"+_dc.id+"</span> <span class='mv'>"+_dc.mv+"</span> <span class='pw'>"+_dc.pw+" "+_dc.wr+"</span> <span class='pb'>"+_dc.pb+" "+_dc.br+"</span> <span class='re'>"+_dc.re+"</span> <span class='dt'>"+_dc.dt+"</span> <div class='clear'> </div> </a>"; } if(_df>_e1){ _dd+="<div class='search-more'><a href='#' id='search-more'>Show more...</a></div>"; } _a(this.dom.searchResultsContainer); this.dom.searchResults.innerHTML=_dd+"<br>"; 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;j<n;j++){ ret+=s; } n=""; } s=c; }else{ n+=c; } } n=parseInt(n,10); n=isNaN(n)?1:n; for(var j=0;j<n;j++){ ret+=s; } return ret; },createMove:function(_fa){ var _fb={}; _fb[this.currentColor]=_fa; var _fc=new eidogo.GameNode(null,_fb); _fc._cached=true; this.totalMoves++; this.cursor.node.appendChild(_fc); this.unsavedChanges=[this.cursor.node._children.last(),this.cursor.node]; this.updatedNavTree=false; this.variation(this.cursor.node._children.length-1); },handleKeypress:function(e){ if(this.editingText){ return true; } var _fe=e.keyCode||e.charCode; if(!_fe||e.ctrlKey||e.altKey||e.metaKey){ return true; } var _ff=String.fromCharCode(_fe).toLowerCase(); var _100=[]; for(var i=0;i<this.variations.length;i++){ var _102=this.variations[i].move; var _103=this.sgfCoordToPoint(_102); var _104=""+(i+1); var _105=this.board.getMarker(_103); if(_103.x!=null&&_105!=this.board.EMPTY&&typeof _105=="string"&&!_100.contains(_102)){ _104=_105.toLowerCase(); } _104=_104.replace(/^var:/,""); if(_ff==_104.charAt(0)){ this.variation(this.variations[i].varNum); _7(e); return; } _100.push(_102); } if(_fe==112||_fe==27){ this.selectTool("play"); } var stop=true; switch(_fe){ case 39: if(e.shiftKey){ var _107=this.totalMoves-this.moveNumber; var _108=(_107>9?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=["<table>"]; for(var prop in this.infoLabels){ html.push("<tr><td>"+this.infoLabels[prop]+":"+"</td><td>"+"<input type=\"text\" id=\"game-info-edit-field-"+prop+"\""+" value=\""+(root[prop]||"")+"\">"+"</td></tr>"); } html.push("</table>"); 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"]+": <span>"+this.board.captures.W+"</span>"; this.dom.blackCaptures.innerHTML=t["captures"]+": <span>"+this.board.captures.B+"</span>"; this.dom.whiteTime.innerHTML=t["time left"]+": <span>"+(this.timeW?this.timeW:"--")+"</span>"; this.dom.blackTime.innerHTML=t["time left"]+": <span>"+(this.timeB?this.timeB:"--")+"</span>"; _9(this.dom.controlPass,"pass-on"); this.dom.variations.innerHTML=""; for(var i=0;i<this.variations.length;i++){ var _11e=i+1; var _11f=false; if(!this.variations[i].move||this.variations[i].move=="tt"){ _8(this.dom.controlPass,"pass-on"); }else{ if(this.prefs.markNext||this.variations.length>1){ 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="<div class='variation-nav none'>"+t["no variations"]+"</div>"; } 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+="<a href='"+js+(pos-1)+",0])'>"+t["previous game"]+"</a>"; } if(node._parent._children[pos+1]){ html+=(pos?" | ":"")+"<a href='"+js+(pos+1)+",0])'>"+t["next game"]+"</a>"; } 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,"<br />"); },prependComment:function(_142,cls){ cls=cls||"comment-status"; this.dom.comments.innerHTML="<div class='"+cls+"'>"+_142+"</div>"+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=" <div id='board-container' class='board-container'></div> <div id='controls-container' class='controls-container'> <ul id='controls' class='controls'> <li id='control-first' class='control first'>First</li> <li id='control-back' class='control back'>Back</li> <li id='control-forward' class='control forward'>Forward</li> <li id='control-last' class='control last'>Last</li> <li id='control-pass' class='control pass'>Pass</li> </ul> <div id='move-number' class='move-number"+(this.permalinkable?" permalink":"")+"'></div> <div id='nav-slider' class='nav-slider'> <div id='nav-slider-thumb' class='nav-slider-thumb'></div> </div> <div id='variations-container' class='variations-container'> <div id='variations-label' class='variations-label'>"+t["variations"]+":</div> <div id='variations' class='variations'></div> </div> <div class='controls-stop'></div> </div> <div id='tools-container' class='tools-container'"+(this.prefs.showTools?"":" style='display: none'")+"> <div id='tools-label' class='tools-label'>"+t["tool"]+":</div> <select id='tools-select' class='tools-select'> <option value='play'>► "+t["play"]+"</option> <option value='view'>→ "+t["view"]+"</option> <option value='add_b'>● "+t["add_b"]+"</option> <option value='add_w'>○ "+t["add_w"]+"</option> "+(this.searchUrl?("<option value='region'>▒ "+t["region"]+"</option>"):"")+" "+(this.saveUrl&&!this.progressiveLoad?("<option value='comment'>¶ "+t["edit comment"]+"</option>"):"")+" "+(this.saveUrl?("<option value='gameinfo'>⌂ "+t["edit game info"]+"</option>"):"")+" <option value='tr'>▲ "+t["triangle"]+"</option> <option value='sq'>■ "+t["square"]+"</option> <option value='cr'>● "+t["circle"]+"</option> <option value='x'>× "+t["x"]+"</option> <option value='letter'>A "+t["letter"]+"</option> <option value='number'>5 "+t["number"]+"</option> <option value='label'>Ç "+t["label"]+"</option> <option value='dim'>▓ "+t["dim"]+"</option> <option value='clear'>░ "+t["clear"]+"</option> </select> <input type='button' id='score-est' class='score-est-button' value='"+t["score est"]+"' /> <select id='search-algo' class='search-algo'> <option value='corner'>"+t["search corner"]+"</option> <option value='center'>"+t["search center"]+"</option> </select> <input type='button' id='search-button' class='search-button' value='"+t["search"]+"' /> <input type='text' id='label-input' class='label-input' /> </div> <div id='comments' class='comments'></div> <div id='comments-edit' class='comments-edit'> <textarea id='comments-edit-ta' class='comments-edit-ta'></textarea> <div id='comments-edit-done' class='comments-edit-done'>"+t["done"]+"</div> </div> <div id='game-info-edit' class='game-info-edit'> <div id='game-info-edit-form' class='game-info-edit-form'></div> <div id='game-info-edit-done' class='game-info-edit-done'>"+t["done"]+"</div> </div> <div id='search-container' class='search-container'> <div id='search-close' class='search-close'>"+t["close search"]+"</div> <p class='search-count'><span id='search-count'></span> "+t["matches found"]+" Showing <span id='search-offset-start'></span>-<span id='search-offset-end'></span></p> <div id='search-results-container' class='search-results-container'> <div class='search-result'> <span class='pw'><b>"+t["white"]+"</b></span> <span class='pb'><b>"+t["black"]+"</b></span> <span class='re'><b>"+t["result"]+"</b></span> <span class='dt'><b>"+t["date"]+"</b></span> <div class='clear'></div> </div> <div id='search-results' class='search-results'></div> </div> </div> <div id='info' class='info'> <div id='info-players' class='players'> <div id='white' class='player white'> <div id='white-name' class='name'></div> <div id='white-captures' class='captures'></div> <div id='white-time' class='time'></div> </div> <div id='black' class='player black'> <div id='black-name' class='name'></div> <div id='black-captures' class='captures'></div> <div id='black-time' class='time'></div> </div> </div> <div id='info-game' class='game'></div> </div> <div id='nav-tree-container' class='nav-tree-container'> <div id='nav-tree' class='nav-tree'></div> </div> <div id='options' class='options'> "+(this.saveUrl?"<a id='option-save' class='option-save' href='#'>"+t["save to server"]+"</a>":"")+" "+(this.downloadUrl||_c?"<a id='option-download' class='option-download' href='#'>"+t["download sgf"]+"</a>":"")+" <div class='options-stop'></div> </div> <div id='preferences' class='preferences'> <div><input type='checkbox'> Show variations on board</div> <div><input type='checkbox'> Mark current move</div> </div> <div id='footer' class='footer'></div> <div id='shade' class='shade'></div> "; _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;i<Math.abs(_160);i++){ if(_160>0){ 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._children.length;i++){ path.push(i); _166(node._children[i],x,y); path.pop(); } }; _166(_164,0,0); var html=["<table class='nav-tree'>"],node,td,cur=new eidogo.GameCursor(),x,y,_175,_176=1,LINE=2; for(x=0;x<maxx;x++){ _175=false; for(y=_163.length-1;y>0;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("<tr>"); for(x=0;x<_163[y].length;x++){ node=_163[y][x]; if(node==_176){ td="<div class='elbow'></div>"; }else{ if(node==LINE){ td="<div class='line'></div>"; }else{ if(node){ td=["<a href='#' id='navtree-node-",node._pathStr,"' class='",(typeof node.W!="undefined"?"w":(typeof node.B!="undefined"?"b":"x")),"'>",x,"</a>"].join(""); }else{ td="<div class='empty'></div>"; } } } html.push("<td>"); html.push(td); html.push("</td>"); } html.push("</tr>"); } html.push("</table>"); 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(l<maxl){ ntc.scrollLeft-=(maxl-l); } if(l+w>maxr){ ntc.scrollLeft+=((l+w)-maxr); } if(t<maxt){ ntc.scrollTop-=(maxt-t); } if(t+h>maxb){ 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+="<div class='eidogo-error "+(this.theme?" theme-"+this.theme:"")+"'>"+msg.replace(/\n/g,"<br />")+"</div>"; 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); } }); })();