/* API function initSelectBoard(name,width,height,flip,start,style,size) function setpoza(name,poza) function getpoza(name) function isSelectBoardFlipped(name) function piecestyle(name) function squaresize_selectboard(name) function refresh_selectboard(name,style,size,flip,bordercolor,coordinatescolor,dark,light) selectboard_positionchange(name) is called whenever position on the selectboard is changed */ function RemoveSelection() {if (window.getSelection) (window.getSelection()).removeAllRanges(); else if (document.selection.createRange) {var range = document.selection.createRange(); document.selection.empty();} } function literka(i) {if (i==1) return "a"; if (i==2) return "b"; if (i==3) return "c"; if (i==4) return "d"; if (i==5) return "e"; if (i==6) return "f"; if (i==7) return "g"; if (i==8) return "h"; if (i==9) return "i"; if (i==10) return "j"; if (i==11) return "k"; if (i==12) return "l"; if (i==13) return "m"; if (i==14) return "n"; if (i==15) return "o"; if (i==16) return "p"; if (i==17) return "q"; if (i==18) return "r"; if (i==19) return "s"; if (i==20) return "t"; if (i==21) return "u"; if (i==22) return "v"; if (i==23) return "w"; if (i==24) return "x"; if (i==25) return "y"; if (i==26) return "z"; return "("+i+")"; } function img_src(style,what,size) { var prefix = 'http://www.agnes-bruckner.com/apronus_images/chess/'; if (what == '_') return 'http://www.agnes-bruckner.com/apronus_images/chess/onepixel.gif'; var img; if (what == 'K') img = 'whiteking'; if (what == 'Q') img = 'whitequeen'; if (what == 'R') img = 'whiterook'; if (what == 'B') img = 'whitebishop'; if (what == 'N') img = 'whiteknight'; if (what == 'P') img = 'whitepawn'; if (what == 'k') img = 'blackking'; if (what == 'q') img = 'blackqueen'; if (what == 'r') img = 'blackrook'; if (what == 'b') img = 'blackbishop'; if (what == 'n') img = 'blackknight'; if (what == 'p') img = 'blackpawn'; return prefix + style + '/' + img + size + '.vers1.png'; } function load_images(style,size) { var empty = new Image(); empty.src = img_src(style,'_',size); var whiteking = new Image(); whiteking.src = img_src(style,'K',size); var whitequeen = new Image(); whitequeen.src = img_src(style,'Q',size); var whiterook = new Image(); whiterook.src = img_src(style,'R',size); var whitebishop = new Image(); whitebishop.src = img_src(style,'B',size); var whiteknight = new Image(); whiteknight.src = img_src(style,'N',size); var whitepawn = new Image(); whitepawn.src = img_src(style,'P',size); var blackking = new Image(); blackking.src = img_src(style,'k',size); var blackqueen = new Image(); blackqueen.src = img_src(style,'q',size); var blackrook = new Image(); blackrook.src = img_src(style,'r',size); var blackbishop = new Image(); blackbishop.src = img_src(style,'b',size); var blackknight = new Image(); blackknight.src = img_src(style,'n',size); var blackpawn = new Image(); blackpawn.src = img_src(style,'p',size); } function squarename(name,x,y) { return name + "_" + x + '_' + y; } function html_select(name,x,y) { var a = ''; a += "'; return doc; } function html_sizeselect(name,size) { var doc = ''; return doc; } function html_selectboard(name,width,height,style,squaresize) { var font = 'Courier, Courier New, Verdana'; var textstyle = 'font-family: '+font+'; color:gray;'; var flipper = '\n'; doc += '\n'; doc += ''; doc += literka(x)+'\r\n'; } doc += '\r\n'; for (y=height; y>=1; y--) { doc += '\r\n'; for (x=1; x<=width; x++) { doc += ' \r\n'; } // letters row doc += ''; for (x=1; x<=width; x++) { doc += ' \r\n'; } doc += '\r\n'; doc += '
'+html_styleselect(name,style)+'
'; doc += y + ''; doc += y + '
'+flipper+''; doc += literka(x)+''+html_sizeselect(name,squaresize)+'
\r\n'; return doc; } function styletd(name,x,y,size) { var td = document.getElementById('td'+squarename(name,x,y)); td.style.width = size+'px'; td.style.height = size+'px'; var backgroundcolor, isdark = !((x+y)%2); if (isdark) backgroundcolor = '#bbbbbb'; else backgroundcolor = '#eeeeee'; td.style.backgroundColor = backgroundcolor; td.style.textAlign = 'center'; } function stylesel(name,x,y) { var select = document.getElementById('select'+squarename(name,x,y)); select.style.display = 'none'; } function html_init_selectboard(name,width,height,style,size) { load_images(style,size); document.write(html_selectboard(name,width,height,style,size)); for (x=1; x<=width; x++) for (y=1; y<=height; y++) { styletd(name,x,y,size); stylesel(name,x,y); } } function piecestyle(name) { var a = document.getElementById(name+'_styleselect'); return a.options[a.selectedIndex].value; } function squaresize_selectboard(name) { var a = document.getElementById('td'+squarename(name,1,1)).style.width; return a.substr(0,a.length-2); // remove 'px' at the end } function isSelectBoardFlipped(name) { return (document.getElementById(name+"_flip")).checked; } function setsquare(name,x,y,what) { var src = img_src(piecestyle(name),what,squaresize_selectboard(name)); var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; if (isSelectBoardFlipped(name)) { x = width-x+1; y = height-y+1; } var sqn = squarename(name,x,y); document.getElementById('td'+sqn).style.backgroundImage = "url('"+src+"')"; document.getElementById('select'+sqn).value = what; } function startingdeska(width,height) { var x,y, deska = new Array(); for (x=1; x<=width; x++) { deska[x] = new Array(); for (y=1; y<=height; y++) deska[x][y] = '_'; } if (height < 4 || width < 8) return deska; for (var i=0; i squarename(name,width-x+1,height-y+1)) { ac = tda.style.backgroundColor; bc = tdb.style.backgroundColor; tda.style.backgroundColor = bc; tdb.style.backgroundColor = ac; as = tda.style.backgroundImage; bs = tdb.style.backgroundImage; if (as != bs) { tda.style.backgroundImage = bs; tdb.style.backgroundImage = as; } sela = document.getElementById('select'+squarename(name,x,y)); selb = document.getElementById('select'+squarename(name,width-x+1,height-y+1)); v = sela.value; sela.value = selb.value; selb.value = v; } } } function initSelectBoard(name,width,height,flip,start,style,size) { html_init_selectboard(name,width,height,style,size); set_empty_or_start(name,start); if (flip) { (document.getElementById(name+"_flip")).checked = true; _FlipSelectBoard(name); } //document.getElementById(name+'_styleselect').style.display = 'none'; //document.getElementById(name+'_sizeselect').style.display = 'none'; //document.getElementById(name+"_flip").style.display = 'none'; } function whatonsquare(name,x,y) { var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; if (isSelectBoardFlipped(name)) { x = width-x+1; y = height-y+1; } var a = document.getElementById('td'+squarename(name,x,y)).style.backgroundImage; if (/whiteking/.test(a)) return 'K'; if (/whitequeen/.test(a)) return 'Q'; if (/whiterook/.test(a)) return 'R'; if (/whitebishop/.test(a)) return 'B'; if (/whiteknight/.test(a)) return 'N'; if (/whitepawn/.test(a)) return 'P'; if (/blackking/.test(a)) return 'k'; if (/blackqueen/.test(a)) return 'q'; if (/blackrook/.test(a)) return 'r'; if (/blackbishop/.test(a)) return 'b'; if (/blackknight/.test(a)) return 'n'; if (/blackpawn/.test(a)) return 'p'; return '_'; } function restyle_selectboard(name,style,size) { load_images(style,size); var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; var x,y; for (x=1; x<=width; x++) for (y=1; y<=height; y++) { var a = document.getElementById('td'+squarename(name,x,y)); a.style.width = size+'px'; a.style.height = size+'px'; setsquare(name,x,y,whatonsquare(name,x,y)); } } function resize_selectboard(name) { var a = document.getElementById(name+'_sizeselect'); var size = a.options[a.selectedIndex].value; restyle_selectboard(name,piecestyle(name),size); } function mouseover(sqn) { RemoveSelection(); var a = document.getElementById('select'+sqn); a.style.display = 'inline'; } function mousemove(sqn) { mouseover(sqn); } function mouseout(sqn) { RemoveSelection(); var a = document.getElementById('select'+sqn); a.style.display = 'none'; } function squarechange(sqn) { var what = document.getElementById('select'+sqn).value; var a = sqn.split('_'); var name = a[0], x = a[1], y = a[2]; var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; if (isSelectBoardFlipped(name)) { x = width-x+1; y = height-y+1; } setsquare(name,x,y,what); selectboard_positionchange(name); } function setbordercolor(name,color) { var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; var x,y,td; for (x=1; x<=width; x++) { td = document.getElementById('td'+squarename(name,x,height)); td.style.borderTop = '1px solid '+color; td = document.getElementById('td'+squarename(name,x,1)); td.style.borderBottom = '1px solid '+color; } for (y=1; y<=height; y++) { td = document.getElementById('td'+squarename(name,1,y)); td.style.borderLeft = '1px solid '+color; td = document.getElementById('td'+squarename(name,width,y)); td.style.borderRight = '1px solid '+color; } } function setcoordinatescolor(name,color) { var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; var i; for (i=1; i<=width; i++) { (document.getElementById(name+'_t'+i)).style.color = color; (document.getElementById(name+'_b'+i)).style.color = color; } for (i=1; i<=height; i++) { (document.getElementById(name+'_l'+i)).style.color = color; (document.getElementById(name+'_r'+i)).style.color = color; } } function setdarklight(name,dark,light) { var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; var flip = isSelectBoardFlipped(name); var x,y,td,backgroundcolor,isdark; for (x=1; x<=width; x++) for (y=1; y<=height; y++) { td = document.getElementById('td'+squarename(name,x,y)); isdark = !((x+y)%2); if (flip && (width+height)%2) isdark = !isdark; if (isdark) backgroundcolor = dark; else backgroundcolor = light; td.style.backgroundColor = backgroundcolor; } } function getpoza(name) { var poza = 'P'; var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; var x,y; for (y=1; y<=height; y++) for (x=1; x<=width; x++) { poza += whatonsquare(name,x,y); } return poza; } function setpoza(name,poza) { if (poza == 'empty') { set_empty_or_start(name,false); return getpoza(name); } if (poza == 'start') { set_empty_or_start(name,true); return getpoza(name); } var width = (document.getElementById(name+'_width')).value; var height = (document.getElementById(name+'_height')).value; var x,y,i; for (x=1; x<=width; x++) for (y=1; y<=height; y++) { i = (y-1)*width + x; setsquare(name,x,y,poza[i]); } return poza; } function refresh_selectboard(name,style,size,flip,bordercolor,coordinatescolor,dark,light) { document.getElementById(name+'_styleselect').value = style; document.getElementById(name+'_sizeselect').value = size; resize_selectboard(name,size); restyle_selectboard(name,style,size); var isflipped = isSelectBoardFlipped(name); if (isflipped != flip) { document.getElementById(name+"_flip").checked = flip; _FlipSelectBoard(name); } if (bordercolor) setbordercolor(name,bordercolor); if (coordinatescolor) setcoordinatescolor(name,coordinatescolor); if (dark && light) setdarklight(name,dark,light); } function defaultcolor(id) { if (id == 'darks') return [187,187,187]; if (id == 'lights') return [238,238,238]; if (id == 'bordercolor') return [150,150,150]; if (id == 'textcolor') return [0,0,0]; if (id == 'coolor') return [254,254,254]; if (id.substr(0,2) == 'ss') return [0,0,200]; if (id.charAt(0)=='a') return [255,0,255]; } function tohex(x) { if (x<10) return ''+x; if (x==10) return 'A'; if (x==11) return 'B'; if (x==12) return 'C'; if (x==13) return 'D'; if (x==14) return 'E'; if (x==15) return 'F'; return tohex(Math.floor(x / 16)) + tohex(x % 16); } function hexcolorcode(R,G,B) { var r,g,b; if (R<16) r = '0'+tohex(R); else r = tohex(R); if (G<16) g = '0'+tohex(G); else g = tohex(G); if (B<16) b = '0'+tohex(B); else b = tohex(B); return r+g+b; } function querystring() { var q = '?d='+poza; if (width != 8) q += '&w='+width; if (height != 8) q += '&h='+height; if (flip) q += '&f=1'; q += '&p='+size; if (style == 'merida') q += '&s=0'; if (style == 'alpha') q += '&s=1'; if (style == 'linares') q += '&s=2'; { q += '&c=' + hexcolorcode(darkR,darkG,darkB) + hexcolorcode(lightR,lightG,lightB); q += hexcolorcode(borderR,borderG,borderB) + hexcolorcode(textR,textG,textB); } if (!rimjest) q += '&q='; else { q += '&r=' + hexcolorcode(rimR,rimG,rimB); if (arrows != '') q += '&a='+arrows; if (kwadraciki != '') q += '&k='+kwadraciki; if (document.getElementById('tomove').checked) { if (whitetomove) q += '&z=w'; if (blacktomove) q += '&z=b'; } } return q; } function URL_stagram() { var prefix = 'http://www.apronus.com/chess/diagram/stagram.php'; return prefix + querystring(); } function updatekwadraciki() { var i,a,x,y,kk=''; for (i=1; i<=4; i++) { a = parseSquare(document.getElementById('ss'+i).value); if (a != 'wrong' && a != 'empty') { a = a.split(','); x = a[0]; y = a[1]; a = parseColor(document.getElementById('ss'+i+'color').value); if (a == 'wrong' || a == 'empty') a = defaultcolor('ss'+i+'color'); else a = a.split(','); kk += ''+x+'Q'+y+'Q'+a[0]+'Q'+a[1]+'Q'+a[2]+'A'; } } if (kk == '') return ''; return kk.substr(0,kk.length-1); } function updatearrows() { var i,a,b,x1,y1,x2,y2,kk=''; for (i=1; i<=4; i++) { a = parseSquare(document.getElementById('a'+i+'s1').value); b = parseSquare(document.getElementById('a'+i+'s2').value); if (a != 'wrong' && a != 'empty' && b != 'wrong' && b != 'empty') { a = a.split(','); x1 = a[0]; y1 = a[1]; b = b.split(','); x2 = b[0]; y2 = b[1]; a = parseColor(document.getElementById('a'+i+'color').value); if (a == 'wrong' || a == 'empty') a = defaultcolor('a'+i+'color'); else a = a.split(','); kk += ''+x1+'Q'+y1+'Q'+x2+'Q'+y2+'Q'+a[0]+'Q'+a[1]+'Q'+a[2]+'A'; } } if (kk == '') return ''; return kk.substr(0,kk.length-1); } function refresh() { size = document.getElementById('sizeselector').value; style = document.getElementById('styleselector').value; flip = document.getElementById('flipper').checked; rimjest = !document.getElementById('rimjest').checked; kwadraciki = updatekwadraciki(); arrows = updatearrows(); document.getElementById('diagram').src = URL_stagram(); var a = document.getElementById('feninput'); a.value = getfen(); a.style.backgroundColor = 'white'; a.style.color = 'black'; var bordercolor = '#'+hexcolorcode(borderR,borderG,borderB); var coordinatescolor = '#'+hexcolorcode(textR,textG,textB); var darkcolor = '#'+hexcolorcode(darkR,darkG,darkB); var lightcolor = '#'+hexcolorcode(lightR,lightG,lightB); refresh_selectboard('selectboard',style,size,flip,bordercolor,coordinatescolor,darkcolor,lightcolor); document.getElementById('selectboardcontainer').style.backgroundColor = '#'+hexcolorcode(rimR,rimG,rimB); } function parseColor(input) { if (input=='') return 'empty'; var R,G,B,a; a = input.search(/^[#]{0,1}[0-9a-f]{6}$/i); if (a>-1) { if (input.charAt(a) == '#') a++; R = parseInt(input.charAt(a)+input.charAt(a+1), 16); G = parseInt(input.charAt(a+2)+input.charAt(a+3), 16); B = parseInt(input.charAt(a+4)+input.charAt(a+5), 16); return ''+R+','+G+','+B; } a = input.search(/^[#]{0,1}[0-9a-f]{3}$/i); if (a>-1) { if (input.charAt(a) == '#') a++; R = 16*parseInt(input.charAt(a), 16); G = 16*parseInt(input.charAt(a+1), 16); B = 16*parseInt(input.charAt(a+2), 16); return ''+R+','+G+','+B; } var rex = /[0-9]{1,3}/g; //[^\D] if (a = rex.exec(input)) { R = a[0]; if (a = rex.exec(input.substring())) { G = a[0]; if (a = rex.exec(input)) { B = a[0]; if (R<256 && G<256 && B<256) return ''+R+','+G+','+B; } } } return 'wrong'; } function okcolor(id,r,g,b) { var ok; if (''+r+g+b == '254254254') ok = 'transparent'; else ok = '#'+hexcolorcode(r,g,b)+' rgb('+r+','+g+','+b+')'; var a = document.getElementById(id); a.title = ok; a.style.color = 'black'; a.style.backgroundColor = 'white'; a.style.fontWeight = 'normal'; } function wrongcolor(id) { var a = document.getElementById(id); a.style.color = 'black'; a.style.backgroundColor = '#ffdddd'; a.style.fontWeight = 'bold'; a.focus(); } function oncolorchange(id) { var rgb,r,g,b, a = parseColor(document.getElementById(id).value); if (a == 'wrong') { wrongcolor(id); refresh(); return; } if (a == 'empty') rgb = defaultcolor(id); else rgb = a.split(','); r = rgb[0]; g = rgb[1]; b = rgb[2]; okcolor(id,r,g,b); if (id == 'coolor'){ rimR = r; rimG = g; rimB = b; } if (id == 'textcolor') { textR = r; textG = g; textB = b; } if (id == 'bordercolor') { borderR = r; borderG = g; borderB = b; } if (id == 'darks') { darkR = r; darkG = g; darkB = b; } if (id == 'lights') { lightR = r; lightG = g; lightB = b; } refresh(); if (a == 'empty') document.getElementById(id).value = r+' '+g+' '+b; } function parseSquare(input) { if (input == '') return 'empty'; input = input.toLowerCase(); var x,y; x = input.charCodeAt(0) - 'a'.charCodeAt(0) + 1; if (x >= 1 && x <= width) { y = parseInt(input.substr(1)); if (y >= 1 && y <= height) return x+','+y; } return 'wrong'; } function onSSchange(ss) { if (parseSquare(ss.value) == 'wrong') { ss.style.color = 'black'; ss.style.backgroundColor = '#ffdddd'; ss.style.fontWeight = 'bold'; ss.focus(); refresh(); return; } ss.style.color = 'black'; ss.style.backgroundColor = 'white'; ss.style.fontWeight = 'normal'; refresh(); } function populatecolor(id,r,g,b) { okcolor(id,r,g,b); document.getElementById(id).value = r+' '+g+' '+b; } function make_castling_fen_part() { if (width != 8) return "-"; var a1 = poza[1]; var h1 = poza[8]; var e1 = poza[5]; var a8 = poza[(height-1)*8+1]; var h8 = poza[(height-1)*8+8]; var e8 = poza[(height-1)*8+5]; var whiteOO = document.getElementById('whiteOO').checked; var whiteOOO = document.getElementById('whiteOOO').checked; var blackOO = document.getElementById('blackOO').checked; var blackOOO = document.getElementById('blackOOO').checked; var castling = ""; if (whiteOO && e1=='K' && h1=='R') castling += "K"; if (whiteOOO && e1=='K' && a1=='R') castling += "Q"; if (blackOO && e8=='k' && h8=='r') castling += "k"; if (blackOOO && e8=='k' && a8=='r') castling += "q"; if (castling == "") castling = "-"; return castling; } function getfen() { var x,y,c,n=0,fen=""; for (y=height; y>=1; y--) { for (x=1; x<=width; x++) { c = poza.charAt((y-1)*width + x); if (c == '_') { n++; } else { if (n > 0) { fen += n; n = 0; } fen += c; } } if (n > 0) { fen += n; n=0; } if (y>1) fen += "/"; } if (blacktomove) fen += " b "; else fen += " w "; fen += make_castling_fen_part(); fen += " -"; // no enpassant fen += " 0 1"; // move count return fen; } function detailschange() { if (document.getElementById('blackstarts').checked) { blacktomove = true; whitetomove = false; } else { blacktomove = false; whitetomove = true; } document.getElementById('feninput').value = getfen(); } function pozafromFEN(fen) { if (!fen) return ""; var fenek = fen.split(' '); var horizontals = fenek[0].split('/'); if (horizontals.length != height) return ""; var pozycja = ""; for (var y=height-1; y>=0; y--) { var hora = horizontals[y]; while (hora != "") { switch(hora.charAt(0)) { case 'K' : pozycja += "K"; break; case 'k' : pozycja += "k"; break; case 'Q' : pozycja += 'Q'; break; case 'q' : pozycja += 'q'; break; case 'R' : pozycja += 'R'; break; case 'r' : pozycja += 'r'; break; case 'B' : pozycja += 'B'; break; case 'b' : pozycja += 'b'; break; case 'N' : pozycja += 'N'; break; case 'n' : pozycja += 'n'; break; case 'P' : pozycja += 'P'; break; case 'p' : pozycja += 'p'; break; case '1' : pozycja += '_'; break; case '2' : pozycja += "__"; break; case '3' : pozycja += '___'; break; case '4' : pozycja += '____'; break; case '5' : pozycja += '_____'; break; case '6' : pozycja += '______'; break; case '7' : pozycja += '_______'; break; case '8' : pozycja += '________'; break; default : return ""; } hora = hora.substring(1,hora.length); } } if (pozycja.length != width*height) return ""; return '_' + pozycja; } function castling_from_fen(fen) { var a = (fen.split(' '))[2]; if (!a) return [false,false,false,false]; var whiteOO = false, whiteOOO = false, blackOO = false, blackOOO = false; if (a.charAt(0)=='K') { whiteOO = true; a = a.substr(1,a.length); } if (a.charAt(0)=='Q') { whiteOOO = true; a = a.substr(1,a.length); } if (a.charAt(0)=='k') { blackOO = true; a = a.substr(1,a.length); } if (a.charAt(0)=='q') { blackOOO = true; a = a.substr(1,a.length); } return [whiteOO, whiteOOO, blackOO, blackOOO]; } function setcastling(a) { document.getElementById('whiteOO').checked = a[0]; document.getElementById('whiteOOO').checked = a[1]; document.getElementById('blackOO').checked = a[2]; document.getElementById('blackOOO').checked = a[3]; } function onfenchange() { var a = document.getElementById('feninput'); var b = pozafromFEN(a.value); if (b != '') { setcastling( castling_from_fen(a.value) ); a.style.backgroundColor = 'white'; a.style.color = 'black'; poza = b; refresh(); setpoza('selectboard',poza); return; } a.style.backgroundColor = '#ffdddd'; a.style.color = 'black'; } function valid_castling() { if (width != 8) return [false,false,false,false]; var a1 = poza[1]; var h1 = poza[8]; var e1 = poza[5]; var a8 = poza[(height-1)*8+1]; var h8 = poza[(height-1)*8+8]; var e8 = poza[(height-1)*8+5]; var whiteOO = document.getElementById('whiteOO').checked; var whiteOOO = document.getElementById('whiteOOO').checked; var blackOO = document.getElementById('blackOO').checked; var blackOOO = document.getElementById('blackOOO').checked; if (!(whiteOO && e1=='K' && h1=='R')) whiteOO = false; if (!(whiteOOO && e1=='K' && a1=='R')) whiteOOO = false; if (!(blackOO && e8=='k' && h8=='r')) blackOO = false; if (!(blackOOO && e8=='k' && a8=='r')) blackOOO = false; return [whiteOO,whiteOOO,blackOO,blackOOO]; } function wiseboard_URL() { var a = valid_castling(); var whiteOO = a[0]; var whiteOOO = a[1]; var blackOO = a[2]; var blackOOO = a[3]; a = 0; if (whiteOO) a += 1; if (whiteOOO) a += 2; if (blackOO) a += 4; if (blackOOO) a += 8; var castling_char = String.fromCharCode(a+65); var url = "http://www.apronus.com/chess/pgnviewer/?"; if (blacktomove) url += "s=black&"; if (flip) url += "f=1"; if (width != 8) url += "w="+width+"&"; if (height != 8) url += "h="+height+"&"; url += "p=" + castling_char + poza.substr(1,poza.length); return url; } function wiseboard() { var url = wiseboard_URL(); if (document.getElementById('newwindow').checked) window.open(url); else window.location.href = url; } function replace(a,m,r) { var s = a.replace(m,r); if (s == a) return s; return replace(s,m,r); } function export_computerURL() { var flipdigit, prefix = "http://www.apronus.com/chess/playcomputer/"; if (isSelectBoardFlipped('selectboard')) flipdigit = '1'; else flipdigit = '0'; var FEN = getfen(); return prefix + "?fen=" + flipdigit + replace(replace(FEN,"/","X")," ","_"); } function computer() { if (document.getElementById('newwindowcomputer').checked) window.open(export_computerURL()); else window.location.href = export_computerURL(); } function populate() { var a,b,i; document.getElementById('flipper').checked = flip; document.getElementById('rimjest').checked = !rimjest; document.getElementById('sizeselector').value = size; document.getElementById('styleselector').value = style; document.getElementById('tomove').checked = showtomove; document.getElementById('blackstarts').checked = blacktomove; var roszady = poza.charCodeAt(0); setcastling( [(roszady-65)%2 == 1, Math.floor((roszady-65)/2)%2 == 1, Math.floor((roszady-65)/4)%2 == 1, Math.floor((roszady-65)/8)%2 == 1 ] ); populatecolor('coolor',rimR,rimG,rimB); populatecolor('textcolor',textR,textG,textB); populatecolor('bordercolor',borderR,borderG,borderB); populatecolor('darks',darkR,darkG,darkB); populatecolor('lights',lightR,lightG,lightB); for (i=1; i<=4; i++) { a = defaultcolor('ss'+i+'color'); okcolor('ss'+i+'color',a[0],a[1],a[2]); document.getElementById('ss'+(i)+'color').value = a[0]+' '+a[1]+' '+a[2]; } if (kwadraciki) { a = kwadraciki.split('A'); for (i=0; i"; a += imgdoc; a += "\n"; return a; } function emptyboard() { document.getElementById('whiteOO').checked = false; document.getElementById('whiteOOO').checked = false; document.getElementById('blackOO').checked = false; document.getElementById('blackOOO').checked = false; setpoza("selectboard","empty"); selectboard_positionchange("selectboard"); } function startboard() { document.getElementById('whiteOO').checked = true; document.getElementById('whiteOOO').checked = true; document.getElementById('blackOO').checked = true; document.getElementById('blackOOO').checked = true; document.getElementById('whitestarts').checked = true; setpoza("selectboard","start"); selectboard_positionchange("selectboard"); } function bookmarkURL() { absorb_selectboard_parameters('selectboard'); refresh(); var prefix = 'http://www.apronus.com/chess/diagram/editor/'; return prefix + querystring(); } function downloadURL() { absorb_selectboard_parameters('selectboard'); refresh(); return URL_stagram() + '&download='; }