<!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 doemailsynch=true;

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 blurb=location.search.split('blurb=')[1] ? decodeURIComponent(location.search.split('blurb=')[1].split('&')[0]) : 'Spell out a Job Description in Information Technology below.';

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 reblurb(inu) {
var outu=inu, vs='';
var binu=inu.split('blurb=');
if (binu.length > 1) {
vs=decodeURIComponent((inu + '&').split('blurb=')[1].split('&')[0]);
}
if (blurb != 'Spell out a Job Description in Information Technology below.') {
if (vs != blurb) {
if (vs == '') {
outu=(inu + '&blurb=' + encodeURIComponent(blurb)).replace('.html&','.html?').replace('.htm&','.htm?');
} else {
vs=(inu + '&').split('blurb=')[1].split('&')[0];
outu=inu.replace('blurb=' + vs, 'blurb=' + encodeURIComponent(blurb));
}
}
}
return outu;
}

function emailsynch() {
if (document.getElementById('def' + deflength)) {
if (document.getElementById('def' + deflength).value != '') {
if (deflength == 5) {
fivec=document.getElementById('def' + deflength).value;
fivea=eval("[" + fivec + "]");
document.getElementById('def' + deflength).value="";
blurb=document.getElementById('blurb').innerHTML;
thisurlis=(reblurb(document.URL.split('#')[0]) + '&five=' + encodeURIComponent(fivec.replace(/\ /g,''))).replace('.html&','.html?').replace('.htm&','.htm?');
document.getElementById('eemail').style.display='inline';
drawtable();
} else if (deflength == 6) {
sixc=document.getElementById('def' + deflength).value;
sixa=eval("[" + sixc + "]");
document.getElementById('def' + deflength).value="";
blurb=document.getElementById('blurb').innerHTML;
thisurlis=(reblurb(document.URL.split('#')[0]) + '&six=' + encodeURIComponent(sixc.replace(/\ /g,''))).replace('.html&','.html?').replace('.htm&','.htm?');
document.getElementById('eemail').style.display='inline';
drawtable();
} else if (deflength == 7) {
sevenc=document.getElementById('def' + deflength).value;
sevena=eval("[" + sevenc + "]");
document.getElementById('def' + deflength).value="";
blurb=document.getElementById('blurb').innerHTML;
thisurlis=(reblurb(document.URL.split('#')[0]) + '&seven=' + encodeURIComponent(sevenc.replace(/\ /g,''))).replace('.html&','.html?').replace('.htm&','.htm?');
document.getElementById('eemail').style.display='inline';
drawtable();
} else if (deflength == 8) {
eightc=document.getElementById('def' + deflength).value;
eighta=eval("[" + eightc + "]");
document.getElementById('def' + deflength).value="";
blurb=document.getElementById('blurb').innerHTML;
thisurlis=(reblurb(document.URL.split('#')[0]) + '&eight=' + encodeURIComponent(eightc.replace(/\ /g,''))).replace('.html&','.html?').replace('.htm&','.htm?');
document.getElementById('eemail').style.display='inline';
drawtable();
}
}
}
setTimeout(emailsynch,1000);
}

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=eval(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() {
document.getElementById('blurb').innerHTML=blurb;
thisurlis=document.URL.split('#')[0];
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() {
if (deflength < 5) {
deflength=Math.floor(Math.random() * 3) + 5;
if (deflength == 5) {
thisurlis=(reblurb(document.URL.split('#')[0]) + '&five=' + encodeURIComponent(fivec.replace(/\ /g,''))).replace('.html&','.html?').replace('.htm&','.htm?');
} else if (deflength == 6) {
thisurlis=(reblurb(document.URL.split('#')[0]) + '&six=' + encodeURIComponent(sixc.replace(/\ /g,''))).replace('.html&','.html?').replace('.htm&','.htm?');
} else if (deflength == 7) {
thisurlis=(reblurb(document.URL.split('#')[0]) + '&seven=' + encodeURIComponent(sevenc.replace(/\ /g,''))).replace('.html&','.html?').replace('.htm&','.htm?');
} else if (deflength == 8) {
thisurlis=(reblurb(document.URL.split('#')[0]) + '&eight=' + encodeURIComponent(eightc.replace(/\ /g,''))).replace('.html&','.html?').replace('.htm&','.htm?');
}
}
document.getElementById('eemail').style.display='inline';
drawtable();
}

function drawtable() {
var ourarr, ouru, huhs, thischar=' ';
cleargame();
solved=0;
solvedones="";
spellsout="";
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) {
huhs=fivec.replace(/\ /g,'').split('""');
solved=eval(-1 + huhs.length);
ourarr=fivea;
}
if (deflength == 6) {
huhs=sixc.replace(/\ /g,'').split('""');
solved=eval(-1 + huhs.length);
ourarr=sixa;
}
if (deflength == 7) {
huhs=sevenc.replace(/\ /g,'').split('""');
solved=eval(-1 + huhs.length);
ourarr=sevena;
}
if (deflength == 8) {
huhs=eightc.replace(/\ /g,'').split('""');
solved=eval(-1 + huhs.length);
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 if (ourarr[eval(-1 + ii)].length < jj) {
thischar=' ';
document.getElementById("td" + ii + "_" + jj).style.display='table-cell';
if (jj == ouru) {
spellsout+=thischar;
if (thischar == ' ') {
document.getElementById("td" + ii + "_" + jj).style.backgroundColor='yellow';
document.getElementById("td" + ii + "_" + jj).innerHTML=thischar;
} else {
document.getElementById("td" + ii + "_" + jj).style.backgroundColor='yellow';
document.getElementById("td" + ii + "_" + jj).innerHTML=defsel.replace(' id=?', ' id=s' + 'td' + ii + '_' + jj).replace('">' + thischar + '</',' ">' + thischar + ' </');
}
} else {
document.getElementById("td" + ii + "_" + jj).style.backgroundColor='lightblue';
document.getElementById("td" + ii + "_" + jj).innerHTML=thischar;
}
} else {
document.getElementById("td" + ii + "_" + jj).style.display='table-cell';
if (jj == ouru) {
thischar=ourarr[eval(-1 + ii)].substring(eval(-1 + jj),jj);
spellsout+=thischar;
if (thischar == ' ') {
document.getElementById("td" + ii + "_" + jj).style.backgroundColor='yellow';
document.getElementById("td" + ii + "_" + jj).innerHTML=thischar;
} else {
document.getElementById("td" + ii + "_" + jj).style.backgroundColor='yellow';
document.getElementById("td" + ii + "_" + jj).innerHTML=defsel.replace(' id=?', ' id=s' + 'td' + ii + '_' + jj).replace('">' + thischar + '</',' ">' + thischar + ' </');
}
} 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='';
} else if (osel.value.substring(0,1) == "-") {
var widea='???????', xouru=eval(1 + unknownchar[eval(-5 + eval(osel.value.replace('-','').replace('-','')))]);
if (osel.value.indexOf("--") != 0) {
widea=prompt("For the " + osel.value.replace('-','') + " letter Middle Word Game what is your desired vertical word (and please note filling with ? will get computer to work out this word, secret even to you, and no need to worry about the rest here, because computer will supply the clue) to solve for, and, optionally follow it up by semicolon followed by a better alternative text instead of 'Spell out a Job Description in Information Technology below.'", "documenter;Spell out a Job Description in Information Technology below.");
}
if (widea == null) widea='';
if (widea != '') {
var awidea=widea.split(';');
if (awidea.length > 1) {
blurb=awidea[1];
document.getElementById('blurb').innerHTML=awidea[1];
}
if (doemailsynch) {
doemailsynch=false;
emailsynch();
}
deflength=eval(osel.value.replace('-','').replace('-',''));
//alert(document.URL.split('#')[0].split('?')[0].replace('.html','.php').replace('.htm','.php') + '?len=' + osel.value.replace('-','').replace('-','') + '&at=' + xouru + '&fitswith=' + encodeURIComponent(awidea[0].toLowerCase()));
document.getElementById('wordgen').src=document.URL.split('#')[0].split('?')[0].replace('.html','.php').replace('.htm','.php') + '?len=' + osel.value.replace('-','').replace('-','') + '&at=' + xouru + '&fitswith=' + encodeURIComponent(awidea[0].toLowerCase());
}
}
}
if (retval != '') {
location.href=document.URL.split('#')[0].split('?')[0] + defname + encodeURIComponent(retval.replace(/\ /g,''));
}
}

function shareviaemail() {
var prefix=document.getElementById('aemail').href.split('body=');
document.getElementById('aemail').href=prefix[0] + 'body=' + encodeURIComponent(thisurlis);
document.getElementById('aemail').click();
}
</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>
<option value="-5">Computer 5 Letter Game</option>
<option value="-6">Computer 6 Letter Game</option>
<option value="-7">Computer 7 Letter Game</option>
<option value="-8">Computer 8 Letter Game</option>
<option value="--5">Computer 5 Letter Mystery 7 Game</option>
<option value="--6">Computer 6 Letter Mystery 7 Game</option>
<option value="--7">Computer 7 Letter Mystery 7 Game</option>
<option value="--8">Computer 8 Letter Mystery 7 Game</option>
</select> Middle Word Game <a id='eemail' style='display:none;' onclick='shareviaemail();' title='Share via Email a link to this Current Game you are Playing'>📧</a><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 id='blurb'>Spell out a Job Description in Information Technology below.</h4>
<table id='mytable' cellpadding=15 cellspacing=2>
<tbody id='mytbody'>
</tbody>
</table>
<a style='display:none;' href='mailto:fillin@email.to?subject=Middle%20Word%20Game&body=' id='aemail'>Share via Email</a>
<input type='hidden' id='def5' value=''></input>
<input type='hidden' id='def6' value=''></input>
<input type='hidden' id='def7' value=''></input>
<input type='hidden' id='def8' value=''></input>
<iframe id='wordgen' src='about:blank' title='Finder of words' style='display:none;'></iframe>
</body>
</html>