<html>
<head>
<title>Experimental Drag and Drop - RJM Programming - July, 2023 ... thanks to https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setData</title>
<style>
th.source {
border: 1px solid transparent;
}
</style>
<script type=text/javascript>
var playerb='Black';
var playerw='White';
var clonedata='', clonedatatwo='', pos3=0, pos4=0, secs=0, score=0, tdid='', tdcheck=true;
var tdnum=location.search.split('tdnum=')[1] ? eval(location.search.split('tdnum=')[1].split('&')[0]) : 9;
var across=location.search.split('across=')[1] ? eval(location.search.split('across=')[1].split('&')[0]) : 3;
var twosubsfrom=['',''], twosubsto=['',''], onenewmove=[];
var trad='', idone='', idtwo='', gval='', idzero='';
var yesnod=true, iyesnod=0, previyesnod=0;
var amove='';
if (document.URL.indexOf('traditional=') != -1) {
trad=decodeURIComponent(document.URL.split('traditional=')[1].split('&')[0]);
}
if (document.URL.indexOf('move=') != -1) {
amove=decodeURIComponent(document.URL.split('move=')[1].split('&')[0]);
}
var movefrom=-1, moveto=-1, nextmove=-1, mirroring=false;
var dragh=false;
var sdone=false;
var sourceid='sou' + 'rce';
var shuffle=('' + location.hash + ' ' + location.search + ' ').split('shuffle=')[1] ? true : false;
var yourblurb=location.search.split('yourblurb=')[1] ? decodeURIComponent('' + location.hash + ' ' + location.search.split('yourblurb=')[1].split('&')[0]).replace(/\+/g,' ').replace(/\ \ \ /g,' + ') : '';
var sourcenum=location.search.split('sourcenum=')[1] ? Math.floor(eval(('' + location.search.split('sourcenum=')[1].split('&')[0]) + '.0')) : 1;
if ((document.URL.split('#')[0] + '&').indexOf('sourcenum=&') != -1 && sourcenum == 1) { sourcenum=0; }
var originalsn=sourcenum;
var originalsh=shuffle;
var origsnc='';
var bdone=false;
var lastbco=null;
var lastoh='', prevlastoh='', prevlastih='', prevtih='', lohfulloh='', newlohfulloh='';
var lastih='', loh='', lohoh='';
var lastevid='', bcklastid='';
var lastid='';
var prefx='th';
var itisthiscmove='', lastitisthiscmove=' ';
var fauxmove='';
if (document.URL.indexOf('draughts=') != -1) {
fauxmove=decodeURIComponent(document.URL.split('draughts=')[1].split('&')[0]);
if (fauxmove.trim() != '') {
itisthiscmove=fauxmove.substring(0,1).replace('w','B').replace('b','W').toLowerCase();
if (itisthiscmove == 'b') {
setTimeout(function(){ consolelog(playerb + ', it is your turn. '); }, 3000);
} else if (itisthiscmove == 'w') {
setTimeout(function(){ consolelog(playerw + ', it is your turn. '); }, 3000);
}
}
}
var cpa=['bK','wK','bQ','wQ','bR1','wR1','bR2','wR2','bB1','wB1','bB2','wB2','bK1','wK1','bK2','wK2','bP1','wP1','bP2','wP2','bP3','wP3','bP4','wP4','bP5','wP5','bP6','wP6','bP7','wP7','bP8','wP8'];
var staidmap=[4,60,3,59,0,56,7,63, 2,58,5,61, 1,57,6,62, 8,48,9,49,10,50,11,51,12,52,13,53,14,54,15,55];
if (document.URL.indexOf('draughts') != -1) {
cpa=['bB1','wB1','bB2','wB2','bB3','wB3','bB4','wB4','bB5','wB5','bB6','wB6','bB7','wB7','bB8','wB8','bB9','wB9','bBv','wBv','bBu','wBu','bBt','wBt'];
staidmap=[1,56,3,58,5,60,7,62,8,49,10,51,12,53,14,55,17,40,19,42,21,44,23,46];
}
var occupiedlist=',', qid='', qqid='';
var blackchecked=false, blackcheckmated=false;
var whitechecked=false, whitecheckmated=false;
var fouroh='', eightoh='', sixoh='', spanzero='', tdtte='';
var wwwtdtte='', wwtdtte='', wtdtte='', wsixoh='', spanfive='', ppt=false;
var domcmds=[];
var wastitle='';
var gev=null, hostid='', prelegal=true, cm='';
var lastmove='', waslastmove='';
var startboard='', endboard='';
var wstartsincheck=false, wendsincheck=false;
var bstartsincheck=false, bendsincheck=false;
var thissquare=-1;
var eightaround=[-1,-1,-1,-1,-1,-1,-1,-1,-1];
var isbad=false, iswrong=false;
function anybw(asq, thebrd, bwenemy, alertallowed) {
thebrd+='&';
isbad=false;
iswrong=false;
var bwfriend=bwenemy.replace('w','!').replace('b','W').replace('!', 'b').toLowerCase();
var okfornow=true, startat=eval('' + asq), twos=[];
var startrow=Math.floor(eval(-1 + asq) / 8);
var startcol=Math.floor(eval(-1 + asq) % 8);
var lastcol=-1, lastrow=-1;
var kposa=[18,-18,17,-17,15,-15,6,-6,10,10];
var pposa=[9,7];
var kgposa=[9,8,7,-1,1,-7,-8,-9];
var ikposa=0;
if (asq == thissquare) {
asq=asq;
}
if (bwfriend == 'w') {
pposa=[-9,-7];
}
//alert('Checking ' + bwfriend + ' King at ' + asq);
// Horizontal check
startat=eval(-1 + asq);
while (startat >= 1 && startat <= 64 && startrow == Math.floor(eval(-1 + startat) / 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(1);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(2);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(3);
return asq;
}
}
}
startat--;
}
startat=eval(1 + asq);
while (startat >= 1 && startat <= 64 && startrow == Math.floor(eval(-1 + startat) / 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(11);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(12);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(13);
return asq;
}
}
}
startat++;
}
// Vertical check
startat=eval(-8 + asq);
while (startat >= 1 && startat <= 64 && startcol == Math.floor(eval(-1 + startat) % 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(21);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(22);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(23);
return asq;
}
}
}
startat-=8;
}
startat=eval(8 + asq);
while (startat >= 1 && startat <= 64 && startcol == Math.floor(eval(-1 + startat) % 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(24);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(25);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('R') != -1) {
isbad=true;
//alert(26);
return asq;
}
}
}
startat+=8;
}
// Diagonal check
lastcol=Math.floor(eval(-1 + asq) % 8);
lastrow=Math.floor(eval(-1 + asq) / 8);
startat=eval(-9 + asq);
while (startat >= 1 && startat <= 64 && Math.abs(lastcol - Math.floor(eval(-1 + startat) % 8)) == 1 && Math.abs(lastrow - Math.floor(eval(-1 + startat) / 8)) == 1) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert('31 ' + bwfriend + ' ' + twos[0].slice(-3) + ' ' + startat + ' ' + asq);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(32);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(33);
return asq;
}
}
}
lastcol=Math.floor(eval(-1 + startat) % 8);
lastrow=Math.floor(eval(-1 + startat) / 8);
startat-=9;
}
lastcol=Math.floor(eval(-1 + asq) % 8);
lastrow=Math.floor(eval(-1 + asq) / 8);
startat=eval(-7 + asq);
while (startat >= 1 && startat <= 64 && Math.abs(lastcol - Math.floor(eval(-1 + startat) % 8)) == 1 && Math.abs(lastrow - Math.floor(eval(-1 + startat) / 8)) == 1) { // && startcol == Math.floor(eval(-1 + startat) % 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(41);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(42);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(43);
return asq;
}
}
}
lastcol=Math.floor(eval(-1 + startat) % 8);
lastrow=Math.floor(eval(-1 + startat) / 8);
startat-=7;
}
lastcol=Math.floor(eval(-1 + asq) % 8);
lastrow=Math.floor(eval(-1 + asq) / 8);
startat=eval(9 + asq);
while (startat >= 1 && startat <= 64 && Math.abs(lastcol - Math.floor(eval(-1 + startat) % 8)) == 1 && Math.abs(lastrow - Math.floor(eval(-1 + startat) / 8)) == 1) { // && startcol == Math.floor(eval(-1 + startat) % 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(44);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(45);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(46);
return asq;
}
}
}
lastcol=Math.floor(eval(-1 + startat) % 8);
lastrow=Math.floor(eval(-1 + startat) / 8);
startat+=9;
}
lastcol=Math.floor(eval(-1 + asq) % 8);
lastrow=Math.floor(eval(-1 + asq) / 8);
startat=eval(7 + asq);
while (startat >= 1 && startat <= 64 && Math.abs(lastcol - Math.floor(eval(-1 + startat) % 8)) == 1 && Math.abs(lastrow - Math.floor(eval(-1 + startat) / 8)) == 1) { // && startcol == Math.floor(eval(-1 + startat) % 8)) {
//alert('checking square ' + startat);
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(51);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(52);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
break;
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('Q') != -1 || twos[0].slice(-3).indexOf('B') != -1) {
isbad=true;
//alert(53);
return asq;
}
}
}
lastcol=Math.floor(eval(-1 + startat) % 8);
lastrow=Math.floor(eval(-1 + startat) / 8);
startat+=7;
}
// Knight check
for (ikposa=0; ikposa<kposa.length; ikposa++) {
startat=eval(kposa[ikposa] + asq);
if (startat >= 1 && startat <= 64 && startrow != Math.floor(eval(-1 + startat) / 8) && startcol != Math.floor(eval(-1 + startat) % 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('K1') != -1 || twos[0].slice(-3).indexOf('K2') != -1) {
isbad=true;
//alert(61);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('K1') != -1 || twos[0].slice(-3).indexOf('K2') != -1) {
isbad=true;
//alert(62);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('K1') != -1 || twos[0].slice(-3).indexOf('K2') != -1) {
isbad=true;
//alert(63);
return asq;
}
}
}
}
}
// Pawn check
for (ikposa=0; ikposa<pposa.length; ikposa++) {
startat=eval(pposa[ikposa] + asq);
if (startat >= 1 && startat <= 64 && startrow != Math.floor(eval(-1 + startat) / 8) && startcol != Math.floor(eval(-1 + startat) % 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('P') != -1) {
isbad=true;
//alert(71);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('P') != -1) {
isbad=true;
//alert(72);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('P') != -1) {
isbad=true;
//alert(73);
return asq;
}
}
}
}
}
// King too near King check
for (ikgposa=0; ikgposa<kgposa.length; ikgposa++) {
startat=eval(kgposa[ikgposa] + asq);
//alert('startat=' + startat + ' and asq=' + asq + ' ' + thebrd);
if (startat >= 1 && startat <= 64) { // && startrow != Math.floor(eval(-1 + startat) / 8) && startcol != Math.floor(eval(-1 + startat) % 8)) {
if (thebrd.indexOf('_' + startat + 'w') != -1) {
twos=thebrd.split('_' + startat + 'w');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('K') != -1 && twos[0].slice(-3).indexOf('K1') == -1 && twos[0].slice(-3).indexOf('K2') == -1) {
iswrong=true;
if (alertallowed) { alert('Kings can not be this close together.'); }
//alert(91);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + 'b') != -1) {
twos=thebrd.split('_' + startat + 'b');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('K') != -1 && twos[0].slice(-3).indexOf('K1') == -1 && twos[0].slice(-3).indexOf('K2') == -1) {
iswrong=true;
if (alertallowed) { alert('Kings can not be this close together.'); }
//alert(92);
return asq;
}
}
} else if (thebrd.indexOf('_' + startat + '&') != -1) {
twos=thebrd.split('_' + startat + '&');
if (twos[0].slice(-3).indexOf(bwfriend) != -1) {
twos[0]=twos[0];
} else if (twos[0].slice(-3).indexOf(bwenemy) != -1) {
if (twos[0].slice(-3).indexOf('K') != -1 && twos[0].slice(-3).indexOf('K1') == -1 && twos[0].slice(-3).indexOf('K2') == -1) {
iswrong=true;
if (alertallowed) { alert('Kings can not be this close together.'); }
//alert(93);
return asq;
}
}
}
}
}
return asq;
}
function wrtincheck(thepiece, theboard) {
//if (theboard.length < 70) { alert('endboard=' + endboard); }
thissquare=-1;
eightaround=[-1,-1,-1,-1,-1,-1,-1,-1,-1];
if (theboard.indexOf(thepiece + '_') == -1 && theboard.indexOf(thepiece.replace('w','!').replace('b','W').replace('!', 'b').toLowerCase() + '_') != -1) {
if (thepiece.substring(0,1) == 'w') {
wstartsincheck=true;
wendsincheck=true;
alert('Checkmate! Congratulations, ' + playerb);
return true;
} else {
bstartsincheck=true;
bendsincheck=true;
alert('Checkmate! Congratulations, ' + playerw);
return true;
}
} else {
// Get this square and eight squares around
//alert('theboard=' + theboard + ' and thepiece=' + thepiece);
thissquare=eval('' + theboard.split(thepiece + '_')[1].split('b')[0].split('w')[0].split('&')[0]);
eightaround[0]=anybw(thissquare, theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
if (isbad && thepiece.substring(0,1) == 'w') {
consolelog(playerw + ', your King is in check.');
}
if (isbad && thepiece.substring(0,1) == 'b') {
consolelog(playerb + ', your King is in check.');
}
if (1 == 7) {
if (eval(-9 + thissquare) >= 1 && eval(-9 + thissquare) <= 64) {
eightaround[1]=anybw(eval(-9 + thissquare), theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
}
if (eval(-8 + thissquare) >= 1 && eval(-8 + thissquare) <= 64) {
eightaround[2]=anybw(eval(-8 + thissquare), theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
}
if (eval(-7 + thissquare) >= 1 && eval(-7 + thissquare) <= 64) {
eightaround[3]=anybw(eval(-7 + thissquare), theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
}
if (eval(-1 + thissquare) >= 1 && eval(-1 + thissquare) <= 64) {
eightaround[4]=anybw(eval(-1 + thissquare), theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
}
if (eval(1 + thissquare) >= 1 && eval(1 + thissquare) <= 64) {
eightaround[5]=anybw(eval(1 + thissquare), theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
}
if (eval(7 + thissquare) >= 1 && eval(7 + thissquare) <= 64) {
eightaround[6]=anybw(eval(7 + thissquare), theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
}
if (eval(8 + thissquare) >= 1 && eval(8 + thissquare) <= 64) {
eightaround[7]=anybw(eval(8 + thissquare), theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
}
if (eval(9 + thissquare) >= 1 && eval(9 + thissquare) <= 64) {
eightaround[8]=anybw(eval(9 + thissquare), theboard, thepiece.substring(0,1).replace('w','!').replace('b','W').replace('!', 'b').toLowerCase(), false);
}
}
}
}
function checkstartcheck() {
var mbits=amove.split('_'), ppbits=[], prerepbit='', repbit='', tdso=[], itdso=0;
if (document.getElementById('fshare')) {
if (document.getElementById('fshare').innerHTML.indexOf('_') != -1) {
if (tradmove(trad + '&move=' + amove).indexOf('_') != -1) {
startboard=tradmove(trad + '&move=' + amove);
} else {
startboard=document.getElementById('fshare').href.split('&')[0] + '&';
}
if (startboard.indexOf('_') == -1) { startboard=document.getElementById('fshare').innerHTML; }
if (eval('' + mbits.length) >= 3) {
if (startboard.indexOf('_' + mbits[2] + 'w') != -1) {
ppbits=startboard.split('_' + mbits[2] + 'w');
repbit='_' + mbits[2] + 'w';
while (ppbits[0].slice(-1) != 'w' && ppbits[0].slice(-1) != 'b') {
prerepbit=ppbits[0].slice(-1) + prerepbit;
ppbits[0]=ppbits[0].substring(0, eval(-1 + eval('' + ppbits[0].length)));
}
prerepbit=ppbits[0].slice(-1) + prerepbit;
startboard=startboard.replace(prerepbit + repbit, 'w');
} else if (startboard.indexOf('_' + mbits[2] + 'b') != -1) {
ppbits=startboard.split('_' + mbits[2] + 'b');
repbit='_' + mbits[2] + 'b';
while (ppbits[0].slice(-1) != 'w' && ppbits[0].slice(-1) != 'b') {
prerepbit=ppbits[0].slice(-1) + prerepbit;
ppbits[0]=ppbits[0].substring(0, eval(-1 + eval('' + ppbits[0].length)));
}
prerepbit=ppbits[0].slice(-1) + prerepbit;
startboard=startboard.replace(prerepbit + repbit, 'b');
} else if (startboard.indexOf('_' + mbits[2] + '&') != -1) {
ppbits=startboard.split('_' + mbits[2] + '&');
repbit='_' + mbits[2] + '&';
while (ppbits[0].slice(-1) != 'w' && ppbits[0].slice(-1) != 'b') {
prerepbit=ppbits[0].slice(-1) + prerepbit;
ppbits[0]=ppbits[0].substring(0, eval(-1 + eval('' + ppbits[0].length)));
}
prerepbit=ppbits[0].slice(-1) + prerepbit;
startboard=startboard.replace(prerepbit + repbit, '&');
}
}
}
} else {
startboard='';
if (tradmove(trad + '&move=' + amove).indexOf('_') != -1) {
startboard=tradmove(trad + '&move=' + amove);
} else {
tdso=document.getElementsByTagName('td');
for (itdso=0; itdso<tdso.length; itdso++) {
if (tdso[itdso].outerHTML.indexOf(' data-square="') != -1 && tdso[itdso].outerHTML.indexOf(' data-piece="') != -1) {
startboard+=tdso[itdso].outerHTML.split(' data-piece="')[1].split('"')[0] + '_' + tdso[itdso].outerHTML.split(' data-square="')[1].split('"')[0];
}
}
}
if (document.getElementById('fnodz')) {
document.getElementById('fnodz').innerHTML+='<a id=fshare href="mailto:?subject=Chess&body=' + startboard + '" style=display:none;>' + startboard + '</a>';
}
}
if (startboard == '') {
if (tradmove(trad + '&move=' + amove).indexOf('_') != -1) {
startboard=tradmove(trad + '&move=' + amove);
} else {
for (var iix=0; iix<cpa.length; iix++) {
startboard+=cpa[iix] + '_' + eval(1 + staidmap[iix]);
}
}
startboard+='&';
if (document.getElementById('fshare')) {
document.getElementById('fshare').href='mailto:?subject=Chess&body=' + startboard;
document.getElementById('fshare').innerHTML=startboard;
} else if (document.getElementById('fnodz')) {
document.getElementById('fnodz').innerHTML+='<a id=fshare href="mailto:?subject=Chess&body=' + startboard + '" style=display:none;>' + startboard + '</a>';
}
}
if (document.URL.indexOf('draughts') == -1) {
wstartsincheck=wrtincheck('wK', startboard);
bstartsincheck=wrtincheck('bK', startboard);
}
if (iswrong) {
alert('In a chess game the two Kings can not be this close');
}
}
function firstok(inm) {
if (document.URL.indexOf('draughts') != -1) { return inm; }
if (inm == 'bP1_9_17') { return inm; }
if (inm == 'bP1_9_25') { return inm; }
if (inm == 'bP2_10_18') { return inm; }
if (inm == 'bP2_10_26') { return inm; }
if (inm == 'bP3_11_19') { return inm; }
if (inm == 'bP3_11_27') { return inm; }
if (inm == 'bP4_12_20') { return inm; }
if (inm == 'bP4_12_28') { return inm; }
if (inm == 'bP5_13_21') { return inm; }
if (inm == 'bP5_13_29') { return inm; }
if (inm == 'bP6_14_22') { return inm; }
if (inm == 'bP6_14_30') { return inm; }
if (inm == 'bP7_15_23') { return inm; }
if (inm == 'bP7_15_31') { return inm; }
if (inm == 'bP8_16_24') { return inm; }
if (inm == 'bP8_16_32') { return inm; }
if (inm == 'bK1_3_20') { return inm; }
if (inm == 'bK1_3_22') { return inm; }
if (inm == 'bK2_6_23') { return inm; }
if (inm == 'bK2_6_25') { return inm; }
if (inm == 'wK1_59_42') { return inm; }
if (inm == 'wK1_59_44') { return inm; }
if (inm == 'wK2_62_45') { return inm; }
if (inm == 'wK2_62_47') { return inm; }
if (inm == 'wP1_49_41') { return inm; }
if (inm == 'wP1_49_33') { return inm; }
if (inm == 'wP2_50_42') { return inm; }
if (inm == 'wP2_50_34') { return inm; }
if (inm == 'wP3_51_43') { return inm; }
if (inm == 'wP3_51_35') { return inm; }
if (inm == 'wP4_52_44') { return inm; }
if (inm == 'wP4_52_36') { return inm; }
if (inm == 'wP5_53_45') { return inm; }
if (inm == 'wP5_53_37') { return inm; }
if (inm == 'wP6_54_46') { return inm; }
if (inm == 'wP6_54_38') { return inm; }
if (inm == 'wP7_55_47') { return inm; }
if (inm == 'wP7_55_39') { return inm; }
if (inm == 'wP8_56_48') { return inm; }
if (inm == 'wP8_56_40') { return inm; }
return '';
}
function tradmove(proposedtm) {
var outp=proposedtm, idoneoh='';
if (gval != '') { return gval; }
if (outp.indexOf('_') != -1 && outp.split('&')[0].indexOf('_') == -1) {
outp='';
for (var iix=0; iix<cpa.length; iix++) {
outp+=cpa[iix] + '_' + eval(1 + staidmap[iix]);
}
startboard=outp + '&';
endboard=outp + '&';
var mbits=amove.split('_'), ppbits=[], prerepbit='', repbit='';
if (eval('' + mbits.length) >= 3) {
if (2 == 12) {
lastmove=amove;
//amove='';
fixamove(lastmove);
consolelog('Chess piece ' + mbits[0] + ' moved from square ' + mbits[1] + ' to ' + mbits[2]);
} else {
if (amove != '') {
lastmove=firstok(amove);
if (lastmove != '') {
var tdsz=document.getElementsByTagName('td'), itdsz=0;
for (itdsz=0; itdsz<tdsz.length; itdsz++) {
if (tdsz[itdsz].outerHTML.indexOf(' data-square="' + mbits[1] + '"') != -1) {
idzero=tdsz[itdsz].id;
mbits[0]=mbits[0].substring(0,1).toLowerCase() + mbits[0].substring(1).substring(0,1).toUpperCase() + mbits[0].substring(2);
//alert(mbits[0] + ' ' + tdsz[itdsz].outerHTML);
if (tdsz[itdsz].outerHTML.indexOf(' data-piece="' + mbits[0] + '"') != -1) {
idone='' + tdsz[itdsz].outerHTML.split(' data-square="' + mbits[1] + '"')[1].split('>')[1].split(' id="')[1].split('"')[0];
idoneoh=document.getElementById(idone).outerHTML;
//alert('175 ' + idone);
//document.getElementById(idone).addEventListener("click", (ev) => { gev=ev; if (1 == 1) { setTimeout(delayedrefit, 500); } else { refit(ev); } });
//domcmds.push("document.getElementById('" + idone + "').click();");
} else {
idone='' + tdsz[itdsz].id;
//alert('176 ' + idone);
//tdsz[itdsz].click();
//document.getElementById(idone).addEventListener("click", (ev) => { gev=ev; if (1 == 1) { setTimeout(delayedrefit, 500); } else { refit(ev); } });
//domcmds.push("document.getElementById('" + idone + "').click();");
}
}
}
for (itdsz=0; itdsz<tdsz.length; itdsz++) {
if (tdsz[itdsz].outerHTML.indexOf(' data-square="' + mbits[2] + '"') != -1) {
if (tdsz[itdsz].outerHTML.indexOf(' data-piece="') != -1) {
//alert(276);
idtwo='' + tdsz[itdsz].outerHTML.split(' data-square="' + mbits[2] + '"')[1].split('>')[1].split(' id="')[1].split('"')[0];
//document.getElementById(idtwo).addEventListener("click", (ev) => { gev=ev; if (1 == 1) { setTimeout(delayedrefit, 500); } else { refit(ev); } });
domcmds.push("document.getElementById('" + idtwo + "').click();");
} else {
//alert(376);
idtwo='' + tdsz[itdsz].id;
if (idoneoh != '') {
document.getElementById(idzero).innerHTML='';
tdsz[itdsz].innerHTML=idoneoh;
if (amove != '') {
lastmove=amove;
document.getElementById('pstatus').setAttribute('data-decided', 'bw');
nextmove=eval('' + mbits[2]);
consolelog('Chess piece ' + mbits[0] + ' moved from square ' + mbits[1] + ' to square ' + mbits[2]);
//amove='';
fixamove(lastmove);
itisthiscmove=amove.substring(0,1).replace('b','!').replace('w','B').replace('!','W').toLowerCase();
}
}
//tdsz[itdsz].click();
//document.getElementById(idtwo).addEventListener("click", (ev) => { gev=ev; if (1 == 1) { setTimeout(delayedrefit, 500); } else { refit(ev); } });
//domcmds.push("document.getElementById('" + idone + "').click();");
}
}
}
}
}
}
}
gval=outp + '&' + proposedtm.split('&')[1];
return outp + '&' + proposedtm.split('&')[1];
}
gval=outp;
return outp;
}
function fixabw(thebname, thewname) {
if (document.getElementById('fshare')) {
//alert('HeRe');
var mbits=amove.split('_'), ppbits=[], prerepbit='', repbit='';
if (eval('' + mbits.length) >= 3) {
//if (endboard.indexOf((mbits[0] + '_' + mbits[1])) == -1) { alert('prepostOOPS'); }
//if (document.getElementById('fshare').href.indexOf((mbits[0] + '_' + mbits[1])) == -1) { alert('preOOPS'); }
//if (document.getElementById('fshare').innerHTML.indexOf((mbits[0] + '_' + mbits[1])) == -1) { alert('apreOOPS'); }
//if (document.getElementById('fshare').href.indexOf(encodeURIComponent(mbits[0] + '_' + mbits[1])) == -1) { alert('bpreOOPS'); }
//alert(document.getElementById('fshare').href);
if (document.getElementById('fshare').href.indexOf('_' + mbits[2] + 'w') != -1) { //|| document.getElementById('fshare').href.indexOf('_' + mbits[2] + 'b') != -1document.getElementById('fshare').href.indexOf('_' + mbits[2] + '&') != -1) {
ppbits=document.getElementById('fshare').href.split('_' + mbits[2] + 'w');
repbit='_' + mbits[2] + 'w';
while (ppbits[0].slice(-1) != 'w' && ppbits[0].slice(-1) != 'b') {
prerepbit=ppbits[0].slice(-1) + prerepbit;
ppbits[0]=ppbits[0].substring(0, eval(-1 + eval('' + ppbits[0].length)));
}
prerepbit=ppbits[0].slice(-1) + prerepbit;
document.getElementById('fshare').href=document.getElementById('fshare').href.replace(prerepbit + repbit, 'w');
} else if (document.getElementById('fshare').href.indexOf('_' + mbits[2] + 'b') != -1) { //|| document.getElementById('fshare').href.indexOf('_' + mbits[2] + 'b') != -1document.getElementById('fshare').href.indexOf('_' + mbits[2] + '&') != -1) {
ppbits=document.getElementById('fshare').href.split('_' + mbits[2] + 'b');
repbit='_' + mbits[2] + 'b';
while (ppbits[0].slice(-1) != 'w' && ppbits[0].slice(-1) != 'b') {
prerepbit=ppbits[0].slice(-1) + prerepbit;
ppbits[0]=ppbits[0].substring(0, eval(-1 + eval('' + ppbits[0].length)));
}
prerepbit=ppbits[0].slice(-1) + prerepbit;
document.getElementById('fshare').href=document.getElementById('fshare').href.replace(prerepbit + repbit, 'b');
} else if (document.getElementById('fshare').href.indexOf('_' + mbits[2] + '&') != -1) { //|| document.getElementById('fshare').href.indexOf('_' + mbits[2] + 'b') != -1document.getElementById('fshare').href.indexOf('_' + mbits[2] + '&') != -1) {
ppbits=document.getElementById('fshare').href.split('_' + mbits[2] + '&');
repbit='_' + mbits[2] + '&';
while (ppbits[0].slice(-1) != 'w' && ppbits[0].slice(-1) != 'b') {
prerepbit=ppbits[0].slice(-1) + prerepbit;
ppbits[0]=ppbits[0].substring(0, eval(-1 + eval('' + ppbits[0].length)));
}
prerepbit=ppbits[0].slice(-1) + prerepbit;
document.getElementById('fshare').href=document.getElementById('fshare').href.replace(prerepbit + repbit, '&');
}
//if (document.getElementById('fshare').href.indexOf((mbits[0] + '_' + mbits[1])) == -1) { alert('OOPS'); }
document.getElementById('fshare').href=document.getElementById('fshare').href.replace((mbits[0] + '_' + mbits[1]), (mbits[0] + '_' + mbits[2])).replace(/\+\(black\)\+\(black\)/g,'+(black)').replace(/\+\(white\)\+\(white\)/g,'+(white)').replace('wR_','wR1_');
if (startboard == '') {
startboard=document.getElementById('fshare').href; // new
if (startboard.indexOf('bP2') == -1) { alert('OoPs'); }
//alert('sb=' + startboard);
}
}
if (decodeURIComponent(document.getElementById('fshare').href).indexOf('bname=' + encodeURIComponent(thebname)) == -1 && decodeURIComponent(document.getElementById('fshare').href).indexOf('bname=') != -1) {
document.getElementById('fshare').href=document.getElementById('fshare').href.replace(encodeURIComponent('bname='), encodeURIComponent('bname=' + encodeURIComponent(thebname) + '&x=x')).replace('wR_','wR1_');
}
if (decodeURIComponent(document.getElementById('fshare').href).indexOf('wname=' + encodeURIComponent(thewname)) == -1 && decodeURIComponent(document.getElementById('fshare').href).indexOf('wname=') != -1) {
document.getElementById('fshare').href=document.getElementById('fshare').href.replace(encodeURIComponent('wname='), encodeURIComponent('wname=' + encodeURIComponent(thewname) + '&x=x')).replace('wR_','wR1_');
}
if (startboard == '') {
if (tradmove(trad + '&move=' + amove).indexOf('_') != -1) {
startboard=tradmove(trad + '&move=' + amove);
} else {
for (var iix=0; iix<cpa.length; iix++) {
startboard+=cpa[iix] + '_' + eval(1 + staidmap[iix]);
}
}
startboard+='&';
if (document.getElementById('fshare')) {
document.getElementById('fshare').href='mailto:?subject=Chess&body=' + startboard;
document.getElementById('fshare').innerHTML=startboard;
} else if (document.getElementById('fnodz')) {
document.getElementById('fnodz').innerHTML+='<a id=fshare href="mailto:?subject=Chess&body=' + startboard + '" style=display:none;>' + startboard + '</a>';
}
endboard=startboard;
}
//alert('startboard=' + startboard);
if (endboard == '') {
if (tradmove(trad + '&move=' + amove).indexOf('_') != -1) {
endboard=tradmove(trad + '&move=' + amove);
//if (endboard.indexOf((mbits[0] + '_' + mbits[1])) == -1) { alert('qprepostOOPS'); } else { alert('good'); }
document.getElementById('fshare').innerHTML=endboard;
if (startboard == '') { startboard=endboard; }
}
}
if (document.getElementById('fshare')) {
if (endboard == '') {
endboard=document.getElementById('fshare').href.split('&')[0] + '&';
if (endboard.indexOf('_') == -1) { endboard=document.getElementById('fshare').innerHTML; }
if (startboard == '') { startboard=endboard; }
}
if (endboard.indexOf('_') == -1 && tradmove(trad + '&move=' + amove).indexOf('_') != -1) {
endboard=tradmove(trad + '&move=' + amove);
if (startboard == '') { startboard=endboard; }
}
//alert('Endboard=' + endboard);
if (document.URL.indexOf('draughts') == -1) {
wendsincheck=wrtincheck('wK', endboard);
if (iswrong) { alert('Kings can not be this close.'); return ' '; }
if (isbad) { return 'w'; }
bendsincheck=wrtincheck('bK', endboard);
if (iswrong) { alert('Kings can not be this close.'); return ' '; }
if (isbad) { return 'b'; }
}
startboard=endboard;
}
}
return '';
}
function fixamove(proposedmove) {
var subjbit='';
var atrue=true, btrue='';
var wasfs='';
if (document.getElementById('fshare')) {
wasfs=document.getElementById('fshare').href;
}
if (document.getElementById('fshare') && twosubsfrom[0] != '' && eval('' + onenewmove.length) == 1 && proposedmove == '') {
//alert('567 ' + wasfs);
proposedmove=onenewmove[0];
var washref=document.getElementById('fshare').href;
if (twosubsfrom[0] == 'bR1') {
washref=washref.replace('bR1_1', 'bR1_4');
washref=washref.replace('bK_5', 'bK_2');
proposedmove='bK_2_3';
endboard=washref.replace('bK_2','bK_3');
} else if (twosubsfrom[0] == 'bR2') {
washref=washref.replace('bR2_8', 'bR2_6');
washref=washref.replace('bK_5', 'bK_8');
proposedmove='bK_8_7';
endboard=washref.replace('bK_8','bK_7');
} else if (twosubsfrom[0] == 'wR1') {
washref=washref.replace('wR1_57', 'wR1_60');
washref=washref.replace('wK_61', 'wK_58');
proposedmove='bK_58_59';
endboard=washref.replace('wK_58','wK_59');
} else if (twosubsfrom[0] == 'wR2') {
washref=washref.replace('wR2_64', 'wR2_62');
washref=washref.replace('wK_61', 'wK_64');
proposedmove='bK_64_63';
endboard=washref.replace('wK_64','wK_63');
}
onenewmove=[];
document.getElementById('fshare').href=washref;
//endboard=washref;
btrue=fixabw(playerb, playerw);
if (btrue != '') {
if (btrue == 'w' && proposedmove.substring(0,1) == 'w') {
onenewmove=[];
atrue=false;
consolelog(playerw + ', your King is in check with this move.');
ouralert(playerw + ', your King is in check with this move.');
if (wasfs != '') {
document.getElementById('fshare').href=wasfs;
endboard=startboard;
}
return atrue;
} else if (btrue == 'b' && proposedmove.substring(0,1) == 'b') {
onenewmove=[];
atrue=false;
consolelog(playerb + ', your King is in check with this move.');
ouralert(playerb + ', your King is in check with this move.');
if (wasfs != '') {
document.getElementById('fshare').href=wasfs;
endboard=startboard;
}
return atrue;
} else if (btrue == 'w' && proposedmove.substring(0,1) == 'b') {
consolelog(playerw + ', your King has been put into check.');
setTimeout(function(){ ouralert(playerw + ', your King has been put into check.'); }, 1000);
} else if (btrue == 'b' && proposedmove.substring(0,1) == 'w') {
consolelog(playerb + ', your King has been put into check.');
setTimeout(function(){ ouralert(playerb + ', your King has been put into check.'); }, 1000);
} else if (btrue == ' ') {
onenewmove=[];
atrue=false;
consolelog('This move has caused Kings to be too close together.');
ouralert('This move has caused Kings to be too close together.');
if (wasfs != '') {
document.getElementById('fshare').href=wasfs;
endboard=startboard;
}
return atrue;
}
}
twosubsfrom[0]='';
twosubsto[0]='';
}
if (document.getElementById('fshare') && proposedmove.trim() != '') {
//if (5 == 5) { endboard=document.getElementById('fshare').innerHTML; if (document.getElementById('fshare').href.indexOf(endboard) != -1) { alert('ouch '); } }
//alert('HeRE ' + proposedmove + ' ' + endboard);
var mbits=proposedmove.split('_');
if (endboard == '') {
if (tradmove(trad + '&move=' + amove).indexOf('_') != -1) {
endboard=tradmove(trad + '&move=' + amove);
}
endboard=document.getElementById('fshare').href;
}
//alert('proposedmove=' + proposedmove);
endboard=endboard.replace(encodeURIComponent(mbits[0] + '_' + mbits[1]), encodeURIComponent(mbits[0] + '_' + mbits[2])).replace((mbits[0] + '_' + mbits[1]), (mbits[0] + '_' + mbits[2]));
//startboard=endboard;
//alert('EndBoard=' + endboard + ' ' + document.getElementById('fshare').href);
btrue=fixabw(playerb, playerw);
if (btrue != '') {
if (btrue == 'w' && proposedmove.substring(0,1) == 'w') {
onenewmove=[];
atrue=false;
consolelog(playerw + ', your King is in check with this move.');
setTimeout(function(){ ouralert(playerw + ', your King is in check with this move.'); itisthiscmove='w'; }, 5000);
if (wasfs != '') {
document.getElementById('fshare').href=wasfs;
endboard=startboard;
}
return atrue;
} else if (btrue == 'b' && proposedmove.substring(0,1) == 'b') {
onenewmove=[];
atrue=false;
consolelog(playerb + ', your King is in check with this move.');
setTimeout(function(){ ouralert(playerb + ', your King is in check with this move.'); itisthiscmove='b'; }, 5000);
if (wasfs != '') {
document.getElementById('fshare').href=wasfs;
endboard=startboard;
}
return atrue;
} else if (btrue == 'w' && proposedmove.substring(0,1) == 'b') {
consolelog(playerw + ', your King has been put into check.');
setTimeout(function(){ ouralert(playerw + ', your King has been put into check.'); }, 5000);
} else if (btrue == 'b' && proposedmove.substring(0,1) == 'w') {
consolelog(playerb + ', your King has been put into check.');
setTimeout(function(){ ouralert(playerb + ', your King has been put into check.'); }, 5000);
} else if (btrue == ' ' && proposedmove.substring(0,1) == 'w') {
onenewmove=[];
atrue=false;
consolelog('This move has caused Kings to be too close together.');
setTimeout(function(){ ouralert('This move has caused Kings to be too close together.'); itisthiscmove='w'; }, 5000);
if (wasfs != '') {
document.getElementById('fshare').href=wasfs;
endboard=startboard;
}
return atrue;
} else if (btrue == ' ' && proposedmove.substring(0,1) == 'b') {
onenewmove=[];
atrue=false;
consolelog('This move has caused Kings to be too close together.');
setTimeout(function(){ ouralert('This move has caused Kings to be too close together.'); itisthiscmove='b'; }, 5000);
if (wasfs != '') {
document.getElementById('fshare').href=wasfs;
endboard=startboard;
}
return atrue;
}
}
//alert(amove + ' vs ' + proposedmove + ' 78 ' + document.getElementById('fshare').href + ' ' + document.getElementById('pstatus').innerHTML);
if (amove == proposedmove && amove.substring(0,1) == 'w') {
setTimeout(function(){ document.getElementById('pstatus').innerHTML=document.getElementById('pstatus').innerHTML + ' Your next move ' + playerb; }, 2500);
} else if (amove == proposedmove && amove.substring(0,1) == 'b') {
setTimeout(function(){ document.getElementById('pstatus').innerHTML=document.getElementById('pstatus').innerHTML + ' Your next move ' + playerw; }, 2500);
}
document.getElementById('fshare').href=document.getElementById('fshare').href.replace(/\&$/g, encodeURIComponent('&move='));
if (amove == proposedmove) {
var wrd1='youllneverfindthis';
var wrd2='';
var mmbits=amove.split('_');
if (document.getElementById('fshare').href.indexOf('_' + mmbits[2] + 'w') != -1) {
wrd1=(document.getElementById('fshare').href.split('_' + mmbits[2] + 'w')[0].slice(-3) + '_' + mmbits[2]).replace(/^[0-9]/g,'');
} else if (document.getElementById('fshare').href.indexOf('_' + mmbits[2] + 'b') != -1) {
wrd1=(document.getElementById('fshare').href.split('_' + mmbits[2] + 'b')[0].slice(-3) + '_' + mmbits[2]).replace(/^[0-9]/g,'');
} else if ((document.getElementById('fshare').href + '&').indexOf('_' + mmbits[2] + '&') != -1) {
wrd1=((document.getElementById('fshare').href + '&').split('_' + mmbits[2] + '&')[0].slice(-3) + '_' + mmbits[2]).replace(/^[0-9]/g,'');
}
//if (document.getElementById('fshare').href.indexOf(mmbits[0] + '_' + mmbits[1]) == -1) {
//if (document.getElementById('fshare').href.indexOf(mmbits[0] + '_' + mmbits[2]) != -1) {
// alert('oh');
//}
// alert('oops');
//}
document.getElementById('fshare').href=document.getElementById('fshare').href.replace(wrd1,wrd2).replace(mmbits[0] + '_' + mmbits[1], mmbits[0] + '_' + mmbits[2]);
endboard=document.getElementById('fshare').href;
//} else {
//alert(89);
// document.getElementById('fshare').href=document.getElementById('fshare').innerHTML; // new idea
}
if (amove != proposedmove && decodeURIComponent(document.getElementById('fshare').href).indexOf('move=' + proposedmove) == -1 && decodeURIComponent(document.getElementById('fshare').href).indexOf('move=') != -1) {
//alert('178');
if (document.getElementById('fshare').href.indexOf(encodeURIComponent('&move=')) == -1) {
document.getElementById('fshare').href=document.getElementById('fshare').href.replace('&move=',encodeURIComponent('&wmoveas=')) + encodeURIComponent('&move=');
}
document.getElementById('fshare').href=document.getElementById('fshare').href.replace('&move=',encodeURIComponent('&wmoveas=')).replace(encodeURIComponent('move='), encodeURIComponent('move=' + proposedmove + '&x=x'));
if (document.getElementById('fshare').href.indexOf('body=') != -1 && document.getElementById('fshare').href.indexOf('body=' + encodeURIComponent(document.URL.split('?')[0])) == -1) {
document.getElementById('fshare').href=document.getElementById('fshare').href.replace('body=', 'body=' + encodeURIComponent(document.URL.split('?')[0] + '?wname=' + encodeURIComponent(playerw) + '&bname=' + encodeURIComponent(playerb) + '&traditional='));
}
//alert(document.getElementById('fshare').href);
subjbit=document.getElementById('fshare').href.split('&body=')[1];
//if (eval('' + mbits.length) >= 3) {
// subjbit=subjbit.replace(encodeURIComponent(mbits[0] + '_' + mbits[1]), encodeURIComponent(mbits[0] + '_' + mbits[2]));
//}
if (proposedmove.substring(0,1) == 'w') {
if (playerb.indexOf('[') != -1 && playerb.indexOf('[]') == -1) {
if (playerb.split('[')[1].split(']')[0].indexOf('@') != -1) {
document.getElementById('fshare').href='mailto:' + playerb.split('[')[1].split(']')[0] + '?subject=Chess%20Game&body=' + subjbit.replace(/\ /g,encodeURIComponent('+'));
//alert(document.getElementById('fshare').href);
//if (document.getElementById('fshare').href.indexOf('bP2') == -1) { alert('OoPs1'); }
checkxx(document.getElementById('fshare')).click();
setTimeout(function(){ alert('Email readied for ' + playerb.split('[')[1].split(']')[0]); }, 15000);
} else {
document.getElementById('fshare').href='sms:' + playerb.split('[')[1].split(']')[0] + '&body=' + subjbit.replace(/\ /g,encodeURIComponent('+'));
//alert(document.getElementById('fshare').href);
//if (document.getElementById('fshare').href.indexOf('bP2') == -1) { alert('OoPs2'); }
checkxx(document.getElementById('fshare')).click();
setTimeout(function(){ alert('SMS readied for ' + playerb.split('[')[1].split(']')[0]); }, 15000);
}
}
} else if (proposedmove.substring(0,1) == 'b') {
if (playerw.indexOf('[') != -1 && playerw.indexOf('[]') == -1) {
if (playerw.split('[')[1].split(']')[0].indexOf('@') != -1) {
document.getElementById('fshare').href='mailto:' + playerw.split('[')[1].split(']')[0] + '?subject=Chess%20Game&body=' + subjbit.replace(/\ /g,encodeURIComponent('+'));
//alert(document.getElementById('fshare').href);
//if (document.getElementById('fshare').href.indexOf('bP2') == -1) { alert('OoPs3'); }
checkxx(document.getElementById('fshare')).click();
setTimeout(function(){ alert('Email readied for ' + playerw.split('[')[1].split(']')[0]); }, 15000);
} else {
document.getElementById('fshare').href='sms:' + playerw.split('[')[1].split(']')[0] + '&body=' + subjbit.replace(/\ /g,encodeURIComponent('+'));
//alert(document.getElementById('fshare').href);
//if (document.getElementById('fshare').href.indexOf('bP2') == -1) { alert('OoPs4'); }
checkxx(document.getElementById('fshare')).click();
setTimeout(function(){ alert('SMS readied for ' + playerw.split('[')[1].split(']')[0]); }, 15000);
}
}
}
}
}
return atrue;
}
function checkxx(ina) {
var inas=ina.href.split('&x=x'), opiece='', ineas='';
var inase=ina.href.split(encodeURIComponent('&x=x'));
if (inas.length != 1) {
opiece=(amove + ina.href.split('&x=x')[eval(-1 + ina.href.split('&x=x').length)].split('&')[0]).split('_')[0];
if (opiece != '') {
//alert(65);
if (inas[0].indexOf(opiece) == -1) {
//alert(165);
var tos=document.getElementById('mytable').innerHTML.split(' data-piece="' + opiece + '"');
if (tos.length != 1) {
//alert(265);
var newsq=tos[0].split(' data-square="')[eval(-1 + tos[0].split(' data-square="').length)].split('"')[0];
//alert(ina.href);
ina.href=ina.href.replace(encodeURIComponent('traditional='), encodeURIComponent('traditional=' + opiece + '_' + newsq)).replace('traditional=', 'traditional=' + opiece + '_' + newsq);
}
}
}
inas=ina.href.split(('&x=x'));
ineas=(ina.href.replace(inas[0],'')).split(('&wname='))[0].split(('&bname='))[0].split(('&move='))[0];
if (ineas != '') { ina.href=ina.href.replace(ineas, '&x.x'); }
if (ina.href.split('body=')[1].indexOf((document.URL.replace('https:','http:').split('?')[0] + '?traditional=')) > 0) {
ina.href=ina.href.replace((document.URL.replace('https:','http:').split('?')[0] + '?traditional='), '');
}
} else if (inase.length != 1) {
opiece=(amove + ina.href.split(encodeURIComponent('&x=x'))[eval(-1 + ina.href.split(encodeURIComponent('&x=x')).length)].split(encodeURIComponent('&'))[0]).split('_')[0];
if (opiece != '') {
//alert('465 ' + opiece);
if (inase[0].indexOf(opiece) == -1) {
//alert(1165);
var tos=document.getElementById('mytable').innerHTML.split(' data-piece="' + opiece + '"');
if (tos.length != 1) {
//alert(1265);
var newsq=tos[0].split(' data-square="')[eval(-1 + tos[0].split(' data-square="').length)].split('"')[0];
ina.href=ina.href.replace(encodeURIComponent('traditional='), encodeURIComponent('traditional=' + opiece + '_' + newsq)).replace('traditional=', 'traditional=' + opiece + '_' + newsq);
//alert(ina.href);
}
}
}
inase=ina.href.split(encodeURIComponent('&x='));
ineas=(ina.href.replace(inase[0],'')).split(encodeURIComponent('&wname='))[0].split(encodeURIComponent('&bname='))[0].split(encodeURIComponent('&move='))[0];
if (ineas != '') { ina.href=ina.href.replace(ineas, encodeURIComponent('&x=x')); }
if (ina.href.split('body=')[1].indexOf(encodeURIComponent(document.URL.replace('https:','http:').split('?')[0] + '?traditional=')) > 0) {
ina.href=ina.href.replace(encodeURIComponent(document.URL.replace('https:','http:').split('?')[0] + '?traditional='), '');
}
}
if (document.URL.indexOf('draughts') != -1) {
ina.href=ina.href.replace(/move/g, 'draughts').replace(/Chess/g, 'Draughts');
}
return ina;
}
function consolelog(what) {
if (document.URL.indexOf('/chess') != -1) {
if (what.indexOf('Chess piece ') != -1) {
if (what.indexOf(' from square ') != -1) {
if (what.indexOf(' square ') != -1) {
lastmove=what.split('Chess piece ')[1].split(' ')[0] + '_' + what.split('Chess piece ')[1].split(' from square ')[1].split(' ')[0] + '_' + what.split('Chess piece ')[1].split(' from square ')[1].split(' square ')[1].split(' ')[0];
}
}
}
if (document.getElementById('pstatus')) {
if (document.getElementById('pstatus').innerHTML.indexOf(' ... Your next move ') != -1) {
document.getElementById('pstatus').innerHTML=('Move just made by ' + document.getElementById('pstatus').innerHTML.split('Your next move ')[eval(-1 + document.getElementById('pstatus').innerHTML.split('Your next move ').length)] + ' ... ' + what).replace(/\ \(black\)\ \(black\)/g,' (black)').replace(/\ \(white\)\ \(white\)/g,' (white)');
} else {
document.getElementById('pstatus').innerHTML+=(' ... ' + what.split(' ... ')[0] + ' ... ').replace(/\ \(black\)\ \(black\)/g,' (black)').replace(/\ \(white\)\ \(white\)/g,' (white)');
}
}
}
if (document.URL.indexOf('draughts') != -1) {
document.getElementById('pstatus').innerHTML=document.getElementById('pstatus').innerHTML.replace(/Chess\ /g, 'Draughts ');
console.log(what.replace(/Chess\ /g, 'Draughts '));
} else {
console.log(what);
}
}
function ouralert(what) {
if (document.URL.indexOf('/chess') != -1) {
if (document.getElementById('pstatus')) {
if (document.getElementById('pstatus').innerHTML.indexOf(' ... ') != -1) {
if (document.getElementById('pstatus').innerHTML.indexOf(' ... Your next move ') != -1) {
document.getElementById('pstatus').innerHTML='Move just made by ' + document.getElementById('pstatus').innerHTML.split('Your next move ')[eval(-1 + document.getElementById('pstatus').innerHTML.split('Your next move ').length)] + ' ... ' + what;
} else {
document.getElementById('pstatus').innerHTML+=' ... ' + what.split(' ... ')[0] + ' ... ';
}
}
}
}
if (document.URL.indexOf('draughts') != -1) { return alert(what.replace(/Chess\ /g, 'Draughts ')); }
return alert(what);
}
function rerefit() {
document.title=wastitle;
}
function delayedrefit() {
refit(gev);
}
function refit(ev) {
var waspl=prelegal;
prelegal=true;
if (wastitle == '') { wastitle=document.title; }
//document.title=itisthiscmove + ' ' + ev.target.id + ' at refit';
//if (ev.target.id == 'mytable') { document.title='mytable'; return true; }
//alert(15643);
if (lastitisthiscmove != itisthiscmove && ev.target.id != 'mytable') {
//alert(5643);
ppt=false;
//document.title=itisthiscmove + ' ' + ev.target.id + ' 1 at refit';
if (itisthiscmove != '' && itisthiscmove != (ev.target.outerHTML.split(' data-piece="')[1]).substring(0,1)) {
if (waspl) { ouralert('It is not your turn.'); }
} else {
lastitisthiscmove=(itisthiscmove + ev.target.outerHTML.split(' data-piece="')[1]).substring(0,1);
itisthiscmove=lastitisthiscmove;
if (itisthiscmove == 'b') {
consolelog('Your next move ' + playerb + ' ... ');
} else {
consolelog('Your next move ' + playerw + ' ... ');
}
//ouralert('no1 ' + lastitisthiscmove + ' ' + itisthiscmove + ' ' + ev.target.id);
if (ev.target.outerHTML.indexOf(' data-piece="') != -1) {
if (ev.target.outerHTML.split(' data-piece="')[1].substring(0,1) == (itisthiscmove + ev.target.outerHTML.split(' data-piece="')[1].substring(0,1)).substring(0,1)) {
//document.title=itisthiscmove + ' ' + ev.target.id + ' 1.0 at refit';
lohfulloh=ev.target.outerHTML;
newlohfulloh=ev.target.outerHTML;
hostid=bigv(newlohfulloh).split(' id="')[1].split('"')[0];
lastid=ev.target.id;
}
}
}
} else if (newlohfulloh != ev.target.outerHTML && ev.target.id != 'mytable') {
//ouralert('yes0 ' + lastitisthiscmove + ' ' + itisthiscmove + ' ' + ev.target.id);
lohfulloh=newlohfulloh;
//document.title=itisthiscmove + ' ' + ev.target.id + ' 2 at refit';
lastoh=newlohfulloh; //ev.target.outerHTML;
lastih='>' + newlohfulloh.split('</')[0].split('>')[eval(-1 + newlohfulloh.split('</')[0].split('>').length)] + '<'; //'>' + ev.target.innerHTML + '<';
console.log('yes ' + lastitisthiscmove + ' ' + itisthiscmove + ' ' + ev.target.id);
if (lohfulloh != '') {
console.log("lohfulloh=" + lohfulloh);
//ouralert('yes2 ' + lastitisthiscmove + ' ' + itisthiscmove + ' ' + ev.target.id);
if (lohfulloh.indexOf(' data-piece="') != -1) {
//ouralert('yes3 ' + lastitisthiscmove + ' ' + itisthiscmove + ' ' + ev.target.id);
if (ev.target.outerHTML.indexOf(' data-piece="') != -1 && ev.target.outerHTML != lohfulloh) {
//ouralert('yes4 ' + lastitisthiscmove + ' ' + itisthiscmove + ' ' + ev.target.id);
if (ev.target.outerHTML.split(' data-piece="')[1].substring(0,1) != lohfulloh.split(' data-piece="')[1].substring(0,1)) {
//ouralert('yes5 ' + lastitisthiscmove + ' ' + itisthiscmove + ' ' + ev.target.id);
console.log('Potential piece take');
ppt=true;
}
}
}
}
lastid=ev.target.id;
bcklastid=lastid;
loh=ev.target.id;
lohoh=bigv(ev.target.outerHTML.split('>')[0] + '></' + ev.target.outerHTML.substring(1).split(' ')[0].split('>')[0] + '>');
console.log("Drop 3");
if (newlohfulloh.indexOf(' data-piece="' + itisthiscmove + 'R') != -1 && ev.target.outerHTML.indexOf(' data-piece="' + itisthiscmove + 'K') != -1) {
if (mightbecastling(ev.target.outerHTML.split(' data-piece="')[1].split('"')[0], newlohfulloh.split(' data-piece="')[1].split('"')[0], ev.target.outerHTML, newlohfulloh) == 1) {
prelegal=false;
}
} else if (newlohfulloh.indexOf(' data-piece="' + itisthiscmove + 'K') != -1 && ev.target.outerHTML.indexOf(' data-piece="' + itisthiscmove + 'R') != -1) {
if (mightbecastling(ev.target.outerHTML.split(' data-piece="')[1].split('"')[0], newlohfulloh.split(' data-piece="')[1].split('"')[0], ev.target.outerHTML, newlohfulloh) == 1) {
prelegal=false;
}
}
if (!prelegal) {
//ouralert('Illegal move ... please start again');
lastitisthiscmove = itisthiscmove + ' ';
//ouralert(lastitisthiscmove + '!');
hostid='';
} else if (islegal()) {
//alert(5645);
if (hostid != '') {
document.getElementById(hostid).innerHTML='';
} else {
document.getElementById('mytable').innerHTML=document.getElementById('mytable').innerHTML.replace(newlohfulloh, '');
}
gev=ev;
setTimeout(gevit,1500); //ev.target.innerHTML=newlohfulloh;
//itisthiscmove=itisthiscmove.replace('w','B').replace('b','W').toLowerCase();
lastitisthiscmove = itisthiscmove + ' ';
hostid='';
} else {
if (waspl) { ouralert('Illegal move ... please start again'); }
lastitisthiscmove = itisthiscmove + ' ';
hostid='';
}
// }
}
setTimeout(rerefit, 3000);
}
function gevit() {
gev.target.innerHTML=newlohfulloh;
if (document.getElementById(newlohfulloh.split(' id="')[1].split('"')[0])) {
adddrop(newlohfulloh.split(' id="')[1].split('"')[0]);
}
//ouralert('' + gev.target.id + '=' + newlohfulloh);
newlohfulloh='';
lastitisthiscmove = itisthiscmove + ' ';
}
function dodoms() {
var stopit=false;
if (document.getElementById('span4') && fouroh == '') { fouroh=document.getElementById('span4').outerHTML; }
if (document.getElementById('span5') && wsixoh == '') { wsixoh=document.getElementById('span5').outerHTML; }
if (document.getElementById('span6') && sixoh == '') { sixoh=document.getElementById('span6').outerHTML; }
if (document.getElementById('span0') && spanzero == '') { spanzero=document.getElementById('span0').outerHTML; }
if (document.getElementById('span1') && spanfive == '') { spanfive=document.getElementById('span1').outerHTML; }
if (document.getElementById('td22') && tdtte == '') { tdtte=document.getElementById('td22').outerHTML.split('>')[0] + '></td>'; }
if (document.getElementById('td211') && wtdtte == '') { wtdtte=document.getElementById('td211').outerHTML.split('>')[0] + '></td>'; }
if (document.getElementById('td193') && wwtdtte == '') { wwtdtte=document.getElementById('td193').outerHTML.split('>')[0] + '></td>'; }
if (document.getElementById('td11') && wwwtdtte == '') { wwwtdtte=document.getElementById('td11').outerHTML.split('>')[0] + '></td>'; }
if (nextmove != -1) {
var tds=document.getElementsByTagName('td');
for (var itds=0; itds<tds.length; itds++) {
if (tds[itds].outerHTML.indexOf(' data-square="' + nextmove + '"') != -1) {
if (tds[itds].innerHTML.indexOf('</span>') != -1) {
document.getElementById(tds[itds].innerHTML.split(' id="')[1].split('"')[0]).click();
} else {
tds[itds].click();
}
}
}
nextmove=-1;
}
if (document.getElementById('pstatus')) {
if (document.getElementById('pblack')) {
playerb=document.getElementById('pblack').innerText;
}
if (document.getElementById('pwhite')) {
playerw=document.getElementById('pwhite').innerText;
}
if (eval('' + ('' + document.getElementById('pstatus').getAttribute('data-decided')).replace(/^null$/g,'').replace(/^undefined$/g,'').length) == 2) {
if (document.getElementById('pblack')) {
document.getElementById('pblack').style.display='none';
}
if (document.getElementById('pwhite')) {
document.getElementById('pwhite').style.display='none';
}
if (document.getElementById('pvs')) {
document.getElementById('pvs').style.display='none';
}
if (playerb != 'Black' && playerb.indexOf('(black)') == -1) {
playerb+=' (black)';
}
if (playerw != 'White' && playerw.indexOf('(white)') == -1) {
playerw+=' (white)';
}
fixabw(playerb, playerw);
document.getElementById('pstatus').setAttribute('data-decided', document.getElementById('pstatus').getAttribute('data-decided') + ' ');
}
if (eval('' + ('' + document.getElementById('pstatus').getAttribute('data-decided')).replace(/^null$/g,'').replace(/^undefined$/g,'').length) == 3) {
if (document.getElementById('pstatus').innerText == '') {
document.getElementById('pstatus').innerHTML='Welcome to the Chess Game between ' + playerb + ' (black) and ' + playerw + ' (white).';
}
document.getElementById('pstatus').setAttribute('data-decided', document.getElementById('pstatus').getAttribute('data-decided') + ' ');
}
if (eval('' + ('' + document.getElementById('pstatus').getAttribute('data-decided')).replace(/^null$/g,'').replace(/^undefined$/g,'').length) == 4) {
if (itisthiscmove != '') {
if (itisthiscmove == 'b') {
document.getElementById('pstatus').setAttribute('data-decided', document.getElementById('pstatus').getAttribute('data-decided') + ' ');
if (playerb.indexOf(']') == -1) { document.getElementById('pstatus').innerHTML='Your first move ' + playerb + ' ... '; }
} else {
document.getElementById('pstatus').setAttribute('data-decided', document.getElementById('pstatus').getAttribute('data-decided') + ' ');
if (playerw.indexOf(']') == -1) { document.getElementById('pstatus').innerHTML='Your first move ' + playerw + ' ... '; }
}
} else if (lastoh.indexOf(' data-piece="') != -1) {
if (lastoh.indexOf(' data-piece="b') != -1) {
document.getElementById('pstatus').setAttribute('data-decided', document.getElementById('pstatus').getAttribute('data-decided') + ' ');
if (playerb.indexOf(']') == -1) { document.getElementById('pstatus').innerHTML='Your first move ' + playerb + ' ... '; }
} else {
document.getElementById('pstatus').setAttribute('data-decided', document.getElementById('pstatus').getAttribute('data-decided') + ' ');
if (playerw.indexOf(']') == -1) { document.getElementById('pstatus').innerHTML='Your first move ' + playerw + ' ... '; }
}
}
}
if (eval('' + ('' + document.getElementById('pstatus').getAttribute('data-decided')).replace(/^null$/g,'').replace(/^undefined$/g,'').length) == 5) {
}
}
for (var ikj=0; ikj<domcmds.length; ikj++) {
if (!stopit && domcmds[ikj] != '') {
stopit=true;
//if (prompt(domcmds[ikj], domcmds[ikj])) {
//if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
// var huh=prompt(domcmds[ikj], domcmds[ikj]);
//}
if (document.URL.indexOf('/chess') != -1) {
eval(domcmds[ikj]);
//rejig();
}
//}
domcmds[ikj]='';
}
}
//domcmds=[];
setTimeout(dodoms, 1000);
}
function innards(inele) {
var outele=inele;
if (inele.indexOf('<span') > 0) {
outele='<span' + inele.split('</span>')[0].split('<span')[eval(-1 + inele.split('</span>')[0].split('<span').length)] + '</span>';
}
//ouralert('innards:' + outele);
return outele;
}
function adddrop(inelid) {
document.getElementById(inelid).addEventListener("drop", (ev) => {
console.log("Drop 1");
if (lohfulloh != '') {
console.log("lohfulloh=" + lohfulloh);
if (lohfulloh.indexOf(' data-piece="') != -1) {
if (ev.target.outerHTML.indexOf(' data-piece="') != -1 && ev.target.outerHTML != lohfulloh) {
if (ev.target.outerHTML.split(' data-piece="')[1].substring(0,1) != lohfulloh.split(' data-piece="')[1].substring(0,1)) {
console.log('Potential piece take');
ppt=true;
}
}
}
}
loh=ev.target.id;
lohoh=bigv(ev.target.outerHTML.split('>')[0] + '></' + ev.target.outerHTML.substring(1).split(' ')[0].split('>')[0] + '>');
//if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
// document.title='ev.preventDefault(); //1';
//}
ev.preventDefault();
// Get the data, which is the id of the source element
const data = ev.dataTransfer.getData("text");
const source = document.getElementById(data);
console.log('' + ev.target.id);
if (!document.getElementById('callback')) {
lastevid=ev.target.id;
//ouralert(lastevid);
//ev.target.setAttribute('draggable', true);
if (lastoh == '') {
//ouralert('suspicious ' + document.getElementById(sourceid).outerHTML);
lastoh=ev.target.outerHTML;
lastih='>' + ev.target.innerHTML + '<';
lastid=ev.target.id;
} else if (prefx == 'span') {
if (lastid.indexOf(' ') != -1) {
lastid=lastid.trim();
} else {
lastid=ev.target.id;
}
}
if (document.URL.indexOf('/chess') != -1) {
setTimeout(lastohit, 1000);
if (('' + ev.target.style.backgroundColor).indexOf(',0.6') != -1 || ('' + ev.target.style.backgroundColor).indexOf(',0.5') != -1) {
//ouralert('564 ' + ev.target.getAttribute('data-square'));
ev.target.style.filter='invert(1)';
ev.target.style.backgroundColor='rgba(255,255,255,0.6)';
}
}
if (('' + ev.target.id).substring(0,2) == 'td' && secs > 0 && document.URL.indexOf('/planet_') == -1) {
score+=eval(ev.target.innerHTML.substring(0,1));
}
} else if (document.getElementById('callback')) {
secs++;
if (('' + ev.target.getAttribute('data-answer')) == ('' + document.getElementById('source').getAttribute('data-answer')) || ('' + ev.target.getAttribute('data-answer')) == ('' + document.getElementById(sourceid).getAttribute('data-answer'))) {
score++;
document.getElementById('score').innerHTML='Score: ' + score + '/' + secs + '';
} else {
document.getElementById('score').innerHTML='Score: ' + score + '/' + secs + '';
if (document.getElementById('source').outerHTML.indexOf('<ta' + 'ble') == 0) {
ouralert(('Correct answer was ' + document.getElementById(sourceid).getAttribute('data-answer')).replace('null',''));
} else {
ouralert(('Correct answer was ' + document.getElementById('source').getAttribute('data-answer')).replace('null',''));
}
}
location.href=document.getElementById('callback').value + '?score=' + score + '&secs=' + secs;
}
if (1 == 2) {
clonedatatwo=document.getElementById(sourceid).outerHTML;
document.getElementById('mytable').innerHTML=document.getElementById('mytable').innerHTML.replace(clonedatatwo, '');
ev.target.innerHTML=ev.target.innerHTML.substring(0,1) + clonedatatwo;
} else if (secs > 0 && (9 == 9 || ('' + ev.target.id).substring(0,2) == 'td')) {
if (source) { source.style.cursor='progress'; }
clonedatatwo=document.getElementById(sourceid).outerHTML;
andlater();
//document.getElementById('mytable').innerHTML=document.getElementById('mytable').innerHTML.replace(clonedatatwo, '');
//ev.target.innerHTML=ev.target.innerHTML.substring(0,1) + clonedatatwo;
//document.getElementById('target').appendChild(source);
if (('' + ev.target.id).substring(0,2) != 'td') {
document.getElementById('target').insertAdjacentHTML('beforeend', clonedatatwo);
} else {
if (source) { source.style.cursor='progress'; }
ev.target.insertAdjacentHTML('beforeend', clonedatatwo);
}
} else {
try {
ev.target.appendChild(source);
} catch(ers) { }
}
if (ev.touches) {
if (ev.touches[0].pageX) {
pos3 = ev.touches[0].pageX;
pos4 = ev.touches[0].pageY;
} else {
pos3 = ev.touches[0].clientX;
pos4 = ev.touches[0].clientY;
}
console.log('pos3 = ' + pos3 + ',pos4 = ' + pos4);
} else if (ev.clientX || ev.clientY) {
pos3 = ev.clientX;
pos4 = ev.clientY;
console.log('pos3 = ' + pos3 + ' ,pos4 = ' + pos4);
} else {
pos3 = ev.pageX;
pos4 = ev.pageY;
console.log('pos3 = ' + pos3 + ', pos4 = ' + pos4);
}
});
}
function bigv(inspan) {
var outspan=inspan;
if (inspan.trim().indexOf('<span') == 0 && document.getElementById('target').innerHTML.indexOf(inspan.split('>')[0]) != -1) {
outspan='<' + document.getElementById('target').innerHTML.split(inspan.split('>')[0])[0].split('<')[eval(-1 + document.getElementById('target').innerHTML.split(inspan.split('>')[0])[0].split('<').length)];
outspan+='</' + outspan.substring(1).split(' ')[0].split('>')[0] + '>';
//ouralert('Found ' + outspan);
} //else {
//ouralert('did not find ' + inspan);
//}
return outspan;
}
function bigabb(infind) {
var prefxz='';
var outfind=infind;
var lastchr=infind.slice(-1);
var firstlk=infind.split(lastchr)[0];
var vbits=document.getElementById('target').innerHTML.split(firstlk);
if (eval('' + vbits.length) > 1) {
prefxz='<' + document.getElementById('target').innerHTML.split(firstlk)[0].split('<')[eval(-1 + document.getElementById('target').innerHTML.split(firstlk)[0].split('<').length)];
outfind=prefxz + firstlk + vbits[1].split(lastchr)[0] + lastchr;
}
return outfind;
}
function abb(infind) {
var outfind=infind;
var lastchr=infind.slice(-1);
var firstlk=infind.split(lastchr)[0];
var vbits=document.getElementById('target').innerHTML.split(firstlk);
if (eval('' + vbits.length) > 1) {
outfind=firstlk + vbits[1].split(lastchr)[0] + lastchr;
}
return outfind;
}
function epy(thething, thelook) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
var theid=document.getElementById('mytable').innerHTML.split(thething)[0].split(' id="')[eval(-1 + document.getElementById('mytable').innerHTML.split(thething)[0].split(' id="').length)].split('"')[0];
var thenid='t' + document.getElementById('mytable').innerHTML.split(thelook.split('>')[0])[0].split(' id="t')[eval(-1 + document.getElementById('mytable').innerHTML.split(thelook.split('>')[0])[0].split(' id="t').length)].split('"')[0];
var ithing=innards(thething), thenum=-1, thetds=[], jnum=0, ijk=0;
if (thelook.indexOf(' data-square="') != -1) {
thenum=eval(thelook.split(' data-square="')[1].split('"')[0]);
thetds=document.getElementsByTagName('td');
for (ijk=0; ijk<thetds.length; ijk++) {
if (thetds[ijk].outerHTML.indexOf(' class="black"') != -1 || thetds[ijk].outerHTML.indexOf(' class="white"') != -1) { jnum++; }
if (jnum == thenum || thetds[ijk].outerHTML.indexOf(thelook.split('>')[0]) != -1) {
//ouralert(thenid + ' vs ' + thetds[ijk].id);
thenid=thetds[ijk].id;
if (thetds[ijk].outerHTML.indexOf(thelook.split('>')[0]) != -1) { jnum=-999; }
}
}
}
//ouralert("document.getElementById('" + theid + "').innerHTML=''; " + "document.getElementById('" + thenid + "').innerHTML='" + ithing + "'; ");
domcmds.push("document.getElementById('" + theid + "').innerHTML=''; ");
domcmds.push("document.getElementById('" + thenid + "').innerHTML='" + ithing + "'; ");
}
return thething;
}
function mightbecastling(pthispiece, potherpiece, pthisoh, potheroh) { // thanks to https://www.chessable.com/blog/how-to-castle-in-chess/
var pretval=0, delone='', deltwo='';
var bigih=document.getElementById('target').innerHTML;
var inpthisoh=pthisoh;
var inpotheroh=potheroh;
twosubsfrom[0]='';
if (inpthisoh.indexOf(' data-square="') == -1) {
inpthisoh='<td' + bigih.split(pthisoh)[0].split('<td')[eval(-1 + bigih.split(pthisoh)[0].split('<td').length)];
}
if (inpotheroh.indexOf(' data-square="') == -1) {
inpotheroh='<td' + bigih.split(potheroh)[0].split('<td')[eval(-1 + bigih.split(potheroh)[0].split('<td').length)];
}
if (pthispiece.substring(0,1) != potherpiece.substring(0,1)) { return -5; }
if ((pthispiece.substring(1).substring(0,1) == 'K' && eval('' + pthispiece.length) == 2) && (potherpiece.substring(1).substring(0,1) == 'R' && eval('' + potherpiece.length) == 3)) {
if (pthispiece.substring(0,1) == 'w' && inpthisoh.indexOf(' data-square="61"') != -1 && (inpotheroh.indexOf(' data-square="64"') != -1 || inpotheroh.indexOf(' data-square="57"') != -1)) {
pretval=1;
if (inpotheroh.indexOf(' data-square="57"') != -1 && (bigih.indexOf(abb(' data-square="58">') + '</') == -1 || bigih.indexOf(abb(' data-square="59">') + '</') == -1 || bigih.indexOf(abb(' data-square="60">') + '</') == -1)) {
pretval=-1;
} else if (inpotheroh.indexOf(' data-square="57"') != -1) { //newish
//document.getElementById('target').innerHTML=document.getElementById('target').innerHTML.replace(pthisoh,'').replace(potheroh,'');
//document.getElementById('target').innerHTML=document.getElementById('target').innerHTML.replace(abb(' data-square="60">') + '</', abb(' data-square="60">') + potheroh + '</').replace(abb(' data-square="59">') + '</', abb(' data-square="59">') + pthisoh + '</');
twosubsfrom[0] = 'wR1';
if (wwtdtte != '') { lohoh=wwtdtte; } //rmtwowk
//ouralert('About to Castle ' + lastoh + ' +++ ' + pthisoh + ' --- ' + innards(pthisoh));
bigih=bigih.replace(epy(pthisoh,' data-square="60">'),'').replace(epy(potheroh,' data-square="59">'),'');
if (bigih.indexOf(lohoh.split('</')[0]) != -1) { lohoh=''; } //else { ouralert('found'); }
//bigih=bigih.replace(abb(' data-square="59">') + '</span>', abb(' data-square="59">') + innards(potheroh) + '</span></td>' + bigv(lohoh).split('</td>')[0]);
bigih=bigih.replace(abb(' data-square="59">') + '</', abb(' data-square="59">') + innards(potheroh) + '</');
// + lohoh);
//ouralert('About to Castle1 the rook ' + abb(' data-square="60">') + innards(potheroh) + '</');
bigih=bigih.replace(bigabb(' data-square="60">') + '</', bigabb(' data-square="60">') + innards(pthisoh) + '</'); // + lohoh.split('</td>')[0]);
//ouralert('About to Castle2 ' + innards(potheroh));
if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('target').innerHTML=bigih;
}
//ouralert('About to Castle22 ' + innards(potheroh));
//ouralert('About to Castle223');
if (wwtdtte != '') {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
domcmds.push("document.getElementById('td202').innerHTML='" + wsixoh + "'; ");
domcmds.push("document.getElementById('td203').innerHTML='" + spanfive + "'; ");
domcmds.push("document.getElementById('tr8').innerHTML='" + wwtdtte + "' + document.getElementById('tr8').innerHTML; itisthiscmove='b'; consolelog('Your next move ' + playerb + ' ... '); adddrop('" + lohoh.split(' id="')[1].split('"')[0] + "'); ");
}
}
if (lohoh != '') {
adddrop(lohoh.split(' id="')[1].split('"')[0]);
lohoh='';
}
}
if (inpotheroh.indexOf(' data-square="64"') != -1 && (bigih.indexOf(abb(' data-square="62">') + '</') == -1 || bigih.indexOf(abb(' data-square="63">') + '</') == -1)) {
//ouralert(bigih.split(' data-square="62"')[1].substring(0,40) + '*62');
//ouralert(bigih.split(' data-square="63"')[1].substring(0,40) + '*63');
pretval=-1;
} else if (inpotheroh.indexOf(' data-square="64"') != -1) { //new
twosubsfrom[0] = 'wR2';
//ouralert('About to Castle ' + lastoh);
bigih=bigih.replace(epy(pthisoh,' data-square="63">'),'').replace(epy(potheroh,' data-square="62">'),'');
//ouralert('About to Castle1 the rook ' + abb(' data-square="62">') + innards(potheroh) + '</');
bigih=bigih.replace(abb(' data-square="62">') + '</', abb(' data-square="62">') + innards(potheroh) + '</');
//ouralert('About to Castle12 the king ' + abb(' data-square="63">') + innards(pthisoh) + '</ ... ' + bigih.split(' data-square="63"')[1] + ' +++ ' + lohoh);
if (bigih.indexOf(lohoh.split('</')[0]) != -1) { lohoh=''; }
bigih=bigih.replace(abb(' data-square="63">') + '</td>', abb(' data-square="63">') + innards(pthisoh) + '</td>' + lohoh);
//ouralert('About to Castle2');
if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('target').innerHTML=bigih;
}
//ouralert('About to Castle22');
if (lohoh != '') {
adddrop(lohoh.split(' id="')[1].split('"')[0]);
lohoh='';
}
}
}
if (pthispiece.substring(0,1) == 'b' && inpthisoh.indexOf(' data-square="5"') != -1 && (inpotheroh.indexOf(' data-square="8"') != -1 || inpotheroh.indexOf(' data-square="1"') != -1)) {
pretval=1;
if (inpotheroh.indexOf(' data-square="8"') != -1 && (bigih.indexOf(abb(' data-square="6">') + '</') == -1 || bigih.indexOf(abb(' data-square="7">') + '</') == -1)) {
pretval=-1;
} else if (inpotheroh.indexOf(' data-square="8"') != -1) { // new
//document.getElementById('target').innerHTML=document.getElementById('target').innerHTML.replace(pthisoh,'').replace(potheroh,'');
//document.getElementById('target').innerHTML=document.getElementById('target').innerHTML.replace(abb(' data-square="6">') + '</', abb(' data-square="6">') + pthisoh + '</').replace(abb(' data-square="7">') + '</', abb(' data-square="7">') + potheroh + '</');
twosubsfrom[0] = 'bR2';
//if (eightoh != '') { lohoh=eightoh; }
//ouralert('About to Castle ' + lastoh + ' +++ ' + pthisoh + ' --- ' + innards(pthisoh));
bigih=bigih.replace(epy(pthisoh, ' data-square="7">'),'').replace(epy(potheroh, ' data-square="6">'),'');
//ouralert('About to Castle1 the rook ' + abb(' data-square="6">') + innards(potheroh) + '</');
bigih=bigih.replace(abb(' data-square="6">') + '</', abb(' data-square="6">') + innards(potheroh) + '</');
//ouralert('About to Castle12 the king ' + abb(' data-square="7">') + innards(pthisoh) + '</ ... ' + bigih.split(' data-square="7"')[1] + ' +++ ' + lohoh);
if (bigih.indexOf(lohoh.split('</')[0]) != -1) { lohoh=''; } //else { ouralert('found'); }
//if (bigih.indexOf(abb(' data-square="7">') + '</') == -1) {
// ouralert('Not found ' + bigabb(' data-square="7">') + '</');
//} else {
// ouralert(' ... ' + bigv(lohoh));
//}
//bigih=bigih.replace(abb(' data-square="7">') + '</span>', abb(' data-square="7">') + innards(pthisoh) + '</span></td>' + bigv(lohoh).split('</td>')[0]);
bigih=bigih.replace(abb(' data-square="7">') + '</', abb(' data-square="7">') + innards(pthisoh) + '</');
// + lohoh);
//ouralert('About to Castle2 ' + innards(pthisoh));
if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('target').innerHTML=bigih;
}
if (eightoh != '') {
if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
//domcmds.push("document.getElementById('td23').innerHTML='" + innards(potheroh) + "'; ");
//domcmds.push("document.getElementById('td31').innerHTML='" + innards(pthisoh) + "'; ");
//domcmds.push("document.getElementById('td32').innerHTML=''; ");
eightoh=eightoh;
} else {
document.getElementById('tr1').innerHTML+=eightoh;
document.getElementById('td31').innerHTML=innards(pthisoh);
domcmds.push("document.getElementById('td31').innerHTML='" + innards(pthisoh) + "'; ");
}
}
//ouralert('About to Castle22 ' + innards(pthisoh));
//document.getElementById('td31').innerHTML=innards(pthisoh);
//ouralert('About to Castle223');
if (lohoh != '') {
adddrop(lohoh.split(' id="')[1].split('"')[0]);
lohoh='';
}
}
if (inpotheroh.indexOf(' data-square="1"') != -1 && (bigih.indexOf(abb(' data-square="4">') + '</') == -1 || bigih.indexOf(abb(' data-square="2">') + '</') == -1 || bigih.indexOf(abb(' data-square="3">') + '</') == -1)) {
pretval=-1;
} else if (inpotheroh.indexOf(' data-square="1"') != -1) { //newer
//document.getElementById('target').innerHTML=document.getElementById('target').innerHTML.replace(pthisoh,'').replace(potheroh,'');
//document.getElementById('target').innerHTML=document.getElementById('target').innerHTML.replace(abb(' data-square="3">') + '</', abb(' data-square="3">') + pthisoh + '</').replace(abb(' data-square="4">') + '</', abb(' data-square="4">') + potheroh + '</');
twosubsfrom[0] = 'bR1';
if (wwwtdtte != '') { lohoh=wwwtdtte; } //rmtwowk4
//ouralert('About to Castle ' + lastoh + ' +++ ' + pthisoh + ' --- ' + innards(pthisoh));
bigih=bigih.replace(epy(pthisoh,' data-square="4">'),'').replace(epy(potheroh,' data-square="3">'),'');
if (bigih.indexOf(lohoh.split('</')[0]) != -1) { lohoh=''; } //else { ouralert('found'); }
//bigih=bigih.replace(abb(' data-square="3">') + '</span>', abb(' data-square="3">') + innards(potheroh) + '</span></td>' + bigv(lohoh).split('</td>')[0]);
bigih=bigih.replace(abb(' data-square="3">') + '</', abb(' data-square="3">') + innards(potheroh) + '</');
// + lohoh);
//ouralert('About to Castle1 the rook ' + abb(' data-square="4">') + innards(potheroh) + '</');
bigih=bigih.replace(bigabb(' data-square="4">') + '</', bigabb(' data-square="4">') + innards(pthisoh) + '</'); // + lohoh.split('</td>')[0]);
//ouralert('About to Castle2 ' + innards(potheroh));
if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('target').innerHTML=bigih;
}
//ouralert('About to Castle22 ' + innards(potheroh));
//ouralert('About to Castle223');
if (wwwtdtte != '') {
if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
domcmds.push("document.getElementById('td13').innerHTML='" + fouroh + "'; ");
domcmds.push("document.getElementById('td21').innerHTML='" + spanzero + "'; ");
domcmds.push("document.getElementById('tr1').innerHTML='" + wwwtdtte + "' + document.getElementById('tr1').innerHTML; itisthiscmove='w'; consolelog('Your next move ' + playerw + ' ... '); adddrop('" + lohoh.split(' id="')[1].split('"')[0] + "'); ");
}
}
if (lohoh != '') {
adddrop(lohoh.split(' id="')[1].split('"')[0]);
lohoh='';
}
}
}
} else if ((potherpiece.substring(1).substring(0,1) == 'K' && eval('' + potherpiece.length) == 2) && (pthispiece.substring(1).substring(0,1) == 'R' && eval('' + pthispiece.length) == 3)) {
if (potherpiece.substring(0,1) == 'w' && inpotheroh.indexOf(' data-square="61"') != -1 && (inpthisoh.indexOf(' data-square="64"') != -1 || inpthisoh.indexOf(' data-square="57"') != -1)) {
pretval=1;
if (inpthisoh.indexOf(' data-square="57"') != -1 && (bigih.indexOf(abb(' data-square="58">') + '</') == -1 || bigih.indexOf(abb(' data-square="59">') + '</') == -1 || bigih.indexOf(abb(' data-square="60">') + '</') == -1)) {
pretval=-1;
} else if (inpthisoh.indexOf(' data-square="57"') != -1) { // new
//document.getElementById('target').innerHTML=document.getElementById('target').innerHTML.replace(pthisoh,'').replace(potheroh,'');
//document.getElementById('target').innerHTML=document.getElementById('target').innerHTML.replace(abb(' data-square="60">') + '</', abb(' data-square="60">') + pthisoh + '</').replace(abb(' data-square="59">') + '</', abb(' data-square="59">') + potheroh + '</');
twosubsfrom[0] = 'wR1';
if (wtdtte != '') { lohoh=wtdtte; } //rmtwow
//ouralert('About to Castle ' + lastoh + ' +++ ' + pthisoh + ' --- ' + innards(pthisoh));
bigih=bigih.replace(epy(pthisoh,' data-square="60">'),'').replace(epy(potheroh,' data-square="59">'),'');
if (bigih.indexOf(lohoh.split('</')[0]) != -1) { lohoh=''; } //else { ouralert('found'); }
//bigih=bigih.replace(abb(' data-square="59">') + '</span>', abb(' data-square="59">') + innards(potheroh) + '</span></td>' + bigv(lohoh).split('</td>')[0]);
bigih=bigih.replace(abb(' data-square="59">') + '</', abb(' data-square="59">') + innards(potheroh) + '</');
// + lohoh);
//ourale'')) - minleft) + ',';
az+='' + Math.floor(eval(eval(eval('' + zerozeroy)) - mintop)) + ' ';
az+='' + Math.floor(eval('' + document.getElementById('hrlg' + sfx[eval(-1 + ifufg)] + lasthr).style.left.replace('px','')) - minleft) + ',';
az+='' + Math.floor(eval(eval(eval('' + zerozeroy)) - mintop)) + ' ';
az+='" style="fill:' + acol + ';stroke:purple;stroke-width:1" /></svg></div>';
//alert(az);
document.getElementById('daxes').innerHTML+=az;
}
} //else {
//alert(' numsets=' + numsets + ' and orignumsets=' + orignumsets);
//}
if (ifufg == fufg) { lasthr=hrlgcnt; }
} else if (document.getElementById('h1column').innerHTML == 'Bar') { // yvalue.toLowerCase().indexOf('bar') != -1) {
bc=cgcols[Math.floor(Math.random() * cgcols.length)];
if (fufg != 2) {
bc=sfxa[eval(-1 + ifufg)];
//if (document.getElementById('daxes').innerHTML.replace('top: ','top:').indexOf("top:" + dwt + "px;") == -1) {
//alert('ifufg=' + ifufg + ' and xvalue=' + xvalue.split(' and ')[0].split(';')[0] + ' and divby=' + divby + ' width=' + eval(xfactor * eval(eval('' + xvalue.split(' and ')[0].split(';')[0]) - eval('' + xoffset))));
//}
}
document.getElementById('daxes').innerHTML+="<div onclick='alert(this.title);' title='" + xlabel.split(' and ')[eval(-2 + ifufg)] + ": " + xvalue.split(' and ')[0].split(';')[0] + "' style='background-color:" + bc + ";opacity:0.5;z-index:24;position:absolute;top:" + dwt + "px;left:" + eval(zerozerox + 14) + "px;height:" + eval(dw / divby) + "px;width:" + eval(xfactor * eval(eval('' + xvalue.split(' and ')[0].split(';')[0]) - eval('' + xoffset))) + "px;'></div>";
if (ifufg == 2) { document.getElementById('daxes').innerHTML+='<b><sub style="margin-top:20px;margin-left:-50px;position:absolute;top:' + dwt + 'px;left:' + zerozerox + 'px;">' + yvalue.split(' and ')[0].split(';')[0] + rest + '</sub></b>'; }
if (fufg != 2) { if (xvalue.indexOf(' and ') != -1 || xvalue.indexOf(';') != -1) { xvalue=xvalue.replace(xvalue.split(' and ')[0] + ' and ','').replace(xvalue.split(';')[0] + ';',''); } if (yvalue.indexOf(' and ') != -1 || yvalue.indexOf(';') != -1) { yvalue=yvalue.replace(yvalue.split(' and ')[0] + ' and ','').replace(yvalue.split(';')[0] + ';',''); } }
if (divby > 1) {
dwt-=eval(dw / divby); // 2
dwl+=eval(dw / divby); // 2
rdw=0; //eval(dw / divby);
}
} else {
bc=cgcols[Math.floor(Math.random() * cgcols.length)];
if (fufg != 2) { bc=sfxa[eval(-1 + ifufg)]; }
//alert('yvalue=' + yvalue);
document.getElementById('daxes').innerHTML+="<div onclick='alert(this.title);' title='" + ylabel.split(' and ')[eval(-2 + ifufg)] + ": " + yvalue.split(' and ')[0].split(';')[0] + "' style='background-color:" + bc + ";opacity:0.5;z-index:24;position:absolute;top:" + eval(zerozeroy + 14 - eval(eval(yfactor * eval(eval('' + yvalue.split(' and ')[0].split(';')[0]) - eval('' + yoffset))))) + "px;left:" + dwl + "px;width:" + eval(dw / divby) + "px;height:" + eval(yfactor * eval(eval('' + yvalue.split(' and ')[0].split(';')[0]) - eval('' + yoffset))) + "px;'></div>";
if (ifufg == 2) { document.getElementById('daxes').innerHTML+='<b><sub style="margin-top:20px;position:absolute;left:' + dwl + 'px;top:' + zerozeroy + 'px;">' + xvalue.split(' and ')[0].split(';')[0] + rest + '</sub></b>'; }
if (fufg != 2) { if (xvalue.indexOf(' and ') != -1 || xvalue.indexOf(';') != -1) { xvalue=xvalue.replace(xvalue.split(' and ')[0] + ' and ','').replace(xvalue.split(';')[0] + ';',''); } if (yvalue.indexOf(' and ') != -1 || yvalue.indexOf(';') != -1) { yvalue=yvalue.replace(yvalue.split(' and ')[0] + ' and ','').replace(yvalue.split(';')[0] + ';',''); } }
if (divby > 1) {
dwt-=eval(dw / divby); // 2
dwl+=eval(dw / divby); // 2
rdw=0; //eval(dw / divby);
}
}
}
eqplotsuffix=eqplotsuffix.replace(/\;undefined/g,'').replace(/\;\|/g,'|');
numsets--;
if (numsets == 0) { document.getElementById('daxes').innerHTML+='<style> hr.vertex { visibility:hidden; } </style>'; }
dwl+=rdw;
dwt-=rdw;
dwl+=5;
dwt-=5;
iois.value='';
iois.placeholder=altnextph; //'Line formula y=Gx + O ... G is gradient, O is Y-offset ... please comma separate G,O';
}
} else {
var gradient=0.0;
var offset=0.0;
if (ioisval == '') { ioisval=iois.value; }
var things=ioisval.split(',');
//alert(ioisval + ' ... things.length=' + things.length);
if (things.length >= 3) {
if (jans == '') { if (eqplotsuffix == '') { eqplotsuffix='|'; } eqplotsuffix+=(ioisval + '|'); }
var rootsy=[0,0]; // thanks to http://www.biology.arizona.edu/biomath/tutorials/quadratic/roots.html
for (var kkk=minx; kkk<=maxx; kkk+=0.05) {
//alert(eval(eval(eval('' + kkk) * eval('' + kkk) * eval('' + things[0])) + (eval('' + kkk) * eval('' + things[1])) + eval('' + things[2]))));
if (eval(1.0 * eval('' + kkk)) > maxx || eval(1.0 * eval('' + kkk)) < minx) {
hrcnt=hrcnt;
} else if (eval(1.0 * eval(eval('' + kkk) + ',' + eval(eval(eval('' + kkk) * eval('' + kkk) * eval('' + things[0])) + (eval('' + kkk) * eval('' + things[1])) + eval('' + things[2]))) + eval('' + offset)) > maxy || eval(1.0 * eval(eval('' + kkk) + ',' + eval(eval(eval('' + kkk) * eval('' + kkk) * eval('' + things[0])) + (eval('' + kkk) * eval('' + things[1])) + eval('' + things[2]))) + eval('' + offset)) < miny) {
hrcnt=hrcnt;
} else if (eval('' + kkk) != 0 && Math.abs(eval(eval(eval('' + kkk) * eval('' + kkk) * eval('' + things[0])) + (eval('' + kkk) * eval('' + things[1])) + eval('' + things[2]))) > 0.05) {
hrcnt++;
document.getElementById('hrs').innerHTML+='<hr class="vertex" onclick="alert(this.title);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' title="y=' + things[0] + '*x*x ' + ('+' + things[1]).replace('+-','-').replace('-','- ') + '*x ' + ('+' + things[2]).replace('+-','-').replace('-','- ') + ' plot point (' + eval('' + kkk) + ',' + eval(eval(eval('' + kkk) * eval('' + kkk) * eval('' + things[0])) + (eval('' + kkk) * eval('' + things[1])) + eval('' + things[2])) + ')" style="border-color:orange;position:absolute;top:' + eval(zerozeroy - eval(yfactor * eval(eval('' + kkk) + ',' + eval(eval(eval('' + kkk) * eval('' + kkk) * eval('' + things[0])) + (eval('' + kkk) * eval('' + things[1])) + eval('' + things[2]))) + eval('' + offset))) + 'px;left:' + eval(zerozerox + eval(xfactor * eval('' + kkk))) + 'px;"></hr>';
}
}
if (eval('' + things[0]) != 0) {
//alert(eval(2.0 * eval(eval('' + things[0]))) + ' ... ' + eval(eval(eval('' + things[1]) * eval('' + things[1])) - eval(4.0 * eval('' + things[0]) * eval('' + things[2]))));
if (eval(eval('' + things[1]) * eval('' + things[1]) - eval(4.0 * eval('' + things[0]) * eval('' + things[2]))) >= 0) {
rootsy[0]=eval(eval(eval(('-' + things[1]).replace('--','')) + Math.sqrt(eval(eval(eval('' + things[1])) * eval(eval('' + things[1])) - eval(4.0 * eval(eval('' + things[0])) * eval(eval('' + things[2])))))) / eval(2.0 * eval(eval('' + things[0]))));
rootsy[1]=eval(eval(eval(('-' + things[1]).replace('--','')) - Math.sqrt(eval(eval(eval('' + things[1])) * eval(eval('' + things[1])) - eval(4.0 * eval(eval('' + things[0])) * eval(eval('' + things[2])))))) / eval(2.0 * eval(eval('' + things[0]))));
//alert('' + rootsy[0] + ' ' + rootsy[1]);
}
hrcnt++;
document.getElementById('hrs').innerHTML+='<hr class="vertex" onclick="alert(this.title);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' title="y=' + things[0] + '*x*x ' + ('+' + things[1]).replace('+-','-').replace('-','- ') + '*x ' + ('+' + things[2]).replace('+-','-').replace('-','- ') + ' plot point (' + eval('' + rootsy[0]) + ',0)" style="z-index:234;border-color:pink;position:absolute;left:' + eval(zerozerox + eval(xfactor * eval(eval('' + rootsy[0])))) + 'px;top:' + eval('' + zerozeroy) + 'px;"></hr>';
hrcnt++;
document.getElementById('hrs').innerHTML+='<hr class="vertex" onclick="alert(this.title);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' title="y=' + things[0] + '*x*x ' + ('+' + things[1]).replace('+-','-').replace('-','- ') + '*x ' + ('+' + things[2]).replace('+-','-').replace('-','- ') + ' plot point (' + eval('' + rootsy[1]) + ',0)" style="z-index:234;border-color:pink;position:absolute;left:' + eval(zerozerox + eval(xfactor * eval(eval('' + rootsy[1])))) + 'px;top:' + eval('' + zerozeroy) + 'px;"></hr>';
}
hrcnt++;
document.getElementById('hrs').innerHTML+='<hr class="vertex" onclick="alert(this.title);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' title="y=' + things[0] + '*x*x ' + ('+' + things[1]).replace('+-','-').replace('-','- ') + '*x ' + ('+' + things[2]).replace('+-','-').replace('-','- ') + ' plot point (0,' + eval('' + things[2]) + ')" style="z-index:234;border-color:pink;position:absolute;left:' + eval(zerozerox) + 'px;top:' + eval(zerozeroy - eval(yfactor * eval(eval('' + things[2])))) + 'px;"></hr>';
iois.value='';
iois.placeholder=origph; //'Line formula y=Gx + O ... G is gradient, O is Y-offset ... please comma separate G,O';
oiois=iois;
setTimeout(toggleplaceholder, 5000);
} else if (things.length >= 1) {
if (jans == '') { if (eqplotsuffix == '') { eqplotsuffix='|'; } eqplotsuffix+=(ioisval + '|'); }
gradient=eval('' + things[0]);
offset=eval('' + things[1]);
// y=6x + 12;
if (gradient != 0) {
//alert('' + xfactor + ' ' + yfactor);
hrcnt++;
document.getElementById('hrs').innerHTML+='<hr class="vertex" onclick="alert(this.title);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' title="y=' + gradient + '*x ' + ('+' + offset).replace('+-','-').replace('-','- ') + ' plot point (' + eval(-offset / eval('' + gradient)) + ',0)" style="z-index:134;border-color:pink;position:absolute;top:' + zerozeroy + 'px;left:' + eval(zerozerox - eval(xfactor * eval(offset / eval('' + gradient)))) + 'px;"></hr>';
hrcnt++;
document.getElementById('hrs').innerHTML+='<hr class="vertex" onclick="alert(this.title);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' title="y=' + gradient + '*x ' + ('+' + offset).replace('+-','-').replace('-','- ') + ' plot point (0,' + eval('' + offset) + ')" style="z-index:134;border-color:pink;position:absolute;top:' + eval(zerozeroy - eval(yfactor * eval('' + offset))) + 'px;left:' + zerozerox + 'px;"></hr>';
for (var kkk=minx; kkk<=maxx; kkk+=eval(eval('' + xlen) / Math.floor((80 * Math.abs(eval('' + gradient)))) )) {
if (eval(eval(eval('' + kkk) * eval('' + gradient)) + eval('' + offset)) > maxx || eval(eval(eval('' + kkk) * eval('' + gradient)) + eval('' + offset)) < minx) {
hrcnt=hrcnt;
} else if (eval('' + kkk) > maxy || eval('' + kkk) < miny) {
hrcnt=hrcnt;
} else {
hrcnt++;
document.getElementById('hrs').innerHTML+='<hr class="vertex" onclick="alert(this.title);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' title="y=' + gradient + '*x ' + ('+' + offset).replace('+-','-').replace('-','- ') + ' plot point (' + eval('' + kkk) + ',' + eval(eval(eval('' + kkk) * eval('' + gradient)) + eval('' + offset)) + ')" style="position:absolute;top:' + eval(zerozeroy - eval(yfactor * eval(eval(eval('' + kkk) * eval('' + gradient)) + eval('' + offset)))) + 'px;left:' + eval(zerozerox + eval(xfactor * eval('' + kkk))) + 'px;"></hr>';
}
}
iois.value='';
iois.placeholder=origph; //'Line formula y=Gx + O ... G is gradient, O is Y-offset ... please comma separate G,O';
oiois=iois;
setTimeout(toggleplaceholder, 5000);
}
}
}
return '';
}
function nobuttons() {
jigsaw=true;
document.getElementById('myh1').innerHTML=document.getElementById('myh1').innerHTML.substring('Image Reveal Game or '.length);
//document.getElementById('button').value="Image Map";
document.getElementById('button').innerHTML="Image Map";
document.getElementById('button').style.backgroundColor='lightblue';
document.getElementById('button').title='Click over image for Image Map area element shape=rect definitions';
document.getElementById('anob').style.backgroundColor='green';
document.getElementById('myh1').style.position='absolute';
document.getElementById('myh1').style.top='0px';
document.getElementById('myh1').style.left='10px';
document.getElementById('myh3').style.position='absolute';
document.getElementById('myh3').style.top='60px';
document.getElementById('myh3').style.left='10px';
//document.getElementById('myh4').style.position='absolute';
document.getElementById('myh4').style.marginTop='120px';
//document.getElementById('myh4').style.left='0px';
var bts=document.getElementsByTagName('button');
for (var ibts=0; ibts<bts.length; ibts++) {
if (bts[ibts].innerHTML.replace(' ','') == '') { bts[ibts].style.display='none'; }
}
ttable=document.getElementById('toptable').getBoundingClientRect();
document.getElementById('jigsaw').style.position='absolute';
document.getElementById('jigsaw').style.top='' + ttable.top + 'px';
document.getElementById('jigsaw').style.left='' + ttable.left + 'px';
document.getElementById('jigsaw').style.width='100%';
document.getElementById('jigsaw').style.height='100vh';
document.getElementById('jigsaw').style.zIndex='100';
document.getElementById('jigsaw').style.backgroundColor='transparent';
//document.getElementById('jigsaw').style.border='2px solid red';
document.getElementById('myh4').innerHTML=document.getElementById('myh4').innerHTML.split(' of Player')[0].replace('Enjoy your two player game of Image Revealing','Welcome to Image Jigsaw Guillotine Mapping');
setTimeout(eh, 1000);
}
function draw_hrs() {
var inqis='';
if (('' + location.hash).indexOf('=column') != -1) {
emeq='column';
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Plot%20Axes%','Column%20Graph%');
xlabel='';
ylabel='';
firstp='Please enter Title, Number of data sets, Y-axis minimum, Y-axis maximum';
}
if (('' + location.hash).replace(/\%7C/g,'|').indexOf('|Bar|') != -1) {
origph='Enter X-axis Label (numerical); Y-axis Label' + origphsuffix;
altph=origph;
altnextph='Enter X-axis Value; Y-axis Value (~ is line feed)';
firstp='Please enter Title, Number of data sets, X-axis minimum, X-axis maximum';
}
aem=document.getElementById('aemail').href;
wourx=location.search.split('ourx=')[1] ? decodeURIComponent(location.search.split('ourx=')[1].split('&')[0]) : '';
if (('' + location.hash + '~').indexOf('blank') != -1 && ('' + location.hash + '~').indexOf('blank~') == -1) {
wourx=('' + location.hash + '~').split('blank')[1].split('~')[0];
}
lesscourx=wourx;
if (('' + location.hash).indexOf('hangman') != -1 || ('' + location.hash).indexOf('mathsgrid') != -1 || ('' + location.hash).indexOf('reveal') != -1) {
location.hash=location.hash.replace('mathsgrid','hangman').replace('reveal','hangman#hangman');
if (('' + location.hash).indexOf('.') != -1) {
goes=eval(('' + location.hash).split('.')[1]);
score=eval(('' + location.hash).split('.')[0].split('hangman')[1].replace('-',''));
} else if (document.URL.indexOf('?wording=') != -1 && ('' + location.hash).split('angma').length > 3) { // && ('' + location.hash).indexOf('hangman0.0') != -1) { // && ('' + location.hash).indexOf('00.0') != -1) {
sosize(' '); // sosize('word_wrap.jpg');
} else if (document.URL.indexOf('?wording=') != -1 && ('' + location.hash).split('angma').length > 2) { // && ('' + location.hash).indexOf('hangman0.0') != -1) { // && ('' + location.hash).indexOf('00.0') != -1) {
document.getElementById('myh1').innerHTML=' ';
document.getElementById('myh3').innerHTML=' ';
document.getElementById('myh4').innerHTML=' ';
document.getElementById('dhangman').innerHTML+="<iframe name=iback id=iback style='background-color:transparent;z-index:23;position:absolute;top:200px;left:0px;width:580px;height:100vh;' src=//www.rjmprogramming.com.au/HTMLCSS/user_of_signature_signature.html?rand=" + Math.floor(Math.random() * 123456) + "></iframe>";
document.getElementById('dhangman').innerHTML+="<iframe name=ifront id=ifront style='background-color:transparent;z-index:22;position:absolute;top:0px;left:0px;width:100%;height:100vh;' src=//www.rjmprogramming.com.au/HTMLCSS/square_hr_tracing.htm#hangman-0.0></iframe>";
document.getElementById('dhangman').innerHTML+="<div id=dback title='' style='background-color:transparent;z-index:24;position:absolute;top:200px;left:580px;'></div>";
//return;
}
}
if ((' ' + location.hash).split('#').length > 3 || (' ' + location.hash).indexOf('hangman-00.0') != -1) {
document.getElementById('myh1').innerHTML='Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a> <div id=xdjigsaw></div>';
} else if ((' ' + location.hash).split('#').length > 2 || (' ' + location.hash).indexOf('hangman-0.0') != -1) {
document.getElementById('myh1').innerHTML='Maths Grid Paper';
}
// if (('' + location.hash).indexOf('blank') == -1 && ('' + location.hash).indexOf('square') == -1 && ('' + location.hash).indexOf('grid') == -1) {
if (document.URL.indexOf('?') == -1 && ('' + location.hash).indexOf('blank') == -1 && ('' + location.hash).indexOf('hangman') == -1 && ('' + location.hash).indexOf('square') == -1 && ('' + location.hash).indexOf('grid') == -1) { pickone(inqis); } else if (document.URL.indexOf('?') == -1 && (('' + location.hash).indexOf('blank') != -1 || ('' + location.hash).indexOf('hangman') != -1 || ('' + location.hash).indexOf('square') != -1 || ('' + location.hash).indexOf('grid') != -1)) { inqis=' '; pickone(inqis); }
wording=location.search.split('wording=')[1] ? decodeURIComponent(location.search.split('wording=')[1].split('&')[0]) : ' ';
if ((' ' + location.hash).split('#').length > 3 || (' ' + location.hash).indexOf('hangman-00.0') != -1) {
document.getElementById('myh1').innerHTML='Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a> <div id=xdjigsaw></div>';
} else if ((' ' + location.hash).split('#').length > 2 || (' ' + location.hash).indexOf('hangman-0.0') != -1) {
wording='Maths Grid Paper';
}
inanswer=location.search.split('answer=')[1] ? decodeURIComponent(location.search.split('answer=')[1].split('&')[0]) : inqis;
var inquestion=location.search.split('question=')[1] ? ina(decodeURIComponent(location.search.split('question=')[1].split('&')[0])) : '';
var tds=document.getElementsByTagName('td');
var fhr=0, vdval='', thisv='', into='hrs', defvdval='', toff=6, loff=-2;
dval='';
for (var itds=0; itds<tds.length; itds++) {
tds[itds].id='td' + eval(1 + itds);
if (('' + location.hash).indexOf('grid') != -1) { into='td' + eval(1 + itds); }
if (('' + location.hash).indexOf('blank') != -1 || ('' + location.hash).indexOf('hangman') != -1 || ('' + location.hash).indexOf('square') != -1 || ('' + location.hash).indexOf('grid') != -1) {
if (('' + location.hash).indexOf('square') != -1) { if (eval(1 + itds) > 9) { document.getElementById('spout').innerHTML+="<style> #td" + eval(1 + itds) + "::after { content:'\\00003" + Math.floor(eval(eval(1 + itds) / 10)) + "\\0020e3\\00003" + eval(eval(1 + itds) % 10) + "\\0020e3'; } </style>"; } else { document.getElementById('spout').innerHTML+="<style> #td" + eval(1 + itds) + "::after { content:'\\00003" + eval(eval(1 + itds) % 10) + "\\0020e3'; } </style>"; } defvdval="visibility:hidden;"; tds[itds].style.border='1px solid red'; }
if (('' + location.hash).indexOf('grid') != -1) { tds[itds].style.border='1px solid brown'; }
tds[itds].onclick=function(event) { lastsquare=eval(('' + this.id).replace('td','')); goes++; if (lastsquare == sqchoice) { score++; } if (('' + location.hash).indexOf('square') != -1) { picksq(); } else if (('' + location.hash).indexOf('grid') != -1) { gridinfo(' in square number ' + lastsquare); } };
}
thisrect=tds[itds].getBoundingClientRect();
//squares.push(('' + thisrect.left).replace('px','') + "," + ('' + thisrect.top).replace('px','') + ";" + eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px',''))) + "," + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px',''))));
//alert(('' + thisrect.left) + ' ' + ('' + thisrect.top) + ' ' + ('' + thisrect.width) + ' ' + ('' + thisrect.height) + ' ' + squares[0]);
fhr=hrcnt;
//vertices.push(('' + thisrect.left).replace('px','') + "," + ('' + thisrect.top).replace('px',''));
vdval=defvdval;
thisv=';' + ourmathround(eval(('' + thisrect.left).replace('px',''))) + "," + ourmathround(eval(('' + thisrect.top).replace('px',''))) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + thisrect.top + 'px;left:' + thisrect.left + 'px;"></hr>';
hrcnt++;
//vertices.push(('' + thisrect.left).replace('px','') + "," + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px',''))));
vdval=defvdval;
thisv=';' + ourmathround(('' + thisrect.left).replace('px','')) + "," + ourmathround(eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')))) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px',''))) + 'px;left:' + thisrect.left + 'px;"></hr>';
hrcnt++;
//vertices.push(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px',''))) + "," + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px',''))));
vdval=defvdval;
thisv=';' + ourmathround(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')))) + "," + ourmathround(eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')))) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px',''))) + 'px;left:' + eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px',''))) + 'px;"></hr>';
hrcnt++;
//vertices.push(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px',''))) + "," + ('' + thisrect.top).replace('px',''));
vdval=defvdval;
thisv=';' + ourmathround(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')))) + "," + ourmathround(('' + thisrect.top).replace('px','')) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
//if (hrcnt == 134 || hrcnt == 146) { alert(vdval + ' hr' + hrcnt + ': ' + thisv + ' ... ' + vstr); } // ?
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + thisrect.top + 'px;left:' + eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px',''))) + 'px;"></hr>';
hrcnt++;
//
//vertices.push(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2) + "," + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2));
vdval=defvdval;
thisv=';' + ourmathround(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2)) + "," + ourmathround(eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2)) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2) + 'px;left:' + eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2) + 'px;"></hr>';
hrcnt++;
//vertices.push(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 1) + "," + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2));
vdval=defvdval;
thisv=';' + ourmathround(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 1)) + "," + ourmathround(eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2)) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2) + 'px;left:' + eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 1) + 'px;"></hr>';
hrcnt++;
//vertices.push(('' + thisrect.left).replace('px','') + "," + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2));
vdval=defvdval;
thisv=';' + ourmathround(('' + thisrect.left).replace('px','')) + "," + ourmathround(eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2)) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 2) + 'px;left:' + thisrect.left + 'px;"></hr>';
hrcnt++;
//vertices.push(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2) + "," + ('' + thisrect.top).replace('px',''));
vdval=defvdval;
thisv=';' + ourmathround(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2)) + "," + ourmathround(('' + thisrect.top).replace('px','')) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + thisrect.top + 'px;left:' + eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2) + 'px;"></hr>';
hrcnt++;
//vertices.push(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2) + "," + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 1));
vdval=defvdval;
thisv=';' + ourmathround(eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2)) + "," + ourmathround(eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 1)) + ';';
if (vstr.indexOf(thisv) != -1) { vdval="visibility:hidden;"; } else { vstr+=vplus(thisv.substring(1)); }
document.getElementById(into).innerHTML+='<hr class="vertex' + maybenocont(vdval) + '" onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + vdval + 'position:absolute;top:' + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px','')) / 1) + 'px;left:' + eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px','')) / 2) + 'px;"></hr>';
hrcnt++;
if (eval(itds % 5) == 0) {
dval='';
if (inquestion != '') {
if (parent.document != document) {
if (parent.document.getElementById('myh1')) {
dval=dval;
if ((' ' + location.hash).split('#').length > 3 || (' ' + location.hash).indexOf('hangman-00.0') != -1) {
document.getElementById('myh1').innerHTML='Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a> <div id=xdjigsaw></div>';
} else if ((' ' + location.hash).split('#').length > 2 || (' ' + location.hash).indexOf('hangman-0.0') != -1) {
document.getElementById('myh1').innerHTML='Maths Grid Paper';
} else {
document.getElementById('myh1').innerHTML='Chinese Brain Twisters Answer';
}
} else {
if (('' + location.hash).indexOf('blank') != -1 || ('' + location.hash).indexOf('hangman') != -1 || ('' + location.hash).indexOf('square') != -1 || ('' + location.hash).indexOf('grid') != -1) {
document.getElementById('myh1').innerHTML=wording.replace('Image Reveal Game','Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a>');
//wording=' ';
} else {
if (document.getElementById('myh3').innerHTML.indexOf(' ... ') == -1) { document.getElementById('myh3').innerHTML+=' ... Thanks to Chinese Brain Twisters by Baifang ISBN: 0-471-59505-5'; }
document.getElementById('reveal').style.display='block';
document.getElementById('skip').style.display='block';
if ((' ' + location.hash).split('#').length > 3 || (' ' + location.hash).indexOf('hangman-00.0') != -1) {
document.getElementById('myh1').innerHTML='Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a> <div id=xdjigsaw></div>';
} else if ((' ' + location.hash).split('#').length > 2 || (' ' + location.hash).indexOf('hangman-0.0') != -1) {
document.getElementById('myh1').innerHTML='Maths Grid Paper';
} else {
document.getElementById('myh1').innerHTML='Chinese Brain Twisters Question';
}
}
}
} else {
if (('' + location.hash).indexOf('blank') != -1 || ('' + location.hash).indexOf('hangman') != -1 || ('' + location.hash).indexOf('square') != -1 || ('' + location.hash).indexOf('grid') != -1) {
document.getElementById('myh1').innerHTML=wording.replace('Image Reveal Game','Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a> <div id=xdjigsaw></div>');
//wording=' ';
} else {
if (document.getElementById('myh3').innerHTML.indexOf(' ... ') == -1) { document.getElementById('myh3').innerHTML+=' ... Thanks to Chinese Brain Twisters by Baifang ISBN: 0-471-59505-5'; }
document.getElementById('reveal').style.display='block';
document.getElementById('skip').style.display='block';
if ((' ' + location.hash).split('#').length > 3 || (' ' + location.hash).indexOf('hangman-00.0') != -1) {
document.getElementById('myh1').innerHTML='Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a> <div id=xdjigsaw></div>';
} else if ((' ' + location.hash).split('#').length > 2 || (' ' + location.hash).indexOf('hangman-0.0') != -1) {
document.getElementById('myh1').innerHTML='Maths Grid Paper';
} else {
document.getElementById('myh1').innerHTML='Chinese Brain Twisters Question';
}
}
}
if ((' ' + location.hash).split('#').length > 3 || (' ' + location.hash).indexOf('hangman-00.0') != -1) {
document.getElementById('myh1').innerHTML='Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a> <div id=xdjigsaw></div>';
} else if ((' ' + location.hash).split('#').length > 2 || (' ' + location.hash).indexOf('hangman-0.0') != -1) {
document.getElementById('qh4').innerHTML='Maths Grid Paper';
} else {
//alert('' + location.hash);
if (('' + location.hash).indexOf('=plot') != -1) {
document.getElementById('myh1').innerHTML='<a onclick=emailit(); style=cursor:pointer;display:none;text-decoration:underline; id=ashare>Email </a>Plot Axes - Linear or Polynomial Equation';
document.getElementById('qh4').innerHTML=wording.replace('Vertex Pointing' + osft + ' Game','Plot Axes ... <input style="width:460px;" type=text placeholder="' + firstp + '" onblur=plotthis(this,blk,blk); value="" id=iplot></input>');
document.getElementById('hr2').style.display='none';
document.getElementById('hr8').style.display='none';
document.getElementById('hr1').style.display='none';
document.getElementById('myh4').innerHTML=' ';
} else if (('' + location.hash).indexOf('=column') != -1) {
emeq='column';
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Plot%20Axes%','Column%20Graph%');
document.getElementById('myh1').innerHTML='<a onclick=emailit(); style=cursor:pointer;display:none;text-decoration:underline; id=ashare>Email </a><span id=h1column style=display:inline-block;>Column</span> Graph';
document.getElementById('qh4').innerHTML=wording.replace('Vertex Pointing' + osft + ' Game','<select onchange=changegtypeto(this.value); id=graphsel style=display:inline-block;><option value=Column>Column</option><option value=Line>Line</option><option value=Area>Area</option><option value=Bar>Bar</option></select> Graph ... <input style="width:460px;" type=text placeholder="' + firstp + '" onblur=plotthis(this,blk,blk); value="" id=iplot></input>');
document.getElementById('hr2').style.display='none';
document.getElementById('hr8').style.display='none';
document.getElementById('hr1').style.display='none';
document.getElementById('myh4').innerHTML=' <span id=h1col style=display:inline-block;>Column</span> Graph';
if (('' + location.hash).replace(/\%7C/g,'|').indexOf('|Bar|') == -1) {
origph='Enter X-axis Label; Y-axis Label (numerical)' + origphsuffix;
altph=origph;
altnextph='Enter X-axis Value (~ is line feed); Y-axis Value';
}
} else {
document.getElementById('qh4').innerHTML=wording.replace('Vertex Pointing' + osft + ' Game','Vertex Pointing' + osft + ' Game ... On Each Set of 4 a Bezier Curve is Shown');
}
}
if (inquestion.indexOf('r') == -1) { inquestion='hr' + inquestion.replace(/\,/g,',hr'); }
if ((inquestion + ',').indexOf('r' + hrcnt + ',') == -1 && ('' + location.hash).indexOf('grid') == -1) { dval="display:none;visibility:hidden;"; }
}
//document.getElementById(into).innerHTML+='<hr onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' class=vertical style="' + dval + 'position:absolute;top:' + thisrect.top + 'px;left:' + thisrect.left + 'px;"></hr>';
if (!isIE) {
//alert(document.getElementById('hr' + fhr).outerHTML + ' to ' + document.getElementById('hr' + eval(1 + eval('' + fhr))).outerHTML + ' is ' + connect(document.getElementById('hr' + fhr), document.getElementById('hr' + eval(1 + eval('' + fhr)))).replace('<div ','<div onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' class=vertical '));
document.getElementById(into).innerHTML+=connect(document.getElementById('hr' + fhr), document.getElementById('hr' + eval(1 + eval('' + fhr)))).replace('<div ','<div onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' class=vertical ');
} else {
document.getElementById(into).innerHTML+='<div onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' class=vertical style="' + dval + 'position:absolute;top:' + eval(toff + eval('' + thisrect.top)) + 'px;left:' + eval(loff + eval('' + thisrect.left)) + 'px;"></div>';
}
hrcnt++;
}
if (itds < 5) {
dval='';
if (inquestion != '') {
if ((inquestion + ',').indexOf('r' + hrcnt + ',') == -1 && ('' + location.hash).indexOf('grid') == -1) { dval="display:none;visibility:hidden;"; }
}
document.getElementById(into).innerHTML+='<hr onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + dval + 'width:100px;position:absolute;top:' + thisrect.top + 'px;left:' + thisrect.left + 'px;"></hr>';
hrcnt++;
}
//document.getElementById(into).innerHTML+='<hr onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' class=vertical style="' + dval + 'position:absolute;top:' + thisrect.top + 'px;left:' + eval(eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px',''))) + 'px;"></hr>';
dval='';
if (inquestion != '') {
if ((inquestion + ',').indexOf('r' + hrcnt + ',') == -1 && ('' + location.hash).indexOf('grid') == -1) { dval="display:none;visibility:hidden;"; }
}
if (!isIE) {
//alert(document.getElementById('hr' + fhr).outerHTML + ' to ' + document.getElementById('hr' + eval(1 + eval('' + fhr))).outerHTML + ' is ' + connect(document.getElementById('hr' + fhr), document.getElementById('hr' + eval(1 + eval('' + fhr)))).replace('<div ','<div onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' class=vertical '));
document.getElementById(into).innerHTML+=connect(document.getElementById('hr' + eval(3 + eval('' + fhr))), document.getElementById('hr' + eval(2 + eval('' + fhr)))).replace('<div ','<div onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' class=vertical ');
} else {
document.getElementById(into).innerHTML+='<div onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' class=vertical style="' + dval + 'position:absolute;top:' + eval(toff + eval('' + thisrect.top)) + 'px;left:' + eval(loff + eval(('' + thisrect.left).replace('px','')) + eval(('' + thisrect.width).replace('px',''))) + 'px;"></div>';
}
hrcnt++;
dval='';
if (inquestion != '') {
if ((inquestion + ',').indexOf('r' + hrcnt + ',') == -1 && ('' + location.hash).indexOf('grid') == -1) { dval="display:none;visibility:hidden;"; }
}
document.getElementById(into).innerHTML+='<hr onclick="hrclick(this);" ' + tprefix + 'title=hr' + hrcnt + ' id=hr' + hrcnt + ' style="' + dval + 'width:100px;position:absolute;top:' + eval(eval(('' + thisrect.top).replace('px','')) + eval(('' + thisrect.height).replace('px',''))) + 'px;left:' + thisrect.left + 'px;"></hr>';
hrcnt++;
dval='';
}
onld=false;
dval='';
if (('' + location.hash).indexOf('grid') != -1) { document.getElementById('mytable').style.marginTop='8px'; document.getElementById('mytable').style.marginLeft='3px'; }
if (inquestion.indexOf('.') != -1) {
var xinas=inquestion.split(',');
for (ix=0; ix<xinas.length; ix++) {
if (xinas[ix].indexOf('.') != -1) {
hrclick(document.getElementById('hr' + xinas[ix].split('.')[0].replace('-','').replace('dr','').replace('hr','')));
hrclick(document.getElementById('hr' + xinas[ix].split('.')[1].replace('-','').replace('dr','').replace('hr','')));
}
}
}
document.getElementById('myh3').innerHTML = document.getElementById('myh3').innerHTML.replace(" - ","<select id=selmode style=width:35px; onclick=socwc(event); ontouchmove=socwc(event); onmousemove=socwc(event); onchange=selc(this.value);><option value=" + document.URL.split('#')[0] + location.hash + "> - </option><option value=" + (document.URL.split('#')[0].split('?')[0] + 'l').replace('.htmll','.html') + ">Tracing Square Line Drawing</option> <option value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + ">Chinese Brain Twisters</option><option id=paxes value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + "#blank=plot>Plot Axes - Linear or Polynomial Equation</option><option id=columns value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + "#blank=column>Column or Line or Area or Bar Graph</option><option id=iosos value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + "#blank>Vertex Pointing or SOS (for two) Game or Memories Card Game</option><option value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + "#square>Square Pointing Game</option><option value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + "#grid>Grid Pointing Game</option><option value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + "#hangman>Hangman Game</option><option value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + "#mathsgrid#hangman>Maths Grid Paper</option><option value=" + document.URL.split('#')[0].split('?')[0].replace('.html','.htm') + "#reveal#hangman>Image Reveal Game or Image Guillotine Jigsaw Map</option></select>");
inas=inanswer.split(',');
if (inas.length > 0) {
setTimeout(acl, 2000);
}
if (wourx != '' && wourx.indexOf('=column') == -1 && wourx.indexOf('=plot') == -1 && document.getElementById('selmode')) {
var rectw=document.getElementById('selmode').getBoundingClientRect();
//alert(wourx);
//alert(eval(eval('' + wourx) - eval('' + rectw.left)));
//document.title+=' ' + eval(eval('' + wourx) - eval('' + rectw.left));
if (eval(eval('' + wourx) - eval('' + rectw.left)) <= 20) { wourx=''; }
}
if (wourx != '' && wourx.indexOf('=column') == -1 && wourx.indexOf('=plot') == -1 && (' ' + location.hash).indexOf('blank') != -1) {
osft=' or SOS (for two) or Memories Card';
document.getElementById('qh4').innerHTML=document.getElementById('qh4').innerHTML.replace(' Game', osft + ' Game');
//alert(wourx);
setTimeout(presosize,2000);
}
sqorig=document.getElementById('qh4').innerHTML;
if (('' + location.hash).indexOf('square') != -1) { picksq(); }
if ((('' + location.hash).indexOf('hangman0.0') != -1 || ('' + location.hash).indexOf('hangman00.0') != -1) && document.URL.indexOf('?wording=') != -1) {
sqorig=sqorig; //alert('Grid Paper');
} else if (('' + location.hash).indexOf('hangman') != -1) {
playhangman();
}
//alert(document.getElementById('qh4').innerHTML);
sqorig=sqorig.replace('Pointing Game', 'Pointing <a onclick="osft=' + "'" + ' or SOS (for two)=' + "'" + '; sosize(' + "''" + ');" style=text-decoration:underline;cursor:pointer;>or SOS (for two)</a> <a onclick="osft=' + "'" + ' or Memories Card=' + "'" + '; sosize(' + "''" + ');" style=text-decoration:underline;cursor:pointer;>or Memories Card</a> Game');
document.getElementById('qh4').innerHTML=document.getElementById('qh4').innerHTML.replace('Pointing Game', 'Pointing <a onclick="osft=' + "'" + ' or SOS (for two)=' + "'" + '; sosize(' + "''" + ');" style=text-decoration:underline;cursor:pointer;>or SOS (for two)</a> <a onclick="osft=' + "'" + ' or Memories Card=' + "'" + '; sosize(' + "''" + ');" style=text-decoration:underline;cursor:pointer;>or Memories Card</a> Game');
//alert(document.getElementById('qh4').innerHTML);
if (('' + location.hash).replace(/\%7C/g,'|').indexOf('=plot|') != -1) {
//alert(0);
var pbits=('' + location.hash).replace(/\%7C/g,'|').split('|');
for (var ipbits=1; ipbits<pbits.length; ipbits++) {
//alert(ipbits);
if (pbits[ipbits].indexOf(',') != -1) {
//alert(pbits[ipbits]);
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=(pbits[ipbits] + '|');
if (!document.getElementById('ashare')) {
document.getElementById('myh1').innerHTML='<a onclick=emailit(); style=cursor:pointer;display:inline-block;text-decoration:underline; id=ashare>Email </a>Plot Axes - Linear or Polynomial Equation';
} else {
document.getElementById('ashare').style.display='inline-block';
}
preplot(pbits[ipbits]);
}
}
} else if (decodeURIComponent('' + location.hash).replace(/\%7C/g,'|').indexOf('=column|') != -1) {
if (decodeURIComponent('' + location.hash).replace(/\%7C/g,'|').indexOf('|Line|') != -1) {
document.getElementById('h1column').innerHTML='Line';
document.getElementById('graphsel').value='Line';
if (document.getElementById('h1col')) { document.getElementById('h1col').innerHTML='Area'; }
} else if (decodeURIComponent('' + location.hash).replace(/\%7C/g,'|').indexOf('|Bar|') != -1) {
document.getElementById('h1column').innerHTML='Bar';
document.getElementById('graphsel').value='Bar';
if (document.getElementById('h1col')) { document.getElementById('h1col').innerHTML='Bar'; }
} else if (decodeURIComponent('' + location.hash).replace(/\%7C/g,'|').indexOf('|Area|') != -1) {
document.getElementById('h1column').innerHTML='Area';
document.getElementById('graphsel').value='Area';
if (document.getElementById('h1col')) { document.getElementById('h1col').innerHTML='Area'; }
}
if (document.getElementById('h1column').innerHTML == 'Line') {
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Column%20Graph%','Line%20Graph%');
aem=document.getElementById('aemail').href;
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=('Line|');
} else if (document.getElementById('h1column').innerHTML == 'Area') {
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Column%20Graph%','Area%20Graph%');
aem=document.getElementById('aemail').href;
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=('Area|');
} else if (document.getElementById('h1column').innerHTML == 'Bar') {
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Column%20Graph%','Bar%20Graph%');
aem=document.getElementById('aemail').href;
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=('Bar|');
} else {
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Line%20Graph%','Column%20Graph%');
aem=document.getElementById('aemail').href;
}
//alert(0);
// http://localhost:8888/square_hr_tracing.htm#blank=column|ngfh,2,234,675|Country;Currency|Great%3Cbr%3EBritain;456|hgfjhfg;427|
var pbits=('' + location.hash + (location.search.split('blank=')[1] ? decodeURIComponent(location.search.split('blank=')[1].split('&')[0]) : '')).replace(/\%7C/g,'|').replace(/\%3Cbr\%3E/g,'~').replace(/\%7E/g,'~').split('|');
var uptocoords=0, ijk=0, aijk, cijk='';
for (var ipbits=1; ipbits<pbits.length; ipbits++) {
//alert(ipbits);
//alert(pbits[ipbits]);
if (decodeURIComponent(pbits[ipbits]).indexOf(';') != -1) { uptocoords=true; }
if (decodeURIComponent(pbits[ipbits]).indexOf(',') != -1 || decodeURIComponent(pbits[ipbits]).indexOf(';') != -1) {
if (decodeURIComponent(pbits[ipbits]).indexOf(';') != -1 && uptocoords && document.getElementById('h1column').innerHTML == 'Bar') {
aijk=decodeURIComponent(pbits[ipbits]).split(';');
cijk=aijk[1] + ';' + aijk[0];
for (ijk=2; ijk<aijk.length; ijk++) {
cijk+=';' + aijk[ijk];
}
}
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=(pbits[ipbits] + '|');
if (cijk != '') { pbits[ipbits]=cijk; cijk=''; }
if (!document.getElementById('ashare')) {
document.getElementById('myh1').innerHTML='<a onclick=emailit(); style=cursor:pointer;display:inline-block;text-decoration:underline; id=ashare>Email </a><span id=h1column style=display:inline-block;>Column</span> Graph';
} else {
document.getElementById('ashare').style.display='inline-block';
}
preplot(decodeURIComponent(pbits[ipbits]));
//alert(pbits[ipbits]);
} else if (decodeURIComponent(pbits[ipbits]).toLowerCase() == 'line') {
document.getElementById('h1column').innerHTML='Line';
document.getElementById('graphsel').value='Line';
if (document.getElementById('h1col')) { document.getElementById('h1col').innerHTML='Line'; }
//emeq='line';
}
}
} else if (decodeURIComponent('' + location.hash).replace(/\%7C/g,'|').indexOf('|Line|') != -1) {
document.getElementById('h1column').innerHTML='Line';
document.getElementById('graphsel').value='Line';
if (document.getElementById('h1col')) { document.getElementById('h1col').innerHTML='Line'; }
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Column%20Graph%','Line%20Graph%');
aem=document.getElementById('aemail').href;
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=('Line|');
} else if (decodeURIComponent('' + location.hash).replace(/\%7C/g,'|').indexOf('|Area|') != -1) {
document.getElementById('h1column').innerHTML='Area';
document.getElementById('graphsel').value='Area';
if (document.getElementById('h1col')) { document.getElementById('h1col').innerHTML='Area'; }
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Column%20Graph%','Area%20Graph%');
aem=document.getElementById('aemail').href;
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=('Area|');
} else if (decodeURIComponent('' + location.hash).replace(/\%7C/g,'|').indexOf('|Bar|') != -1) {
document.getElementById('h1column').innerHTML='Bar';
document.getElementById('graphsel').value='Bar';
if (document.getElementById('h1col')) { document.getElementById('h1col').innerHTML='Bar'; }
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Column%20Graph%','Bar%20Graph%');
aem=document.getElementById('aemail').href;
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=('Bar|');
}
}
function changegtypeto(tv) {
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=(tv + '|');
document.getElementById('graphsel').value=tv;
document.getElementById('h1column').innerHTML=tv;
if (tv == 'Line') {
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Column%20Graph%','Line%20Graph%');
aem=document.getElementById('aemail').href;
if (eqplotsuffix == '') { eqplotsuffix='|'; }
eqplotsuffix+=('Line|');
} else {
document.getElementById('aemail').href=document.getElementById('aemail').href.replace('Line%20Graph%','Column%20Graph%');
aem=document.getElementById('aemail').href;
}
if ( document.getElementById('h1col')) { document.getElementById('h1col').innerHTML=tv; }
var lh=('' + location.hash);
for (var ii=1; ii<=2; ii++) {
if (tv != 'Line' && decodeURIComponent(lh).indexOf('|Line|') != -1) {
if (document.URL.indexOf('?') != -1) {
location.href=document.URL.split('#')[0] + '&rand=' + Math.floor(Math.random() * 12345678) + lh.replace(/\%7CLine\%7C/g,'%7C' + tv + '%7C').replace(/\|Line\|/g,'|' + tv + '|');
} else {
location.href=document.URL.split('#')[0] + '?rand=' + Math.floor(Math.random() * 12345678) + lh.replace(/\%7CLine\%7C/g,'%7C' + tv + '%7C').replace(/\|Line\|/g,'|' + tv + '|');
}
} else if (tv != 'Area' && decodeURIComponent(lh).indexOf('|Area|') != -1) {
if (document.URL.indexOf('?') != -1) {
location.href=document.URL.split('#')[0] + '&rand=' + Math.floor(Math.random() * 12345678) + lh.replace(/\%7CArea\%7C/g,'%7C' + tv + '%7C').replace(/\|Area\|/g,'|' + tv + '|');
} else {
location.href=document.URL.split('#')[0] + '?rand=' + Math.floor(Math.random() * 12345678) + lh.replace(/\%7CArea\%7C/g,'%7C' + tv + '%7C').replace(/\|Area\|/g,'|' + tv + '|');
}
} else if (tv != 'Bar' && decodeURIComponent(lh).indexOf('|Bar|') != -1) {
if (document.URL.indexOf('?') != -1) {
location.href=document.URL.split('#')[0] + '&rand=' + Math.floor(Math.random() * 12345678) + lh.replace(/\%7CBar\%7C/g,'%7C' + tv + '%7C').replace(/\|Bar\|/g,'|' + tv + '|');
} else {
location.href=document.URL.split('#')[0] + '?rand=' + Math.floor(Math.random() * 12345678) + lh.replace(/\%7CBar\%7C/g,'%7C' + tv + '%7C').replace(/\|Bar\|/g,'|' + tv + '|');
}
} else if (tv != 'Column' && decodeURIComponent(lh).indexOf('|Column|') != -1) {
if (document.URL.indexOf('?') != -1) {
location.href=document.URL.split('#')[0] + '&rand=' + Math.floor(Math.random() * 12345678) + lh.replace(/\%7CColumn\%7C/g,'%7C' + tv + '%7C').replace(/\|Column\|/g,'|' + tv + '|');
} else {
location.href=document.URL.split('#')[0] + '?rand=' + Math.floor(Math.random() * 12345678) + lh.replace(/\%7CColumn\%7C/g,'%7C' + tv + '%7C').replace(/\|Column\|/g,'|' + tv + '|');
}
} else if (tv != 'Column' && decodeURIComponent(lh).indexOf('=column') != -1) {
if (decodeURIComponent(eqplotsuffix).indexOf('|') != -1 && decodeURIComponent(eqplotsuffix).indexOf(';') != -1 && ii == 1) {
ii=ii;
} else {
if (document.URL.indexOf('?') != -1) {
location.href=document.URL.split('#')[0] + '&rand=' + Math.floor(Math.random() * 12345678) + (lh + '|' + tv + '|');
} else {
location.href=document.URL.split('#')[0] + '?rand=' + Math.floor(Math.random() * 12345678) + (lh + '|' + tv + '|');
}
}
}
if (decodeURIComponent(eqplotsuffix).indexOf('|') != -1 && decodeURIComponent(eqplotsuffix).indexOf(';') != -1) {
lh='#blank=column' + eqplotsuffix;
//alert(lh);
} else {
lh="";
}
}
}
function presosize() {
sosize('');
}
function myguess() {
var myg=prompt('Okay, Player' + eval(3 - thisplayer) + ', what is your guess regarding the contents of the image as it is being revealed?', '');
if (myg == null) { myg=''; }
var mygx=confirm('Okay, Player' + thisplayer + ', is Player' + eval(3 - thisplayer) + ' guess of ' + myg + ' a correct guess?');
if (mygx) {
//alert('score' + eval(3 - thisplayer) + '+=' + availablescore);
eval('sparescore=eval(score' + eval(3 - thisplayer) + '.split("(")[1].split(")")[0])');
sparescore+=availablescore
eval('score' + eval(3 - thisplayer) + '=" (' + sparescore + ')"');
//document.getElementById('myh4').innerHTML+=' ... image of Player1' + score1 + ' versus <a onclick=myguess(); style=text-decoration:underline;cursor:pointer;>guess</a> of Player2' + score2;
thisplayer=eval(3 - thisplayer);
sosize(' '); // sosize('word_wrap.jpg');
}
}
function readUBlob(inimis,xis,yis) {
if (jigsaw) {
//document.getElementById('jigsaw').innerHTML='<img id=ijigsaw src="' + inimis + '" style="z-index:100;position:absolute;left:' + document.getElementById('jigsaw').style.left + ';top:' + document.getElementById('jigsaw').style.top + ';" onclick="alert(65);"></img>';
document.getElementById('jigsaw').innerHTML='<img id=ijigsaw src="' + inimis + '" style="opacity:0.8;z-index:100;" title="Click top left then bottom right of rectangle area to map" ontouchmove="xyi(event,2);" onmousemove="xyi(event,1);" onclick="xyi(event,0);"></img>';
var ri=document.getElementById('ijigsaw').getBoundingClientRect();
wh=(' width="' + ('' + ri.width).replace('px','') + '" height="' + ('' + ri.height).replace('px','') + '"').replace(' width="0" height="0"','');
document.getElementById('ijigsaw').addEventListener("touchstart",function(event){});
//alert(document.getElementById('jigsaw').outerHTML);
if (document.getElementById('djigsaw').innerHTML.indexOf('<textarea') == -1) {
document.getElementById('djigsaw').innerHTML=' <form target="iemail" style="inline-block;" action="//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php" method="POST"><input type=hidden style=display:inline-block; name=subj value="Image Map HTML Email Attachment"></input><span style="width:50%;float:right;">Click for image map below, and <a style=text-decoration:underline;cursor:pointer; onclick="document.getElementById(' + "'" + 'dc' + "'" + ').style.zIndex=pit(' + "'" + '300' + "'" + ');" class=ev>editable version</a> way below ...' + emailb + '</span><br><br><textarea name=hcont style="font-size:8px;z-index:120;float:right;" value="" onclick="woit(this.innerHTML);" id=tdhuhta cols=160 rows=4><HTML><body><map id="mijigsaw" name="mijigsaw">' + String.fromCharCode(10) + '<area shape="default" nohref alt="" />' + String.fromCharCode(10) + '</map>' + String.fromCharCode(10) + '<img' + wh + ' style="z-index:100;" usemap="#mijigsaw" alt="click map" border="0" id="ijigsaw" src="' + inimis + '"></img></body></html></textarea></form><br><div style="width:100%;float:right;display:block;"> </div><br><div style="width:98%;float:right;font-size:10px;" onblur="fixta(prefixta(this.innerHTML)); this.style.zIndex=' + "'" + '1' + "'" + ';" id=dc contenteditable=true></div>';
//document.getElementById('myh4').style.position='absolute';
//document.getElementById('myh4').style.top='120px';
//document.getElementById('myh4').style.left='0px';
document.getElementById('myh4').innerHTML=' ';
}
} else if (inimis.trim() != '') {
document.getElementById('mytable').style.background="url('" + inimis.trim() + "')";
document.getElementById('dpf').style.display='none';
}
}
function process(infilecontents) {
if (infilecontents != null) {
//alert(99);
if (jigsaw) {
// alert(199);
//document.getElementById('jigsaw').innerHTML='<img id=ijigsaw src="' + inimis + '" style="z-index:100;position:absolute;left:' + document.getElementById('jigsaw').style.left + ';top:' + document.getElementById('jigsaw').style.top + ';" onclick="alert(65);"></img>';
var bti=btoa(infilecontents);
document.getElementById('jigsaw').innerHTML='<img id=ijigsaw src="data:image/png;base64,' + bti + '" style="opacity:0.8;z-index:100;" title="Click top left then bottom right of rectangle area to map" ontouchmove="xyi(event,2);" onmousemove="xyi(event,1);" onclick="xyi(event,0);"></img>';
var ri=document.getElementById('ijigsaw').getBoundingClientRect();
wh=(' width="' + ('' + ri.width).replace('px','') + '" height="' + ('' + ri.height).replace('px','') + '"').replace(' width="0" height="0"','');
if (document.getElementById('djigsaw').innerHTML.indexOf('<textarea') == -1) {
document.getElementById('djigsaw').innerHTML=' <form target="iemail" style="inline-block;" action="//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php" method="POST"><input type=hidden style=display:inline-block; name=subj value="Image Map HTML Email Attachment"></input><span style="width:50%;float:right;">Click for image map below, and <a style=text-decoration:underline;cursor:pointer; onclick="document.getElementById(' + "'" + 'dc' + "'" + ').style.zIndex=pit(' + "'" + '300' + "'" + ');" class=ev>editable version</a> way below ...' + emailb + '</span><br><br><textarea name=hcont style="font-size:8px;z-index:120;float:right;" value="" onclick="woit(this.innerHTML);" id=tdhuhta cols=160 rows=4><html><BODY><map id="mijigsaw" name="mijigsaw">' + String.fromCharCode(10) + '<area shape="default" nohref alt="" />' + String.fromCharCode(10) + '</map>' + String.fromCharCode(10) + '<img' + wh + ' style="z-index:100;" usemap="#mijigsaw" alt="click map" border="0" id="ijigsaw" src="' + 'data:image/png;base64,' + bti + '"></img></body></html>' + String.fromCharCode(10) + '</textarea></form><br><div style="width:100%;float:right;display:block;"> </div><br><div style="width:98%;float:right;font-size:10px;" onblur="fixta(prefixta(this.innerHTML)); this.style.zIndex=' + "'" + '1' + "'" + ';" id=dc contenteditable=true></div>';
}
document.getElementById('ijigsaw').addEventListener("touchstart",function(event){});
//alert(document.getElementById('jigsaw').outerHTML);
//document.getElementById('myh4').style.position='absolute';
//document.getElementById('myh4').style.top='120px';
//document.getElementById('myh4').style.left='0px';
document.getElementById('myh4').innerHTML=' ';
} else {
document.getElementById('mytable').style.backgroundImage="URL('data:image/png;base64," + btoa(infilecontents) + "')";
}
//alert(999);
document.getElementById('dpf').style.display='none';
//alert(9999);
}
}
function readBlob(opt_startByte, opt_stopByte) {
//alert(33);
var files = document.getElementById("file").files;
//alert(333);
if (!files.length) {
alert("Please select a file!");
return;
} else {
w = files[0].name;
//document.getElementById("fil").value = w;
}
var file = files[0];
var start = parseInt(opt_startByte) || 0;
var stop = parseInt(opt_stopByte) || file.size - 1;
//alert(stop);
var reader = new FileReader();
// If we use onloadend, we need to check the readyState.
reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
//alert(77);
process(evt.target.result);
//alert(777);
}
};
var blob = file.slice(start, stop + 1);
reader.readAsBinaryString(blob);
}
function eh() {
document.querySelector('.readBytesButtons').addEventListener('click', function(evt) {
//alert(2);
if (evt.target.tagName.toLowerCase() == 'button') {
var startByte = evt.target.getAttribute('data-startbyte');
var endByte = evt.target.getAttribute('data-endbyte');
//alert(22);
readBlob(startByte, endByte);
//alert(222);
}
}, false);
}
function latersrc() { // delayed scoring allowing for peek at second card picked by player
memcardio[1].src=memcard[1];
memcard[1]=memcard[1].split('/')[eval(-1 + memcard[1].split('/').length)];
if (memcard[0].substring(0,2) == memcard[1].substring(0,2)) {
memcardio[0].style.visibility='hidden';
memcardio[1].style.visibility='hidden';
memscores[eval(-1 + memplayer)]++;
memgoes[eval(-1 + memplayer)]++;
document.getElementById('qh4').innerHTML=preqh4 + 'Yay! <div style="display:inline-block;" contenteditable=true onchange="memnames[' + eval(-1 + memplayer) + ']=this.innerHTML;" onblur="memnames[' + eval(-1 + memplayer) + ']=this.innerHTML;">' + memnames[eval(-1 + memplayer)] + '</div> <sup>' + memscores[eval(-1 + memplayer)] + '/' + memgoes[eval(-1 + memplayer)] + '</sup> (vs ' + '<div style="display:inline-block;" contenteditable=true onchange="memnames[' + eval(1 - eval(memplayer - 1)) + ']=this.innerHTML;" onblur="memnames[' + eval(1 - eval(memplayer - 1)) + ']=this.innerHTML;">' + memnames[eval(1 - eval(memplayer - 1))] + '</div> <sup>' + memscores[eval(1 - eval(memplayer - 1))] + '/' + memgoes[eval(1 - eval(memplayer - 1))] + '</sup>) continue to try to pick pair(s)';
memturn=1;
if (eval(eval('' + memscores[0]) + eval('' + memscores[1])) >= 26) { alert(document.getElementById('qh4').textContent.split(' continue to try to pick pair(s)')[0] + ' ... ready for new game?').replace('Vertex Pointing or SOS (for two) or ',''); memories(''); }
} else {
memcardio[0].src=defcard;
memcardio[1].src=defcard;
memgoes[eval(-1 + memplayer)]++;
memplayer=eval(3 - memplayer);
document.getElementById('qh4').innerHTML=preqh4 + '<div style="display:inline-block;" contenteditable=true onchange="memnames[' + eval(-1 + memplayer) + ']=this.innerHTML;" onblur="memnames[' + eval(-1 + memplayer) + ']=this.innerHTML;">' + memnames[eval(-1 + memplayer)] + '</div> <sup>' + memscores[eval(-1 + memplayer)] + '/' + memgoes[eval(-1 + memplayer)] + '</sup> (vs ' + '<div style="display:inline-block;" contenteditable=true onchange="memnames[' + eval(1 - eval(memplayer - 1)) + ']=this.innerHTML;" onblur="memnames[' + eval(1 - eval(memplayer - 1)) + ']=this.innerHTML;">' + memnames[eval(1 - eval(memplayer - 1))] + '</div> <sup>' + memscores[eval(1 - eval(memplayer - 1))] + '/' + memgoes[eval(1 - eval(memplayer - 1))] + '</sup>) to try to pick pair(s)';
memturn=1;
}
}
function thissrc(imgio, cardurl) { // on a player click of a card
if (memturn == 1) {
memcardio[0]=imgio;
memcard[0]=cardurl.split('/')[eval(-1 + cardurl.split('/').length)];
imgio.src=cardurl;
memturn++;
} else {
memcardio[1]=imgio;
memcard[1]=cardurl; //.split('/')[eval(-1 + cardurl.split('/').length)];
imgio.src=cardurl;
if (1 == 1) {
setTimeout(latersrc, 1500);
} else {
if (memcard[0].substring(0,2) == cardurl.split('/')[eval(-1 + cardurl.split('/').length)].substring(0,2)) {
memcardio[0].style.visibility='hidden';
memcardio[1].style.visibility='hidden';
memscores[eval(-1 + memplayer)]++;
memgoes[eval(-1 + memplayer)]++;
document.getElementById('qh4').innerHTML=preqh4 + 'Yay! <div style="display:inline-block;" contenteditable=true onchange="memnames[' + eval(-1 + memplayer) + ']=this.innerHTML;" onblur="memnames[' + eval(-1 + memplayer) + ']=this.innerHTML;">' + memnames[eval(-1 + memplayer)] + '</div> <sup>' + memscores[eval(-1 + memplayer)] + '/' + memgoes[eval(-1 + memplayer)] + '</sup> (vs ' + '<div style="display:inline-block;" contenteditable=true onchange="memnames[' + eval(1 - eval(memplayer - 1)) + ']=this.innerHTML;" onblur="memnames[' + eval(1 - eval(memplayer - 1)) + ']=this.innerHTML;">' + memnames[eval(1 - eval(memplayer - 1))] + '</div> <sup>' + memscores[eval(1 - eval(memplayer - 1))] + '/' + memgoes[eval(1 - eval(memplayer - 1))] + '</sup>) continue to try to pick pair(s)';
memturn=1;
} else {
memcardio[0].src=defcard;
memcardio[1].src=defcard;
memgoes[eval(-1 + memplayer)]++;
memplayer=eval(3 - memplayer);
document.getElementById('qh4').innerHTML=preqh4 + '<div style="display:inline-block;" contenteditable=true onchange="memnames[' + eval(-1 + memplayer) + ']=this.innerHTML;" onblur="memnames[' + eval(-1 + memplayer) + ']=this.innerHTML;">' + memnames[eval(-1 + memplayer)] + '</div> <sup>' + memscores[eval(-1 + memplayer)] + '/' + memgoes[eval(-1 + memplayer)] + '</sup> (vs ' + '<div style="display:inline-block;" contenteditable=true onchange="memnames[' + eval(1 - eval(memplayer - 1)) + ']=this.innerHTML;" onblur="memnames[' + eval(1 - eval(memplayer - 1)) + ']=this.innerHTML;">' + memnames[eval(1 - eval(memplayer - 1))] + '</div> <sup>' + memscores[eval(1 - eval(memplayer - 1))] + '/' + memgoes[eval(1 - eval(memplayer - 1))] + '</sup>) to try to pick pair(s)';
memturn=1;
}
}
}
}
function memories(inim) { // draw memories card 52 cards into 10 x 10 grid
//alert(osft);
var itds=0; tds=document.getElementsByTagName('td');
var sqsi=0, ioffset=0, bextras='', s1=0, s2=0, ainim=inim;
var ii, jj, mm, kk=0, nn=0, found=false, sqc=',-1,';
var beenhere=false;
if (inim == '') {
memplayer=1;
memturn=1;
memscores = [0, 0];
memgoes = [0, 0];
usedcards = [];
deckcards = [];
of100 = [];
if (preqh4 == '') {
document.getElementById('myh1').innerHTML='Memories Card Game';
document.getElementById('myh4').innerHTML=' ';
document.getElementById('daxes').innerHTML+='<style> hr.vertex { visibility:hidden; } </style>';
document.getElementById('qh4').innerHTML=document.getElementById('qh4').innerHTML.replace('On Each Set of 4 a Bezier Curve is Shown',memnames[0] + ' (vs ' + memnames[1] + ') go to find pair(s)');
preqh4=document.getElementById('qh4').innerHTML.split(memnames[0] + ' (vs ' + memnames[1] + ') go to find pair(s)')[0];
} else {
beenhere=true;
document.getElementById('qh4').innerHTML=preqh4 + memnames[0] + ' (vs ' + memnames[1] + ') go to find pair(s)';
}
for (ii=0; ii<52; ii++) {
found = true;
mm=-1;
while (sqc.indexOf(',' + mm + ',') != -1) {
mm = Math.floor((Math.random()*100)+0);
}
sqc+='' + mm + ',';
while (found) {
mm = Math.floor((Math.random()*52)+0);
found = false;
for (jj=0; jj<usedcards.length; jj++) {
if (usedcards[jj] == mypictures[mm]) found = true;
}
}
deckcards[kk] = mypictures[mm];
usedcards[kk] = mypictures[mm];
kk = kk+1;
}
usedcards = [];
of100=sqc.replace(',-1,','').split(',');
}
var typicalrect=tds[0].getBoundingClientRect();
for (var itrs=0; itrs<5; itrs++) {
for (var itds=eval(5 * itrs); itds<eval(5 + eval(5 * itrs)); itds++) {
thisrect=tds[itds].getBoundingClientRect();
if (beenhere) { tds[itds].innerHTML=''; }
tds[itds].style.verticalAlign='top';
sqsi=eval(2 * itds + ioffset);
if (inim == '') {
if (sqc.indexOf(',' + nn + ',') != -1) {
mm=eval(-1 + sqc.split(',' + nn + ',')[0].replace('-1,','').split(',').length);
tds[itds].innerHTML+='<img style="' + 'height:' + eval(eval('' + typicalrect.height) / 2) + 'px;width:' + eval(eval('' + typicalrect.width) / 2) + 'px;top:' + thisrect.top + 'px;left:' + thisrect.left + 'px;' + '" onclick="thissrc(this,' + "'" + deckcards[mm] + "'" + ');" data-title="' + deckcards[mm] + '" src="' + defcard + '"></img>';
}
nn++;
if (sqc.indexOf(',' + nn + ',') != -1) {
mm=eval(-1 + sqc.split(',' + nn + ',')[0].replace('-1,','').split(',').length);
tds[itds].innerHTML+='<img style="' + 'height:' + eval(eval('' + typicalrect.height) / 2) + 'px;width:' + eval(eval('' + typicalrect.width) / 2) + 'px;top:' + thisrect.top + 'px;left:' + eval(eval('' + thisrect.left) + eval('' + typicalrect.width) / 2) + 'px;' + '" onclick="thissrc(this,' + "'" + deckcards[mm] + "'" + ');" data-title="' + deckcards[mm] + '" src="' + defcard + '"></img>';
}
nn++;
if (sqc.indexOf(',' + nn + ',') != -1) {
mm=eval(-1 + sqc.split(',' + nn + ',')[0].replace('-1,','').split(',').length);
tds[itds].innerHTML+='<img style="' + 'height:' + eval(eval('' + typicalrect.height) / 2) + 'px;width:' + eval(eval('' + typicalrect.width) / 2) + 'px;top:' + eval(eval('' + thisrect.top) + eval('' + typicalrect.height) / 2) + 'px;left:' + thisrect.left + 'px;' + '" onclick="thissrc(this,' + "'" + deckcards[mm] + "'" + ');" data-title="' + deckcards[mm] + '" src="' + defcard + '"></img>';
}
nn++;
if (sqc.indexOf(',' + nn + ',') != -1) {
mm=eval(-1 + sqc.split(',' + nn + ',')[0].replace('-1,','').split(',').length);
tds[itds].innerHTML+='<img style="' + 'height:' + eval(eval('' + typicalrect.height) / 2) + 'px;width:' + eval(eval('' + typicalrect.width) / 2) + 'px;top:' + eval(eval('' + thisrect.top) + eval('' + typicalrect.height) / 2) + 'px;left:' + eval(eval('' + thisrect.left) + eval('' + typicalrect.width) / 2) + 'px;' + '" onclick="thissrc(this,' + "'" + deckcards[mm] + "'" + ');" data-title="' + deckcards[mm] + '" src="' + defcard + '"></img>';
}
nn++;
}
}
ioffset+=10;
}
}
function woit(tav){
if (tav != '') {
var wo=window.open('', '_blank', 'top=50,left=50,width=600,height=600');
wo.document.write(tav.replace(/\<\;/g,'<').replace(/\>\;/g,'>'));
}
}
function pit(inval) {
var prevpv=document.getElementById('dc').innerHTML.replace(/\<\;/g,'<').replace(/\>\;/g,'>');
var pv=prompt('Edit Image Map ... prefixed Javascript <scr' + 'ipt> ... </scr' + 'ipt> welcome?', prevpv);
if (pv == null) { return '1'; }
if (pv != prevpv) { document.getElementById('dc').innerHTML=pv.replace(/\</g,'<').replace(/\>/g,'>\;'); fixta(prefixta(document.getElementById('dc').innerHTML)); inval='1'; }
return inval;
}
function sosize(inim) {
//var hors=[], vers=[], diags=[];
if (osft.indexOf('Memories') != -1 && osft.indexOf('SOS') == -1) {
memories(inim);
} else {
var itds=0; tds=document.getElementsByTagName('td');
var sqsi=0, ioffset=0, bextras='', s1=0, s2=0, ainim=inim;
if (inim != '') {
availablescore=100;
if (inim.trim() != '') {
inim=prompt('Okay, Player' + thisplayer + ' what is your image (to be revealed by Player' + eval(3 - thisplayer) + ') as a URL? Else if you answer with a blank you can browse for the image file.', inim);
}
eval('s1=score' + thisplayer);
eval('s2=score' + eval(3 - thisplayer));
//document.title+=' x';
document.getElementById('myh4').innerHTML='Enjoy your two player game of Image Revealing';
//document.title+=' y';
if (inim.trim() != '' && ainim.trim() != '') {
document.getElementById('myh4').innerHTML+=' ... image <div id=dpf style=display:NONE;><input style=display:inline-block; id=file type=file name=file></input><span class=readBytesButtons><button style=display:none; data-endbyte=4 data-startbyte=0>1-5</button><button style=display:none; data-endbyte=14 data-startbyte=5>6-15</button><button style=display:none; data-endbyte=7 data-startbyte=6>7-8</button><button name=button id=button value=Process data-endbyte=0 data-startbyte=0>Process</button></span> or URL <input id=vsiurl type=url onblur=readUBlob(this.value,0,0); value="' + inim.trim() + '"></input></div> of Player' + thisplayer + s1 + ' versus <a onclick=myguess(); style=text-decoration:underline;cursor:pointer;>guess</a> of Player' + eval(3 - thisplayer) + s2;
if (jigsaw) {
//document.getElementById('jigsaw').innerHTML='<img id=ijigsaw src="' + inimis + '" style="z-index:100;position:absolute;left:' + document.getElementById('jigsaw').style.left + ';top:' + document.getElementById('jigsaw').style.top + ';" onclick="alert(65);"></img>';
document.getElementById('jigsaw').innerHTML='<img id=ijigsaw src="' + inim + '" style="opacity:0.8;z-index:100;" title="Click top left then bottom right of rectangle area to map" ontouchmove="xyi(event,2);" onmousemove="xyi(event,1);" onclick="xyi(event,0);"></img>';
var ri=document.getElementById('ijigsaw').getBoundingClientRect();
wh=(' width="' + ('' + ri.width).replace('px','') + '" height="' + ('' + ri.height).replace('px','') + '"').replace(' width="0" height="0"','');
if (document.getElementById('djigsaw').innerHTML.indexOf('<textarea') == -1) {
document.getElementById('djigsaw').innerHTML=' <form target="iemail" style="inline-block;" action="//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php" method="POST"><input type=hidden style=display:inline-block; name=subj value="Image Map HTML Email Attachment"></input><span style="width:50%;float:right;">Click for image map below, and <a style=text-decoration:underline;cursor:pointer; onclick="document.getElementById(' + "'" + 'dc' + "'" + ').style.zIndex=pit(' + "'" + '300' + "'" + ');" class=ev>editable version</a> way below ...' + emailb + '</span><br><br><textarea name=hcont style="font-size:8px;z-index:120;float:right;" value="" onclick="woit(this.innerHTML);" id=tdhuhta cols=160 rows=4><HTML><BODY><map id="mijigsaw" name="mijigsaw">' + String.fromCharCode(10) + '<area shape="default" nohref alt="" />' + String.fromCharCode(10) + '</map>' + String.fromCharCode(10) + '<img' + wh + ' usemap="#mijigsaw" alt="click map" border="0" id="ijigsaw" src="' + inim + '"></img></body></html>' + String.fromCharCode(10) + '</textarea></form><br><div style="width:100%;float:right;display:block;"> </div><br><div style="width:98%;float:right;font-size:10px;" onblur="fixta(prefixta(this.innerHTML)); this.style.zIndex=' + "'" + '1' + "'" + ';" id=dc contenteditable=true></div>';
}
document.getElementById('ijigsaw').addEventListener("touchstart",function(event){});
//alert(document.getElementById('jigsaw').outerHTML);
//document.getElementById('myh4').style.position='absolute';
//document.getElementById('myh4').style.top='120px';
//document.getElementById('myh4').style.left='0px';
document.getElementById('myh4').innerHTML=' ';
} else {
document.getElementById('mytable').style.background="url('" + inim + "')";
}
} else {
document.getElementById('myh4').innerHTML+=' ... image <div id=dpf style=display:INLINE-BLOCK;><input style=display:inline-block; id=file type=file name=file></input><span class=readBytesButtons><button style=display:none; data-endbyte=4 data-startbyte=0>1-5</button><button style=display:none; data-endbyte=14 data-startbyte=5>6-15</button><button style=display:none; data-endbyte=7 data-startbyte=6>7-8</button><button name=button id=button value=Process data-endbyte=0 data-startbyte=0>Process</button></span> or URL <input id=vsiurl type=url onblur=readUBlob(this.value,0,0); value="' + inim.trim() + '"></input></div> of Player' + thisplayer + s1 + ' versus <a onclick=myguess(); style=text-decoration:underline;cursor:pointer;>guess</a> of Player' + eval(3 - thisplayer) + s2;
}
setTimeout(eh, 1000);
//document.title+=' z';
//document.getElementById('myh4').innerHTML+=' ... image of Player' + thisplayer + s1 + ' versus <a onclick=myguess(); style=text-decoration:underline;cursor:pointer;>guess</a> of Player' + eval(3 - thisplayer) + s2;
} else {
if (osft.indexOf('Memories') == -1 && osft.indexOf('SOS') != -1) { document.getElementById('myh1').innerHTML='SOS Game'; }
document.getElementById('myh4').innerHTML+=' ... turn of Player1' + score1 + ' versus Player2' + score2;
}
for (var itrs=0; itrs<5; itrs++) {
for (var itds=eval(5 * itrs); itds<eval(5 + eval(5 * itrs)); itds++) {
thisrect=tds[itds].getBoundingClientRect();
tds[itds].style.verticalAlign='top';
sqsi=eval(2 * itds + ioffset);
if (inim != '') {
if (itds == 0) {
document.getElementById('myh1').innerHTML='Image Reveal Game or <a id=anob onclick="nobuttons(); this.style.backgroundColor=' + "'green'" + ';" style=cursor:pointer;background-color:yellow;>Image Guillotine Jigsaw Map</a> <div id=xdjigsaw></div>';
document.getElementById('qh4').innerHTML=' ';
}
bextras='position:absolute;height:' + eval(eval('' + thisrect.height) / 2) + 'px;width:' + eval(eval('' + thisrect.width) / 2) + 'px;top:' + thisrect.top + 'px;left:' + thisrect.left + 'px;';
tds[itds].innerHTML='<button title="Click/touch me to reveal 1/100th of image below" class=reveal title="" style="' + bextras + 'display:inline-block;' + '" id=sqsisqsi' + sqsi + ' onclick=sosmove(this); value=" "> </button>';
//sqsi++;
bextras='position:absolute;height:' + eval(eval('' + thisrect.height) / 2) + 'px;width:' + eval(eval('' + thisrect.width) / 2) + 'px;top:' + thisrect.top + 'px;left:' + eval(eval('' + thisrect.left) + eval('' + thisrect.width) / 2) + 'px;';
tds[itds].innerHTML+='<button title="Click/touch me to reveal 1/100th of image below" class=reveal title="" style="' + bextras + 'display:inline-block;' + '" id=sqsisqsi' + eval(1 + sqsi) + ' onclick=sosmove(this); value=" "> </button>';
//sqsi++;
bextras='position:absolute;height:' + eval(eval('' + thisrect.height) / 2) + 'px;width:' + eval(eval('' + thisrect.width) / 2) + 'px;top:' + eval(eval('' + thisrect.top) + eval('' + thisrect.height) / 2) + 'px;left:' + thisrect.left + 'px;';
tds[itds].innerHTML+='<button title="Click/touch me to reveal 1/100th of image below" class=reveal title="" style="' + bextras + 'display:inline-block;' + '" id=sqsisqsi' + eval(10 + sqsi) + ' onclick=sosmove(this); value=" "> </button>';
//sqsi++;
bextras='position:absolute;height:' + eval(eval('' + thisrect.height) / 2) + 'px;width:' + eval(eval('' + thisrect.width) / 2) + 'px;top:' + eval(eval('' + thisrect.top) + eval('' + thisrect.height) / 2) + 'px;left:' + eval(eval('' + thisrect.left) + eval('' + thisrect.width) / 2) + 'px;';
tds[itds].innerHTML+='<button title="Click/touch me to reveal 1/100th of image below" class=reveal title="" style="' + bextras + 'display:inline-block;' + '" id=sqsisqsi' + eval(11 + sqsi) + ' onclick=sosmove(this); value=" "> </button>';
} else {
//alert(sqsi);
tds[itds].innerHTML='<select title="" style=vertical-align:top;width:50%;height:50%;text-align:center; size=3 id=sqsi' + sqsi + ' onchange=sosmove(this);><option value=" "> </option><option value="S">S</option><option value="O">O</option></select>';
//sqsi++;
tds[itds].innerHTML+='<select title="" style=vertical-align:top;width:50%;height:50%;text-align:center; size=3 id=sqsi' + eval(1 + sqsi) + ' onchange=sosmove(this);><option value=" "> </option><option value="S">S</option><option value="O">O</option></select>';
//sqsi++;
tds[itds].innerHTML+='<br><select title="" style=vertical-align:bottom;width:50%;height:50%;text-align:center; size=3 id=sqsi' + eval(10 + sqsi) + ' onchange=sosmove(this);><option value=" "> </option><option value="S">S</option><option value="O">O</option></select>';
//sqsi++;
tds[itds].innerHTML+='<select title="" style=vertical-align:bottom;width:50%;height:50%;text-align:center; size=3 id=sqsi' + eval(11 + sqsi) + ' onchange=sosmove(this);><option value=" "> </option><option value="S">S</option><option value="O">O</option></select>';
//sqsi++;
//alert(tds[itds].innerHTML);
}
}
ioffset+=10;
}
}
}
function checkifsos(t1, t2, t3) { //, camv) {
//var score1=' (0)', score2=' (0)';
//var amv=camv.split('.')[0];
var retv=false;
if (t1 >= 0 && t1 < 100 && t2 >= 0 && t2 < 100 && t3 >= 0 && t3 < 100) {
if (document.getElementById('sqsi' + t1).value == 'S' && document.getElementById('sqsi' + t2).value == 'O' && document.getElementById('sqsi' + t3).value == 'S') {
if (thisplayer == 1) {
document.getElementById('sqsi' + t1).style.border='1px inset red';
document.getElementById('sqsi' + t2).style.border='1px inset red';
document.getElementById('sqsi' + t3).style.border='1px inset red';
if (document.getElementById('sqsi' + t1).title.indexOf('2') != -1) {
document.getElementById('sqsi' + t1).style.backgroundColor='';
document.getElementById('sqsi' + t1).className='bicol'; //style.backgroundColor="linear-gradient(top, pink, yellow)";
} else {
document.getElementById('sqsi' + t1).style.backgroundColor='pink';
}
if (document.getElementById('sqsi' + t2).title.indexOf('2') != -1) {
document.getElementById('sqsi' + t2).style.backgroundColor='';
document.getElementById('sqsi' + t2).className='bicol'; //style.backgroundColor="linear-gradient(top, pink, yellow)";
} else {
document.getElementById('sqsi' + t2).style.backgroundColor='pink';
}
if (document.getElementById('sqsi' + t3).title.indexOf('2') != -1) {
document.getElementById('sqsi' + t3).style.backgroundColor='';
document.getElementById('sqsi' + t3).className='bicol'; //style.backgroundColor="linear-gradient(top, pink, yellow)";
} else {
document.getElementById('sqsi' + t3).style.backgroundColor='pink';
}
document.getElementById('sqsi' + t1).title+='1';
document.getElementById('sqsi' + t2).title+='1';
document.getElementById('sqsi' + t3).title+='1';
} else {
document.getElementById('sqsi' + t1).style.border='1px inset olive';
document.getElementById('sqsi' + t2).style.border='1px inset olive';
document.getElementById('sqsi' + t3).style.border='1px inset olive';
if (document.getElementById('sqsi' + t1).title.indexOf('1') != -1) {
document.getElementById('sqsi' + t1).style.backgroundColor='';
document.getElementById('sqsi' + t1).className='bicol'; //style.backgroundColor="linear-gradient(top, pink, yellow)";
} else {
document.getElementById('sqsi' + t1).style.backgroundColor='yellow';
}
if (document.getElementById('sqsi' + t2).title.indexOf('1') != -1) {
document.getElementById('sqsi' + t2).style.backgroundColor='';
document.getElementById('sqsi' + t2).className='bicol'; //style.backgroundColor="linear-gradient(top, pink, yellow)";
} else {
document.getElementById('sqsi' + t2).style.backgroundColor='yellow';
}
if (document.getElementById('sqsi' + t3).title.indexOf('1') != -1) {
document.getElementById('sqsi' + t3).style.backgroundColor='';
document.getElementById('sqsi' + t3).className='bicol'; //style.backgroundColor="linear-gradient(top, pink, yellow)";
} else {
document.getElementById('sqsi' + t3).style.backgroundColor='yellow';
}
document.getElementById('sqsi' + t1).title+='2';
document.getElementById('sqsi' + t2).title+='2';
document.getElementById('sqsi' + t3).title+='2';
}
retv=true;
if (thisplayer == 1) {
score1=' (' + eval(eval(score1.split('(')[1].split(')')[0]) + 1) + ')';
} else {
score2=' (' + eval(eval(score2.split('(')[1].split(')')[0]) + 1) + ')';
}
}
}
return retv;
}
function sosmove(osel) {
if (osel.id.indexOf('sqsisqsi') != -1) {
availablescore--;
osel.style.visibility='hidden';
if (availablescore == 0) {
myguess();
}
} else {
var cosel=osel.value, anothergo=false, prevplayer=thisplayer;
var thistile=eval(osel.id.replace('sqsi',''));
var surrounds='';
var prevscore1=score1;
var prevscore2=score2;
if (cosel.trim() != '') {
osel.size=1;
osel.style.border='1px inset blue';
osel.innerHTML='<option value=' + cosel + '>' + cosel + '</option>';
document.getElementById('myh4').innerHTML=document.getElementById('myh4').innerHTML.replace(' Player1' + score1 + ' versus Player2' + score2,' Player02' + score2 + ' versus Player01' + score1).replace(' Player2' + score2 + ' versus Player1' + score1,' Player01' + score1 + ' versus Player02' + score2).replace(' Player0',' Player').replace(' Player0',' Player');
// hmiddle -1 me +1
// hend -2 -1 me
// hstart me +1 +2
// vmiddle -10 me +10
// vend -20 -10 me
// vstart me +10 +20
// ddmiddle -11 me +11
// ddend -22 -11 me
// ddstart me +11 +22
// udmiddle -9 me +9
// udend -18 -9 me
// udstart me +9 +18
if (eval(thistile % 10) > 0 && eval(thistile % 10) < 9) {
anothergo|=checkifsos(eval(-1 + thistile), thistile, eval(1 + thistile));
}
if (eval(thistile % 10) > 1) {
anothergo|=checkifsos(eval(-2 + thistile), eval(-1 + thistile), thistile);
}
if (eval(thistile % 10) < 8) {
anothergo|=checkifsos(thistile, eval(1 + thistile), eval(2 + thistile));
}
if (eval(thistile / 10) > 0 && eval(thistile / 10) < 9) {
anothergo|=checkifsos(eval(-10 + thistile), thistile, eval(10 + thistile));
}
if (eval(thistile / 10) > 1) {
anothergo|=checkifsos(eval(-20 + thistile), eval(-10 + thistile), thistile);
}
if (eval(thistile / 10) < 8) {
anothergo|=checkifsos(thistile, eval(10 + thistile), eval(20 + thistile));
}
if (eval(thistile % 10) > 0 && eval(thistile % 10) < 9 && eval(thistile / 10) > 0 && eval(thistile / 10) < 9) {
anothergo|=checkifsos(eval(-11 + thistile), thistile, eval(11 + thistile));
}
if (eval(thistile % 10) > 1 && eval(thistile / 10) > 2) {
anothergo|=checkifsos(eval(-22 + thistile), eval(-11 + thistile), thistile);
}
if (eval(thistile % 10) < 8 && eval(thistile / 10) < 8) {
anothergo|=checkifsos(thistile, eval(11 + thistile), eval(22 + thistile));
}
if (eval(thistile % 10) > 0 && eval(thistile % 10) < 9 && eval(thistile / 10) > 0 && eval(thistile / 10) < 9) {
anothergo|=checkifsos(eval(-9 + thistile), thistile, eval(9 + thistile));
}
if (eval(thistile % 10) >= 0 && eval(thistile / 10) < 8) {
anothergo|=checkifsos(eval(-18 + thistile), eval(-9 + thistile), thistile);
}
if (eval(thistile % 10) > 2 && eval(thistile / 10) < 8) {
anothergo|=checkifsos(thistile, eval(9 + thistile), eval(18 + thistile));
}
if (!anothergo) { thisplayer=eval(eval('' + 3) - eval('' + prevplayer)); } else { document.getElementById('myh4').innerHTML=document.getElementById('myh4').innerHTML.replace(' Player1' + prevscore1 + ' versus Player2' + prevscore2,' Player02' + score2 + ' versus Player01' + score1).replace(' Player2' + prevscore2 + ' versus Player1' + prevscore1,' Player01' + score1 + ' versus Player02' + score2).replace(' Player0',' Player').replace(' Player0',' Player'); }
}
}
}
function playhangman() {
if (vocabulary[0] == '') {
mode=5;
//alert('hangman');
document.getElementById('imyword').src='//www.rjmprogramming.com.au/PHP/surprise.php?min=' + eval(1 + 10) + '&max=' + eval(1 + 20) + '&phrase=y&youllneverfindthis=y' + Math.floor(Math.random() * 134567);
} else {
mode=5;
document.getElementById('imyword').src='//www.rjmprogramming.com.au/PHP/surprise.php?min=' + eval(1 + 10) + '&max=' + eval(1 + 20) + '&phrase=y&youllneverfindthis=y' + Math.floor(Math.random() * 134567);
//alert(vocabulary[0]);
}
}
function selc(tvi) {
asocwc();
if (courx != '') {
if (tvi.indexOf(courx) == -1 && tvi.indexOf('&') != -1) { tvi=tvi.replace('&', courx + '&'); } else if (tvi.indexOf(courx) == -1 && tvi.indexOf('#') != -1) { tvi=tvi + courx.split('=')[1]; }
}
if ((document.URL.split('#')[0] + location.hash) != tvi) { if (((' ' + location.hash).split('#').length > 2 || (' ' + location.hash).indexOf('hangman-0.0') != -1) || ('' + tvi).replace('hangman','blank').replace('vertex','blank').replace('#square','#blank').replace('#grid','#blank').indexOf('blank') != -1) { top.location.href=tvi; } else { location.href=tvi.replace('.htm#','.htm?rand=' + Math.floor(Math.random() * 123456) + '#').replace('.html#','.html?rand=' + Math.floor(Math.random() * 123456) + '#'); } }
}
function getOffset(el) { // thanks to https://stackoverflow.com/questions/8672369/how-to-draw-a-line-between-two-divs
var rect = el.getBoundingClientRect();
return {
left: rect.left + window.pageXOffset,
top: rect.top + window.pageYOffset,
width: rect.width || el.offsetWidth,
height: rect.height || el.offsetHeight
};
}
function connect(div1, div2) { //, color, thickness) { // draw a line connecting elements
var thickness = 0;
var titleextra="";
var ioff=-4;
if (!onld && 4 == 5) { ioff=0; }
var off1 = getOffset(div1);
var off2 = getOffset(div2);
// bottom right
var x1 = off1.left + off1.width;
var y1 = off1.top + off1.height;
// top right
var x2 = off2.left + off2.width;
var y2 = off2.top;
// distance
var length = Math.sqrt(((x2-x1) * (x2-x1)) + ((y2-y1) * (y2-y1)));
// center
var cx = ((x1 + x2) / 2) - (length / 2);
var cy = ((y1 + y2) / 2) - (thickness / 2);
// angle
var angle = Math.atan2((y1-y2),(x1-x2))*(180/Math.PI);
// make hr
if (div1.title.indexOf(': ') != -1 && div2.title.indexOf(': ') != -1) {
titleextra=' title="' + div1.title + ' to ' + div2.title + '"';
}
var htmlLine = ("<div" + titleextra).replace('<div ','<DIV ') + " style='" + dval + "padding:0px; margin:0px; height:4px; position:absolute; left:" + eval(ioff + cx) + "px; top:" + eval(ioff + cy) + "px; width:" + length + "px; -moz-transform:rotate(" + angle + "deg); -webkit-transform:rotate(" + angle + "deg); -o-transform:rotate(" + angle + "deg); -ms-transform:rotate(" + angle + "deg); transform:rotate(" + angle + "deg);' />";
//
// alert(htmlLine);
return htmlLine; //document.body.innerHTML += htmlLine;
}
function maybeontop(swhat,swhatshort) {
//alert(mode + ' swhatshort=' + swhatshort);
if (mode == 5) { // hangman
document.getElementById('sq').style.display='none';
//alert('<input onclick="alert(' + "'" + swhatshort + "'" + ');" type=button value="Player ' + curplayer + ' click reveals phrase while Player ' + eval(3 - curplayer) + ' turns away?"></input>');
document.getElementById('ontopsq').innerHTML='<input onclick=" document.getElementById(' + "'" + 'mya' + "'" + ').click(); clue=' + "'" + '?' + "'" + '; while (clue == ' + "'" + '?' + "'" + ') { clue=' + "''" + '; try { clue=prompt(' + "'" + swhatshort + " ... to leave a hint for your playing partner, enter one here optionally, and know that to read a helper window enter ?, and that it closes itself in one minute',''" + '); } catch { perr=true; } if (clue == ' + "'" + '?' + "'" + ') { prowoo(); } } if (clue == null) { clue=' + "''" + '; } cluey(' + "'" + swhatshort + "'" + '); " type=button value="Player ' + curplayer + ' click reveals phrase while Player ' + eval(3 - curplayer) + ' turns away?"></input>';
if (document.getElementById('ihangman')) {
document.getElementById('ihangman').src="//www.rjmprogramming.com.au/HTMLCSS/hangman_bg.html?curplayer=1&tosolve=" + encodeURIComponent(swhatshort) + "&clue=" + encodeURIComponent(clue);
} else {
document.getElementById('dhangman').innerHTML='<br><div id=shangman></div><br><iframe style="transform:scale(0.5);margin-left:-50%;margin-top:-200px;width:200%;height:720px;" id="ihangman" src="//www.rjmprogramming.com.au/HTMLCSS/hangman_bg.html?curplayer=' + curplayer + '&tosolve=' + encodeURIComponent(swhatshort) + "&clue=" + encodeURIComponent(clue) + '"></iframe><br>';
document.getElementById('dhangman').style.display='block';
}
lookforend();
}
return swhat;
}
function handon() {
location.href=document.URL.split('#')[0].split('?')[0] + '#hangman' + score + '.' + goes;
}
function hguess(gthis,othis) {
var ifnd=0, fnd=false, newval='';
for (ifnd=0; ifnd<vocabulary[0].length; ifnd++) {
if (vocabulary[0].substring(ifnd,eval(1 + ifnd)).toLowerCase() == gthis.toLowerCase()) {
fnd=true;
newval+=gthis;
} else {
newval+=document.getElementById('sletters').innerHTML.substring(ifnd,eval(1 + ifnd));
}
}
document.getElementById('sletters').innerHTML=newval;
document.getElementById('sletters').title=newval;
othis.style.visibility='hidden';
if (!fnd) {
eval(hangmanc[ihangman]);
ihangman++;
}
if (ihangman >= hangmanc.length) {
goes++;
newval='';
for (ifnd=0; ifnd<vocabulary[0].length; ifnd++) {
if (document.getElementById('sletters').innerHTML.substring(ifnd,eval(1 + ifnd)).toLowerCase() == "_") {
newval+='<font color=red>' + vocabulary[0].substring(ifnd,eval(1 + ifnd)) + '</font>';
} else {
newval+=document.getElementById('sletters').innerHTML.substring(ifnd,eval(1 + ifnd));
}
}
document.getElementById('sletters').innerHTML=newval;
document.getElementById('sletters').title=vocabulary[0];
setTimeout(handon, 5000);
} else if (document.getElementById('sletters').innerHTML.indexOf('_') != -1) {
} else {
score+=document.getElementById('sletters').innerHTML.length;
goes++;
setTimeout(handon, 5000);
}
}
function checkwi(iois) {
var okay=true, hiddenv='', hletters=' ', letters=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
if (iois != null) {
try {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
vocabulary[0] = aconto.body.innerHTML.replace('</pre>','').replace('<pre>','');
if (vocabulary[0].indexOf('-') != -1) { okay=false; }
if (mode == 5) {
for (var iji=0; iji<letters.length; iji++) {
hletters+='<input style=inline-block; type=button onclick=hguess(this.value,this); value=' + letters[iji] + '>' + '' + '</input>';
if (letters[iji].toLowerCase() == 'm') { hletters+='<br>'; document.getElementById('qh4').innerHTML=' '; }
}
for (var ii=0; ii<vocabulary[0].length; ii++) {
if (vocabulary[0].substring(ii, eval(1 + ii)) == ' ') {
hiddenv+=' ';
} else {
hiddenv+='_';
}
}
if ((' ' + location.hash).split('#').length > 3 || (' ' + location.hash).indexOf('hangman-00.0') != -1) {
//document.title+=' a';
//document.getElementById('myh4').innerHTML='Enjoy your two player game of Image Revealing';
if (inim.trim() != '') {
document.getElementById('myh4').innerHTML='Enjoy your two player game of Image Revealing ... image <div id=dpf style=display:NONE;><input style=display:inline-block; id=file type=file name=file></input><span class=readBytesButtons><button style=display:none; data-endbyte=4 data-startbyte=0>1-5</button><button style=display:none; data-endbyte=14 data-startbyte=5>6-15</button><button style=display:none; data-endbyte=7 data-startbyte=6>7-8</button><button name=button id=button value=Process data-endbyte=0 data-startbyte=0>Process</button></span> or URL <input id=vsiurl type=url onblur=readUBlob(this.value,0,0); value="' + inim.trim() + '"></input></div> of Player' + thisplayer + score1 + ' versus <a onclick=myguess(); style=text-decoration:underline;cursor:pointer;>guess</a> of Player' + eval(3 - thisplayer) + score2;
} else {
document.getElementById('myh4').innerHTML='Enjoy your two player game of Image Revealing ... image <div id=dpf style=display:INLINE-BLOCK;><input style=display:inline-block; id=file type=file name=file></input><span class=readBytesButtons><button style=display:none; data-endbyte=4 data-startbyte=0>1-5</button><button style=display:none; data-endbyte=14 data-startbyte=5>6-15</button><button style=display:none; data-endbyte=7 data-startbyte=6>7-8</button><button name=button id=button value=Process data-endbyte=0 data-startbyte=0>Process</button></span> or URL <input id=vsiurl type=url onblur=readUBlob(this.value,0,0); value="' + inim.trim() + '"></input></div> of Player' + thisplayer + score1 + ' versus <a onclick=myguess(); style=text-decoration:underline;cursor:pointer;>guess</a> of Player' + eval(3 - thisplayer) + score2;
}
setTimeout(eh, 1000);
//document.title+=' b';
//document.getElementById('myh4').innerHTML+=' ... image <input style=display:inline-block; id=file type=file name=file></input><div id=dpf style=display:INLINE-BLOCK;><span class=readBytesButtons><button style=display:none; data-endbyte=4 data-startbyte=0>1-5</button><button style=display:none; data-endbyte=14 data-startbyte=5>6-15</button><button style=display:none; data-endbyte=7 data-startbyte=6>7-8</button><button name=button id=button value=Process>Process</button></span> or URL <input id=vsiurl type=url onblur=readUBlob(this.value,0,0); value="' + inim.trim() + '"></input></div> of Player' + thisplayer + score1 + ' versus <a onclick=myguess(); style=text-decoration:underline;cursor:pointer;>guess</a> of Player' + eval(3 - thisplayer) + score2;
//document.title+=' c';
//if (inim.trim() != '') { document.getElementById('dpf').style.display='none'; }
} else if ((' ' + location.hash).split('#').length > 2 || (' ' + location.hash).indexOf('hangman-0.0') != -1) {
document.getElementById('myh4').innerHTML='Enjoy scribbling <a style=text-decoration:underline;cursor:pointer; onclick="parent.document.getElementById(' + "'" + 'iback' + "'" + ').src=' + "'" + 'user_of_signature_signature.html?rand=' + "'" + ' + Math.floor(Math.random() * 123456);" title="Clear Maths Grid Paper below">away</a>! Four discrete vertex clicks define image extraction rectangle.';
} else {
document.getElementById('myh4').innerHTML='<span id=gscore>Score: ' + score + '/' + goes + '</span> <span id=hint title="' + vocabulary[0].length + ' long">Hint:</span> ' + '<span id=sletters data-title="' + vocabulary[0] + '" title="' + hiddenv + '">' + hiddenv + '</span>' + hletters;
}
//document.getElementById('qh4').innerHTML=hletters;
}
hangman[0] = maybeontop('', vocabulary[0]);
var ws=vocabulary[0].split(' ');
for (var iws=0; iws<ws.length; iws++) {
if (ws[iws].length > maxanyone) { okay=false; }
}
//if (mode == 4) questions[0] = vocabulary[0];
}
}
} catch(ee) {
if (vocabulary[0] == '' && mode == 5) { okay=false; }
}
}
//if (!okay) { document.getElementById('imyword').src='//www.rjmprogramming.com.au/PHP/surprise.php?min=' + eval(1 + wlens) + '&max=' + eval(1 + wlenb) + '&phrase=y&youllneverfindthis=y' + Math.floor(Math.random() * 134567); }
if (!okay) { document.getElementById('imyword').src='../PHP/surprise.p