<html>
<head>
<title>Units of Measure Game - RJM Programming - June, 20146</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<script type='text/javascript'>

// Thanks to (bit of lateral thinking off) Five-Minute Activities by Penny Ur and Andrew Wright p. 50
// Additional thanks to http://www.allaboutcircuits.com/textbook/direct-current/chpt-14/magnetic-units-of-measurement/
// https://www.google.com.au/?client=firefox-b-ab#q=what+does+fluid+ounce+measure
// http://www.fileformat.info/info/unicode/char/b3/browsertest.htm
// https://www.google.com.au/?client=firefox-b-ab#q=what+does+a+Maxwell+measure
// http://www.thefreedictionary.com/Gilbert
// https://www.google.com.au/?client=firefox-b-ab#q=what+does+a+Gilbert+measure&gfe_rd=cr
// https://www.google.com.au/search?q=what+does+a+Gilbert+measure&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei=QhVWV7i8CrDD8AeL-YmwAw
// http://www.allaboutcircuits.com/textbook/direct-current/chpt-14/magnetic-units-of-measurement/
// https://www.google.com.au/?client=firefox-b-ab#q=measures+of+magnetism
// https://scholar.google.com.au/scholar?q=measures+of+fluidity&hl=en&as_sdt=0&as_vis=1&oi=scholart&sa=X&ved=0ahUKEwjFreKs05TNAhXHk5QKHaTYCXYQgQMIGjAA
// https://www.google.com.au/?client=firefox-b-ab#q=measures+of+fluidity&gfe_rd=cr
// https://www.google.com.au/search?q=measures+of+fluidity&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei=MBRWV-rhGLDD8AeL-YmwAw
// http://www.fileformat.info/info/unicode/char/b2/browsertest.htm
// http://www.fileformat.info/info/unicode/char/b2/index.htm
// https://www.google.com.au/?client=firefox-b-ab#q=superscript+2
// http://www.fileformat.info/info/unicode/char/2082/index.htm
// https://www.google.com.au/?client=firefox-b-ab#q=subscript+2&gfe_rd=cr
// https://www.google.com.au/search?q=subscript+2&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei=XxNWV-ziMKfD8AfWzYDYBQ
// https://www.google.com.au/?client=firefox-b-ab#q=measures+of+acceleration
// https://www.google.com.au/?client=firefox-b-ab#q=what+is+ampere
// https://www.google.com.au/?client=firefox-b-ab#q=measures+of+conductivity
// https://answers.yahoo.com/question/index?qid=20080924211112AAP45PY
// https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwjYuqzwz5TNAhXDlJQKHSKFB9UQFgghMAE&url=// https%3A%2F%2Fanswers.yahoo.com%2Fquestion%2Findex%3Fqid%3D20080924211112AAP45PY&usg=AFQjCNG9kETiQygkNOiDhxS0zVLxPb9chg&sig2=KRo21tr6mRQ_nbAXZ_W5Ag
// http://www.technologystudent.com/joints/conduct1.html
// http://www.engineersedge.com/material_science/ductility.htm
// https://en.wikipedia.org/wiki/Ductility
// https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0ahUKEwjYuqzwz5TNAhXDlJQKHSKFB9UQFggoMAI&url=// https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FDuctility&usg=AFQjCNEFQ1j9kTlPfMXTt8t5vB9BV04f0w&sig2=RbqeQMMwHLulY5aM8DSMdw&bvm=bv.123664746,d.dGo
// https://www.google.com.au/?client=firefox-b-ab#q=measures+of+malleability
// https://www.google.com.au/?client=firefox-b-ab#q=measures+of+stress
// https://www.youtube.com/watch?v=ACfOLpCM0AQ&index=7&list=LLtVd0c0tGXuTSbU5d8cSBUg
// https://www.google.com.au/?client=firefox-b-ab#q=measures+of+pressure&gfe_rd=cr
// https://www.google.com.au/search?q=measures+of+pressure&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei=xA9WV_m8JafD8AfWzYDYBQ
// http://www.synonym.com/synonyms/dyne
// http://www.synonym.com/synonyms/sthene
// http://www.synonym.com/synonyms/newton
// https://www.google.com.au/?client=firefox-b-ab#q=synonyms+for+newton&gfe_rd=cr
// https://www.google.com.au/search?q=synonyms+for+newton&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei=cg9WV5SNEKfD8AfWzYDYBQ
// https://scholar.google.com.au/scholar?q=synonyms+for+newton&btnG=&hl=en&as_sdt=0%2C5&as_vis=1
// https://scholar.google.com.au/scholar?q=measures+of+force+other+than+newton&btnG=&hl=en&as_sdt=0%2C5&as_vis=1
// https://scholar.google.com.au/scholar?q=measures+of+force&hl=en&as_sdt=0&as_vis=1&oi=scholart&sa=X&ved=0ahUKEwibj8C_zpTNAhUBpZQKHWy7CcIQgQMIGjAA
// https://www.google.com.au/?client=firefox-b-ab#q=measures+of+force&gfe_rd=cr
// https://www.google.com.au/search?q=measures+of+force&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei=GQ9WV7XBIKfD8AfWzYDYBQ
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+alkalinity&gfe_rd=cr
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+acidity
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+friction
// https://answers.yahoo.com/question/index?qid=20081019072224AAFjbJm
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+smell
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+an+earthquakes+magnitude
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+energy
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+frequency
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+gravity
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+heat
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+noise
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+sound
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+national+income
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+obesity
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+radiation
// https://www.google.com.au/?client=firefox-b-ab#q=what+unit+does+a+geiger+counter+measure
// https://www.google.com.au/?client=firefox-b-ab#q=measure+of+variance
// https://www.google.com.au/?client=firefox-b-ab#q=mean+mode+median+are+measures+of

var measure = ["central tendency","variance","radioactive exposure","radiation","elevation","angle","obesity","national income","noise","sound","illumination","iron in blood","heat","temperature","gravity","frequency","energy","blood pressure","vibration","smell","friction","acidity","alkalinity","time","mass","luminocity","area","volume","velocity","length","rotation speed","force","pressure","conductivity","resistance","ductility","malleability","current","acceleration","magnetomotive force","magnetic flux","magnetic field intensity","magnetic flux density","magnetic reluctance","magnetic permeability"];

var measure_central_tendency = ["mean","average","mode","median"];
var measure_variance = ["standard deviation","standard variance"];
var measure_radioactive_exposure = ["µSv/hr","micro-Sieverts per hour"];
var measure_radiation = ["rad","Gy","Sv"];
var measure_elevation = ["cm","m","inch","ft","yd","km","mile","mm"];
var measure_depth = ["cm","m","inch","ft","yd","km","mile","mm"];
var measure_angle = ["degree","radian","grad"];
var measure_obesity = ["BMI"];
var measure_national_income = ["GDP"];
var measure_noise = ["decibels"];
var measure_sound = ["decibels","dBA of sound pressure"];
var measure_illumination = ["lumen per square metre","foot-candle"];
var measure_iron_in_blood = ["CBC"];
var measure_heat = ["calorie","Btu"];
var measure_temperature = ["Celsius","Kelvin","Fahrenheit"];
var measure_gravity = ["m/s²","newtons per kilogram","N/kg","N. kg−1","m. s−2"];
var measure_frequency = ["cycles per second","rpm"];
var measure_energy = ["Joule","kilowatt-hour","Watt"];
var measure_blood_pressure = ["mmHg"];
var measure_vibration = ["Richter"];
var measure_smell = ["ouE/m³"];
var measure_friction = ["newton","sthene","dyne"];
var measure_acidity = ["pH"];
var measure_alkalinity = ["pH"];
var measure_time = ["second","minute","hour","nanosecond","millisecond","day","month","year","decade","century"];
var measure_mass = ["kg","pound","stone","ton","tonne","gram","mg","nanogram"];
var measure_luminocity = ["lumens"];
var measure_area = ["m²","hectare","acre","km²","square mile","cm²","mm²"];
var measure_volume = ["m³","litre","millilitre","km³","fluid ounce","cm³","mm³"];
var measure_velocity = ["km/h","m/h","m/s","knot"];
var measure_speed = ["km/h","m/h","m/s","knot"];
var measure_length = ["cm","m","inch","ft","yd","km","mile","mm","light year","nanometer"];
var measure_distance = ["cm","m","inch","ft","yd","km","mile","mm","light year","nanometer","nautical mile"];
var measure_rotation_speed = ["rpm","cycles per second"];
var measure_force = ["newton","sthene","dyne"];
var measure_pressure = ["pascal","kPa","psi","mbar","atm","hPa"];
var measure_conductivity = ["µS/cm"];
var measure_resistance = ["ohms"];
var measure_ductility = ["elongation","RA"];
var measure_malleability = ["hardness"];
var measure_current = ["ampere"];
var measure_acceleration = ["m/s²","newtons per kilogram","N/kg","N. kg−1","m. s−2"];
var measure_magnetomotive_force = ["Gb","amp-turn"];
var measure_magnetic_flux = ["Mx","Wb","Line"];
var measure_magnetic_field_intensity = ["Oe","amp-turns per meter","amp-turns per inch"];
var measure_magnetic_flux_density = ["G","T","Lines per square inch"];
var measure_magnetic_reluctance = ["Gilberts per Maxwell","Amp-turns per Weber","Amp-turns per line"];
var measure_magnetic_permeability = ["Gauss per Oersted","Tesla-meters per Amp-turn","Lines per inch-Amp-turn"];

var nmeasure = measure.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(";");
var alljobs = asis[1].split(",");
sisvalue = sisvalue.replace(asis[0] + ";", ",") + ",";
var proposedurl = "http://www.thefreedictionary.com/" + asis[0].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+");
var proposed2url = "https://www.google.com.au/?client=firefox-b-ab#q=" + encodeURIComponent(asis[0].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+"));
proposed2url = "https://www.google.com/search?q=" + encodeURIComponent(asis[0].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<alljobs.length; mm++) {
if (radvalue == alljobs[mm]) alljobs[mm] = '';
}
} else if (wedonotthink == "") {
wedonotthink = "We do not think the following units of measure work with " + asis[0] + ": " + radvalue;
} else {
wedonotthink = wedonotthink + ", " + radvalue;
}
}
}

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

if (plusbit < alljobs.length) {

for (mm=0; mm<alljobs.length; mm++) {
if (alljobs[mm] != "") {
if (wealsothink == "") {
wealsothink = "We think the following units of measure could also work with " + asis[0] + ": " + alljobs[mm];
} else {
wealsothink = wealsothink + ", " + alljobs[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.", asis[0].replace("-1", "").replace("-2", ""));
if (maybe != null) {
if (maybe.replace(" ", "+").replace(" ", "+") == asis[0].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+")) {
window.open(proposedurl, asis[0].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+"), "top=20,left=20,width=800,height=600");
window.open(proposed2url, asis[0].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+"), "top=40,left=40,width=600,height=500");
}
}
} else if (wedonotthink != "" || wealsothink != '') {
alert("It did not stop you scoring, but ... " + wealsothink + wedonotthink);
}

oois = document.getElementById("s_measure");
oois.value = easnames[Math.floor(Math.random() * numwords) + 0];
}


function writeItOut() {
var i = 0, j = 0, k = 0, m = 0, ois, selbit = '', selbit = '', thisdiv = '', myarr = [], myword = [], answerword = [], thisrb = "", measurecell = "<td>", advancedcell = "<td>";
var esnames = new Array(nmeasure);
var tstr = "<table style='background-color: lightblue;' border=5 cellpadding=5 cellspacing=5><tbody id='wctbody'><tr style='background-color: pink;'><th>Unit of Measure (1 point per correct matching (means or) unit of measure)</th></tr><tr><td>";
thisrb = "<form action='' id='f_measure' name='f_measure'>";
measure.sort();
for (i=1; i<=nmeasure; i++) {
if ((i % 5) == 0) {
thisrb = thisrb + "<input type='checkbox' name='r_measure' value='" + measure[i - 1] + "'>" + measure[i - 1] + "<br>";
} else {
thisrb = thisrb + "<input type='checkbox' name='r_measure' value='" + measure[i - 1] + "'>" + measure[i - 1];
}
}
thisrb = thisrb + "</form>  <input id='i_measure' type='button' onclick='check(this);' value='Check unit of measure word associations above with word(s) below'></input>";
thisdiv = "<div id='measure' style='border: 2px solid green;'>" + thisrb + "</div>";
tstr = tstr + thisdiv;
selbit = "<br><br>  <select id='s_measure'></select>"
for (i=0; i<nmeasure; i++) {
esnames[i] = "measure_" + measure[i].replace(" ", "_").replace(" ", "_").replace(" ", "_").replace(" ", "_").replace(" ", "_").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(">" + myarr[j] + "<") != -1) {
for (m=0; m<k; m++) {
if (easnames[m].indexOf(myarr[j] + ";") != -1) {
selbit = selbit.replace("'" + myarr[j] + ";", "'" + myarr[j] + ";" + measure[i] + ",");
easnames[m] = easnames[m].replace(myarr[j] + ";", myarr[j] + ";" + measure[i] + ",");
}
}
} else {
selbit = selbit.replace("</select>", "<option value='" + myarr[j] + ";" + measure[i] + "'>" + myarr[j] + "</option></select>");
easnames[k] = myarr[j] + ";" + measure[i];
k = eval(k + 1);
}

}


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

numwords = k;

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

for (j=0; j<numwords; j++) {
ois = document.getElementById("s_measure");
ois.value = easnames[Math.floor(Math.random() * numwords) + 0];
}
}


function begin() {
writeItOut();
}


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

<h1 align='center'>Units of Measure Match Game</h1>
<h3 align='center' id='score'>Score: 0 from 0 goes</h3>
<div align='center'>
<script> begin(); </script>
</div>
</body>
</html>