<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Match Word Techniques - RJM Programming - May, 2017 ... Thanks to Text Types in English by Mark Anderson and Kathy Anderson (ISBN: 0-7329-4584-4) p. 72-74</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>

<script type='text/javascript'>

// Thanks to Text Types in English p. 72-74
var characteristic = ["alliteration;the use of the same letter or sound in two or more words that are close together. It is indicated by repeated consonants.",
"antonym;a word that has the opposite meaning to another",
"assonance;the use of the same letter or sound in words that are close together. It is indicated by repeated vowels or vowel sounds.",
"compound word;a word made up by putting two or more existing words together",
"colloquialism;a word used in everyday writing or speech, as opposed to formal or literary texts",
"ephemism;a word or phrase used to communicate an idea in a polite or less direct way",
"gerund;a verb that functions as a noun",
"homonym;a word with the same spelling as another, but with a different meaning",
"homophone;a word that sounds the same as another but has a different meaning",
"jargon;the use of words that are particular to a specific subject or occupation",
"neologism;a new word or expression in a language",
"onomatopoeia;the use of words that sound like the action they represent",
"palindrome;a word or phrase that reads the same backwards as forwards",
"personification;the use of words, usually verbs, that are associated with people to describe non-human things",
"pun;the use of one word to suggest different meanings",
"rhyme;the sound of two or more words matching",
"slang;words that are not accepted in 'formal' English",
"solecism;the mispronunciation of a word that relates to technical language, or jargon",
"synonym;a word that has a similar meaning to another"];
var sentencephrase = ["Around the rugged rocks the ragged rascal ran.",
"hot versus cold, tall versus short",
"I lie here and cry, my eyes like fires.",
"goldfish, footpath",
"'undies' for underpants, 'get flogged for' for beaten in a game",
"'the bathroom' for toilet, 'passed away' for died",
"she likes drinking, swimming is good for you",
"Come and wave goodbye to Grandma. She surfed wave after wave.",
"flour and flower, sail and sale",
"'slips' in cricket, 'starboard' in sailing",
"'fax' for facsimile machine, 'modem' for modulator plus demodulator",
"the hiss of a snake, the click of his fingers",
"radar, mum",
"The dam wall, tired of holding back the water, crumbled. The oak tree, standing tall, shed lots of leaves.",
"Why did the teacher need glasses? Because he couldn't control his pupils.",
"right and light, day and way",
"'crook' for sick, 'what a bummer' for that was bad luck",
"'Boats-wain' for boatswain (pronounced bo-sun), 'mid-wife-ery' for midwifery (pronounced mid-wiffery)",
"stop and halt, neat and tidy",
"bloodhound, campground"
];

var sentencephrase_0 = [characteristic[0].split(";")[0]];
var sentencephrase_1 = [characteristic[1].split(";")[0]];
var sentencephrase_2 = [characteristic[2].split(";")[0]];
var sentencephrase_3 = [characteristic[3].split(";")[0]];
var sentencephrase_4 = [characteristic[4].split(";")[0]];
var sentencephrase_5 = [characteristic[5].split(";")[0]];
var sentencephrase_6 = [characteristic[6].split(";")[0]];
var sentencephrase_7 = [characteristic[7].split(";")[0]];
var sentencephrase_8 = [characteristic[8].split(";")[0]];
var sentencephrase_9 = [characteristic[9].split(";")[0]];
var sentencephrase_10 = [characteristic[10].split(";")[0]];
var sentencephrase_11 = [characteristic[11].split(";")[0]];
var sentencephrase_12 = [characteristic[12].split(";")[0]];
var sentencephrase_13 = [characteristic[13].split(";")[0]];
var sentencephrase_14 = [characteristic[14].split(";")[0]];
var sentencephrase_15 = [characteristic[15].split(";")[0]];
var sentencephrase_16 = [characteristic[16].split(";")[0]];
var sentencephrase_17 = [characteristic[17].split(";")[0]];
var sentencephrase_18 = [characteristic[18].split(";")[0]];
var sentencephrase_19 = [characteristic[3].split(";")[0],characteristic[15].split(";")[0]];

var nsentencephrase = sentencephrase.length;
var numwords = 0;
var easnames = [];
var score = 0;
var goes = 0;

function check(bis) {
var plusbit = 0, jj, mm, oois, wealsothink = "", wedonotthink = "";
goes = goes + 1;
//alert(bis.id);
var sisvalue = document.getElementById(bis.id.replace("i_", "s_")).value;
var asis = sisvalue.split(";");
//alert(asis[1] + ' ... ' + sisvalue);
var allwordtechniques = asis[1].split(",");
sisvalue = sisvalue.replace(asis[0] + ";", ",") + ",";
var proposedurl = "http://www.thefreedictionary.com/" + asis[1].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+");
//alert(sisvalue);
var radis = document.getElementsByName(bis.id.replace("i_", "r_"));
var radvalue = '';
for (var i = 0, length = radis.length; i < length; i++) {
if (radis[i].checked) {
radvalue = radis[i].value;
if (sisvalue.indexOf("," + radvalue + ",") != -1) {
if (sisvalue.indexOf("-2") != -1) {
plusbit = eval(plusbit + 2);
} else {
plusbit = eval(plusbit + 1);
}
for (mm=0; mm<allwordtechniques.length; mm++) {
if (radvalue == allwordtechniques[mm]) allwordtechniques[mm] = '';
}
} else if (wedonotthink == "") {
wedonotthink = "We do not think the following word techniques work with " + asis[0] + ": " + radvalue + " " + however(radvalue);
} else {
wedonotthink = wedonotthink + ", " + radvalue + " " + however(radvalue);
}
}
}

if (wedonotthink != "") wedonotthink = wedonotthink + ". ";

if (plusbit < allwordtechniques.length) {

for (mm=0; mm<allwordtechniques.length; mm++) {
if (allwordtechniques[mm] != "") {
if (wealsothink == "") {
wealsothink = "We think the following word techniques could also work with " + asis[0] + ": " + allwordtechniques[mm] + " " + however(allwordtechniques[mm]);
} else {
wealsothink = wealsothink + ", " + allwordtechniques[mm] + " " + however(allwordtechniques[mm]);
}
}
}
wealsothink = wealsothink + ". ";
}

score = eval(score + plusbit);
document.getElementById('score').innerHTML = "Score: " + score + " from " + goes + " goes";

if (plusbit == 0) {
var maybe = prompt(wealsothink + wedonotthink + "If you want to see a dictionary lookup press OK button. " + however(asis[1].replace("-1", "").replace("-2", "")), asis[1].replace("-1", "").replace("-2", ""));
if (maybe != null) {
if (maybe.replace(" ", "+").replace(" ", "+") == asis[1].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+")) {
window.open(proposedurl, asis[1].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+"), "top=20,left=20,width=800,height=600");
}
}
} else if (wedonotthink != "" && wealsothink != '') {
alert("It did not stop you scoring, but ... " + wealsothink + wedonotthink);
} else if (wedonotthink != "") {
alert("It didn't stop you scoring, but ... " + wedonotthink);
} else if (wealsothink != "") {
alert("It didn't stop you scoring, but " + wealsothink);
}

//oois = document.getElementById("s_sentencephrase");
//oois.value = easnames[Math.floor(Math.random() * numwords) + 0];
setTimeout(delayit,500);
}

function however(idea) {
var ii, retval="";
for (ii=0; ii<characteristic.length; ii++) {
if (characteristic[ii].indexOf(idea + ";") == 0) retval=String.fromCharCode(10) + idea.substring(0,1).toUpperCase() + idea.substring(1) + ': ' + characteristic[ii].split(';')[1];
}
return retval;
}


function writeItOut() {
var i = 0, j = 0, k = 0, m = 0, ois, selbit = '', selbit = '', thisdiv = '', myarr = [], myword = [], answerword = [], thisrb = "", sentencephrasecell = "<td>", advancedcell = "<td>";
var esnames = new Array(nsentencephrase);
var tstr = "<table style='width:100%;text-align:center;background-color: lightgreen;' border=5 cellpadding=5 cellspacing=5><tbody id='wctbody'><tr style='background-color: pink;'><th>Word Technique (1 point per correct matching word technique)</th></tr><tr><td>";
thisrb = "<form action='' id='f_sentencephrase' name='f_sentencephrase'>";
//sentencephrase.sort();
for (i=1; i<=characteristic.length; i++) {
if ((i % 5) == 0) {
thisrb = thisrb + "<input type='checkbox' name='r_sentencephrase' title='" + characteristic[i - 1].split(";")[1] + "' value='" + characteristic[i - 1].split(";")[0] + "'>" + characteristic[i - 1].split(";")[0] + "<br>";
} else {
thisrb = thisrb + "<input type='checkbox' name='r_sentencephrase' title='" + characteristic[i - 1].split(";")[1] + "' value='" + characteristic[i - 1].split(";")[0] + "'>" + characteristic[i - 1].split(";")[0];
}
}
thisrb = thisrb + "</form><br>  <input style='background-color:yellow;' id='i_sentencephrase' type='button' onclick='check(this);' value='Check word techniques above with phrase(s) and/or sentence(s) below'></input>";
thisdiv = "<div id='sentencephrase' style='border: 2px solid green;'>" + thisrb + "</div>";
tstr = tstr + thisdiv;
selbit = "<br><br>  <select id='s_sentencephrase'></select><br><br>"
for (i=0; i<nsentencephrase; i++) {
esnames[i] = "sentencephrase_" + i; //sentencephrase[i].replace(" ", "_");
//alert(esnames[i] + thisrb);
for (j=0; j<eval(esnames[i] + ".length"); j++) {
myarr[j] = eval(esnames[i] + "[" + j + "]");
//alert("myarr[j]=" + myarr[j] + ":" + selbit);
if (selbit.indexOf(">" + sentencephrase[i] + "<") != -1) {
for (m=0; m<k; m++) {
if (easnames[m].indexOf(sentencephrase[i] + ";") != -1) {
selbit = selbit.replace("\"" + sentencephrase[i] + ";", "\"" + sentencephrase[i] + ";" + myarr[j] + ",");
easnames[m] = easnames[m].replace(sentencephrase[i] + ";", sentencephrase[i] + ";" + myarr[j] + ",");
//alert("m:" + easnames[m]);
}
}
} else {
selbit = selbit.replace("</select>", "<option value=\"" + sentencephrase[i] + ";" + myarr[j] + "\">" + sentencephrase[i] + "</option></select>");
easnames[k] = sentencephrase[i] + ";" + myarr[j];
//alert(easnames[k]);
k = eval(k + 1);
}

}


}
tstr = tstr.replace("</div>", selbit.replace("</select>", "<option selected value=></option></select>") + "</td></div>");

numwords = k;

tstr = tstr + "</tr></tbody></table>";
//alert(tstr);
document.write(tstr);


//alert("numwords=" + numwords);

//for (j=0; j<numwords; j++) {
// ois = document.getElementById("s_sentencephrase");
// ois.value = easnames[Math.floor(Math.random() * numwords) + 0];
//}
setTimeout(delayit,500);
}

function delayit() {
var j, ois;
ois = document.getElementById("s_sentencephrase");
ois.value='';
while (ois.value == '') {
for (j=0; j<numwords; j++) {
ois.value = easnames[Math.floor(Math.random() * numwords) + 0].replace("|",";");
//document.title=easnames[Math.floor(Math.random() * numwords) + 0];
}
}
setTimeout(nextdelayit,500);
}

function nextdelayit() {
var ois;
ois = document.getElementById("s_sentencephrase");
ois.click();
}

function begin() {
writeItOut();
}


</script>
</head>
<body style="background-color: lightblue;">

<h1 style='width:100%;text-align:center;'>Match Word Techniques Game</h1>
<h3 style='width:100%;text-align:center;'>RJM Programming - May, 2017</h3>
<h3 style='width:100%;text-align:center;'>Thanks to Text Types in English by Mark Anderson and Kathy Anderson (ISBN: 0-7329-4584-4)</h3>
<h4 style='width:100%;text-align:center;' id='score'>Score: 0 from 0 goes</h4>
<div style='width:100%;text-align:center;'>
<script type='text/javascript'> begin(); </script>
</div>
</body>
</html>