<html>
<head>
<script type='text/javascript'>
var randstart='1';
var thisrect=null, thatrect=null, compy=1, offx=0, offy=0; //3451
var vsmode=location.search.split('mode=')[1] ? eval(decodeURIComponent(location.search.split('mode=')[1].split('&')[0]).replace(/\+/g,' ')) : 0;
var tgon='', gta=null;
var ans='', cans='', lastq=-1;
var quss=["? sum game.",
"? is the only number.",
"Tea for ?",
"? is a crowd.",
"? score and seven years ago ...",
"Man alive ?",
"? - Pick up sticks",
"Number of days in the week?",
"? - Lay them straight",
"I say Pluto makes ? planets.",
"Aardvark's got 3?",
"Honey collector shortening?",
"See?",
"Franklin Roosevelt middle initial?",
"Charlotte's Web author first initial?",
"The Great Gatsby author first initial?",
"Father Brown author middle initial?",
"The Joker actor first initial?",
"Goes before pad or pod or phone?",
"Bird name shortening?",
"JF?",
"Fifty in Roman?",
"Thousand in Roman?",
"Nitrogren?",
"Oxygen?",
"Widdle shortening?",
"Needs U?",
"Closest thing to pirate snarl?",
"Instantaneous plurality in English?",
"? for 2 shortening",
"The ? bend where you might find rings?",
"? for victory",
"Wider character?",
"Chinese leader last name initial?",
"Up and down co-ordinator?",
"Elevation co-ordinator?",
"? Swinton - actress",
"Shouty character?",
"Email character?",
"Hashtag character?",
"Power of the ?",
"100th proportionate",
"Bugs Bunny food character",
"And ?",
"All of wildcard",
"Reversed quotation mark?",
"Positive",
"Equality",
"Negative",
"Under the score?",
"Below the stomach, unless standing on your head?",
"Pause, in a sentence?",
"Opening HTML character",
"Closing HTML character",
"CSV delimiter",
"Sentence ender?",
"Fraction character",
"Question everything",
"Square starter",
"Square ender",
"Brace starter",
"Brace ender",
"Round start",
"Round ender"
];
var anss='0123456789abcdefghijklmnopqrstuvwxyz
$%^&*`+=-_:;<>,./?[]{}()';

function toggleFullScreen() { // Thanks to https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
if (!document.fullscreenElement) {
tgon='y';
if (eval(eval('' + vsmode) % 2) == 0) { vsmode++; document.getElementById('mode').value='' + vsmode; }
document.documentElement.requestFullscreen();
} else if (document.exitFullscreen) {
tgon='n';
if (eval(eval('' + vsmode) % 2) == 1) { vsmode--; document.getElementById('mode').value='' + vsmode; }
document.exitFullscreen();
tgon='';
}
}


function checkit(event) { // Thanks to https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_event_key_location
var x = event.location;
randstart='';
if (event.key === "Alt" || event.key === "Ctrl" || event.which == 91 || event.which == 17 || event.which == 93) {
event.preventDefault();
//document.getElementById('sa').innerHTML+='' + x;
document.getElementById('ta' + x).focus();
} //else {
//document.getElementById('sa').innerHTML+='.' + event.which;
//}
if (('' + vsmode) != '2' && ('' + vsmode) != '3') {
document.getElementById('score1').innerHTML='' + document.getElementById('ta1').value.length;
document.getElementById('score2').innerHTML='' + document.getElementById('ta2').value.length;
if (document.getElementById('ta1').value.length == document.getElementById('ta2').value.length) {
document.getElementById('score1').style.backgroundColor='white';
document.getElementById('score2').style.backgroundColor='white';
} else if (eval('' + document.getElementById('ta1').value.length) > eval('' + document.getElementById('ta2').value.length)) {
document.getElementById('score1').style.backgroundColor='yellow';
document.getElementById('score2').style.backgroundColor='white';
} else {
document.getElementById('score2').style.backgroundColor='yellow';
document.getElementById('score1').style.backgroundColor='white';
}
}
gta=event.target;
if (('' + vsmode) == '2' || ('' + vsmode) == '3') {
setTimeout(prelookta, 500);
}
}

function randf() {
var isok=true;
if (randstart != '' && compy < 0) {
thatrect=top.document.body.getBoundingClientRect();
//document.getElementById('sa').innerHTML='eval(thatrect.top + offy - 400)=' + eval(thatrect.top + offy - 400) + ' compy=' + compy + ' thatrect.top=' + thatrect.top; // + ' thisrect.y=' + thisrect.y + ' thatrect.y=' + thatrect.y;
if (eval('' + thatrect.top) != eval('' + compy)) { isok=false; randstart=''; }
}
if (isok) {
if (randstart == '1') {
randstart='2';
document.getElementById('ta' + randstart).focus();
//if (compy < 0) { compy--; }
setTimeout(randf, 5000);
} else if (randstart == '2') {
randstart='1';
document.getElementById('ta' + randstart).focus();
setTimeout(randf, 5000);
//if (compy < 0) { compy--; }
}
}
}

function prerandstart() {
//thisrect=document.body.getBoundingClientRect();
thatrect=top.document.body.getBoundingClientRect();
if (offx == 0 && offy == 0) {
var iofs=top.document.getElementsByTagName('iframe');
for (jofs=0; jofs<iofs.length; jofs++) {
if (('' + iofs[jofs].src).indexOf(document.URL) != -1) {
offx=iofs[jofs].offsetLeft;
offy=iofs[jofs].offsetTop;
}
}
//document.getElementById('sa').innerHTML='eval(thatrect.top + offy - 400)=' + eval(thatrect.top + offy - 400) + ' offy=' + offy + ' thatrect.top=' + thatrect.top; // + ' thisrect.y=' + thisrect.y + ' thatrect.y=' + thatrect.y;
}
if (eval(thatrect.y + offy - 400) >= 0 && Math.abs(eval(thatrect.y + offy - 400)) < 110) {
//document.getElementById('sa').innerHTML='eval(thatrect.top + offy - 400)=' + eval(thatrect.top + offy - 400) + ' offy=' + offy + ' thatrect.top=' + thatrect.top; // + ' thisrect.y=' + thisrect.y + ' thatrect.y=' + thatrect.y;
if (randstart != '') {
compy=eval('' + thatrect.top);
randf();
}
} else {
//document.getElementById('sa').innerHTML='Eval(thatrect.top + offy - 400)=' + eval(thatrect.top + offy - 400) + ' offy=' + offy + ' thatrect.top=' + thatrect.top; // + ' thisrect.y=' + thisrect.y + ' thatrect.y=' + thatrect.y;
//document.getElementById('sa').innerHTML=' offy=' + offy + ' thatrect.top=' + thatrect.top + ' thisrect.y=' + thisrect.y + ' thatrect.y=' + thatrect.y;
setTimeout(prerandstart, 1000);
}
}

function modegame(so) {
if (('' + so.value) == ('' + vsmode)) {
//alert('first');
vsmode=vsmode;
} else if (eval(eval('' + so.value) % 2) == 1 && eval(eval('' + so.value) - eval(('' + vsmode))) == 1) {
//alert('second');
if (('' + vsmode) == '0') {
document.getElementById('aim').innerHTML='Longest Blurb Wins!';
} else {
document.getElementById('aim').innerHTML='Alt Button In to One Character Answers!';
}
vsmode=eval('' + so.value);
if (tgon == '') { toggleFullScreen(); }
} else if (eval(eval('' + so.value) % 2) == 0 && eval(eval(('' + vsmode) - eval('' + so.value))) == 1) {
//alert('third');
if (('' + vsmode) == '1') {
document.getElementById('aim').innerHTML='Longest Blurb Wins!';
} else {
document.getElementById('aim').innerHTML='Alt Button In to One Character Answers!';
}
vsmode=eval('' + so.value);
if (tgon != '') { toggleFullScreen(); }
document.getElementById('aim').innerHTML='Longest Blurb Wins!';
} else if (eval('' + so.value) == 2 || eval('' + so.value) == 3) {
//alert('four');
document.getElementById('aim').innerHTML='Alt Button In to One Character Answers!';
document.getElementById('ta1').value='';
document.getElementById('ta2').value='';
document.getElementById('score2').style.backgroundColor='white';
document.getElementById('score1').style.backgroundColor='white';
vsmode=eval('' + so.value);
if (tgon != '' && eval('' + so.value) == 2) { toggleFullScreen(); } else if (tgon == '' && eval('' + so.value) == 3) { toggleFullScreen(); }
setquestion();
} else if (eval('' + so.value) == 0) {
//alert('five');
location.href='./multiple_keyboard_game.html';
} else if (eval('' + so.value) == 1) {
//alert('six');
location.href='./multiple_keyboard_game.html?mode=1';
}
}

function setquestion() {
var thisq=Math.floor(Math.random() * quss.length);
while (lastq == thisq) {
thisq=Math.floor(Math.random() * quss.length);
}
document.getElementById('ta1').value='';
document.getElementById('ta2').value='';
lastq=thisq;
document.getElementById('thquiz').innerHTML=quss[eval('' + thisq)]; // + ' ... ' + anss.substring(eval('' + thisq)).substring(0,1).toLowerCase().replace('<','<').replace('>','>');
ans='';
cans=anss.substring(eval('' + thisq)).substring(0,1).toLowerCase();
}

function prelookta() {
lookta(gta);
}

function lookta(tao) {
if (('' + vsmode) == '2' || ('' + vsmode) == '3') {
if (tao.value != '') {
if (tao.value.toLowerCase().substring(0,1) == cans) {
var thisx=eval('' + tao.id.replace('ta',''));
var thisscore=eval('' + document.getElementById('score' + tao.id.replace('ta','')).innerHTML);
document.getElementById('score' + thisx).innerHTML='' + eval(1 + thisscore);
document.getElementById('score' + thisx).style.backgroundColor='yellow';
document.getElementById('score' + eval(3 - thisx)).style.backgroundColor='white';
setquestion();
} else {
tao.value='';
}
}
}
}

//setTimeout(randf, 5000);
</script>
</head>
<body onload=" if (eval(eval('' + vsmode) % 2) == 1) { toggleFullScreen(); } if (window.self !== window.top) { prerandstart(); } else { document.getElementById('ta1').focus(); setTimeout(randf, 5000); }">
<h1>Multiple Keyboard <select id=mode onchange=modegame(this);><option value=0>Long Blurb</option><option value=1>Long Blurb Full Screen</option><option value=2>Hot Key Quiz</option><option value=3>Hot Key Quiz Full Screen</option></select> Game ... Maybe Bluetooth Extra Keyboard, to Play</h1>
<h3>RJM Programming - October, 2022 <span id=sa></span></h3>
<h4>Players Get Focus to Their Blurb via Their Left or Right Alt or Ctrl Keyboard Press ... <span id=aim>Longest Blurb Wins!</span></h4>
<table border=20 style='width:100%;'>
<tr><th colspan=2 id=thquiz>Blurb</th></tr>
<tr><th id=player1 contenteditable=true>Player Left Alt 1</th><th id=player2 contenteditable=true>Player Right Alt 2</th></tr>
<tr><th id=score1>9</th><th id=score2>9</th></tr>
<tr><td id=cell1><textarea data-onchange='lookta(this);' id=ta1 style='width:100%;height:460px;' onkeydown=checkit(event);>Blurb ...</textarea></td><td id=cell2><textarea data-onchange='lookta(this);' id=ta2 style='width:100%;height:460px;' onkeydown=checkit(event);>Blurb ...</textarea></td></tr>
</table>
</body>
</html>