ÿþ<!doctype html>
<html>
<head>
<title>Middle Word Game - RJM Programming - February, 2017 ... thanks to Science Puzzles for Young Einsteins by Helene Hovanec (page 49) and http://wordfinder.yourdictionary.com/letter-words/</title>
<style>
td { border: 3px solid darkgray; }
select { background-color: pink; }
</style>
<script type='text/javascript'>
var deflength=-1, thislength=-1, solved=0, solvedones="", spellsout='', vsspellsout='';
var maxrows=-1;

var unknownchar=[2, 3, 3, 3];

var deffive=location.search.split('all=')[1] ? decodeURIComponent(location.search.split('all=')[1].split('&')[0]).split(';')[0] : '"APPLE", "SHRUB", "STOOP", "ANGER", "BERRY", "GRAPE", "REMIT", "COMET", "EVENT", "FIRST"';
var defsix=location.search.split('all=')[1] ? decodeURIComponent(location.search.split('all=')[1].split('&')[0]).split(';')[1] : '"VIZORS", "JUMPED", "INJECT", "CHIRPY", "KEBABS", "PRETAX", "ENJOYS", "MATRIX"';
var defseven=location.search.split('all=')[1] ? decodeURIComponent(location.search.split('all=')[1].split('&')[0]).split(';')[2] : '"REEDITS", "ROSETTE", "CRAVING", "STEERER", "ISOLATE", "TOROIDS", "KAMPONG", "RESEEDS", "ZEBROID"';
var defeight=location.search.split('all=')[1] ? decodeURIComponent(location.search.split('all=')[1].split('&')[0]).split(';')[3] : '"NUMCHUCK", "RESORTER", "STUDIERS", "HERESIES", "INERRANT" ';

var fivec=location.search.split('five=')[1] ? decodeURIComponent(location.search.split('five=')[1].split('&')[0]) : deffive; // '"APPLE", "SHRUB", "STOOP", "ANGER", "BERRY", "GRAPE", "REMIT", "COMET", "EVENT", "FIRST"';
var fivea=eval("[" + fivec + "]");
var sixc=location.search.split('six=')[1] ? decodeURIComponent(location.search.split('six=')[1].split('&')[0]) : defsix; // '"VIZORS", "JUMPED", "INJECT", "CHIRPY", "KEBABS", "PRETAX", "ENJOYS", "MATRIX"';
var sixa=eval("[" + sixc + "]");
var sevenc=location.search.split('seven=')[1] ? decodeURIComponent(location.search.split('seven=')[1].split('&')[0]) : defseven; // '"REEDITS", "ROSETTE", "CRAVING", "STEERER", "ISOLATE", "TOROIDS", "KAMPONG", "RESEEDS", "ZEBROID"';
var sevena=eval("[" + sevenc + "]");
var eightc=location.search.split('eight=')[1] ? decodeURIComponent(location.search.split('eight=')[1].split('&')[0]) : defeight; // '"NUMCHUCK", "RESORTER", "STUDIERS", "HERESIES", "INERRANT" ';
var eighta=eval("[" + eightc + "]");

var score=location.search.split('score=')[1] ? location.search.split('score=')[1].split('&')[0] : 0;
var goes=location.search.split('goes=')[1] ? location.search.split('goes=')[1].split('&')[0] : 0;

var defsel='<select id=? onchange="changed(this);"><option value=>?</option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option><option value="E">E</option><option value="F">F</option><option value="G">G</option><option value="H">H</option><option value="I">I</option><option value="J">J</option><option value="K">K</option><option value="L">L</option><option value="M">M</option><option value="N">N</option><option value="O">O</option><option value="P">P</option><option value="Q">Q</option><option value="R">R</option><option value="S">S</option><option value="T">T</option><option value="U">U</option><option value="V">V</option><option value="W">W</option><option value="X">X</option><option value="Y">Y</option><option value="Z">Z</option></select>';

function changed(oosel) {
if (oosel.value != '') {
if (solvedones.indexOf((';' + oosel.id + ';')) == -1) {
if (oosel.options[oosel.selectedIndex].text.indexOf(' ') != -1 || oosel.value.indexOf(' ') != -1) {
solvedones+=(';' + oosel.id + ';');
solved++;
} else {
oosel.value='';
}
}
if (solved >= thislength) {
// Work out vsspellsout
score+=spellsout.length;
goes++;
document.getElementById('score').innerHTML='Score: ' + score + '/' + goes;
alert('Congratulations on solving for ' + spellsout + ' ... you score ' + spellsout.length + ' points.');
deflength=-1;
chooseagame();
}
}
}

function cleargame() {
var defih='';
for (var ii=1; ii<=maxrows; ii++) {
defih+='<tr id=tr' + ii + '></TR>';
for (var jj=1; jj<=8; jj++) {
defih=defih.replace("</TR>","<td id=td" + ii + "_" + jj + "></td></TR>");
}
defih=defih.replace(/<\/TR>/g, "</tr>");
}
//alert(defih);
document.getElementById('mytbody').innerHTML=defih;
}

function tweakdef() {
if (document.URL.indexOf('five=') != -1) deflength=5;
if (document.URL.indexOf('six=') != -1) deflength=6;
if (document.URL.indexOf('seven=') != -1) deflength=7;
if (document.URL.indexOf('eight=') != -1) deflength=8;
if (fivea.length > maxrows) maxrows=fivea.length;
if (sixa.length > maxrows) maxrows=sixa.length;
if (sevena.length > maxrows) maxrows=sevena.length;
if (eighta.length > maxrows) maxrows=eighta.length;
}

function chooseagame() {
var ourarr, ouru;
cleargame();
solved=0;
solvedones="";
spellsout="";
if (deflength < 5) {
deflength=Math.floor(Math.random() * 3) + 5;
}
if (deflength == 5) thislength=fivea.length;
if (deflength == 6) thislength=sixa.length;
if (deflength == 7) thislength=sevena.length;
if (deflength == 8) thislength=eighta.length;
if (deflength == 5) ourarr=fivea;
if (deflength == 6) ourarr=sixa;
if (deflength == 7) ourarr=sevena;
if (deflength == 8) ourarr=eighta;
ouru=eval(1 + unknownchar[eval(-5 + deflength)]);

for (var ii=1; ii<=maxrows; ii++) {
if (ii > thislength) {
document.getElementById("tr" + ii).style.display='none';
} else {
document.getElementById("tr" + ii).style.display='table-row';
for (var jj=1; jj<=8; jj++) {
if (jj > deflength) {
document.getElementById("td" + ii + "_" + jj).style.display='none';
} else {
document.getElementById("td" + ii + "_" + jj).style.display='table-cell';
if (jj == ouru) {
spellsout+=ourarr[eval(-1 + ii)].substring(eval(-1 + jj),jj);
document.getElementById("td" + ii + "_" + jj).style.backgroundColor='yellow';
document.getElementById("td" + ii + "_" + jj).innerHTML=defsel.replace(' id=?', ' id=s' + 'td' + ii + '_' + jj).replace('">' + ourarr[eval(-1 + ii)].substring(eval(-1 + jj),jj) + '</',' ">' + ourarr[eval(-1 + ii)].substring(eval(-1 + jj),jj) + ' </');
} else {
document.getElementById("td" + ii + "_" + jj).style.backgroundColor='lightblue';
document.getElementById("td" + ii + "_" + jj).innerHTML=ourarr[eval(-1 + ii)].substring(eval(-1 + jj),jj);
}
}
}
}
}



}

function ask(osel) {
var retval='', defvalues=deffive + ';' + defsix + ';' + defseven + ';' + defeight, defname='?score=' + score + '&goes=' + goes + '&all=';
if (osel.value != "") {
if (osel.value == "0") {
retval=prompt("Please adjust given words as applicable to suit 'Spell out a Job Description in Information Technology below.'", defvalues);
if (retval == null) retval='';
} else if (osel.value == "5") {
defname=defname.replace('all=','five=');
retval=prompt("Please adjust given 5 Letter words as applicable to suit 'Spell out a Job Description in Information Technology below.'", deffive);
if (retval == null) retval='';
} else if (osel.value == "6") {
defname=defname.replace('all=','six=');
retval=prompt("Please adjust given 6 Letter words as applicable to suit 'Spell out a Job Description in Information Technology below.'", defsix);
if (retval == null) retval='';
} else if (osel.value == "7") {
defname=defname.replace('all=','seven=');
retval=prompt("Please adjust given 7 Letter words as applicable to suit 'Spell out a Job Description in Information Technology below.'", defseven);
if (retval == null) retval='';
} else if (osel.value == "8") {
defname=defname.replace('all=','eight=');
retval=prompt("Please adjust given 8 Letter words as applicable to suit 'Spell out a Job Description in Information Technology below.'", defeight);
if (retval == null) retval='';
}
}
if (retval != '') {
location.href=document.URL.split('#')[0].split('?')[0] + defname + encodeURIComponent(retval.replace(/\ /g,''));
}
}
</script>
</head>
<body onload='tweakdef(); chooseagame();' style='background-color: orange;'>
<h1><select id='ours' onchange='ask(this);'><option value="">Our Default</option>
<option value="5">Your Default 5 Letter</option>
<option value="6">Your Default 6 Letter</option>
<option value="7">Your Default 7 Letter</option>
<option value="8">Your Default 8 Letter</option>
<option value="0">Your Default All Above</option>
</select> Middle Word Game<h1>
<h2>RJM Programming - February, 2017</h2>
<h3>Thanks to Science Puzzles for Young Einsteins by Helene Hovanec (page 49) and <br><a target=_blank title='Great Scrabble word search resource' href='http://wordfinder.yourdictionary.com/letter-words/'>this Great Scrabble word search resource link</a></h3>
<h4 id='score'>Score: 0/0</h4>
<h4>Spell out a Job Description in Information Technology below.</h4>
<table id='mytable' cellpadding=15 cellspacing=2>
<tbody id='mytbody'>
</tbody>
</table>
</body>
</html>