<!doctype html>
<html>
<head>
<title>Timed Count - RJM Programming - December, 2016</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<script type='text/javascript'>

var count_items=["Semi-Trailer", "Truck", "Bus", "Van", "Car", "Motor Bike", "Motor Scooter", "Bicycle"];
count_items=location.search.split('items=')[1] ? eval('[' + decodeURIComponent(location.search.split('items=')[1].split('&')[0]) + ']') : count_items;

var imax=20;
var goes=0;
var score=0;
var curgo=[];
var pastgo=[];
var count=00;
var startcount=0;
var endcount=0;
var allokay=true;
var inf=false;
var subject='Vehicles';
var savedih='';
var prevcount=0;
var prevtime='';
var firsttime='';
var previval=900;
var fivehundred=500;

function isitallokay() {
var curplus=0, curminus=0, curdiv=0.0, curmult=0.0, j=0, jj, prevone=-1, donebefore=',';
if ((eval(pastgo.length) + eval(curgo.length)) >= 3) {
for (jj=0; jj<eval(pastgo.length); jj++) {
j++;
if (donebefore.indexOf(',' + pastgo[jj] + ',') != -1) {
have_to_stop_you_there('repeated number');
return 0;
}
donebefore+=pastgo[jj] + ',';
if (j >= 3) {
if (eval(pastgo[jj] - prevone) == curplus) {
have_to_stop_you_there('three in a row with +(' + curplus + ')');
return 0;
} else if (eval(prevone - pastgo[jj]) == curminus) {
have_to_stop_you_there('three in a row with -(' + curminus + ')');
return 0;
} else if (eval(pastgo[jj] / prevone) == curmult) {
have_to_stop_you_there('three in a row with *(' + curmult + ')');
return 0;
} else if (eval(prevone / pastgo[jj]) == curdiv) {
have_to_stop_you_there('three in a row with /(' + curdiv + ')');
return 0;
}
curplus=eval(pastgo[jj] - prevone);
curminus=eval(prevone - pastgo[jj]);
curmult=eval(pastgo[jj] / prevone);
curdiv=eval(prevone / pastgo[jj]);
} else if (j > 1) {
curplus=eval(pastgo[jj] - prevone);
curminus=eval(prevone - pastgo[jj]);
curmult=eval(pastgo[jj] / prevone);
curdiv=eval(prevone / pastgo[jj]);
}
prevone=pastgo[jj];
}

for (jj=0; jj<eval(curgo.length); jj++) {
j++;
if (donebefore.indexOf(',' + curgo[jj] + ',') != -1) {
have_to_stop_you_there('repeated number');
return 0;
}
donebefore+=curgo[jj] + ',';
if (j >= 3) {
if (eval(curgo[jj] - prevone) == curplus) {
have_to_stop_you_there('three in a row with +(' + curplus + ')');
return;
} else if (eval(prevone - curgo[jj]) == curminus) {
have_to_stop_you_there('three in a row with -(' + curminus + ')');
return;
} else if (eval(curgo[jj] / prevone) == curmult) {
have_to_stop_you_there('three in a row with *(' + curmult + ')');
return;
} else if (eval(prevone / curgo[jj]) == curdiv) {
have_to_stop_you_there('three in a row with /(' + curdiv + ')');
return;
}
curplus=eval(curgo[jj] - prevone);
curminus=eval(prevone - curgo[jj]);
curmult=eval(curgo[jj] / prevone);
curdiv=eval(prevone / curgo[jj]);
} else if (j > 1) {
curplus=eval(curgo[jj] - prevone);
curminus=eval(prevone - curgo[jj]);
curmult=eval(curgo[jj] / prevone);
curdiv=eval(prevone / curgo[jj]);
}
prevone=curgo[jj];
}


}
return eval(curgo.length) * 20 - eval(count - startcount);
}

function have_to_stop_you_there(reason) {
var ans=prompt('Sorry ... have to stop you there at score of ' + score + ' from ' + goes + ' goes ... ' + reason + '. Another game?', 'Y');
if (ans == null) {
location.href=document.URL.split('?')[0].split('#')[0] + '?score=' + score + '&goes=' + goes + '&max=' + imax;
} else if (ans.toUpperCase().substring(0,1) != 'Y') {
location.href=document.URL.split('?')[0].split('#')[0] + '?score=' + score + '&goes=' + goes + '&max=' + imax;
} else {
location.href=document.URL.split('?')[0].split('#')[0];
}
return;
}

function myoclick(ois) {
var bw=1;
//alert(ois.id);
if (document.getElementById('mysel').options[0].text.indexOf('Please ') != 0) {
pastgo=document.getElementById('mysel').options[0].text.split(',');
if ((',' + document.getElementById('mysel').options[0].text + ',').indexOf(',' + ois.id.replace('o','') + '*') != -1) {
bw=eval((',' + document.getElementById('mysel').options[0].text + ',').split(',' + ois.id.replace('o','') + '*')[1].split(',')[0]);
document.getElementById('mysel').options[0].text=document.getElementById('mysel').options[0].text.replace(ois.id.replace('o','') + '*' + bw, ois.id.replace('o','') + '*' + eval(1 + bw));
} else {
document.getElementById('mysel').options[0].text+=',' + ois.id.replace('o','') + '*1';
}
} else {
document.getElementById('mysel').options[0].text=ois.id.replace('o','') + '*1';
}
var thisone=eval(ois.id.replace('o',''));
//if (pastgo.indexOf('' + thisone) != -1) {
// have_to_stop_you_there('repeated number');
//}
curgo.push(eval(ois.id.replace('o','')));
// var scoredelta=isitallokay();
}


function mytclick(ois) {
//alert(95);
myclick(ois);
}

function myclick(ois) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('imysel').style.display='none'; //'block';
document.getElementById('imysel').style.width='100px';
document.getElementById('imysel').style.height='60px';
} else {
document.getElementById('imysel').style.display='none'; //'block';
document.getElementById('mysel').multiple=true;
document.getElementById('mysel').style.height='310px';
}
startcount=count;
}

function mymchange(iois) {
var i,ii,found=false,ois=document.getElementById(iois.id.replace('i','')), cois=ois.options[0].text, thiscois='',thiscoisa;
if (curgo.length == 0 && ois.options.length > 0) {
for (i=0; i<ois.options.length; i++) {
if (ois.options[i].selected) {
if (ois.options[i].value != '') {
//alert(ois.options[i].value);
curgo.push(ois.options[i].value);
}
}
}
}
for (ii=0; ii<curgo.length; ii++) {
found=false;
for (i=0; i<ois.options.length; i++) {
if (ois.options[i].selected) {
if (ois.options[i].value != '') {
if (thiscois == '' && ('' + ois.options[i].value) == ('' + curgo[ii])) {
thiscois=ois.options[i].value;
} else if (('' + ois.options[i].value) == ('' + curgo[ii])) {
thiscois+=',' + ois.options[i].value;
}
if (cois.indexOf('Please ') == 0 && ('' + ois.options[i].value) == ('' + curgo[ii])) {
cois=ois.options[i].value;
found=true;
} else if (('' + ois.options[i].value) == ('' + curgo[ii])) {
cois+=',' + ois.options[i].value;
found=true;
}
}
}
}
if (!found) {
thiscois+=',' + curgo[i];
cois+=',' + curgo[i];
}
}
thiscoisa=thiscois.split(',');
if (thiscoisa.length != curgo.length) {
curgo=thiscois.split(',');
}
var scoredelta=isitallokay();
if (cois.indexOf('Please ') != 0) {
ois.options[0].text=cois;
}
ois.multiple=false;
ois.style.height='20px';
ois.value='';
document.getElementById('imysel').style.display='none';
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('imysel').style.width='1px';
document.getElementById('imysel').style.height='1px';
}
score+=scoredelta;
pastgo=ois.options[0].text.split(',');
goes++;
document.getElementById('score').innerHTML='Score: ' + score + ' from ' + goes + ' dropdown reveal goes';
curgo=[];
//document.getElementById('tops').focus();
}

function dohuha(ii) {
var huha=['','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
if (ii >= huha.length) return '' + ii;
return huha[ii];
}

function amendvia(cmax) {
var huhsc=location.search.split('cscore=')[1] ? decodeURIComponent(location.search.split('cscore=')[1].split('&')[0]) : 'Score: 0 from 0 dropdown reveal goes';
var howm=location.search.split('howoften=')[1] ? location.search.split('howoften=')[1].split('&')[0] : '60000';
document.getElementById('score').innerHTML=huhsc;
document.getElementById('howoften').value=howm;
subject=location.search.split('subject=')[1] ? location.search.split('subject=')[1].split('&')[0] : 'Vehicles';
score=location.search.split('score=')[1] ? eval(location.search.split('score=')[1].split('&')[0]) : score;
goes=location.search.split('goes=')[1] ? eval(location.search.split('goes=')[1].split('&')[0]) : goes;
document.getElementById('score').innerHTML='Score: ' + score + ' from ' + goes + ' dropdown reveal goes';
document.getElementById('its').options[0].text = 'of ' + subject;
//for (var ii=3; ii<=Math.max(100,(50 +imax)); ii++) {
// document.getElementById('tops').innerHTML+="<option id='oo" + ii + "' ontouchdown='myoclick(this);' onclick='myoclick(this);' value=" + ii + ">" + ii + "</option>";
//}
for (var i=1; i<=count_items.length; i++) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('mydsel').innerHTML+="<input type=button id='o" + i + "' ontouchdown='myoclick(this);' onclick='myoclick(this);' value=" + i + ">" + dohuha(i) + " = " + count_items[eval(-1 + i)] + "</input><br>";
} else {
document.getElementById('mysel').innerHTML+="<option id='o" + i + "' ontouchdown='myoclick(this);' onclick='myoclick(this);' value=" + i + ">" + dohuha(i) + " = " + count_items[eval(-1 + i)] + "</option>";
}
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('imysel').style.display='none'; //'block';
document.getElementById('imysel').style.width='100px';
document.getElementById('imysel').style.height='60px';
} else {
document.getElementById('mysel').multiple=true;
document.getElementById('mysel').style.height='310px';
document.getElementById('imysel').style.display='none'; //'block';
}
document.getElementById('mykb').focus();
document.getElementById('isubmit').style.display='block';
startcount=count;
}

function butmaybe(outc) {
if (outc.indexOf('Please ') == 0) return '1*0';
return outc;
}

function predocount() {
//if (fivehundred != 500) fivehundred=eval(1000 - fivehundred);
var dd=new Date();
var ival=dd.getTime();
//document.title=eval(document.getElementById('howoften').value) + ' ' + ival + ' ' + eval(ival % eval(document.getElementById('howoften').value));
var thisival=eval(ival % eval(document.getElementById('howoften').value));
if (thisival <= previval) {
fivehundred=950;
//alert(prevcount + ":" + document.getElementById('mytbody').innerHTML);
var was=document.getElementById('next' + eval(0 * prevcount)).innerHTML;
document.getElementById('next' + eval(0 * prevcount)).innerHTML="<p name='data" + prevtime + "'>" + prevtime + "<br>" + butmaybe(document.getElementById('mysel').options[0].text) + "</p>" + was;
//<div id='next" + count + "'></div><div id='td" + count + "' style='display:table-cell;'>" + savedih.replace(firsttime,thetime()) + "</div>";
document.getElementById('td' + eval(0 * prevcount)).innerHTML=savedih.replace(firsttime,thetime());
prevcount=count;
for (var i=1; i<=count_items.length; i++) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('mydsel').innerHTML+="<input type=button id='o" + i + "' ontouchdown='myoclick(this);' onclick='myoclick(this);' value=" + i + ">" + dohuha(i) + " = " + count_items[eval(-1 + i)] + "</input><br>";
} else {
document.getElementById('mysel').innerHTML+="<option id='o" + i + "' ontouchdown='myoclick(this);' onclick='myoclick(this);' value=" + i + ">" + dohuha(i) + " = " + count_items[eval(-1 + i)] + "</option>";
}
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('imysel').style.display='none'; //'block';
document.getElementById('imysel').style.width='100px';
document.getElementById('imysel').style.height='60px';
} else {
document.getElementById('mysel').multiple=true;
document.getElementById('mysel').style.height='310px';
document.getElementById('imysel').style.display='none'; //'block';
}
document.getElementById('mykb').focus();
document.getElementById('isubmit').style.display='block';
} else if (fivehundred != 500) {
if (fivehundred == 50) {
fivehundred=500;
} else {
fivehundred=eval(1000 - fivehundred);
}
}
setTimeout(docount,fivehundred);
}

function docount() {
if (count == 0) {
var tds=document.getElementsByTagName('td');
if (savedih == '') savedih=tds[3].innerHTML;
var ubits=document.URL.split('&data'), vbits;
if (ubits.length > 1) {
var thingos=[];
for (var iubits=eval(-1 + ubits.length); iubits>=1; iubits--) {
vbits=ubits[iubits].split('=');
thingos.push("<p name='data" + vbits[0] + "'>" + vbits[0] + decodeURIComponent(vbits[1].split('&')[0]).replace(vbits[0],'') + "</p><br>");
}
if (thingos.length > 0) {
thingos.sort();
for (var iuubits=eval(-1 + thingos.length); iuubits>=0; iuubits--) {
document.getElementById('next0').innerHTML+=thingos[iuubits];
}
}
}
}
count++;
var dd=new Date();
var ival=dd.getTime();
//document.title=eval(document.getElementById('howoften').value) + ' ' + ival + ' ' + eval(ival % eval(document.getElementById('howoften').value));
var thisival=eval(ival % eval(document.getElementById('howoften').value));
if (thisival <= previval) {
fivehundred=950;
//alert(prevcount + ":" + document.getElementById('mytbody').innerHTML);
var was=document.getElementById('next' + eval(0 * prevcount)).innerHTML;
document.getElementById('next' + eval(0 * prevcount)).innerHTML="<p name='data" + prevtime + "'>" + prevtime + "<br>" + butmaybe(document.getElementById('mysel').options[0].text) + "</p>" + was;
//<div id='next" + count + "'></div><div id='td" + count + "' style='display:table-cell;'>" + savedih.replace(firsttime,thetime()) + "</div>";
document.getElementById('td' + eval(0 * prevcount)).innerHTML=savedih.replace(firsttime,thetime());
prevcount=count;
for (var i=1; i<=count_items.length; i++) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('mydsel').innerHTML+="<input type=button id='o" + i + "' ontouchdown='myoclick(this);' onclick='myoclick(this);' value=" + i + ">" + dohuha(i) + " = " + count_items[eval(-1 + i)] + "</input><br>";
} else {
document.getElementById('mysel').innerHTML+="<option id='o" + i + "' ontouchdown='myoclick(this);' onclick='myoclick(this);' value=" + i + ">" + dohuha(i) + " = " + count_items[eval(-1 + i)] + "</option>";
}
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('imysel').style.display='none'; //'block';
document.getElementById('imysel').style.width='100px';
document.getElementById('imysel').style.height='60px';
} else {
document.getElementById('mysel').multiple=true;
document.getElementById('mysel').style.height='310px';
document.getElementById('imysel').style.display='none'; //'block';
}
document.getElementById('mykb').focus();
startcount=count;
//} else {
//previval=thisival;
} else if (fivehundred != 500) {
if (fivehundred == 50) {
fivehundred=500;
} else {
fivehundred=eval(1000 - fivehundred);
}
}
setTimeout(predocount,fivehundred);
}

function doit() {
document.getElementByIds('imysel').click();
}

function putinquotes(inh) {
var retval='', delim='';
if (inh.indexOf('"') == 0) {
return inh;
} else if (inh.indexOf("'") == 0) {
return inh;
} else {
var rets=inh.split(',');
for (var iretval=0; iretval<rets.length; iretval++) {
retval+=delim + '"' + rets[iretval] + '"';
delim=',';
}
}
return retval;
}

function ask(what) {
var rhuh=prompt("Enter name of Items to Collect Information for, then :, then comma separated list of what to expect as items you will categorize in the count", 'Vehicles:"Semi-Trailer","Truck","Bus","Van","Car","Motor Bike","Motor Scooter","Bicycle"');
if (rhuh != null) {
if (rhuh.indexOf(':') != -1) {
location.href=document.URL.split('?')[0].split('#')[0] + '?howoften=' + document.getElementById('howoften').value + '&score=' + score + '&goes=' + goes + '&subject=' + encodeURIComponent(rhuh.split(':')[0]) + '&items=' + encodeURIComponent(putinquotes(rhuh.split(':')[1]));
}
}
}

function thetime() {
var dd=new Date();
prevtime=(dd.getFullYear() + "_" + ("0" + eval(1 + dd.getMonth())).slice(-2) + "_" + ("0" + dd.getDate()).slice(-2) + "_" + ("0" + dd.getHours()).slice(-2) + ":" + ("0" + dd.getMinutes()).slice(-2) + ":" + ("0" + dd.getSeconds()).slice(-2)).replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(/:/g,'_').replace(/\//g,'_').replace(/-/g,'_');
if (firsttime == '') firsttime=prevtime;
//document.title=prevtime;
return prevtime;
}

function cval(eiois) {
var okn='';
var huha=['','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
//document.title=eiois.which + " " + eiois.keyCode;
if ((eiois.which || eiois.keyCode) == 8) {
eiois.which=eiois.which;
} else {
okn=String.fromCharCode(eiois.which || eiois.keyCode);
var iokn=huha.indexOf(okn.toLowerCase());
if (iokn > 0) {
document.getElementById('o' + iokn).click();
eiois.value='';
}
}
}

function doyourownget() {
var location_href=document.URL.split('?')[0].split('#')[0] + '?howoften=' + document.getElementById('howoften').value;
var ps=document.getElementsByTagName('p');
for (var ips=0; ips<ps.length; ips++) {
if (ps[ips].outerHTML.indexOf(' name="') != -1) {
location_href+='&' + ps[ips].outerHTML.split(' name="')[1].split('"')[0] + '=' + encodeURIComponent(ps[ips].innerHTML);
}
}
location.href=location_href;
}
</script>
</head>
<body onload="docount(); amendvia((location.search.split('max=')[1] ? location.search.split('max=')[1].split('&')[0] : ''));" style='background-color:magenta;'>
<form id='myform' method='GET' action='./timed_count.html'>
<table border=7 cellpadding=20 cellspacing=20><tbody><tr><td style='vertical-align:top;'>
<h4 name='cscore' id='score' style='display:none;'>Score: 0 from 0 dropdown reveal goes</h4>

<table><tbody id='mytbody'><tr id='mytr'><td id='td0'>
<script type='text/javascript'>
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
savedih="<div style='width:100%;text-align:center;'><input style='display:none;width:1px;height:1px;' value='Score Now' type=button onclick=' mymchange(this);' id='imysel'></input><br><div ontouchdown='mytclick(this);' onfocus=' inf=true; ' onclick=\" if (inf) { inf=false; setTimeout(doit,500); }\"><p id='pdatebit'></p><br><select id='mysel' onfocus='myclick(this);' onchange='mytclick(this);' onclick='myclick(this);'><option id='o0' name='data" + thetime() + "' ontouchdown='myoclick(this);' onclick='myoclick(this);' value=>Please select item(s) below as you see them ...</option></select><br><br><br><div id='mydsel'></div><br><br> ... or via Keyboard: <input type=text id=mykb onkeyup='cval(event);' value=''></input></div></div>";
//alert(savedih);
document.write(savedih);
} else {
savedih="<div style='width:100%;text-align:center;'><input style='display:none;' value='Ready?' type=button onclick='mymchange(this);' id='imysel'></input><br><div onclick='myclick(this);'><p id='pdatebit'></p><br><select id='mysel' onfocus='myclick(this);' onclick='myclick(this);'><option id='o0' name='data" + thetime() + "' onclick='myoclick(this);' value=>Please select item(s) below as you see them ...</option></select><br><br> ... or via Keyboard: <input type=text id=mykb onkeyup='cval(event);' value=''></input></div></div>";
//alert(savedih);
document.write(savedih);
}
</script>
</td>
</tr></tbody></table>
</td><td id='next0' style='background-color:yellow;'></td><td>
<h1>Timed Count <select onchange='ask(this.value);' id='its'><option value=''>of Vehicles</option><option value=' '>of Some Other Items</option></select></h1>
<h2>Every Starting <select id='howoften' name='howoften'><option value='30000'>Thirty Seconds</option><option value='60000' selected>Minute</option><option value='300000'>Five Minutes</option><option value='600000'>Ten Minutes</option><option value='900000'>Fifteen Minutes</option><option value='1200000'>Twenty Minutes</option><option value='1800000'>Thirty Minutes</option><option value='2400000'>Forty Minutes</option><option value='3000000'>Fifty Minutes</option><option value='3600000'>One Hour</option><option value='7200000'>Two Hours</option><option value='10800000'>Three Hours</option><option value='14400000'>Four Hours</option><option value='18000000'>Five Hours</option><option value='21600000'>Six Hours</option><option value='25200000'>Seven Hours</option><option value='28800000'>Eight Hours</option><option value='32400000'>Nine Hours</option><option value='36000000'>Ten Hours</option><option value='39600000'>Eleven Hours</option><option value='43200000'>Twelve Hours</option><option value='86400000'>One Day</option><option value='604800000'>One Week</option></select></h2>
<h2>RJM Programming</h2>
<h2>December, 2016</h2>
</td></tr></tbody></table>
<input onclick="doyourownget();" type=button id='isubmit' style='display:none;' value='Save and Recall'></input>
</form>
</body>
</html>