<!doctype html>
<html>
<title>Fruits Quiz - RJM Programming - January, 2019 Thanks to https://www.iemoji.com</title>
<style>

p {
font-size: 94px;
text-align: center;
}

.kb {
background-color: yellow;
}

.peach::after {
content: '\01f351';
}

.eggplant::after {
content: '\01f346';
}

.tangerine::after {
content: '\01f34a';
}

.strawberry::after {
content: '\01f353';
}

.pineapple::after {
content: '\01f34d';
}

.watermelon::after {
content: '\01f349';
}

.grapes::after {
content: '\01f347';
}

.banana::after {
content: '\01f34c';
}

.cherries::after {
content: '\01f352';
}

.red_apple::after {
content: '\01f34e';
}

.lemon::after {
content: '\01f34b';
}

.green_apple::after {
content: '\01f34f';
}

.pear::after {
content: '\01f350';
}

.hot_pepper::after {
content: '\01f336';
}

.tomato::after {
content: '\01f345';
}

.melon::after {
content: '\01f348';
}

</style>
<script type='text/javascript'>
var numplayers=1;
var scores=['0'];
var goes=['0'];
var players=['Player 1'];
var answers=[''];
var classes=['peach', 'eggplant', 'tangerine', 'strawberry', 'pineapple', 'watermelon', 'grapes', 'banana', 'cherries', 'red_apple', 'lemon', 'green_apple', 'pear', 'hot_pepper', 'tomato', 'melon'];
var contents=['127825', '127814', '127818', '127827', '127821', '127817', '127815', '127820', '127826', '127822', '127819', '127823', '127824', '127798', '127813', '127816'];
var analnono=false;
var br='';
var ddd='... ';

function nanalyze(iois) {
var ij=eval(iois.id.replace('c',''));
players[ij]='' + iois.innerHTML;
}

function izeroanalyze() {
analyze(document.getElementById('i0'));
}

function analyze(iois) {
if (!analnono && iois.value != '') {
document.title+=' x';
var ij=eval(iois.id.replace('i',''));
goes[ij]='' + eval(eval('' + goes[ij]) + 1);
if (iois.value.toLowerCase().replace(/_/g,' ').replace('aubergine', 'eggplant').replace('grapes', 'grapX').replace('grape', 'grapes').replace('grapX', 'grapes').replace('cherry', 'cherries') == answers[ij]) {
scores[ij]='' + eval(eval('' + scores[ij]) + 2);
} else if ((answers[ij] + '~').indexOf(' ' + iois.value.toLowerCase().replace(/_/g,' ') + '~') != -1) {
scores[ij]='' + eval(eval('' + scores[ij]) + 1);
} else {
scores[ij]='' + eval(-1 + eval('' + scores[ij]));
}
document.getElementById('s' + ij).innerHTML='' + scores[ij] + '/' + goes[ij];
iois.value='';
another();
}
analnono=false;
}


function precontinuallook() {
if (top.document) {
if (top.document.getElementById('divac')) {
br='<br>';
ddd=' ';
document.getElementById('mytable').border='1';
document.getElementById('estyle').innerHTML="<style> p { font-size: 24px; text-align: center; } </style>";
continuallylook();
}
}
}

function continuallylook() {
var xx='';
if (top.document) {
if (top.document.getElementById('divac')) {
if (top.document.title.split(' ... ').length == 3) {
xx=top.document.title.split(' ... ')[1];
top.document.title=top.document.title.replace(' ... ' + xx, '');
}
if (xx.toLowerCase().indexOf('one ') != -1) {
document.getElementById('i0').value=xx.toLowerCase().split('one ')[1];
analyze(document.getElementById('i0'));
} else if (xx.toLowerCase().indexOf('two ') != -1) {
document.getElementById('i1').value=xx.toLowerCase().split('two ')[1];
analyze(document.getElementById('i1'));
} else if (xx.toLowerCase().indexOf('to ') != -1) {
document.getElementById('i1').value=xx.toLowerCase().split('to ')[1];
analyze(document.getElementById('i1'));
} else if (xx.toLowerCase().indexOf('three ') != -1) {
document.getElementById('i2').value=xx.toLowerCase().split('three ')[1];
analyze(document.getElementById('i2'));
} else if (xx.toLowerCase().indexOf('four ') != -1) {
document.getElementById('i3').value=xx.toLowerCase().split('four ')[1];
analyze(document.getElementById('i3'));
} else if (xx.toLowerCase().indexOf('five ') != -1) {
document.getElementById('i4').value=xx.toLowerCase().split('five ')[1];
analyze(document.getElementById('i4'));
} else if (xx.toLowerCase().indexOf('1 ') != -1) {
document.getElementById('i0').value=xx.toLowerCase().split('1 ')[1];
analyze(document.getElementById('i0'));
} else if (xx.toLowerCase().indexOf('2 ') != -1) {
document.getElementById('i1').value=xx.toLowerCase().split('2 ')[1];
analyze(document.getElementById('i1'));
} else if (xx.toLowerCase().indexOf('3 ') != -1) {
document.getElementById('i2').value=xx.toLowerCase().split('3 ')[1];
analyze(document.getElementById('i2'));
} else if (xx.toLowerCase().indexOf('4 ') != -1) {
document.getElementById('i3').value=xx.toLowerCase().split('4 ')[1];
analyze(document.getElementById('i3'));
} else if (xx.toLowerCase().indexOf('5 ') != -1) {
document.getElementById('i4').value=xx.toLowerCase().split('5 ')[1];
analyze(document.getElementById('i4'));
} else if (xx != '') {
another();
}
}
setTimeout(continuallylook, 500);
}
}

function onl() {
var i, j, k, crowh='<tr></tr>', crowd='<tr id=trd></tr>', vb='';
numplayers=location.search.split('numplayers=')[1] ? eval(location.search.split('numplayers=')[1].split('&')[0]) : numplayers;
document.getElementById('myselect').value='' + numplayers;
var cscores=location.search.split('scores=')[1] ? decodeURIComponent(location.search.split('scores=')[1].split('&')[0]) : '';
if (cscores != '') { scores=cscores.split(','); }
var cgoes=location.search.split('goes=')[1] ? decodeURIComponent(location.search.split('goes=')[1].split('&')[0]) : '';
if (cgoes != '') { goes=cgoes.split(','); }
var cplayers=location.search.split('players=')[1] ? decodeURIComponent(location.search.split('players=')[1].split('&')[0]) : '';
if (cplayers != '' && cplayers.length > 1) { players=cplayers.split(','); answers=cplayers.split(','); }

for (k=1; k<numplayers; k++) {
if (scores.length <= k) {
scores.push('0');
goes.push('0');
players.push('Player ' + eval(1 + k));
answers.push('');
}
}

precontinuallook();

for (i=0; i<numplayers; i++) {
if (numplayers == 2 && i == 0) {
vb=' and tab out';
crowh=crowh.replace('</tr>', '<th id=th' + i + '><div id=c' + i + ' style=inline-block; onblur=nanalyze(this); contenteditable=true>' + players[i] + '</div> ' + ddd + 'score <span id=s' + i + '>' + scores[i] + '/' + goes[i] + '</span> ' + ddd + br + ' guess' + vb + ' <input onkeydown="analnono=false;" onblur=setTimeout(izeroanalyze,1000); id=i' + i + ' type=text value=""></input></th></tr>');
vb=' via buttons below';
} else {
crowh=crowh.replace('</tr>', '<th id=th' + i + '><div id=c' + i + ' style=inline-block; onblur=nanalyze(this); contenteditable=true>' + players[i] + '</div> ' + ddd + 'score <span id=s' + i + '>' + scores[i] + '/' + goes[i] + '</span> ' + ddd + br + ' guess' + vb + ' <input onblur=analyze(this); id=i' + i + ' type=text value=""></input></th></tr>');
vb='';
}
j=Math.floor(Math.random() * classes.length);
answers[i]=classes[j].replace(/_/g, ' ');
crowd=crowd.replace('</tr>', '<td style=vertical-align:top; id=td' + i + '><p id=d' + i + ' class=' + classes[j] + '></p></td></tr>');
}
document.getElementById('mytbody').innerHTML=crowh + crowd;

if (br == '<br>') {
document.getElementById('i0').style.width='60px';
document.getElementById('i1').style.width='60px';
document.getElementById('i2').style.width='60px';
document.getElementById('i3').style.width='60px';
document.getElementById('i4').style.width='60px';
}

if (numplayers == 2) {
document.getElementById('i0').focus();
document.getElementById('th1').innerHTML+='<br>' + '<input class=kb type=button style=inline-block; onclick=append(this); value="a" id=ba1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="b" id=bb1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="c" id=bc1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="d" id=bd1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="e" id=be1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="f" id=bf1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="g" id=bg1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="h" id=bh1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="i" id=bi1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="j" id=bj1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="k" id=bk1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="l" id=bl1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="m" id=bm1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="n" id=bn1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="o" id=bo1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="p" id=bp1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="q" id=bq1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="r" id=br1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="s" id=bs1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="t" id=bt1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="u" id=bu1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="v" id=bv1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="w" id=bw1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="x" id=bx1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="y" id=by1></input>&nbsp;<input class=kb type=button style=inline-block; onclick=append(this); value="z" id=bz1></input>&nbsp;';
}
}

function another() {
var i, j, xcrowd='';
for (i=0; i<numplayers; i++) {
j=Math.floor(Math.random() * classes.length);
answers[i]=classes[j].replace(/_/g, ' ');
xcrowd+='<td style=vertical-align:top; id=td' + i + '><p id=d' + i + ' class=' + classes[j] + '></p></td>';
document.getElementById('i' + i).value='';
}
document.getElementById('trd').innerHTML=xcrowd;
if (numplayers == 2) {
document.getElementById('i0').focus();
}
// if (br == '<br>') { top.document.getElementById('start_button').click(); }
}

function append(ibo) {
document.title+=' z';
analnono=true;
document.getElementById('i' + ibo.id.substring(2)).value+=ibo.id.substring(1,2);
if (document.getElementById('i' + ibo.id.substring(2)).value.toLowerCase().replace(/_/g,' ').replace('aubergine', 'eggplant').replace('grapes', 'grapX').replace('grape', 'grapes').replace('grapX', 'grapes').replace('cherry', 'cherries') == answers[1]) {
analnono=false;
analyze(document.getElementById('i' + ibo.id.substring(2)));
document.getElementById('i' + ibo.id.substring(2)).value='';
another();
} else if ((answers[1] + '~').indexOf(' ' + document.getElementById('i' + ibo.id.substring(2)).value.toLowerCase().replace(/_/g,' ') + '~') != -1) {
analnono=false;
analyze(document.getElementById('i' + ibo.id.substring(2)));
document.getElementById('i' + ibo.id.substring(2)).value='';
another();
}
all();
}

function all() {
document.getElementById('i0').focus();
}

function lhit(sv) {
var k;
var xscores='' + scores[0], xgoes='' + goes[0], xplayers='' + players[0];
numplayers=eval(sv);
for (k=1; k<numplayers; k++) {
if (scores.length <= k) {
scores.push('0');
goes.push('0');
players.push('Player ' + eval(1 + k));
answers.push('');
}
xscores+=',' + scores[k];
xgoes+=',' + goes[k];
xplayers+=',' + players[k];
}
if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1 && eval('' + numplayers) > 2) {
location.href='//www.rjmprogramming.com.au/PHP/speech_supervisor.php?mode=03';
} else {
location.href=document.URL.split('#')[0].split('?')[0] + '?scores=' + encodeURIComponent(xscores) + '&goes=' + encodeURIComponent(xgoes) + '&players=' + encodeURIComponent(xplayers) + '&numplayers=' + numplayers;
}
}

</script>
</head>
<body onload='onl();'>
<h1>Fruits Quiz for <select id=myselect onchange='lhit(this.value);'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select></h1>
<h3 id=myh3>RJM Programming</h3>
<h3>January, 2019 ... Thanks to <a target=_blank title='Iemoji' href='https://www.iemoji.com'>Iemoji</a></h3>
<table id=mytable style='width:100%;text-align:center;' border=10>
<tbody id=mytbody>
</tbody>
</table>
<div id=econtent></div>
<input type=text style='position:absolute;top:-200px;left:-200px;' value=''></input>
<div id=estyle></div>
</body>
</html>