<!doctype html>
<html>
<head>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<meta charset="UTF-8" />
<title>Audio Numbers - RJM Programming - September, 2016</title>
<script type='text/javascript'>
'use strict';

var firstnot=true;
var iuprefix=location.search.split('soundpath=')[1] ? decodeURIComponent(location.search.split('soundpath=')[1].split('&')[0]) : '';
var soundfile1=notthis('one_to_fiftynine.m4a','soundfile1');
var soundfile2=notthis('past_quarterto.m4a','soundfile2');
var soundfile3=notthis('am_pm.m4a','soundfile3');
var soundfile4=notthis('midnight_midday.m4a','soundfile4');
var formis=document.URL.indexOf('showform=');

function trythis() {
document.getElementById('formdiv').innerHTML=formstr;
}

function irrelevant() {
}

function notthis(tthat, wthat) {
var that=tthat.replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace('.','_').replace('.','_').replace('.','_').replace("'","_");
if (wthat != '') {
that=wthat.replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace('.','_').replace('.','_').replace('.','_').replace("'","_");
}
var thatis=tthat;
var xthatis=tthat;
//alert(that);
if (document.URL.indexOf('not' + that + '=') != -1 || document.URL.indexOf('not' + that.toLowerCase() + '=') != -1 || document.URL.indexOf('not' + that.toUpperCase() + '=') != -1 || document.URL.indexOf('not' + that.substring(0,1).toUpperCase() + that.substring(1).toLowerCase() + '=') != -1) {
//alert("(location.search.split('not" + that + "=')[1] ? decodeURIComponent(location.search.split('not" + that + "=')[1].split('&')[0]) : '" + tthat + "')");
thatis=eval("(location.search.split('not" + that + "=')[1] ? decodeURIComponent(location.search.split('not" + that + "=')[1].split('&')[0]).replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ') : \"" + tthat.replace(/~/g,' ') + "\")");
//alert(thatis + ' : ' + tthat);
if (that.toLowerCase() == that) {
xthatis=eval("(location.search.split('not" + that.substring(0,1).toUpperCase() + that.substring(1).toLowerCase() + "=')[1] ? decodeURIComponent(location.search.split('not" + that.substring(0,1).toUpperCase() + that.substring(1).toLowerCase() + "=')[1].split('&')[0]).replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ') : \"" + tthat.substring(0,1).toUpperCase() + tthat.substring(1).toLowerCase().replace(/~/g,' ') + "\")");
//if (firstnot) alert(thatis + ' = ' + tthat);
} else if (that.toUpperCase() == that) {
xthatis=eval("(location.search.split('not" + that.substring(0,1).toUpperCase() + that.substring(1).toLowerCase() + "=')[1] ? decodeURIComponent(location.search.split('not" + that.substring(0,1).toUpperCase() + that.substring(1).toLowerCase() + "=')[1].split('&')[0]).replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ') : \"" + tthat.substring(0,1).toUpperCase() + tthat.substring(1).toLowerCase().replace(/~/g,' ') + "\")");
//if (firstnot) alert(thatis + ' _ ' + tthat);
} else if (tthat.indexOf(' ') == -1) {
xthatis=eval("(location.search.split('not" + that.toLowerCase() + "=')[1] ? decodeURIComponent(location.search.split('not" + that.toLowerCase() + "=')[1].split('&')[0]).replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ') : \"" + tthat.replace(/~/g,' ') + "\")");
if (xthatis == tthat) xthatis=eval("(location.search.split('not" + that.toUpperCase() + "=')[1] ? decodeURIComponent(location.search.split('not" + that.toUpperCase() + "=')[1].split('&')[0]).replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ').replace('+',' ') : \"" + tthat.replace(/~/g,' ') + "\")");
//if (firstnot) alert(thatis + ' == ' + tthat);
}
} //else {
//alert('tthat=' + tthat + ' and wthat=' + wthat + ' and thatis=' + thatis);
//}
// if (firstnot) alert(thatis + ' ' + tthat);
if (firstnot && (thatis != tthat || xthatis != tthat)) setTimeout(irrelevant, 2000);
firstnot=false;
return thatis;
}


var oaudio=null;
var audiomedia=[iuprefix + notthis("one_to_fiftynine.m4a", "soundfile1"),iuprefix + notthis("past_quarterto.m4a", "soundfile2"),iuprefix + notthis("am_pm.m4a", "soundfile3")];
var midmedia=[iuprefix + notthis("midnight_midday.m4a", "soundfile4")];
var astart=0;
var delay=0;
var zero=-1;

var formis=document.URL.indexOf('showform=');

var formstr="<br><div id='fdivorm' style='width:100%;text-align:center;background-color:yellow;'><form action='" + document.URL.split('?')[0].split('#')[0] + "' method='GET'><br><br></form></div><br>";

formstr=formstr.replace('</form>', 'Web Application Title: <input name=notAudio_Numbers value="' + notthis('Audio Numbers','') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', 'Subtitle: <input name=notHear_this____ value="' + notthis('Hear this ...','') + '" type="text"></input><br><br></form>');

formstr=formstr.replace('</form>', notthis('Hour','') + ': <input name=notHour value="' + notthis('Hour','') + '" type="text"></input><br></form>');
formstr=formstr.replace('</form>', notthis('Minute','') + ': <input name=notMinute value="' + notthis('Minute','') + '" type="text"></input><br></form>');
formstr=formstr.replace('</form>', notthis('Context','') + ': <input name=notContext value="' + notthis('Context','') + '" type="text"></input><br><br></form>');

formstr=formstr.replace('</form>', 'Sound File Path: <input name=soundpath type="text" style=width:30%; value="' + iuprefix + '"></input><br><br></form>');

formstr=formstr.replace('</form>', notthis('Hour','') + ' Number Start Word (optional, and perhaps for minimum case): <input name=notmidnight value="' + notthis('midnight','') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Hour','') + ' Number Start: <input name=noth1 value="' + notthis('1','h1') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Hour','') + ' Number End: <input name=noth11 value="' + notthis('11','h11') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Hour','') + ' Number End Word (optional, and perhaps for maximum case): <input name=notmidday value="' + notthis('midday','') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Minute','') + ' Number Start Word (optional, and perhaps for minimum case): <input name=noto_clock value=' + notthis("o'clock","o_clock") + ' type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Minute','') + ' Number Start: <input name=notm1 value="' + notthis('1','m1') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Minute','') + ' Number End: <input name=notm59 value="' + notthis('59','m59') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Context','') + ' Menu Value/Text 1 of 3 (the "Optionally choose a context ..." value): <input name=not value="' + notthis('','not').replace(/~/g,' ') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Context','') + ' Menu Value/Text 2 of 3: <input name=notam value="' + notthis('am/in~the~morning','am').replace(/~/g,' ') + '" type="text" style=width:20%;></input><br></form>');
formstr=formstr.replace('</form>', notthis('Context','') + ' Menu Value/Text 3 of 3: <input name=notpm value="' + notthis('pm/in~the~afternoon','pm').replace(/~/g,' ') + '" type="text" style=width:20%;></input><br></form>');

formstr=formstr.replace('</form>', 'Sound File ' + notthis('Hour','') + ': <input name=notsoundfile1 value=' + soundfile1 + ' type="text" style=width:50%;></input><br></form>');
formstr=formstr.replace('</form>', 'Sound File ' + notthis('Minute','') + ': <input name=notsoundfile2 value=' + soundfile2 + ' type="text" style=width:50%;></input><br></form>');
formstr=formstr.replace('</form>', 'Sound File ' + notthis('Context','') + ': <input name=notsoundfile3 value=' + soundfile3 + ' type="text" style=width:50%;></input><br></form>');
formstr=formstr.replace('</form>', 'Sound File spare: <input name=notsoundfile4 value=' + soundfile4 + ' type="text" style=width:50%;></input><br><br>Show this Form? <input type=checkbox name=showform checked></input>&nbsp;&nbsp;<input type=submit value=Play style=background-color:orange;></input><br><br></form>');

var hd='';
for (var ihd=eval(notthis('1','h1')); ihd<=eval(notthis('11','h11')); ihd++) {
hd+='<option value="' + ihd + '">' + ihd + '</option>';
}

var md='';
for (var imd=eval(notthis('1','m1')); imd<=eval(notthis('59','m59')); imd++) {
md+='<option value="' + imd + '">' + imd + '</option>';
}

var bodyih='<table style="width:100%;text-align:center;"><tr><td><h1 id="myh1">' + notthis('Audio Numbers','') + ' - RJM Programming - September 2016</h1></td><td style="text-align:left;"><a href="#fdivorm" style="text-align:left;text-decoration:underline;" title="Add form" onclick=" trythis(); ">.</a></td></tr></table>'
+ '<h4 style="width:100%;text-align:center;" id="myh4">' + notthis('Hear this ...','') + '</h4>'
+ '<table style="width:100%;text-align:center;" id="mytable" border=200>'
+ '<tr><th>' + notthis('Hour','') + '</th><th>' + notthis('Minute','') + '</th><th>' + notthis('Context','') + '</th></tr>'
+ '<tr><td><select id="hour" name="hour"><option value="' + notthis('midnight','') + '">' + notthis('midnight','') + '</option>'
+ hd
+ '<option value="' + notthis('midday','') + '">' + notthis('midday','') + '</option>'
+ '</select></td><td><select id="minute" name="minute">'
+ '<option value=""></option><option value="' + notthis("o'clock","o_clock") + '">' + notthis("o'clock","o_clock") + '</option>'
+ md
+ '</select></td><td><select id="context">'
+ '<option value="' + notthis('','not').replace(/~/g,' ') + '">Optionally choose a context ...</option>'
+ '<option value="' + notthis('am/in~the~morning','am').replace(/~/g,' ').split('/')[0] + '">' + notthis('am/in~the~morning','am').replace(/~/g,' ').replace(notthis('am/in~the~morning','notam').replace(/~/g,' ').split('/')[0] + '/','') + '</option>'
+ '<option value="' + notthis('pm/in~the~afternoon','pm').replace(/~/g,' ').split('/')[0] + '">' + notthis('am/in~the~afternoon','pm').replace(/~/g,' ').replace(notthis('am/in~the~afternoon','notpm').replace(/~/g,' ').split('/')[0] + '/','') + '</option>'
+ '</select></td></tr>'
+ '<tr><td colspan=3><input title="Click to hear what you proposed above" value="Hear ..." id="hear" name="hear" type="button" onclick="hearthis(0);" style="background-color:yellow;"></input></td></tr>'
+ '</table><div id="formdiv"></div>';


if (formis != -1) bodyih=bodyih + formstr;

function checkget() {
var j=eval(1 + zero);
if (oaudio != null) {
oaudio.pause();
oaudio=null;
}
hearthis(j);
}

function hearthis(which) {
var houris=document.getElementById('hour').value;
var minuteis=document.getElementById('minute').value;
var contextis=document.getElementById('context').value;
var thingis=' ';
astart=0;
oaudio=null;
if (which == 0) thingis=houris;
if (which == 1) thingis=minuteis;
if (which == 2) thingis=contextis;
// alert(houris);
if (thingis.trim() == '') {
zero++;
which++;
if (zero >= audiomedia.length) {
return;
}
} else {
for (var i=which; i<audiomedia.length; i++) {
if (i == which) {
zero=i;
delay=2;
oaudio=new Audio(); // thanks to http://stackoverflow.com/questions/10868249/html5-audio-player-duration-showing-nan
oaudio.autoplay=true;
if (thingis.indexOf('mid') == 0) {
if (thingis.indexOf('day') != -1) astart=delay;
oaudio.src=midmedia[i];
} else if (i == 0) {
if (eval(thingis) <= 30) {
oaudio.src=audiomedia[i].replace('.m4a','.wav');
} else {
oaudio.src=audiomedia[i];
}
astart=eval(eval(-1 + eval(thingis)) + ".4");
//alert(astart);
delay=1.5;
} else if (thingis.toLowerCase().indexOf('clock') != -1) {
oaudio.src=audiomedia[i];
astart=eval("3.1");
delay=1.8;
} else if (i == 1) {
if (eval(thingis) <= 30) {
oaudio.src=audiomedia[0].replace('.m4a','.wav');
} else {
oaudio.src=audiomedia[0];
}
astart=eval(eval(-1 + eval(thingis)) + ".4");
//alert(astart);
delay=1.5;
} else {
oaudio.src=audiomedia[i];
delay=2.7;
if (thingis.toLowerCase().indexOf('am') == -1) astart=delay;
}
//alert(oaudio.src);
oaudio.addEventListener('loadedmetadata', function() {
if (zero < audiomedia.length) {
setTimeout(checkget, eval(1000 * delay));
}
oaudio.play();
if (astart != 0) oaudio.currentTime = eval(astart);
});
}
}
}
}

</script>
</head>
<body onload=" document.body.innerHTML=bodyih; ">
<h1 style="width:100%;text-align:center;" id="myh1">Audio Numbers - RJM Programming - September<a href="#fdivorm" style="text-decoration:underline;" title="Add form" onclick=" document.getElementById(\"formdiv\").innerHTML=formstr; ">,</a> 2016</h1>
<h4 style="width:100%;text-align:center;" id="myh4">Hear this ...</h4>
<table style="width:100%;text-align:center;" id="mytable" border=200>
<tr><th>Hour</th><th>Minute</th><th>Context</th></tr>
<tr><td><select id="hour" name="hour"><option value="midnight">midnight</option>
<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option>
<option value="11">11</option><option value="midday">midday</option>
</select></td><td><select id='minute' name='minute'>
<option value=""></option><option value="o'clock">o'clock</option>
<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option>
<option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option>
<option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option>
<option value="31">31</option><option value="32">32</option><option value="33">33</option><option value="34">34</option><option value="35">35</option><option value="36">36</option><option value="37">37</option><option value="38">38</option><option value="39">39</option><option value="40">40</option>
<option value="41">41</option><option value="42">42</option><option value="43">43</option><option value="44">44</option><option value="45">45</option><option value="46">46</option><option value="47">47</option><option value="48">48</option><option value="49">49</option><option value="50">50</option>
<option value="51">51</option><option value="52">52</option><option value="53">53</option><option value="54">54</option><option value="55">55</option><option value="56">56</option><option value="57">57</option><option value="58">58</option><option value="59">59</option>
</select></td><td><select id="context">
<option value="">Optionally choose a context ...</option>
<option value="am">in the morning</option>
<option value="pm">in the afternoon</option>
</select></td></tr>
<tr><td colspan=3><input title="Click to hear what you proposed above" value="Hear ..." id="hear" name="hear" type="button" onclick="hearthis(0);" style="background-color:yellow;"></input></td></tr>
</table>
</body>
</html>