<!doctype html>
<html>
<head>
<title>Splicing Audio - RJM Programming - August, 2016</title>
<script type='text/javascript'>
var audioobj=[];
var audiofiles=['','','','','','','','',''];
var zero=0;
var delay=0.0;
var noneblock='block';
var hideform='on';
var hideformlater='off';
var burl='';
var wo=null;
function noplus(inp) {
var outp=inp;
while (outp.indexOf('+') != -1) {
outp=outp.replace('+',' ');
}
return outp;
}
function fixhide() {
var sofar='off';
if (document.getElementById('hideform').checked) {
sofar='on';
}
if (document.getElementById('hideformlater').checked) {
sofar+='on';
} else {
sofar+='off';
}
document.getElementById('hide').value=sofar;
}
function precheckget() {
if (wo && wo.closed) {
wo=null;
zero++;
setTimeout(checkget, 20);
} else {
setTimeout(precheckget, 100);
}
}
function checkget() {
var i;
delay=0.0;
if (zero == 0) {
audiofiles[0]=location.search.split('audio1=')[1] ? decodeURIComponent(location.search.split('audio1=')[1].split('&')[0]) : '';
audiofiles[1]=location.search.split('audio2=')[1] ? decodeURIComponent(location.search.split('audio2=')[1].split('&')[0]) : '';
audiofiles[2]=location.search.split('audio3=')[1] ? decodeURIComponent(location.search.split('audio3=')[1].split('&')[0]) : '';
audiofiles[3]=location.search.split('audio4=')[1] ? decodeURIComponent(location.search.split('audio4=')[1].split('&')[0]) : '';
audiofiles[4]=location.search.split('audio5=')[1] ? decodeURIComponent(location.search.split('audio5=')[1].split('&')[0]) : '';
audiofiles[5]=location.search.split('audio6=')[1] ? decodeURIComponent(location.search.split('audio6=')[1].split('&')[0]) : '';
audiofiles[6]=location.search.split('audio7=')[1] ? decodeURIComponent(location.search.split('audio7=')[1].split('&')[0]) : '';
audiofiles[7]=location.search.split('audio8=')[1] ? decodeURIComponent(location.search.split('audio8=')[1].split('&')[0]) : '';
audiofiles[8]=location.search.split('audio9=')[1] ? decodeURIComponent(location.search.split('audio9=')[1].split('&')[0]) : '';
var hide=location.search.split('hide=')[1] ? decodeURIComponent(location.search.split('hide=')[1].split('&')[0]) : 'offoff';
document.getElementById('hide').value=hide;
if (hide.substring(0,2) == 'on') {
hideform='on';
} else {
hideform='off';
}
hide=hide.replace(hideform,'');
//hideform=location.search.split('hideform=')[1] ? decodeURIComponent(location.search.split('hideform=')[1].split('&')[0]) : hideform;
hideformlater=hide; //location.search.split('hideformlater=')[1] ? decodeURIComponent(location.search.split('hideformlater=')[1].split('&')[0]) : hideformlater;
if (hideform == 'on') document.getElementById('hideform').checked=true;
if (hideformlater == 'on') document.getElementById('hideformlater').checked=true;
burl=location.search.split('background=')[1] ? decodeURIComponent(location.search.split('background=')[1].split('&')[0]) : burl;
if (burl != '') {
document.getElementById('background').value=burl;
document.body.style.background=" url('" + burl + "')";
if (hideform != 'on') {
document.body.style.opacity=0.6;
} else {
noneblock='none';
}
} else {
if (hideform == 'on') noneblock='none';
}
if (audiofiles[eval(0 + zero)] != '') {
document.getElementById('subis').value='Currently Playing ...';
}
}
if (audiofiles[eval(0 + zero)] != '') {
for (i=eval(1 + zero); i<=(1 + zero); i++) {
if (noplus(audiofiles[eval(0 + zero)]) != '') {
document.getElementById('audio' + i).value=noplus(audiofiles[eval(0 + zero)]);
//document.getElementById('iaudio' + i).src=audiofiles[eval(0 + zero)];
//document.getElementById('iaudio' + i).load();
//document.getElementById('iaudio' + i).play();
if (noplus(audiofiles[eval(0 + zero)]).indexOf(' ') != -1) {
document.getElementById('subis').value='Currently Playing ' + noplus(audiofiles[eval(0 + zero)]) + " via Google Translate if you press speaker and am waiting for you to close that window.";
wo=window.open('https://translate.google.com/#auto/en/' + encodeURIComponent(noplus(audiofiles[eval(0 + zero)])),'_blank','top=50,left=50,width=600,height=600');
setTimeout(precheckget, 20);
} else {
audioobj.push(new Audio()); // thanks to http://stackoverflow.com/questions/10868249/html5-audio-player-duration-showing-nan
audioobj[zero].src=noplus(audiofiles[eval(0 + zero)]);
audioobj[zero].addEventListener('loadedmetadata', function() {
//alert("Playing " + audioobj[zero].src + ", for: " + audioobj[zero].duration + "seconds.");
delay+=audioobj[zero].duration;
document.getElementById('subis').value='Currently Playing ' + audioobj[zero].src + " for " + audioobj[zero].duration + " seconds";
zero++;
if (zero < audiofiles.length) {
setTimeout(checkget, eval(1000 * delay));
}
audioobj[eval(-1 + zero)].play();
});
}
} else {
document.getElementById('subis').value='Play Sequentially';
if (hideformlater != 'on') {
document.getElementById('formbits').style.display='block';
document.getElementById('formbits').style.backgroundColor='yellow';
} else {
document.getElementById('formbits').style.display='none';
}
}
}
document.getElementById('formbits').style.display=noneblock;
} else if (zero != 0) {
document.getElementById('formbits').style.display=noneblock;
document.getElementById('subis').value='Play Sequentially';
if (hideformlater != 'on') {
document.getElementById('formbits').style.display='block';
document.getElementById('formbits').style.backgroundColor='yellow';
} else {
document.getElementById('formbits').style.display='none';
}
} else {
document.getElementById('formbits').style.display=noneblock;
}
}
</script>
</head>
<body onload='checkget();'>
<div id='formbits' style='display:none;text-align:center; width: 100%; '>
<h1 style='text-align:center; width: 100%;'>Splicing Audio - RJM Programming - August, 2016</h1>
<form style='text-align:center; width: 100%;' method='GET' action='./splice_audio.html'>
Optional Audio File (or Text) 1: <input style='width:50%;' type='text' name='audio1' id='audio1'></input><br>
Optional Audio File (or Text) 2: <input style='width:50%;' type='text' name='audio2' id='audio2'></input><br>
Optional Audio File (or Text) 3: <input style='width:50%;' type='text' name='audio3' id='audio3'></input><br>
Optional Audio File (or Text) 4: <input style='width:50%;' type='text' name='audio4' id='audio4'></input><br>
Optional Audio File (or Text) 5: <input style='width:50%;' type='text' name='audio5' id='audio5'></input><br>
Optional Audio File (or Text) 6: <input style='width:50%;' type='text' name='audio6' id='audio6'></input><br>
Optional Audio File (or Text) 7: <input style='width:50%;' type='text' name='audio7' id='audio7'></input><br>
Optional Audio File (or Text) 8: <input style='width:50%;' type='text' name='audio8' id='audio8'></input><br>
Optional Audio File (or Text) 9: <input style='width:50%;' type='text' name='audio9' id='audio9'></input><br><br>
Optional Background Image: <input style='width:50%;' type='text' name='background' id='background'></input><br><br>
Hide This Form While Audio Plays? <input onchange='fixhide();' type='checkbox' id='hideform'></input><br>
Hide This Form After Audio Plays? <input onchange='fixhide();' type='checkbox' id='hideformlater'></input><br><br>
<input type='hidden' name='hide' id='hide' value='offoff'></input>
<input onclick='fixhide();' id='subis' style='text-align:center; background-color: pink; ' type='submit' value='Play Sequentially'></input>
</form>
</div>
<!--audio id='iaudio1' src=''></audio>
<audio id='iaudio2' src=''></audio>
<audio id='iaudio3' src=''></audio>
<audio id='iaudio4' src=''></audio>
<audio id='iaudio5' src=''></audio>
<audio id='iaudio6' src=''></audio>
<audio id='iaudio7' src=''></audio>
<audio id='iaudio8' src=''></audio>
<audio id='iaudio9' src=''></audio-->
</body>
</html>