<!doctype html>
<html>
<head>
<title>The Homonyms Game - RJM Programming - May, 2015</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<script type='text/javascript'>
function effectiveDeviceWidth() { // thanks to http://stackoverflow.com/questions/9477028/how-to-programmatically-find-the-device-width-in-phonegap-jquery-mobile
var deviceWidth = window.orientation == 0 ? window.screen.width : window.screen.height;
// iOS returns available pixels, Android returns pixels / pixel ratio
// http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html
if (navigator.userAgent.indexOf('Android') >= 0 && window.devicePixelRatio) {
deviceWidth = deviceWidth / window.devicePixelRatio;
}
return deviceWidth;
}
function onl() {
var isrc="https://www.google.com.au/search?q=%22" + document.getElementById('sense').value.replace(/ /g, "%20") + "%20of%20".replace("%20of%20","%20" + document.getElementById('littleword').innerHTML + "%20").replace("%20%20","%20") + document.getElementById('concept').value.replace(/ /g, "%20") + "%22&biw=1280&bih=670&source=lnms&tbm=isch&sa=X&ei=AFBRVZe1OtO3ogTDhYHwCw&ved=0CAcQ_AUoAg";
window.open(isrc, document.getElementById('sense').value + " of ".replace(" of "," " + document.getElementById('littleword').innerHTML + " ").replace(" "," ") + document.getElementById('concept').value, "top=230,left=0,width=" + eval(effectiveDeviceWidth() / 2) + ",height=400");
}
function assess(sis) {
//alert(sis.id);
document.getElementById('myi').style.display='block';
// //document.getElementById('myf').action="https://www.google.com.au/search?q=%22" + document.getElementById('sense').value.replace(/ /g, "%20") + "+of+" + document.getElementById('concept').value.replace(/ /g, "%20") + "%22&biw=1280&bih=670&source=lnms&tbm=isch&sa=X&ei=AFBRVZe1OtO3ogTDhYHwCw&ved=0CAcQ_AUoAg";
var isrc="https://www.google.com.au/search?q=%22" + document.getElementById('sense').value.replace(/ /g, "%20") + "%20of%20".replace("%20of%20","%20" + document.getElementById('littleword').innerHTML + "%20").replace("%20%20","%20") + document.getElementById('concept').value.replace(/ /g, "%20") + "%22&biw=1280&bih=670&source=lnms&tbm=isch&sa=X&ei=AFBRVZe1OtO3ogTDhYHwCw&ved=0CAcQ_AUoAg";
document.getElementById('myi').src="http://www.rjmprogramming.com.au/PHP/YQL/Thesaurus/Ajax_yql_thesaurus.html?startwith=" + document.getElementById('sense').value.replace(/ /g, "%20") + "%20of%20".replace("%20of%20","%20" + document.getElementById('littleword').innerHTML + "%20").replace("%20%20","%20") + document.getElementById('concept').value.replace(/ /g, "%20");
window.open(isrc, document.getElementById('sense').value + " of ".replace(" of "," " + document.getElementById('littleword').innerHTML + " ").replace(" "," ") + document.getElementById('concept').value, "top=230,left=0,width=" + eval(effectiveDeviceWidth() / 2) + ",height=400");
// document.getElementById('submit').click();
}
function ddowntwo(objs,objsval) {
var ii, newword="", newwords, newrhs, optionsense="", optionconcept="", keywords="", littleword="of", ls;
document.getElementById('sense').innerHTML="<option value='Sense'>Sense</option><option value='Scents'>Scents</option><option value='Cents'>Cents</option>";
document.getElementById('concept').innerHTML="<option value='Humour'>Humour</option><option value='Money'>Money</option><option value='Entitlement'>Entitlement</option><option value='Yesteryear'>Yesteryear</option><option value='Perfume'>Perfume</option>"
if (objsval == "") {
keywords=prompt("Please enter comma separated Homonym list (to change middle word from 'of', prefix the comma separated Homonym list by that middle word followed by ;)", "");
if (keywords != null) {
if (keywords.indexOf(";") != -1) {
ls=keywords.split(";");
if (ls.length == 2) {
littleword=ls[0];
keywords=keywords.replace(ls[0] + ";", "");
}
}
if (keywords.indexOf(",") != -1) {
newwords=keywords.split(",");
newword=newwords[0];
var rhs=prompt("Please enter comma separated Right Hand (to '" + littleword + "') list of words", "");
if (rhs != null) {
if (rhs != "") {
newrhs=rhs.split(",");
objs.innerHTML+='<option value="' + newword + '"> ' + newword.substring(0,1).toUpperCase() + newword.substring(1).toLowerCase() + '</option>';
document.body.innerHTML+='<input id="' + newword + '" type="hidden" value="' + littleword + ';' + newwords + '" title="' + rhs + '"></input>';
for (ii=0; ii<newwords.length; ii++) {
optionsense+='<option value="' + newwords[ii] + '">' + newwords[ii] + '</option>';
}
for (ii=0; ii<newrhs.length; ii++) {
optionconcept+='<option value="' + newrhs[ii] + '">' + newrhs[ii] + '</option>';
}
document.getElementById('sense').innerHTML=optionsense;
document.getElementById('concept').innerHTML=optionconcept;
document.getElementById('littleword').innerHTML=littleword;
//objs.value=newword;
assess(document.getElementById('sense'));
document.getElementById('selo').value=newword;
}
}
}
}
} else if (objsval.toLowerCase() != "sense") {
keywords=document.getElementById(objsval).value;
if (keywords.indexOf(";") != -1) {
ls=keywords.split(";");
if (ls.length == 2) {
littleword=ls[0];
keywords=keywords.replace(ls[0] + ";", "");
}
}
newwords=keywords.split(",");
newrhs=document.getElementById(objsval).title.split(",");
for (ii=0; ii<newwords.length; ii++) {
optionsense+='<option value="' + newwords[ii] + '">' + newwords[ii] + '</option>';
}
for (ii=0; ii<newrhs.length; ii++) {
optionconcept+='<option value="' + newrhs[ii] + '">' + newrhs[ii] + '</option>';
}
document.getElementById('sense').innerHTML=optionsense;
document.getElementById('concept').innerHTML=optionconcept;
document.getElementById('littleword').innerHTML=littleword;
assess(document.getElementById('sense'));
} else {
document.getElementById('littleword').innerHTML='of';
assess(document.getElementById('sense'));
}
}
</script>
</head>
<body style='background-color: #e7d7f7;' onload="onl();">
<h1 align='center'>The <a target=_blank title='Homonyms information from Wikipedia ... thanks' href='http://en.wikipedia.org/wiki/Homonym'>Homonym</a> <select style='background-color: pink;' id='selo' onchange='ddowntwo(this,this.value);'><option value='sense'>Sense</option><option value=''>(Add your own)</option><option value='bear'>Bear</option><option value='rest'>Rest</option><option value='pride'>Pride</option></select> Game</h1>
<h4 align='center'>RJM Programming - May, 2015</h4>
<div id='mydiv' align='center'>
<select style='background-color: pink;' onchange="assess(this);" id='sense'><option value='Sense'>Sense</option><option value='Scents'>Scents</option><option value='Cents'>Cents</option></select> <span id='littleword'>of</span> <select style='background-color: lightblue;' onchange="assess(this);" id='concept'><option value='Humour'>Humour</option><option value='Money'>Money</option><option value='Entitlement'>Entitlement</option><option value='Yesteryear'>Yesteryear</option><option value='Perfume'>Perfume</option></select>
</div>
<br><iframe id='myi' src='http://www.rjmprogramming.com.au/PHP/YQL/Thesaurus/Ajax_yql_thesaurus.html?startwith=Sense%20of%20Humour' style='display:block;width:100%;height:600px;border: 3px maroon dashed;opacity:0.6;'></iframe>
<form id='myf' name='myf' target='myi' style='display:none;' action='#'><input type='submit' value='Submit' name='submit' id='submit'></input></form>
<input id='bear' type='hidden' value=';bear,bare' title='pit,bones,necessities,fur'></input>
<input id='rest' type='hidden' value=';rest,wrest' title='break,control,stop'></input>
<input id='pride' type='hidden' value='of;pride,pried' title='place,people,lions,them'></input>
</body>
</html>