// flipit3.js
var cols = new Array("a", "b", "c", "d", "e", "f", "g", "h");
rows = new Array("8", "7", "6", "5", "4", "3", "2", "1");
rcols = new Array("h", "g", "f", "e", "d", "c", "b", "a");
rrows = new Array("1", "2", "3", "4", "5", "6", "7", "8");
playercolor="w";
function flipit() {
var allpieces="";
if (playercolor == "w") { playercolor="b"; } else { playercolor="w"; }
top.frames["bpanel"].document.write("playcolor " + playercolor + "
");
if (playercolor == "b") {
for (row in rows) { top.frames["bpanel"].document.write(rrows[row] + "
");
it="";
it='
' + rrows[row] + ' | ';
document.getElementById("rownumbers").rows[row].innerHTML=it;
}
} else {
// must be white
for (row in rows) { top.frames["bpanel"].document.write(rrows[row] + "
");
it="";
it='' + rows[row] + ' | ';
document.getElementById("rownumbers").rows[row].innerHTML=it;
}
}
if (playercolor == "b") {
for (row in rrows) { for (col in rcols) {
rw=rcols[col] + rrows[row];
revrw=cols[col] + rows[row];
top.frames["bpanel"].document.write(rw + "-" + revrw + " ");
} top.frames["bpanel"].document.write("
"); }
} else {
for (row in rows) { for (col in cols) {
rw=cols[col] + rows[row];
revrw=rcols[col] + rrows[row];
top.frames["bpanel"].document.write(rw + "-" + revrw + " ");
} top.frames["bpanel"].document.write("
"); }
}
// good
//*for (col in rcols) { top.frames["bpanel"].document.write(rcols[col] + "Z" + col + "
"); }
//*}
// playercolor = 1 = black
//*else
// playerclor = 0 = white
//*{
//* top.frames["bpanel"].document.write("playcolor" + playercolor + "
");
//*for (row in rows) { top.frames["bpanel"].document.write(rows[row] + "Y
");
//}
//*it="";
//*it='' + rows[row] + ' | ';
//* document.getElementById("rownumbers").rows[row].innerHTML=it;
//* }
//*for (row in rows) { for (col in cols) { rw=cols[col] + rows[row];
//*revrw= rcols[col] + rrows[row];
//*top.frames["bpanel"].document.write(rw + "-" + revrw + " ");
//*} top.frames["bpanel"].document.write("
"); }
//*}
//*it="";
//*// document.getElementById("colletters").rows[0].innerHTML=it;
for (col in cols) {
if (playercolor = "b") {
top.frames["bpanel"].document.write(rcols[col] + "YY" + col + "
");
}
else
{
top.frames["bpanel"].document.write(cols[col] + "ZZ" + col + "
");
}
}
//*it= it + '' + rcols[col] + ' | ';
//*}
//*else {
//*top.frames["bpanel"].document.write(cols[col] + "X" + col + "
");
//*it= it + '' + cols[col] + ' | ';
//*}
//*}
//*document.getElementById("colletters").rows[0].innerHTML=it;
////document.getElementById("colletters").rows[0].innerHTML + it;
//top.frames["bpanel"].document.write("
HERE" + it);
//*top.frames["bpanel"].document.write('
Click to flip' + playercolor);
top.frames["bpanel"].document.close();
//*
}
// end flipit
// loadlocal.html
var spieces = new Array("wbrook", "bbknight", "wbbishop", "bbqueen", "wbking", "bbbishop", "wbknight", "bbrook", "bbpawn", "wbpawn", "bbpawn", "wbpawn", "bbpawn", "wbpawn", "bbpawn", "wbpawn", "wwpawn", "bwpawn", "wwpawn", "bwpawn", "wwpawn", "bwpawn", "wwpawn", "bwpawn", "bwrook", "wwknight", "bwbishop", "wwqueen", "bwking", "wwbishop", "bwknight", "wwrook");
var allpieces = new Array("b", "bbbishop", "bbking", "bbknight", "bbpawn", "bbqueen", "bbrook", "bwbishop", "bwking", "bwknight", "bwpawn", "bwqueen", "bwrook", "sbbbishop", "sbbking", "sbbknight", "sbbpawn", "sbbqueen", "sbbrook", "sbwbishop", "sbwking", "sbwknight", "sbwpawn", "sbwqueen", "sbwrook", "swbbishop", "swbking", "swbknight", "swbpawn", "swbqueen", "swbrook", "swwbishop", "swwking", "swwknight", "swwpawn", "swwqueen", "swwrook", "w", "wbbishop", "wbking", "wbknight", "wbpawn", "wbqueen", "wbrook", "wwbishop", "wwking", "wwknight", "wwpawn", "wwqueen", "wwrook");
// for (i=0; i\n");
var allimages = new Array();
for (i=0; iAll Images
\n");
//for (i=0; i\n");
//}
//document.write("
\n");
var simages = new Array();
var ssimages = new Array();
for (i=0; i");
allpieces=allpieces + rw + "-" + clipped + "-";
}
}
//br
top.frames["bpanel"].document.write(allpieces + "
");
top.frames["bpanel"].document.close();
}
function setit(name) {
loops++;
selectedsquare=name;
if (!selected) {
// not selected
// switch to simage
// document.a8.src="png/sbbrook.png";
// /document.images[name].src=a8;
piecetoselect=document.images[name].src;
len=piecetoselect.lastIndexOf("/");
len++;
selectpiece=piecetoselect.substring(len);
if (selectpiece == "w.png" || selectpiece == "b.png") {
return 1;
}
newselectsource="png/s" + selectpiece;
document.images[name].src=newselectsource;
// now selected
selected=1;
// write square coordinates to moveframes
// mf movefrom
// m$
top.frames["bpanel"].document.write(loops + "-" + selectpiece);
//document.getElementById("movefrom").write("ITTT");
//mf
// m$
top.frames["bpanel"].document.write("movefrom " + name);
//mf
// m$
top.frames["bpanel"].document.close();
movefrom=name;
}
else {
// some coordinate is selected
// so if not the same square (in which case deselect) move to it
// after checking square color and stashing any piece taken
if (name == movefrom) {
//mf
// m$
top.frames["bpanel"].document.write("do not move" + selectedsquare);
// m$
top.frames["bpanel"].document.write("name is " + name);
// m$
top.frames["bpanel"].document.close();
// /document.images[name].src="png/wbrook.png";
document.images[name].src=piecetoselect;
}
// just deselect
else {
// document.a8.src="png/bbrook.png";
//mt moveto
// m$
top.frames["bpanel"].document.write("do moves" + name);
// top.frames["moveto"].document.writeln("moveto " + name);
// m$
top.frames["bpanel"].document.close();
// set piecetomove from current selectedsquare src
// check new square color
// stash piece taken if not empty
piecetomove=document.images[movefrom].src;
piecetotake=document.images[name].src;
len=piecetomove.lastIndexOf("/");
len2=piecetotake.lastIndexOf("/");
len++;
len++;
// twice to skip last slash and s for selected
len2++;
// only once for the slash
piecename=piecetomove.substring(len);
piecetotakename=piecetotake.substring(len2);
squarecolor=piecename.substring(0,1);
// /
// lose brig top.frames["brig"].document.writeln("IT" + squarecolor);
// turn off noise top.frames["bpanel"].document.write("IT here too" + squarecolor);
takesquarecolor=piecetotakename.substring(0,1);
// lose brig top.frames["brig"].document.writeln("IT2" + takesquarecolor);
nameonly=piecename.substring(1);
takenameonly=piecetotakename.substring(1);
// turn off noise top.frames["bpanel"].document.write("Check for 125 javascripts CASTLING" + movefrom + name);
// need to add make sure its a king
//if ((movefrom == "e8") && (name == "c8")) || ((movefrom == "e8") && (name == "g8")) || ((movefrom == "e1") && (name == "g1")) || ((movefrom == "e1") && (name == "c1"))
//{
//return ;
//}
if (takenameonly != ".png") {
piecestaken=piecestaken + " " + takenameonly; }
newsource="png/" + squarecolor + ".png";
takenewsource="png/" + takesquarecolor + nameonly;
document.images[movefrom].src=newsource;
// replaced movedfrom square with color
// now get squarecolor of moveto
// put
//br brig
// turn off noise top.frames["bpanel"].document.writeln("IT3" + takenewsource + "IT4" + name);
piecetotakecolor=takenameonly.substring(0,1);
if (takenameonly != ".png") {
if (piecetotakecolor == "w") {
stakenameonly="png/w" + takenameonly;
wcounter++;
// now broke document.images["w" + wcounter].src=stakenameonly;
top.frames["lpanel"].document.images["brigw" + wcounter].src=stakenameonly;
} else {
stakenameonly="png/w" + takenameonly;
bcounter++;
bname="b" + bcounter;
// now broke document.images["b" + bcounter].src=stakenameonly;
top.frames["lpanel"].document.images["brigb" + bcounter].src=stakenameonly;
// document.images[bname].src=stakenameonly;
}
}
// dont save empty squares
document.images[name].src=takenewsource;
// doit="document." + selectedsquare + ".src=newsource";
// doit;
// len=length(piecetomove);
// parse for squarecolor to replace
// and piecename to move
// piecename=
// piececolor=
// document.a8.src=piececolor.png;
// /top.frames["moveto"].document.writeln(piecetomove + "NOW" + len + "NAME" + piecename + "COLOR" + squarecolor + "NAAMEONLY" + nameonly + "NEWSOURCE" + newsource);
//mt
// m$
top.frames["bpanel"].document.write("moveto" + name);
// m$
top.frames["bpanel"].document.close();
//top.frames["brig"].document.writeln(piecestaken);
// top.frames["brig"].document.write("
");
// /xit=piecestaken.split(" ");
//piecestaken.replace(/ /g,"
");
//}
// turn off noise top.frames["bpanel"].document.close();
// do move
}
selected=0;
// selectedsquare=name;
}
// selectedsquare=name;
}