<html>
<head>
<title>Canvas HTML Element Surd Board Game (with image copy) Tutorial ... RJM Programming ... April 2014 ... thanks to http://stackoverflow.com/questions/9880279/how-do-i-add-a-simple-onclick-event-handler-to-a-canvas-element</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<script language="JavaScript">
var score = 0.0;
var goes = 0.0;
var realgoes = 0;
var actsym = '+';
var sactsym = '+';
var answeridea = '';
var sansweridea = '';
var operaJUNKtoris = '';
var num1 = 0;
var denom1 = 0;
var num2 = 0;
var denom2 = 1;
var snum1 = 0;
var sdenom1 = 0;
var snum2 = 0;
var sdenom2 = 1;
var ndenom = 0;
var wrand = 0;
var w1rand = 0;
var w2rand = 0;
var w3rand = 0;
var w4rand = 0;
var luckofthedraw = 0;
var beenhere = 0;
var pstuff;
var myin;
var addhashbit='', curaddh=(document.URL.indexOf('addhashbit=') != -1 ? 0 : 999);
var addhashbits=[];
if (curaddh == 0) {
addhashbits=(document.URL.split('addhashbit=')[1] ? decodeURIComponent(document.URL.split('addhashbit=')[1].split('&')[0].split('#')[0]).split('#')[0] : ' ').substring(1).split('_');
}
var collaborateurl=document.URL.split('?')[0].split('#')[0];
var documentURL=document.URL;
var fromhereon = "0";
var alt1num1 = 0;
var alt1denom1 = 1;
var alt1num2 = 0;
var alt1denom2 = 1;
var alt1actsym = '+';
var alt2num1 = 0;
var alt2denom1 = 0;
var alt2num2 = 0;
var alt2denom2 = 1;
var calt2denom2 = "";
var calt2num2 = "";
var alt2actsym = '+';
var retit='';
var anchor=null;
var alreadyaskedfor=';', suffv='';
var collaboration=location.search.split('collaboration=')[1] ? decodeURIComponent(location.search.split('collaboration=')[1].split('&')[0].split('#')[0]) : '';
var collaboratee=collaboration;
function innertextize(whatih) {
var nextfroms=['[',']','{','}'], inxt=0;
//retit+='Is ... ' + + String.fromCharCode(10) + String.fromCharCode(10) + document.getElementById('bguess').value + '[' + document.getElementById('bguessr').value + document.getElementById('biop').value + document.getElementById('bguess2').value + ']' + document.getElementById('bguess2r').value + ' (as my reduced surd) equivalent to but simpler version of ' + String.fromCharCode(10) + String.fromCharCode(10);
retit=retit.replace('!@', document.getElementById('guess').value + '[' + document.getElementById('guessr').value + (document.getElementById('guess2').outerHTML.split('>')[0].indexOf('none;') != -1 ? '' : document.getElementById('iop').value + document.getElementById('guess2').value + ']' + document.getElementById('guess2r').value));
retit+=' while we think a reduced answer could be ' + String.fromCharCode(10) + String.fromCharCode(10);
retit+='' + document.getElementById('bguess').value + '{' + document.getElementById('bguessr').value + (document.getElementById('bguess2').outerHTML.split('>')[0].indexOf('none;') != -1 ? '' : document.getElementById('biop').value + document.getElementById('bguess2').value + '}' + document.getElementById('bguess2r').value) + String.fromCharCode(10) + String.fromCharCode(10) + '?';
//alert(retit);
var rets=whatih.split('>');
for (var jrets=1; jrets<rets.length; jrets++) {
if (rets[eval(-1 + jrets)].slice(-3) == '/tr') {
retit+=String.fromCharCode(10);
}
if (4 == 6 && rets[eval(-1 + jrets)].indexOf(' value="') != -1) {
retit+=rets[eval(-1 + jrets)].split(' value="')[1].split('"')[0];
}
if (4 == 6 && rets[eval(-1 + jrets)].indexOf(' onchange=') != -1) {
retit+=document.getElementById('iop').value;
}
if (rets[eval(-1 + jrets)].indexOf(' src=') != -1 && rets[eval(-1 + jrets)].indexOf('/images/') != -1 && rets[eval(-1 + jrets)].indexOf('rt.') != -1) {
switch (rets[eval(-1 + jrets)].split('/images/')[1].split('.')[0]) {
case 'g0':
case '0':
retit+='0';
break;
case 'g1':
case '1':
retit+='1';
break;
case 'g2':
case '2':
retit+='2';
break;
case 'g3':
case '3':
retit+='3';
break;
case 'g4':
case '4':
retit+='4';
break;
case 'g5':
case '5':
retit+='5';
break;
case 'g6':
case '6':
retit+='6';
break;
case 'g7':
case '7':
retit+='7';
break;
case 'g8':
case '8':
retit+='8';
break;
case 'g9':
case '9':
retit+='9';
break;
case 'divide':
case 'slash':
retit+='/';
break;
case 'gsqrt':
if (4 == 4) {
retit=retit.replace(nextfroms[inxt],String.fromCodePoint(8730)).replace(nextfroms[inxt],String.fromCodePoint(8730));
inxt++;
} else {
retit+=String.fromCodePoint(8730);
}
break;
case 'gcurt':
if (4 == 4) {
retit=retit.replace(nextfroms[inxt],String.fromCodePoint(8731)).replace(nextfroms[inxt],String.fromCodePoint(8731));
inxt++;
} else {
retit+=String.fromCodePoint(8731);
}
break;
case 'plus':
retit+='+';
break;
case 'gminus':
case 'minus':
retit+='-';
break;
case 'multiply':
retit+='*';
break;
case 'mod':
retit+='%';
break;
case 'power':
retit+='**';
break;
case 'dot':
retit+='.';
break;
case 'line':
if (retit.slice(-1) != '_') {
retit+=String.fromCharCode(10);
}
retit+='_';
break;
default:
break;
}
}
if (4 == 6 && rets[jrets].split('<')[0] != '') {
retit+=rets[jrets].split('<')[0];
}
}
//alert(retit);
return retit; //document.getElementsByTagName('td')[1].innerText;
}
function presendto() {
sendto(collaboratee, 'Surd Mathematics Problem ... my answer follows ...', innertextize(document.getElementsByTagName('td')[1].innerHTML));
}
function sendto(collaborate, subj, bodbit) {
if (collaborate.indexOf('@') != -1) {
anchor = document.createElement('a');
anchor.href = 'mailto:' + (collaborate.trim()) + '?subject=' + encodeURIComponent(subj) + '&body=' + encodeURIComponent(bodbit);
anchor.style.display='none';
document.body.appendChild(anchor);
anchor.innerHTML='Email';
anchor.target='_top';
anchor.click();
} else if (collaborate.trim() != '' && collaborate.trim().split(',')[0].replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
anchor = document.createElement('a');
anchor.href = 'sms:' + (collaborate.trim()) + '&body=' + encodeURIComponent(bodbit);
anchor.style.display='none';
anchor.innerHTML='SMS';
anchor.target='_top';
anchor.click();
}
}
function collaborate() {
if (collaboratee.trim() == '') {
collaboratee=prompt('Enter email address or SMS number to collaborate with (and optionally comma separate your email address for more interaction possibilities regarding your answers)?', '');
if (collaboratee == null) { collaboratee=''; }
if (collaboratee.indexOf(',') != -1) {
collaborateurl+='&collaboration=' + encodeURIComponent(collaboratee);
collaboration=collaboratee;
}
}
sendto(collaboratee, 'Surd Mathematics Problem', collaborateurl);
}
function maybe(imgo,xx,yy) {
if (eval('' + addhashbits.length) > curaddh) {
curaddh++;
context.drawImage(document.getElementById(addhashbits[eval(-1 + curaddh)].split(',')[0]), addhashbits[eval(-1 + curaddh)].split(',')[1], addhashbits[eval(-1 + curaddh)].split(',')[2]);
return document.getElementById('imgnothing');
}
return imgo;
}
function reargs(whichone, ccwhi) {
var spare='', suffz='';
suffv='';
if (whichone.indexOf('' + ccwhi + '=') != -1) {
//collaborateurl=document.URL.split('?')[0].split('#')[0];
//documentURL='';
//alert('here ' + ccwhi);
if (whichone.indexOf('' + ccwhi + suffv + '=') != -1) {
suffv+='_';
}
}
if (documentURL == document.URL) {
while (alreadyaskedfor.indexOf(';' + ccwhi + suffz + ';') != -1) {
suffz+='_';
}
spare=documentURL.split(ccwhi + suffz + '=')[1] ? decodeURIComponent(documentURL.split(ccwhi + suffz + '=')[1].split('&')[0].split('#')[0]).split('#')[0] : '';
alreadyaskedfor+=ccwhi + suffz + ';';
if (spare != '' && (spare + ' ').substring(0,1) >= '0' && (spare + ' ').substring(0,1) <= 9) {
if (2 == 6) {
document.getElementsByTagName('p')[0].innerHTML+=' ' + ccwhi + '=' + spare + '';
}
eval('' + ccwhi + '=' + spare + '');
} else if (spare != '' && (spare + ' ').substring(0,1) == '-' && spare != '-') {
if (2 == 6) {
document.getElementsByTagName('p')[0].innerHTML+=' ' + ccwhi + '=' + spare + '';
}
// http://localhost:8888/HTMLCSS/Canvas/Game/Chalkboard/surd_withimagecopy_chalkboard.html?difficulty=Easy&luckofthedraw=5&wrand=1&w1rand=1&w2rand=1&w4rand=0&xrand=2&actsym=-&mrand=870&num1=-8&num2=0&denom1=-70&denom2=1&alt1num1=-8&alt1denom1=-70&alt1num2=0&alt1denom2=1&alt1actsym=-&alt2num1=-8&alt2denom1=-70&alt2num2=0&alt2denom2=1&alt2actsym=%20&num1_=-8&num2_=0&denom1_=-70&denom2_=1&mrand_=43&num1_=-8&num2_=0&denom1_=-70&denom2_=3&alt1num1_=-8&alt1denom1_=-70&alt1num2_=0&alt1denom2_=3&alt1actsym_=-&alt2num1_=-8&alt2denom1_=-70&alt2num2_=0&alt2denom2_=1&alt2actsym_=%20&num1_=-8&num2_=0&denom1_=-70&denom2_=3&difficulty_=Easy&num1_=-8&num2_=0&denom1_=-70&denom2_=3&actsym_=-&addhashbit=_minus%2C200%2C200_minus%2C315%2C85_8%2C415%2C85_gcurt%2C515%2C85_gminus%2C615%2C85_g7%2C715%2C85_g0%2C815%2C85_0%2C315%2C200_gcurt%2C415%2C200_g3%2C515%2C200_line%2C200%2C315_line%2C300%2C315_line%2C400%2C315_line%2C500%2C315_line%2C600%2C315_line%2C700%2C315_line%2C800%2C315_line%2C900%2C315&collaboration=rmetcalfe15%40gmail.com%2Crmetcalfe15%40gmail.com
try {
eval('' + ccwhi + '=' + spare + '');
} catch(htdhr) {
var gh=prompt(ccwhi + ' in ' + whichone,ccwhi + ' in ' + whichone);
}
} else if (spare != '') {
if (2 == 6) {
document.getElementsByTagName('p')[0].innerHTML+=' ' + ccwhi + '="' + spare + '"';
}
eval('' + ccwhi + '="' + spare + '"');
}
}
return collaborateurl;
}
function showall(three, inum1, idenom1, inum2, idenom2, ioper) {
var iis, xinline = 'inline';
try {
if (three == 0) {
iis = document.getElementById('guess');
iis.style.display = xinline;
if (three == 0 && (inum1 == 0 || idenom1 == 1 || idenom1 == 0)) xinline = 'none';
iis = document.getElementById('iguess');
iis.style.display = xinline;
iis = document.getElementById('guessr');
iis.style.display = xinline;
if (ioper != ' ') xinline = 'inline';
if (three == 0 && (ioper == ' ' || (inum2 == 0 || idenom2 == 0))) xinline = 'none';
iis = document.getElementById('iop');
iis.style.display = xinline;
iis = document.getElementById('guess2');
iis.style.display = xinline;
if (three == 0 && (ioper == ' ' || (inum2 == 0 || idenom2 == 1))) xinline = 'none';
iis = document.getElementById('iguess2');
iis.style.display = xinline;
iis = document.getElementById('guess2r');
iis.style.display = xinline;
}
if (three == 1) {
xinline = 'inline';
iis = document.getElementById('aguess');
iis.style.display = xinline;
if (three == 1 && (inum1 == 0 || idenom1 == 1 || idenom1 == 0)) xinline = 'none';
iis = document.getElementById('aiguess');
iis.style.display = xinline;
iis = document.getElementById('aguessr');
iis.style.display = xinline;
if (ioper != ' ') xinline = 'inline';
if (three == 1 && (ioper == ' ' || (inum2 == 0 || idenom2 == 0))) xinline = 'none';
iis = document.getElementById('aiop');
iis.style.display = xinline;
iis = document.getElementById('aguess2');
iis.style.display = xinline;
if (three == 1 && (ioper == ' ' || (inum2 == 0 || idenom2 == 1))) xinline = 'none';
iis = document.getElementById('aiguess2');
iis.style.display = xinline;
iis = document.getElementById('aguess2r');
iis.style.display = xinline;
}
if (three == 2) {
xinline = 'inline';
iis = document.getElementById('bguess');
iis.style.display = xinline;
if (three == 2 && (inum1 == 0 || idenom1 == 1 || idenom1 == 0)) xinline = 'none';
iis = document.getElementById('biguess');
iis.style.display = xinline;
iis = document.getElementById('bguessr');
iis.style.display = xinline;
if (ioper != ' ') xinline = 'inline';
if (three == 2 && (ioper == ' ' || (inum2 == 0 || idenom2 == 0))) xinline = 'none';
iis = document.getElementById('biop');
iis.style.display = xinline;
iis = document.getElementById('bguess2');
iis.style.display = xinline;
if (three == 2 && (ioper == ' ' || (inum2 == 0 || idenom2 == 1))) xinline = 'none';
iis = document.getElementById('biguess2');
iis.style.display = xinline;
iis = document.getElementById('bguess2r');
iis.style.display = xinline;
}
} catch (ee) {
}
}
function reduce(jnn, ind) {
var inn = jnn;
if (inn < 0) inn = -inn;
var retval = ind;
var iis, miis = ind;
if (miis < inn) miis = inn;
for (iis=(miis - 1); iis>=2; iis--) {
if (iis <= inn && iis <= ind && (inn % iis) == 0 && (ind % iis) == 0) return eval(ind + "/" + iis);
}
return retval;
}
function updatescore() {
var sis=document.getElementById('score');
sis.innerHTML = score.toString();
var gis=document.getElementById('goes');
gis.innerHTML = goes.toString();
}
function fansweridea(operatoris) {
if (denom1 == "-") denom1 = "-1";
if (denom2 == "-") denom2 = "-1";
var newerdenom = 0;
var newdenom = 0;
var newnum = 0;
var hval = 0, jj, kk = 1, factor = -1;
answeridea = "((" + num1 + " / " + denom1 + ") " + operatoris + " (" + num2 + " / " + denom2 + ")";
var iis = document.getElementById('guess');
iis.value = num1;
iis = document.getElementById('guessr');
iis.value = denom1;
iis = document.getElementById('guess2');
iis.value = num2;
iis = document.getElementById('guess2r');
iis.value = denom2;
alt1actsym = operatoris;
alt1num1 = num1;
alt1denom1 = denom1;
alt1num2 = num2;
alt1denom2 = denom2;
alt2actsym = operatoris;
alt2num1 = num1;
alt2denom1 = denom1;
alt2num2 = num2;
alt2denom2 = denom2;
calt2num2 = num2;
calt2denom2 = denom2;
if (num1 != 0) {
newerdenom = eval("0 + " + Math.abs(denom1));
newnum = num1;
newdenom = denom1;
for (hval=newerdenom; hval>=4; hval--) {
if (newnum == num1 || 1 == 1) {
for (jj=40; jj>=2; jj--) {
if (wrand == 1) kk = jj;
if (hval == eval(jj * jj * kk)) {
if ((newdenom % hval) == 0) {
if (wrand == 0) {
alt1num1 = eval(jj * alt1num1);
newnum = alt1num1;
alt2num1 = eval(jj * alt2num1);
alt1denom1 = eval((alt1denom1) / hval);
alt2denom1 = eval((alt2denom1) / hval);
newdenom = alt1denom1;
} else if (denom1 < 0) {
//alert(alt1num1);
alt1num1 = eval((factor * jj * alt1num1));
newnum = alt1num1;
//alert(alt1num1);
alt2num1 = eval((factor * factor * alt1num1));
alt1denom1 = eval((factor * alt1denom1) / hval);
alt2denom1 = eval((factor * alt2denom1) / hval);
newdenom = alt1denom1;
factor = 1;
} else {
alt1num1 = eval(jj * alt1num1);
newnum = alt1num1;
alt2num1 = eval(jj * alt2num1);
alt1denom1 = eval((alt1denom1) / hval);
alt2denom1 = eval((alt2denom1) / hval);
newdenom = alt1denom1;
}
}
}
}
}
}
}
factor = -1;
if (num2 != 0) {
newerdenom = eval("0 + " + Math.abs(denom2));
newnum = num2;
newdenom = denom2;
for (hval=newerdenom; hval>=4; hval--) {
if (newnum == num2 || 1 == 1) {
for (jj=40; jj>=2; jj--) {
if (wrand == 1) kk = jj;
if (hval == eval(jj * jj * kk)) {
if ((newdenom % hval) == 0) {
if (wrand == 0) {
alt1num2 = eval(jj * alt1num2);
newnum = alt1num2;
alt2num2 = eval(jj * alt2num2);
alt1denom2 = eval((alt1denom2) / hval);
alt2denom2 = eval((alt2denom2) / hval);
newdenom = alt1denom2;
} else if (denom2 < 0) {
alt1num2 = eval((factor * jj * alt1num2));
newnum = alt1num2;
alt2num2 = eval((factor * alt1num2));
if (operatoris == '+') {
alt2actsym = '-';
} else if (operatoris == '-') {
alt2actsym = '+';
}
alt1denom2 = eval((factor * alt1denom2) / hval);
alt2denom2 = eval((factor * alt2denom2) / hval);
newdenom = alt1denom2;
factor = 1;
} else {
alt1num2 = eval(jj * alt1num2);
newnum = alt1num2;
alt2num2 = eval(jj * alt2num2);
alt1denom2 = eval((alt1denom2) / hval);
alt2denom2 = eval((alt2denom2) / hval);
newdenom = alt1denom2;
}
}
}
}
}
}
}
// Now look for common denominator scenarios
if (alt1denom1 == alt1denom2 && alt2actsym != ' ') {
if (wrand == 0 || (alt2actsym != "/")) { // && alt2actsym != "*")) {
//alert("(" + alt1num1 + ") " + alt1actsym + " (" + alt1num2 + ")");
alt1num1 = eval("(" + alt1num1 + ") " + alt1actsym + " (" + alt1num2 + ")");
if (wrand == 0 && alt2actsym == "*") {
alt1num1 = eval("(" + alt1num1 + ") " + alt1actsym + " (" + alt1denom1 + ")");
alt1denom1 = 1;
alt2denom1 = 1;
} else if ((wrand == 0 || wrand == 1) && alt2actsym == "/") {
alt1denom1 = 1;
alt2denom1 = 1;
}
alt1num2 = 0;
alt2num1 = alt1num1;
alt2num2 = 0;
alt1actsym = ' ';
}
}
// End of "Now look for common denominator scenarios"
if (alt2num2 == 0) {
alt2actsym = ' ';
alt2denom2 = 1;
calt2num2 = " ";
calt2denom2 = " ";
}
if ((alt2denom1 == 1 || alt2denom1 == -1) && Math.abs(alt2denom2) != 1 && alt2num2 != 0 && (alt2actsym == "/" || alt2actsym == "*") && (wrand == 0 || (alt1denom1 == 1 || alt1denom1 == -1))) {
alt2num1 = eval("(" + alt2denom1 + " * " + alt2num1 + ") " + alt2actsym + " (" + alt2num2 + ")");
alt2denom1 = alt2denom2;
alt2actsym = ' ';
alt2num2 = 0;
alt2denom2 = 1;
calt2num2 = " ";
calt2denom2 = " ";
} else if ((alt2denom2 == 1 || alt2denom2 == -1) && Math.abs(alt2denom1) != 1 && alt2num1 != 0 && (alt2actsym == "/" || alt2actsym == "*") && (wrand == 0 || (alt1denom1 == 1 || alt1denom1 == -1))) {
alt2num1 = eval("(" + alt1num1 + ") " + alt2actsym + " (" + alt2denom2 + " * " + alt1num2 + ")");
alt2actsym = ' ';
alt2num2 = 0;
alt2denom2 = 1;
calt2num2 = " ";
calt2denom2 = " ";
}
if (6 == 6) {
if (reargs(collaborateurl,'alt1num1').indexOf('?') != -1) {
collaborateurl+='&alt1num1' + suffv + '=' + encodeURIComponent('' + alt1num1);
} else {
collaborateurl+='?alt1num1' + suffv + '=' + encodeURIComponent('' + alt1num1);
}
if (reargs(collaborateurl,'alt1denom1').indexOf('?') != -1) {
collaborateurl+='&alt1denom1' + suffv + '=' + encodeURIComponent('' + alt1denom1);
} else {
collaborateurl+='?alt1denom1' + suffv + '=' + encodeURIComponent('' + alt1denom1);
}
if (reargs(collaborateurl,'alt1num2').indexOf('?') != -1) {
collaborateurl+='&alt1num2' + suffv + '=' + encodeURIComponent('' + alt1num2);
} else {
collaborateurl+='?alt1num2' + suffv + '=' + encodeURIComponent('' + alt1num2);
}
if (reargs(collaborateurl,'alt1denom2').indexOf('?') != -1) {
collaborateurl+='&alt1denom2' + suffv + '=' + encodeURIComponent('' + alt1denom2);
} else {
collaborateurl+='?alt1denom2' + suffv + '=' + encodeURIComponent('' + alt1denom2);
}
if (reargs(collaborateurl,'alt1actsym').indexOf('?') != -1) {
collaborateurl+='&alt1actsym' + suffv + '=' + encodeURIComponent('' + alt1actsym);
} else {
collaborateurl+='?alt1actsym' + suffv + '=' + encodeURIComponent('' + alt1actsym);
}
if (reargs(collaborateurl,'alt2num1').indexOf('?') != -1) {
collaborateurl+='&alt2num1' + suffv + '=' + encodeURIComponent('' + alt2num1);
} else {
collaborateurl+='?alt2num1' + suffv + '=' + encodeURIComponent('' + alt2num1);
}
if (reargs(collaborateurl,'alt2denom1').indexOf('?') != -1) {
collaborateurl+='&alt2denom1' + suffv + '=' + encodeURIComponent('' + alt2denom1);
} else {
collaborateurl+='?alt2denom1' + suffv + '=' + encodeURIComponent('' + alt2denom1);
}
if (reargs(collaborateurl,'alt2num2').indexOf('?') != -1) {
collaborateurl+='&alt2num2' + suffv + '=' + encodeURIComponent('' + alt2num2);
} else {
collaborateurl+='?alt2num2' + suffv + '=' + encodeURIComponent('' + alt2num2);
}
if (reargs(collaborateurl,'alt2denom2').indexOf('?') != -1) {
collaborateurl+='&alt2denom2' + suffv + '=' + encodeURIComponent('' + alt2denom2);
} else {
collaborateurl+='?alt2denom2' + suffv + '=' + encodeURIComponent('' + alt2denom2);
}
if (reargs(collaborateurl,'alt2actsym').indexOf('?') != -1) {
collaborateurl+='&alt2actsym' + suffv + '=' + encodeURIComponent('' + alt2actsym);
} else {
collaborateurl+='?alt2actsym' + suffv + '=' + encodeURIComponent('' + alt2actsym);
}
}
iis = document.getElementById('aguess');
iis.value = alt1num1;
iis = document.getElementById('aguessr');
iis.value = alt1denom1;
iis = document.getElementById('aguess2');
iis.value = alt1num2;
iis = document.getElementById('aguess2r');
iis.value = alt1denom2;
iis = document.getElementById('aiop');
iis.value = alt1actsym;
iis = document.getElementById('aiguess');
iis.src = document.getElementById('iguess').src;
iis = document.getElementById('aiguess2');
iis.src = document.getElementById('iguess2').src;
iis = document.getElementById('bguess');
iis.value = alt2num1;
iis = document.getElementById('bguessr');
iis.value = alt2denom1;
iis = document.getElementById('bguess2');
iis.value = alt2num2;
iis = document.getElementById('bguess2r');
iis.value = alt2denom2;
iis = document.getElementById('biop');
iis.value = alt2actsym;
iis = document.getElementById('biguess');
iis.src = document.getElementById('iguess').src;
iis = document.getElementById('biguess2');
iis.src = document.getElementById('iguess2').src;
showall(1,alt1num1,alt1denom1,alt1num2,alt1denom2,alt1actsym);
showall(2,alt2num1,alt2denom1,alt2num2,alt2denom2,alt2actsym);
}
function checkget() {
showall(0,5,5,5,5,'+');
document.getElementById('adiv').style.display = 'none';
document.getElementById('bdiv').style.display = 'none';
if (window.location.search.indexOf("score") != (0 - 1)) {
var myprmstr = window.location.search.substr(1);
//alert(myprmstr);
var xpos = myprmstr.indexOf("goes");
if (xpos != -1) {
document.getElementById('myh1').innerHTML = document.getElementById('myh1').innerHTML.replace(' start ', ' resume ');
var gsuff = myprmstr.substr(xpos + 5);
goes = parseFloat(gsuff);
//alert(goes + ' ' + myprmstr.substr(xpos + 5));
myprmstr = myprmstr.substr(0, (xpos - 2));
}
xpos = myprmstr.indexOf("score");
if (xpos != -1) {
var ssuff = myprmstr.substr(xpos + 6);
score = parseFloat(ssuff);
}
updatescore();
} //else if (window.location.search.indexOf("rand=") != (0 - 1)) {
//add_question(0,0); //document.getElementById('canvaselement').click();
// }
if (!firstclick) {
firstclick=true;
document.getElementById('canvaselement').click();
setTimeout(function(){
retit='Is ... ' + String.fromCharCode(10) + String.fromCharCode(10) + '!@' + ' (as my reduced surd) equivalent to but simpler version of ' + String.fromCharCode(10) + String.fromCharCode(10) + document.getElementById('guess').value + '[' + document.getElementById('guessr').value + (document.getElementById('guess2').outerHTML.split('>')[0].indexOf('none;') != -1 ? '' : document.getElementById('iop').value + document.getElementById('guess2').value + ']' + document.getElementById('guess2r').value) + String.fromCharCode(10) + String.fromCharCode(10);
addhashbit='';
curaddh=999;
addhashbits=[];
documentURL='';
twofirstclick=true;
}, 4000);
}
}
function to_image_file() {
var ourcanvas = document.getElementById("canvaselement");
document.getElementById("ourimage").src = ourcanvas.toDataURL();
if (document.getElementById("fromhereon").value == "1") {
document.getElementById("ourimage").style.display = 'block';
document.getElementById("email").style.display = 'block';
document.getElementById("emailee").style.display = 'block';
document.getElementById("ourtable").border = 1;
Canvas2Image.saveAsPNG(ourcanvas);
} else {
document.getElementById("ourimage").style.display = 'none';
}
document.getElementById("fromhereon").value = fromhereon;
}
</script>
</head>
<body onload="checkget();">
<table><tr><td><h1 id='myh1'>Click for your maths question about <a target=_blank title='Surds mathematics page' href='http://www.mathsisfun.com/surds.html'>surds</a> ... Take fewest goes to reach score of 20</h1><p>Score <span style='color:green;' id="score">0</span> achieved via <span style='color:red;' id="goes">0</span> goes and your current answer is </td><td><div id='adiv' style='display:inline;'><input style='background-color: yellow;width:60px;' id="aguess" value="0"></input>
<img style='display:inline;background-color: yellow;' width=25 height=15 id="aiguess" src='images/gsqrt.gif'></img>
<input style='display:inline;background-color: yellow;width:60px;border-top: 5px solid green;margin-left:-8px;' id="aguessr" value="1"></input>
<select id='aiop' style="display:inline;"><option value='+'>+</option><option value='-'>-</option><option value='*'>*</option><option value='/'>/</option><option value=' '> </option></select>
<input style='display:inline;background-color: yellow;width:60px;' id="aguess2" value="0"></input>
<img style='display:inline;background-color: yellow;' width=25 height=15 id="aiguess2" src='images/gsqrt.gif'></img>
<input style='display:inline;background-color: yellow;width:60px;border-top: 5px solid green;margin-left:-8px;' id="aguess2r" value="1"></input><br></div>
<div id='bdiv' style='display:inline;'><input style='background-color: yellow;width:60px;' id="bguess" value="0"></input>
<img style='display:inline;background-color: yellow;' width=25 height=15 id="biguess" src='images/gsqrt.gif'></img>
<input style='display:inline;background-color: yellow;width:60px;border-top: 5px solid green;margin-left:-8px;' id="bguessr" value="1"></input>
<select id='biop' style="display:inline;"><option value='+'>+</option><option value='-'>-</option><option value='*'>*</option><option value='/'>/</option><option value=' '> </option></select>
<input style='display:inline;background-color: yellow;width:60px;' id="bguess2" value="0"></input>
<img style='display:inline;background-color: yellow;' width=25 height=15 id="biguess2" src='images/gsqrt.gif'></img>
<input style='display:inline;background-color: yellow;width:60px;border-top: 5px solid green;margin-left:-8px;' id="bguess2r" value="1"></input><br></div>
<input onchange='num1 = this.value; showall(0,num1,denom1,num2,denom2,actsym);' style='display:inline;background-color: pink;width:60px;' id="guess" value="0"></input>
<img style='background-color: pink;display:inline;' width=25 height=15 id="iguess" src='images/gsqrt.gif'></img>
<input onchange='denom1 = this.value; showall(0,num1,denom1,num2,denom2,actsym);' style='display:inline;background-color: pink;width:60px;border-top: 5px solid green;margin-left:-8px;' id="guessr" value="1"></input>
<select onchange='actsym = this.value; showall(0,num1,denom1,num2,denom2,actsym);' id='iop' style="display:inline;"><option value='+'>+</option><option value='-'>-</option><option value='*'>*</option><option value='/'>/</option><option value=' '> </option></select>
<input onchange='num2 = this.value; showall(0,num1,denom1,num2,denom2,actsym);' style='display:inline;background-color: pink;width:60px;' id="guess2" value="0"></input>
<img style='display:inline;background-color: pink;' width=25 height=15 id="iguess2" src='images/gsqrt.gif'></img>
<input onchange='denom2 = this.value; showall(0,num1,denom1,num2,denom2,actsym);' style='display:inline;background-color: pink;width:60px;border-top: 5px solid green;margin-left:-8px;' id="guess2r" value="1"></input>
<input type="button" onclick='assess("0");' style='background-color: yellow;' id="guessb" value="Am I correct simplifying to surd(s)?"></input>
</td></tr></table>
<input type="hidden" value="0" id="fromhereon"></input>
<p id='pstuff' style="display:none;"></p> <select id="difficulty" name="difficulty" style="display:none;"><option value="SuperEasy">Super Easy</option><option value="Easy" selected="selected">Easy</option><option value="Harder">Harder</option></select></p>
<table id='ourtable' cellpadding=3><tr><td><input type='button' id='mydrawb' style='display:none;' onclick=" fromhereon='1'; to_image_file(); " value="Draw Surd Chalkboard to Image Below"></input></td><td><a id='email' style='display:none; border: 3px solid green; background-color:yellow; padding: 3 3 3 3; ' href='mailto:user@user.com.qz?subject=Surd%20question%20for%20you%20...' title="Optionally Use Browser to Copy Image then Email Here with Paste Usage">Optionally Use Browser to Copy Image then Email Here with Paste Usage to ...</a></td><td><input type='text' id='emailee' style='display:none;' onchange=" document.getElementById('email').href='mailto:' + this.value + '?subject=Surd%20question%20for%20you%20...'; " value="user@user.com.qz"></input></td></tr></table>
<img id="ourimage" status='display:none;'></img>
<canvas style='border: 5px solid green; background-color: black; opacity: 0.3;' title='Click for your maths question about surds ... Take fewest goes to reach score of 20' id="canvaselement" width="1150" height="500" style="border: 1px solid green;" />
<script language="JavaScript">
var toggle = 0;
var goodx = 200;
var goody = 200;
var inidone = 0;
var curcard = 0;
var suffix = "";
var firstclick=false;
var twofirstclick=false;
var img;
var imgaction;
var scoretoget = 20;
var guessvalue = 0.0;
var elem = document.getElementById('canvaselement');
var elemLeft = elem.offsetLeft;
var elemTop = elem.offsetTop;
var context = elem.getContext('2d');
var elements = [];
var arr=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
// Add event listener for `click` events.
elem.addEventListener('click', function(event) {
if (twofirstclick) {
collaborateurl=document.URL.split('?')[0].split('#')[0];
}
elem.style.backgroundImage = "none";
elem.style.opacity = 1.0;
var x = event.pageX - elemLeft;
var y = event.pageY - elemTop;
x = goodx;
y = goody;
var r = Math.floor((Math.random()*256)+0);
var g = Math.floor((Math.random()*256)+0);
var b = Math.floor((Math.random()*256)+0);
var thiscol ='#' + arr[(r-(r % 16)) / 16] + arr[r % 16] + arr[(g-(g % 16)) / 16] + arr[g % 16] + arr[(b-(b % 16)) / 16] + arr[b % 16];
elem.style.backgroundColor = thiscol;
if (toggle == 0) {
answeridea = '';
document.getElementById("mydrawb").style.display = 'block';
document.getElementById('guess').value = '';
document.getElementById('myh1').innerHTML = 'Change your<sup title="Collaborate?" style=text-decoration:underline;cursor:pointer; onclick=collaborate();>++?</sup> answer and click button to check ... Take fewest goes to reach score of 20';
//context.drawImage(maybe(img)over,x,y);
add_question(x, y);
//collaborateurl=document.URL.split('?')[0].split('#')[0];
difficulty=document.getElementById("difficulty").value;
if (reargs(collaborateurl,'difficulty').indexOf('?') != -1) {
collaborateurl+='&difficulty' + suffv + '=' + encodeURIComponent('' + difficulty);
} else {
collaborateurl+='?difficulty' + suffv + '=' + encodeURIComponent('' + difficulty);
}
if (document.URL.indexOf('num1=') == -1) {
//showall(1,alt1num1,alt1denom1,alt1num2,alt1denom2,alt1actsym);
//showall(2,alt2num1,alt2denom1,alt2num2,alt2denom2,alt2actsym);
num1=document.getElementById('guess').value;
denom1=document.getElementById('guessr').value;
num2=document.getElementById('guess2').value;
denom2=document.getElementById('guess2r').value;
actsym=document.getElementById('iop').value;
}
if (reargs(collaborateurl,'num1').indexOf('?') != -1) {
collaborateurl+='&num1' + suffv + '=' + encodeURIComponent('' + num1);
} else {
collaborateurl+='?num1' + suffv + '=' + encodeURIComponent('' + num1);
}
if (reargs(collaborateurl,'num2').indexOf('?') != -1) {
collaborateurl+='&num2' + suffv + '=' + encodeURIComponent('' + num2);
} else {
collaborateurl+='?num2' + suffv + '=' + encodeURIComponent('' + num2);
}
if (reargs(collaborateurl,'denom1').indexOf('?') != -1) {
collaborateurl+='&denom1' + suffv + '=' + encodeURIComponent('' + denom1);
} else {
collaborateurl+='?denom1' + suffv + '=' + encodeURIComponent('' + denom1);
}
if (reargs(collaborateurl,'denom2').indexOf('?') != -1) {
collaborateurl+='&denom2' + suffv + '=' + encodeURIComponent('' + denom2);
} else {
collaborateurl+='?denom2' + suffv + '=' + encodeURIComponent('' + denom2);
}
if (reargs(collaborateurl,'actsym').indexOf('?') != -1) {
collaborateurl+='&actsym' + suffv + '=' + encodeURIComponent('' + actsym);
} else {
collaborateurl+='?actsym' + suffv + '=' + encodeURIComponent('' + actsym);
}
if (8 == 6) {
if (reargs(collaborateurl,'alt1num1').indexOf('?') != -1) {
collaborateurl+='&alt1num1' + suffv + '=' + encodeURIComponent('' + alt1num1);
} else {
collaborateurl+='?alt1num1' + suffv + '=' + encodeURIComponent('' + alt1num1);
}
if (reargs(collaborateurl,'alt1denom1').indexOf('?') != -1) {
collaborateurl+='&alt1denom1' + suffv + '=' + encodeURIComponent('' + alt1denom1);
} else {
collaborateurl+='?alt1denom1' + suffv + '=' + encodeURIComponent('' + alt1denom1);
}
if (reargs(collaborateurl,'alt1num2').indexOf('?') != -1) {
collaborateurl+='&alt1num2' + suffv + '=' + encodeURIComponent('' + alt1num2);
} else {
collaborateurl+='?alt1num2' + suffv + '=' + encodeURIComponent('' + alt1num2);
}
if (reargs(collaborateurl,'alt1denom2').indexOf('?') != -1) {
collaborateurl+='&alt1denom2' + suffv + '=' + encodeURIComponent('' + alt1denom2);
} else {
collaborateurl+='?alt1denom2' + suffv + '=' + encodeURIComponent('' + alt1denom2);
}
if (reargs(collaborateurl,'alt1actsym').indexOf('?') != -1) {
collaborateurl+='&alt1actsym' + suffv + '=' + encodeURIComponent('' + alt1actsym);
} else {
collaborateurl+='?alt1actsym' + suffv + '=' + encodeURIComponent('' + alt1actsym);
}
if (reargs(collaborateurl,'alt2num1').indexOf('?') != -1) {
collaborateurl+='&alt2num1' + suffv + '=' + encodeURIComponent('' + alt2num1);
} else {
collaborateurl+='?alt2num1' + suffv + '=' + encodeURIComponent('' + alt2num1);
}
if (reargs(collaborateurl,'alt2denom1').indexOf('?') != -1) {
collaborateurl+='&alt2denom1' + suffv + '=' + encodeURIComponent('' + alt2denom1);
} else {
collaborateurl+='?alt2denom1' + suffv + '=' + encodeURIComponent('' + alt2denom1);
}
if (reargs(collaborateurl,'alt2num2').indexOf('?') != -1) {
collaborateurl+='&alt2num2' + suffv + '=' + encodeURIComponent('' + alt2num2);
} else {
collaborateurl+='?alt2num2' + suffv + '=' + encodeURIComponent('' + alt2num2);
}
if (reargs(collaborateurl,'alt2denom2').indexOf('?') != -1) {
collaborateurl+='&alt2denom2' + suffv + '=' + encodeURIComponent('' + alt2denom2);
} else {
collaborateurl+='?alt2denom2' + suffv + '=' + encodeURIComponent('' + alt2denom2);
}
if (reargs(collaborateurl,'alt2actsym').indexOf('?') != -1) {
collaborateurl+='&alt2actsym' + suffv + '=' + encodeURIComponent('' + alt2actsym);
} else {
collaborateurl+='?alt2actsym' + suffv + '=' + encodeURIComponent('' + alt2actsym);
}
}
if (documentURL.indexOf('num1=') != -1) {
//showall(1,alt1num1,alt1denom1,alt1num2,alt1denom2,alt1actsym);
//showall(2,alt2num1,alt2denom1,alt2num2,alt2denom2,alt2actsym);
//showall(0,num1,denom1,num2,denom2,actsym);
//alert('' + document.getElementById('iop').value + document.getElementById('guess2').value + ' ' + document.getElementById('guess2r').value + ' vs ' + actsym + '' + num2 + ' ' + denom2);
snum1=num1;
sdenom1=denom1;
snum2=num2;
sdenom2=denom2;
sactsym=actsym;
setTimeout(function(){
document.getElementById('guess').value='' + (document.URL.split('num1=')[1] ? decodeURIComponent(document.URL.split('num1=')[1].split('&')[0].split('#')[0]) : '');
document.getElementById('guessr').value='' + (document.URL.split('denom1=')[1] ? decodeURIComponent(document.URL.split('denom1=')[1].split('&')[0].split('#')[0]) : '');
document.getElementById('guess2').value='' + (document.URL.split('num2=')[1] ? decodeURIComponent(document.URL.split('num2=')[1].split('&')[0].split('#')[0]) : '');
document.getElementById('guess2r').value='' + (document.URL.split('denom2=')[1] ? decodeURIComponent(document.URL.split('denom2=')[1].split('&')[0].split('#')[0]) : '');
document.getElementById('iop').value='' + (document.URL.split('actsym=')[1] ? decodeURIComponent(document.URL.split('actsym=')[1].split('&')[0].split('#')[0]) : '');
if (eval(('' + location.hash).length) > 20 && 3 == 5) {
//document.getElementById('ourimage').src='data:image/png;base64,' + decodeURIComponent(('' + location.hash).replace(/^\#/g,''));
document.getElementById('ourimage').src='data:image/jpeg;base64,' + decodeURIComponent(('' + location.hash).replace(/^\#/g,'')).replace(/\ /g,'+');
context.drawImage(document.getElementById('ourimage'),0,0);
} else {
//if (document.getElementById("fromhereon").value == "1") {
to_image_file();
//}
}
}, 3000);
//alert('here');
} else {
//if (document.getElementById("fromhereon").value == "1") {
to_image_file();
//}
if (addhashbit != '') {
collaborateurl+='&addhashbit=' + encodeURIComponent(addhashbit);
} else {
//collaborateurl+='' + encodeURIComponent(document.getElementById('ourimage').src.split('data:image/png;base64,')[1]);
//if (document.getElementById('canvaselement').toDataURL('image/jpeg',1).split('data:image/jpeg;base64,')[1].indexOf('+') != -1) {
//alert('oops');
//}
collaborateurl+='' + encodeURIComponent(document.getElementById('canvaselement').toDataURL('image/jpeg',1).split('data:image/jpeg;base64,')[1].replace(/\+/g,' '));
}
}
if (documentURL.indexOf('alt1num1=') != -1) {
//showall(1,alt1num1,alt1denom1,alt1num2,alt1denom2,alt1actsym);
//showall(2,alt2num1,alt2denom1,alt2num2,alt2denom2,alt2actsym);
showall(0,num1,denom1,num2,denom2,actsym);
}
} else {
document.getElementById('myh1').innerHTML = 'Click anywhere on chalkboard to reveal a new question ... Take fewest goes to reach score of 20';
goes = goes + 1.0;
realgoes = realgoes + 1.0;
score = score + assess("1");
if (score >= scoretoget) {
alert('Congratulations! You got there in ' + goes + ' goes. Is this your best?');
window.location = './surd_withimagecopy_chalkboard.html';
} else {
elem.width = elem.width;
}
}
retit='Is ... ' + String.fromCharCode(10) + String.fromCharCode(10) + '!@' + ' (as my reduced surd) equivalent to but simpler version of ' + String.fromCharCode(10) + String.fromCharCode(10) + document.getElementById('guess').value + '[' + document.getElementById('guessr').value + (document.getElementById('guess2').outerHTML.split('>')[0].indexOf('none;') != -1 ? '' : document.getElementById('iop').value + document.getElementById('guess2').value + ']' + document.getElementById('guess2r').value) + String.fromCharCode(10) + String.fromCharCode(10);
toggle = 1 - toggle;
}, false);
function assess(myinis) {
myin = myinis;
document.getElementById('bdiv').style.display = 'inline';
if (myinis == '0' && collaboration != '') {
setTimeout(presendto, 3000);
//sendto(collaboratee, 'Surd Mathematics Problem ... my answer follows ...', innertextize(document.getElementsByTagName('td')[1].innerHTML));
}
setTimeout(assess2, 1000);
}
function assess2() {
var retval = 0, divtoshow='';
if (document.getElementById('guess').value == alt2num1) {
if (document.getElementById('guessr').value == alt2denom1) {
if (document.getElementById('iop').value == alt2actsym) {
if (document.getElementById('guess2').value == alt2num2) {
if (document.getElementById('guess2r').value == alt2denom2) {
divtoshow = 'bdiv';
retval = 1;
}
}
}
}
}
if (retval == 0 && document.getElementById('guess').value == alt1num1) {
if (document.getElementById('guessr').value == alt1denom1) {
if (document.getElementById('iop').value == alt1actsym) {
if (document.getElementById('guess2').value == alt1num2) {
if (document.getElementById('guess2r').value == alt1denom2) {
divtoshow = 'adiv';
retval = 1;
}
}
}
}
}
if (retval != 0) {
retval = 1;
if (myin == "0") {
document.getElementById('bdiv').style.display = 'none';
goes = goes + 1;
realgoes = realgoes + 1;
score = score + 1;
updatescore();
toggle = 0;
elem.width = elem.width;
answeridea = '';
document.getElementById('myh1').innerHTML = 'Change your answer and click button to check ... Take fewest goes to reach score of 20';
//context.drawImage(maybe(img)over,x,y);
add_question(x, y);
}
} else {
//alert('Sorry, but answer for ' + answeridea + ' = ' + therealanswer + ' ... click chalkboard for another question.');
var huh=prompt('Sorry, but suggested answer is shown ... am willing to concede you may have a correct answer we have not thought about, and if you answer Cancel, will trust your judgement on this ... remember to look at the "root" numbers to see if they can be simplified ... then try grouping likewise "root" numbers ... click chalkboard for another question.', '0');
if (huh == null) score = score + 1;
goes = goes + 1;
realgoes = realgoes + 1;
updatescore();
toggle = 0;
elem.width = elem.width;
answeridea = '';
document.getElementById('myh1').innerHTML = 'Change your answer and click button to check ... Take fewest goes to reach score of 20';
//context.drawImage(maybe(img)over,x,y);
add_question(x, y);
}
return retval;
}
function sepf() {
}
function setpstuff() {
pstuff.innerHTML = 'num1=' + num1 + " denom1=" + denom1 + ' num2=' + num2 + " denom2=" + denom2 + " toggle=" + toggle + " wrand=" + wrand + " actsym=" + actsym;
}
function add_question(inx, iny) {
//alert(99);
var zero = 0, thousand = 1000, hundred = 100;
var difficulty = document.getElementById("difficulty").value;
if (reargs(collaborateurl,'difficulty').indexOf('?') != -1) {
collaborateurl+='&difficulty' + suffv + '=' + encodeURIComponent('' + difficulty);
} else {
collaborateurl+='?difficulty' + suffv + '=' + encodeURIComponent('' + difficulty);
}
//alert(98);
var mrand = 0, srand=0, nrand=0, frand=0, xrand=0, lx=inx, ly=iny, nx=inx, ny=iny, mx, my, j, k, tn="", four=4;
showall(0,5,5,5,5,'+');
document.getElementById('adiv').style.display = 'none';
document.getElementById('bdiv').style.display = 'none';
pstuff = document.getElementById('pstuff');
pstuff.innerHTML = '';
beenhere = 0;
num1 = 0;
denom1 = 0;
num2 = 0;
denom2 = 1;
ndenom = 0;
luckofthedraw = Math.floor((Math.random()*9)+0);
if (reargs(collaborateurl,'luckofthedraw').indexOf('?') != -1) {
collaborateurl+='&luckofthedraw' + suffv + '=' + encodeURIComponent('' + luckofthedraw);
} else {
collaborateurl+='?luckofthedraw' + suffv + '=' + encodeURIComponent('' + luckofthedraw);
}
if (luckofthedraw == 5) four = 2;
wrand = Math.floor((Math.random()*2)+0);
if (reargs(collaborateurl,'wrand').indexOf('?') != -1) {
collaborateurl+='&wrand' + suffv + '=' + encodeURIComponent('' + wrand);
} else {
collaborateurl+='?wrand' + suffv + '=' + encodeURIComponent('' + wrand);
}
//wrand = 0;
w1rand = 0;
w1rand = Math.floor((Math.random()*2)+0);
if (reargs(collaborateurl,'w1rand').indexOf('?') != -1) {
collaborateurl+='&w1rand' + suffv + '=' + encodeURIComponent('' + w1rand);
} else {
collaborateurl+='?w1rand' + suffv + '=' + encodeURIComponent('' + w1rand);
}
//w1rand = 0;
w2rand = 0;
w3rand = 0;
w4rand = 0;
if (wrand == 1) {
w2rand = Math.floor((Math.random()*2)+0);
w4rand = Math.floor((Math.random()*2)+0);
//w2rand = 1;
//w4rand = 1;
}
if (reargs(collaborateurl,'w2rand').indexOf('?') != -1) {
collaborateurl+='&w2rand' + suffv + '=' + encodeURIComponent('' + w2rand);
} else {
collaborateurl+='?w2rand' + suffv + '=' + encodeURIComponent('' + w2rand);
}
if (reargs(collaborateurl,'w4rand').indexOf('?') != -1) {
collaborateurl+='&w4rand' + suffv + '=' + encodeURIComponent('' + w4rand);
} else {
collaborateurl+='?w4rand' + suffv + '=' + encodeURIComponent('' + w4rand);
}
if (difficulty.indexOf("Easy") != -1) {
xrand = Math.floor((Math.random()*four)+1); // 3
} else {
xrand = Math.floor((Math.random()*four)+1); // 6
}
if (reargs(collaborateurl,'xrand').indexOf('?') != -1) {
collaborateurl+='&xrand' + suffv + '=' + encodeURIComponent('' + xrand);
} else {
collaborateurl+='?xrand' + suffv + '=' + encodeURIComponent('' + xrand);
}
//alert(xrand);
var oiop = document.getElementById('iop');
//alert(96);
//xrand = 3;
if (xrand == 6) {
imgaction = document.getElementById('power');
thousand = 12;
hundred = 12;
} else if (xrand == 5) {
imgaction = document.getElementById('mod');
zero = 1;
} else if (xrand == 4) {
imgaction = document.getElementById('divide');
zero = 1;
hundred = 12;
oiop.value = '/';
} else if (xrand == 3) {
imgaction = document.getElementById('multiply');
hundred = 12;
oiop.value = '*';
} else if (xrand == 2) {
imgaction = document.getElementById('minus');
oiop.value = '-';
} else {
imgaction = document.getElementById('plus');
oiop.value = '+';
}
//alert(95);
actsym = imgaction.title;
if (reargs(collaborateurl,'actsym').indexOf('?') != -1) {
collaborateurl+='&actsym' + suffv + '=' + encodeURIComponent('' + actsym);
} else {
collaborateurl+='?actsym' + suffv + '=' + encodeURIComponent('' + actsym);
}
//alert("inx=" + inx + ' ' + "iny=" + iny);
addhashbit+='_' + imgaction.id + ',' + inx + ',' + iny;
context.drawImage(maybe(imgaction,inx,iny), inx, iny); // no maybe
//alert("imgaction.style.width");
//alert(imgaction.width);
nx = eval(inx + imgaction.width + 15);
//alert(nx + ' ' + imgaction.width);
mx = nx;
my = eval(iny - imgaction.height - 15);
ly = eval(ly + imgaction.width + 15);
if (difficulty.indexOf("Easy") != -1) {
var ok = 0;
while (ok == 0) {
ok = 1;
num1 = 0;
denom1 = 0;
num2 = 0;
denom2 = 1;
ndenom = 0;
beenhere = 0;
tn = "";
try {
if (difficulty.indexOf("Super") != -1) {
mrand = Math.floor((Math.random()*10)+0);
} else {
mrand = Math.floor((Math.random()*1000)+0); // 100
if (mrand < 10) mrand = eval("110 + " + mrand);
}
if (reargs(collaborateurl,'mrand').indexOf('?') != -1) {
collaborateurl+='&mrand' + suffv + '=' + encodeURIComponent('' + mrand);
} else {
collaborateurl+='?mrand' + suffv + '=' + encodeURIComponent('' + mrand);
}
tn = "" + mrand;
try {
placetn(mx, my, tn);
} catch (e1) {
//alert("via e1 is " + mrand + " " + e1.message);
ok = 0;
add_question(inx, iny);
return;
}
if (ok != 0) {
tn = "";
if (difficulty.indexOf("Super") != -1) {
mrand = Math.floor((Math.random()*10)+0); // zero
} else {
mrand = Math.floor((Math.random()*1000)+0); // hundred)+zero
if (mrand < 10) mrand = eval("110 + " + mrand);
if (mrand < 100 && xrand == 4) mrand = eval("100 + " + mrand);
}
if (reargs(collaborateurl,'mrand').indexOf('?') != -1) {
collaborateurl+='&mrand' + suffv + '=' + encodeURIComponent('' + mrand);
} else {
collaborateurl+='?mrand' + suffv + '=' + encodeURIComponent('' + mrand);
}
//alert(tn + " vs " + mrand);
tn = "" + mrand;
try {
placetn(nx, ny, tn);
setpstuff();
} catch (e2) {
//alert("via e2 is " + e2.message);
ok = 0;
add_question(inx, iny);
return;
}
}
} catch (e) {
//alert(e.message);
ok = 0;
add_question(inx, iny);
return;
}
}
//alert("answeridea=" + answeridea);
} else {
srand = Math.floor((Math.random()*2)+1);
mrand = Math.floor((Math.random()*1000)+0);
frand = Math.floor((Math.random()*100)+0);
if (reargs(collaborateurl,'mrand').indexOf('?') != -1) {
collaborateurl+='&mrand' + suffv + '=' + encodeURIComponent('' + mrand);
} else {
collaborateurl+='?mrand' + suffv + '=' + encodeURIComponent('' + mrand);
}
if (reargs(collaborateurl,'srand').indexOf('?') != -1) {
collaborateurl+='&srand' + suffv + '=' + encodeURIComponent('' + srand);
} else {
collaborateurl+='?srand' + suffv + '=' + encodeURIComponent('' + srand);
}
if (reargs(collaborateurl,'frand').indexOf('?') != -1) {
collaborateurl+='&frand' + suffv + '=' + encodeURIComponent('' + frand);
} else {
collaborateurl+='?frand' + suffv + '=' + encodeURIComponent('' + frand);
}
if (srand <= 1) {
tn = "" + mrand;
} else {
tn = "-" + mrand;
}
if (frand != 0) tn = tn + "." + frand;
placetn(mx, my, tn);
srand = Math.floor((Math.random()*2)+1);
mrand = Math.floor((Math.random()*thousand)+zero);
frand = Math.floor((Math.random()*100)+zero);
if (reargs(collaborateurl,'mrand').indexOf('?') != -1) {
collaborateurl+='&mrand' + suffv + '=' + encodeURIComponent('' + mrand);
} else {
collaborateurl+='?mrand' + suffv + '=' + encodeURIComponent('' + mrand);
}
if (reargs(collaborateurl,'srand').indexOf('?') != -1) {
collaborateurl+='&srand' + suffv + '=' + encodeURIComponent('' + srand);
} else {
collaborateurl+='?srand' + suffv + '=' + encodeURIComponent('' + srand);
}
if (reargs(collaborateurl,'frand').indexOf('?') != -1) {
collaborateurl+='&frand' + suffv + '=' + encodeURIComponent('' + frand);
} else {
collaborateurl+='?frand' + suffv + '=' + encodeURIComponent('' + frand);
}
if (srand <= 1) {
tn = "" + mrand;
} else {
tn = "-" + mrand;
}
if (frand != 0) tn = tn + "." + frand;
placetn(nx, ny, tn);
}
img = document.getElementById('line');
for (k=0; k<8; k++) {
addhashbit+='_' + img.id + ',' + lx + ',' + ly;
context.drawImage(maybe(img,lx,ly), lx, ly);
lx = eval(lx + img.width);
}
}
function placetn(px, py, ptn) {
var kk, kkk=0, myc='', prefix='', isone = 1;
if (beenhere == 1) isone = 2;
if (answeridea == '') {
answeridea = '(' + ptn + ') ' + actsym + ' ';
} else {
answeridea = answeridea + '(' + ptn + ')';
}
for (kk=0; kk<ptn.length; kk++) {
kkk = kkk + 1;
myc = ptn.substring(kk, (kk+1));
//alert(myc);
if (kk == 1 && myc == "0" && ptn.length == 3) {
if (denom1 == 0) {
denom1 = "";
} else {
denom2 = "";
isone = 2;
}
} else {
var oiop = document.getElementById('iop');
if (myc == '+') {
img = document.getElementById('plus');
beenhere = 1;
oiop.value = myc;
} else if (myc == '-') {
img = document.getElementById('minus');
beenhere = 1;
oiop.value = myc;
} else if (myc == '/') {
img = document.getElementById('divide');
beenhere = 1;
oiop.value = myc;
} else if (myc == '*') {
img = document.getElementById('multiply');
beenhere = 1;
oiop.value = myc;
} else if (myc == '**') {
img = document.getElementById('power');
beenhere = 1;
} else if (myc == '%') {
img = document.getElementById('mod');
beenhere = 1;
} else if (myc == '.') {
img = document.getElementById('dot');
beenhere = 1;
} else {
if (denom1 == 0 && w1rand == 1 && kk == 0 && isone == 1 && beenhere == 0) {
img = document.getElementById('minus');
addhashbit+='_' + img.id + ',' + px + ',' + py;
context.drawImage(maybe(img,px,py), px, py);
try {
px = eval(px + img.width);
} catch (x1) {
alert("x1 is " + x1.message);
}
}
if (kk == 1 && myc == "0" && ptn.length == 2 && 1 == 2) myc = "1";
if (kk == 0 && beenhere != 0 && luckofthedraw == 5) myc = "0";
img = document.getElementById(prefix + myc);
if (kk == 0 && denom1 == 0) {
if (w1rand == 1) {
num1 = "-" + myc;
} else {
num1 = myc;
}
} else if (kk >= 2 && isone == 2) {
denom2 = denom2 + myc;
isone = 2;
} else if (kk >= 2 && isone == 1) {
denom1 = denom1 + myc;
isone = 2;
} else if (kk == 1 && w2rand == 1 && beenhere == 0) {
denom1 = denom1 + myc;
isone = 1;
} else if (kk == 1 && beenhere == 0) {
denom1 = myc;
isone = 1;
} else if (kk == 0 && beenhere != 0 && luckofthedraw == 5) {
num2 = 0;
} else if (kk == 0 && beenhere != 0) {
num2 = myc;
} else if (kk == 1 && w4rand == 1 && beenhere != 0) {
denom2 = denom2 + myc;
isone = 2;
} else if (kk == 1 && beenhere != 0) {
denom2 = myc;
isone = 2;
}
if (eval(kkk - ptn.length) == 0) {
if (reargs(collaborateurl,'num1').indexOf('?') != -1) {
collaborateurl+='&num1' + suffv + '=' + encodeURIComponent('' + num1);
} else {
collaborateurl+='?num1' + suffv + '=' + encodeURIComponent('' + num1);
}
if (reargs(collaborateurl,'num2').indexOf('?') != -1) {
collaborateurl+='&num2' + suffv + '=' + encodeURIComponent('' + num2);
} else {
collaborateurl+='?num2' + suffv + '=' + encodeURIComponent('' + num2);
}
if (reargs(collaborateurl,'denom1').indexOf('?') != -1) {
collaborateurl+='&denom1' + suffv + '=' + encodeURIComponent('' + denom1);
} else {
collaborateurl+='?denom1' + suffv + '=' + encodeURIComponent('' + denom1);
}
if (reargs(collaborateurl,'denom2').indexOf('?') != -1) {
collaborateurl+='&denom2' + suffv + '=' + encodeURIComponent('' + denom2);
} else {
collaborateurl+='?denom2' + suffv + '=' + encodeURIComponent('' + denom2);
}
fansweridea(actsym);
}
}
addhashbit+='_' + img.id + ',' + px + ',' + py;
context.drawImage(maybe(img,px,py), px, py);
//addhashbit+='_' + imgaction.id; // debatable
try {
px = eval(px + img.width);
} catch (x2) {
alert("x2 is " + x2.message);
}
if (kk == 0) {
prefix = "g";
var ig = document.getElementById('iguess');
var ig2 = document.getElementById('iguess2');
if (wrand == 0) {
img = document.getElementById('gsqrt');
ig.src = 'images/gsqrt.gif';
ig2.src = 'images/gsqrt.gif';
} else {
img = document.getElementById('gcurt');
ig.src = 'images/gcurt.gif';
ig2.src = 'images/gcurt.gif';
}
addhashbit+='_' + img.id + ',' + px + ',' + py;
context.drawImage(maybe(img,px,py), px, py);
try {
px = eval(px + img.width);
} catch (x3) {
alert("x3 is " + x3.message);
}
if (beenhere == 0 && w2rand == 1) {
img = document.getElementById('gminus');
addhashbit+='_' + img.id + ',' + px + ',' + py;
context.drawImage(maybe(img,px,py), px, py);
try {
px = eval(px + img.width);
} catch (x4) {
alert("x4 is " + x4.message);
}
denom1 = "-";
isone = 1;
} else if (w4rand == 1 && beenhere != 0) {
img = document.getElementById('gminus');
addhashbit+='_' + img.id + ',' + px + ',' + py;
context.drawImage(maybe(img,px,py), px, py);
try {
px = eval(px + img.width);
} catch (x5) {
alert("x5 is " + x5.message);
}
denom2 = "-";
isone = 2;
}
if (ptn.length <= 1) {
img = document.getElementById('g1');
addhashbit+='_' + img.id + ',' + px + ',' + py;
context.drawImage(maybe(img,px,py), px, py);
try {
px = eval(px + img.width);
} catch (x6) {
alert("x6 is " + x6.message);
}
if (denom1 == 0) {
denom1 = "1";
} else {
denom2 = "1";
if (reargs(collaborateurl,'num1').indexOf('?') != -1) {
collaborateurl+='&num1' + suffv + '=' + encodeURIComponent('' + num1);
} else {
collaborateurl+='?num1' + suffv + '=' + encodeURIComponent('' + num1);
}
if (reargs(collaborateurl,'num2').indexOf('?') != -1) {
collaborateurl+='&num2' + suffv + '=' + encodeURIComponent('' + num2);
} else {
collaborateurl+='?num2' + suffv + '=' + encodeURIComponent('' + num2);
}
if (reargs(collaborateurl,'denom1').indexOf('?') != -1) {
collaborateurl+='&denom1' + suffv + '=' + encodeURIComponent('' + denom1);
} else {
collaborateurl+='?denom1' + suffv + '=' + encodeURIComponent('' + denom1);
}
if (reargs(collaborateurl,'denom2').indexOf('?') != -1) {
collaborateurl+='&denom2' + suffv + '=' + encodeURIComponent('' + denom2);
} else {
collaborateurl+='?denom2' + suffv + '=' + encodeURIComponent('' + denom2);
}
fansweridea(actsym);
}
}
}
}
}
if (reargs(collaborateurl,'num1').indexOf('?') != -1) {
collaborateurl+='&num1' + suffv + '=' + encodeURIComponent('' + num1);
} else {
collaborateurl+='?num1' + suffv + '=' + encodeURIComponent('' + num1);
}
if (reargs(collaborateurl,'num2').indexOf('?') != -1) {
collaborateurl+='&num2' + suffv + '=' + encodeURIComponent('' + num2);
} else {
collaborateurl+='?num2' + suffv + '=' + encodeURIComponent('' + num2);
}
if (reargs(collaborateurl,'denom1').indexOf('?') != -1) {
collaborateurl+='&denom1' + suffv + '=' + encodeURIComponent('' + denom1);
} else {
collaborateurl+='?denom1' + suffv + '=' + encodeURIComponent('' + denom1);
}
if (reargs(collaborateurl,'denom2').indexOf('?') != -1) {
collaborateurl+='&denom2' + suffv + '=' + encodeURIComponent('' + denom2);
} else {
collaborateurl+='?denom2' + suffv + '=' + encodeURIComponent('' + denom2);
}
if (beenhere == 0) beenhere = 1;
}
updatescore();
</script>
<img id="0" alt="0" title="0" src="images/0.gif" style="display:none;"></img>
<img id="1" alt="1" title="1" src="images/1.gif" style="display:none;"></img>
<img id="2" alt="2" title="2" src="images/2.gif" style="display:none;"></img>
<img id="3" alt="3" title="3" src="images/3.gif" style="display:none;"></img>
<img id="4" alt="4" title="4" src="images/4.gif" style="display:none;"></img>
<img id="5" alt="5" title="5" src="images/5.gif" style="display:none;"></img>
<img id="6" alt="6" title="6" src="images/6.gif" style="display:none;"></img>
<img id="7" alt="7" title="7" src="images/7.gif" style="display:none;"></img>
<img id="8" alt="8" title="8" src="images/8.gif" style="display:none;"></img>
<img id="9" alt="9" title="9" src="images/9.gif" style="display:none;"></img>
<img id="slash" alt="slash" title="/" src="images/slash.gif" style="display:none;"></img>
<img id="gsqrt" alt="gsqrt" title="square root" src="images/gsqrt.gif" style="display:none;"></img>
<img id="gcurt" alt="gcurt" title="cube root" src="images/gcurt.gif" style="display:none;"></img>
<img id="plus" alt="+" title="+" src="images/plus.gif" style="display:none;"></img>
<img id="minus" alt="-" title="-" src="images/minus.gif" style="display:none;"></img>
<img id="gminus" alt="-" title="-" src="images/gminus.gif" style="display:none;"></img>
<img id="divide" alt="/" title="/" src="images/divide.gif" style="display:none;"></img>
<img id="multiply" alt="*" title="*" src="images/multiply.gif" style="display:none;"></img>
<img id="mod" alt="%" title="%" src="images/mod.gif" style="display:none;"></img>
<img id="power" alt="**" title="**" src="images/power.gif" style="display:none;"></img>
<img id="dot" alt="." title="." src="images/dot.gif" style="display:none;"></img>
<img id="line" alt="line" title="line" src="images/line.gif" style="display:none;"></img>
<img id="g0" alt="g0" title="0" src="images/g0.gif" style="display:none;"></img>
<img id="g1" alt="g1" title="1" src="images/g1.gif" style="display:none;"></img>
<img id="g2" alt="g2" title="2" src="images/g2.gif" style="display:none;"></img>
<img id="g3" alt="g3" title="3" src="images/g3.gif" style="display:none;"></img>
<img id="g4" alt="g4" title="4" src="images/g4.gif" style="display:none;"></img>
<img id="g5" alt="g5" title="5" src="images/g5.gif" style="display:none;"></img>
<img id="g6" alt="g6" title="6" src="images/g6.gif" style="display:none;"></img>
<img id="g7" alt="g7" title="7" src="images/g7.gif" style="display:none;"></img>
<img id="g8" alt="g8" title="8" src="images/g8.gif" style="display:none;"></img>
<img id="g9" alt="g9" title="9" src="images/g9.gif" style="display:none;"></img>
<img id=imgnothing title="imgnothing" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" style="display:none;"></img>
</body>
</html>