<!DOCTYPE html>
<html>
<head>
<title>The Wrecking Crew Version - Dynamic Javascript and the YouTube API - Thanks to https://developers.google.com/youtube/iframe_api_reference ... RJM Programming - September, 2020</title>
</head>
<body id=xbody style="background-color:#f0f0f0;width:100%;">
<div id=dkaraoke></div>
<a onclick="location.href=document.URL.split('?')[0].split('#')[0];" id=xshuffle title=Refresh style='display:inline-block;font-size:8px;cursor:pointer;text-decoration:none;visibility:hidden;'>🎥</a>  <a onclick="location.href='#dshuffle';" id=ashuffle title=Shuffles style='display:inline-block;font-size:8px;cursor:pointer;text-decoration:none;visibility:hidden;'>🔀</a>  <span id=wshuffle style='font-size:9px;visibility:hidden;background-color:yellow;font-weight:bold;'><span id=sytitle>The Wrecking Crew</span> <a target=_blank title=YouTube href=//youtube.com>YouTube</a> Videos ... and/or ... <input id=rshuffle style=display:inline-block;visibility:hidden;background-color:pink;width:98%; onblur='if (this.value.length > 0) { topics+=topicd + this.value; topicd=String.fromCharCode(124); ajaxit(this.value); }' placeholder='YouTube Search word(s) ... or your own YouTube video ID comma list (appended by optional | delimited title)' id=iyrs type=text value=''></input> - RJM Programming - September, 2020 <a target=_self href='./the_wrecking_crew.html' title='Refresh'>🔄</a> <a target=_blank href='./the_wrecking_crew.html' title='New window'>📂</a> <a onclick="window.open('./the_wrecking_crew.html','_blank','top=50,left=50,width=600,height=800');" style="text-decoration:none;cursor:pointer;" title="Popup window in front">⛺</a></span>
<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
<table id=myborder border=1 style="width:100%;height:100vh;background-color:#f7f7f7;border:1px solid red;"><tbody>
<tr><td id="vplayer1"></td><td id="vplayer2"></td><td id="vplayer3"></td></tr>
<tr><td id="vplayer4"></td><td id="vplayer5"></td><td id="vplayer6"></td></tr>
<tr><td id="vplayer7"></td><td id="vplayer8"></td><td id="vplayer9"></td></tr>
<tr style=display:none;><td id="vplayer10"></td><td id="vplayer11"></td><td id="vplayer12"></td></tr>
<tr style=display:none;><td id="vplayer13"></td><td id="vplayer14"></td><td id="vplayer15"></td></tr>
<tr style=display:none;><td id="vplayer16"></td><td id="vplayer17"></td><td id="vplayer18"></td></tr>
<tr style=display:none;><td id="vplayer19"></tdg><td id="vplayer20"></td><td id="vplayer21"></td></tr>
<tr style=display:none;><td id="vplayer22"></td><td id="vplayer23"></td><td id="vplayer24"></td></tr>
</tbody></table>
<div id=dshuffle style=visibility:hidden;display:inline-block;><a onclick="location.href='#ashuffle';" id=zshuffle title=Top style='display:block;font-size:8px;cursor:pointer;text-decoration:none;visibility:hidden;'>🎥</a><br><select id=sshuffle style=display:inline-block;background-color:#e0e0e0; multiple><option id=oone value=''>Single selections shuffle with your choice first played (for up to 9 slots available), below ...</option></select> <table id=pshuffle style=display:inline-block;visibility:hidden;vertical-align:top;><th colspan=2><input onclick=process(this); type=button id=bshuffle style=display:inline-block;background-color:yellow;vertical-align:top; value=Shuffle></input></th></tr><tr><th> ... and/or ... </th><th><input id=qshuffle style=display:inline-block;visibility:hidden;background-color:pink; onblur='if (this.value.length > 0) { topics+=topicd + this.value; topicd=String.fromCharCode(124); ajaxit(this.value); }' placeholder='YouTube Search word(s)' id=iyrs type=text value=''></input><input type=text value='' style='position:absolute;top:-200px;left:-200px;'></input></th></tr></table></div>
<script>

// localhost:8888/legend_via_map.php?url=" + encodeURIComponent("//www.youtube.com/results?search_query=" + qsel);

var ourtwc=location.search.split('aprefix=')[1] ? decodeURIComponent(location.search.split('aprefix=')[1].split('&')[0]) : 'twc';
var yourtwc="The Wrecking Crew";
if (ourtwc != 'twc') { yourtwc=location.search.split('atitle=')[1] ? decodeURIComponent(location.search.split('atitle=')[1].split('&')[0]) : "Your List"; }
var trackid=-1;
var zhr=null;
var tselih='';
var qtitle='';
var lastscont='';
var url='';
var zok=0;
var bprefix='';
var lsdone=false;
var keeporder=false;
//console.log(localStorage.getItem('list001'));
if (document.URL.indexOf('clear=') != -1) {
if (window.localStorage) {
//if ((location.search.split('alist=')[1] ? 'x' : '') == '') {
console.log('remove ' + ourtwc + 'list');
localStorage.removeItem('list' + ourtwc);
localStorage.removeItem(ourtwc + 'list');
if (ourtwc != 'twc') { location.href=document.URL.split('?')[0].split('#')[0]; }
//}
}
}

function muchlater() {
document.getElementById('syztitle').innerHTML=tselih; //ddit(yourtwc);
//setTimeout(muchlater, 2000);
}

function ddit(yts) {
var outsug=yts, altttl='', thisttl='', outyts=yts, yoursug='', sofarc='';
var ione=1;
var lastlslook=' ';
if (window.localStorage) {
while (lastlslook != '') {
outsug=('000' + ione).slice(-3);
lastlslook=decodeURIComponent(('' + localStorage.getItem('list' + outsug))).replace(/\+/g,' ').replace(/^null$/g,'').trim();
console.log('yts=' + yts + ' and ione=' + ione + ' and lastlslook=' + lastlslook);
if (lastlslook.toLowerCase().indexOf('http') == 0) {
sofarc+=lastlslook;
//alert(lastlslook + ' ... ' + outyts);
if (lastlslook.indexOf('&atitle=') != -1) {
thisttl=decodeURIComponent(lastlslook.split('&atitle=')[1].split('&')[0].split('#')[0]);
} else {
thisttl=outsug;
}
if (outyts.indexOf('<SELECT') == -1) {
if (yts == 'The Wrecking Crew') {
console.log('s');
outyts="<SELECT id=syztitle onchange='location.href=this.value;'><option value='" + document.URL.split('?')[0].split('#')[0] + "'>The Wrecking Crew</option><option value='" + lastlslook.split('#')[0] + "'>" + thisttl + "</option><option value='" + lastlslook.split('#')[0].replace('?','?clear=y&') + "'>-" + thisttl + "</option><option value='" + document.URL.split('?')[0].split('#')[0].replace('/the_wrecking_crew.','/disco_version.') + "'>Disco</option></SELECT>";
} else if (document.URL.indexOf('atitle=') != -1) {
altttl=decodeURIComponent(document.URL.split('atitle=')[1].split('&')[0].split('#')[0]);
console.log('ta:' + thisttl);
outyts="<SELECT id=syztitle onchange='location.href=this.value;'><option value='" + document.URL.split('#')[0] + "'>" + altttl + "</option><option value='" + document.URL.split('#')[0].replace('?','?clear=y&') + "'>-" + altttl + "</option><option value='" + document.URL.split('?')[0].split('#')[0] + "'>The Wrecking Crew</option><option value='" + lastlslook.split('#')[0] + "'>" + thisttl + "</option><option value='" + lastlslook.split('#')[0].replace('?','?clear=y&') + "'>-" + thisttl + "</option><option value='" + document.URL.split('?')[0].split('#')[0].replace('/the_wrecking_crew.','/disco_version.') + "'>Disco</option></SELECT>";
} else if (document.URL.indexOf('aprefix=') != -1) {
altttl=decodeURIComponent(document.URL.split('aprefix=')[1].split('&')[0].split('#')[0]);
console.log('tb:' + thisttl);
outyts="<SELECT id=syztitle onchange='location.href=this.value;'><option value='" + document.URL.split('#')[0] + "'>" + altttl + "</option><option value='" + document.URL.split('#')[0].replace('?','?clear=y&') + "'>-" + altttl + "</option><option value='" + document.URL.split('?')[0].split('#')[0] + "'>The Wrecking Crew</option><option value='" + lastlslook.split('#')[0] + "'>" + thisttl + "</option><option value='" + lastlslook.split('#')[0].replace('?','?clear=y&') + "'>-" + thisttl + "</option><option value='" + document.URL.split('?')[0].split('#')[0].replace('/the_wrecking_crew.','/disco_version.') + "'>Disco</option></SELECT>";
} else {
console.log('t:' + thisttl);
outyts="<SELECT id=syztitle onchange='location.href=this.value;'><option value='" + lastlslook.split('#')[0] + "'>" + thisttl + "</option><option value='" + lastlslook.split('#')[0].replace('?','?clear=y&') + "'>-" + thisttl + "</option><option value='" + document.URL.split('?')[0].split('#')[0] + "'>The Wrecking Crew</option><option value='" + document.URL.split('?')[0].split('#')[0].replace('/the_wrecking_crew.','/disco_version.') + "'>Disco</option></SELECT>";
}
} else if (lastlslook.toLowerCase().indexOf('http') == 0 && outyts.indexOf("<option value='" + lastlslook.split('#')[0] + "'>" + thisttl + "</option>") == -1) {
outyts=outyts.replace("</SELECT>","<option value='" + lastlslook.split('#')[0] + "'>" + thisttl + "</option><option value='" + lastlslook.split('#')[0].replace('?','?clear=y&') + "'>-" + thisttl + "</option></SELECT>");
}
} else if (outyts.indexOf('<SELECT') == -1) {
if (yts != 'The Wrecking Crew' && document.URL.indexOf('clear=') == -1) {
console.log('Yts=' + yts + ' and ione=' + ione + ' and lastlslook=' + lastlslook);
if (yourtwc.replace("The Wrecking Crew","") != '') {
thisttl=yourtwc;
} else {
thisttl=outsug;
}
outyts="<SELECT id=syztitle onchange=location.href=this.value;><option value='" + document.URL.split('#')[0] + "'>" + thisttl + "</option><option value='" + document.URL.split('#')[0].replace('?','?clear=y&') + "'>-" + thisttl + "</option><option value='" + document.URL.split('?')[0].split('#')[0] + "'>The Wrecking Crew</option><option value='" + document.URL.split('?')[0].split('#')[0].replace('/the_wrecking_crew.','/disco_version.') + "'>Disco</option></SELECT>";
console.log('Yts=' + yts + ' and outsug=' + outsug + ' and thisttl=' + thisttl);
localStorage.setItem('list' + outsug, encodeURIComponent(document.URL.split('#')[0]));
lastlslook=decodeURIComponent(('' + window.localStorage.getItem('list' + outsug))).replace(/\+/g,' ').replace(/^null$/g,'').trim();
console.log('YTs=' + yts + ' and outsug=' + outsug + ' and lastlslook=' + lastlslook);
sofarc+=document.URL.split('#')[0];
yoursug=outsug;
}
} else {
}
ione++;
}
}
if (yoursug != '') {
if (sofarc.indexOf(document.URL.split('#')[0]) == -1 && document.URL.indexOf('clear=') == -1) {
console.log('5');
window.localStorage.setItem('list' + yoursug, encodeURIComponent(document.URL.split('#')[0]));
}
} else if (yts != 'The Wrecking Crew' && sofarc.indexOf(document.URL.split('#')[0]) == -1 && document.URL.indexOf('clear=') == -1) {
console.log('15');
window.localStorage.setItem('list' + outsug, encodeURIComponent(document.URL.split('#')[0]));
}
if (outyts.toLowerCase().indexOf('<select') == 0) {
tselih=outyts;
setTimeout(muchlater, 2000);
}
return outyts;
}

function ourdecodeURIComponent(untriminstuff) {
var instuff=decodeURIComponent(untriminstuff).trim();
if (eval(2 + eval('' + instuff.length)) == eval('' + decodeURIComponent(untriminstuff).length)) { keeporder=true; } else { keeporder=false; }
instuff=encodeURIComponent(decodeURIComponent(untriminstuff).trim());
var arrback=[];
var dl=('' + decodeURIComponent(instuff)).replace(/\'/g,'').replace(/\"/g,'').length;
var instuffs=decodeURIComponent(instuff).replace(/\'/g,'').replace(/\"/g,'').split(',');
if (instuffs.length == 1 && eval(eval('' + dl) % 11) == 0) {
for (var iii=0; iii<eval('' + dl); iii+=11) {
arrback.push(('' + decodeURIComponent(instuff)).replace(/\'/g,'').replace(/\"/g,'').substring(iii).substring(0,11));
}
} else {
for (var ii=0; ii<instuffs.length; ii++) {
arrback.push(instuffs[ii].replace(/\'/g,'').replace(/\"/g,''));
}
}
return arrback;
}

function lessopt(selih) {
var outih=selih, opttoadd='';
var opta=selih.split('</option>');
if (orighastoinclude == '') { orighastoinclude='youllneverfindthis'; }
if (opta.length > 1) {
outih='';
for (var iop=0; iop<opta.length; iop++) {
if (opta[iop] != '') {
opttoadd='<option' + opta[iop].split('<option')[1] + '</option>';
if (outih.indexOf(opttoadd) == -1 && opttoadd.indexOf(orighastoinclude) == -1) {
outih+=opttoadd;
}
}
}
}
return outih;
}

function tryls() {
lastscont='';
if (window.localStorage) {
lastscont=decodeURIComponent(('' + localStorage.getItem(ourtwc + 'list'))).replace(/\+/g,' ').replace(/^null$/g,'');
}
return lastscont;
}

function setls(towhat) {
var lastscont='';
if (window.localStorage) {
console.log('8:' + 'lst' + ourtwc + ';' + towhat);
localStorage.setItem(ourtwc + 'list', encodeURIComponent(towhat));
}
return lastscont;
}

function getXMLHttpRequest() {
if (window.XMLHttpRequest) {
return new window.XMLHttpRequest;
}
else {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
return false;
}
}
}
}

function yourprefix(suggestedone) {
var outsug=suggestedone, ione=1;
var lastlslook=' ';
if (window.localStorage) {
while (lastlslook != '') {
outsug=('000' + ione).slice(-3);
lastlslook=decodeURIComponent(('' + localStorage.getItem('list' + outsug))).replace(/\+/g,' ').replace(/^null$/g,'').trim();
ione++;
}
}
return outsug;
}


function sto() {
window.scrollTo(0,0);
}

function ajaxit(qsel) {
var aplaylist=false; // FLos__61yUFKl-VpnmQB4YIg
var vvprefix='%20%20%20%20%20%20%20%20%20%20%20%20%20';
qtitle='';
if ((qsel.split('|')[0].indexOf(' ') != -1 || qsel.indexOf(',') == -1) && qsel.trim() != '') {
if (eval('' + qsel.length) == 11 && qsel.indexOf(' ') == -1) { vvprefix=''; }
document.getElementById('dkaraoke').innerHTML='<a style="cursor:pointer;text-decoration:none;" href="#xshuffle" title=Down>👇</a><br><iframe style="width:100%;height:800px;" src="./karaoke_youtube_api.htm?vid=' + vvprefix + encodeURIComponent(qsel) + '"></iframe>';
setTimeout(sto, 3000);
location.href='#xbody';
} else {
if (qsel.indexOf('|') != -1) {
qtitle='&atitle=' + encodeURIComponent(qsel.split('|')[1]);
qsel=qsel.split('|')[0];
}
if (qsel.replace(/\'/g,'').replace(/\"/g,'').indexOf(' ') == -1 && qsel.indexOf(',') != -1) {
location.href=document.URL.split('#')[0].split('?')[0] + '?aprefix=' + encodeURIComponent(yourprefix(qsel.replace(/\'/g,'').replace(/\"/g,'').substring(0,3))) + qtitle + '&alist=' + encodeURIComponent(qsel.replace(/\'/g,'').replace(/\"/g,''));
} else if (qsel.replace(/\'/g,'').replace(/\"/g,'').indexOf(' ') == -1 && eval(eval(qsel.replace(/\'/g,'').replace(/\"/g,'').length) % 11) == 0) {
location.href=document.URL.split('#')[0].split('?')[0] + '?aprefix=' + encodeURIComponent(yourprefix(qsel.replace(/\'/g,'').replace(/\"/g,'').substring(0,3))) + qtitle + '&alist=' + encodeURIComponent(qsel.replace(/\'/g,'').replace(/\"/g,''));
//} else if (qsel.replace(/\'/g,'').replace(/\"/g,'').indexOf(' ') == -1 && qsel.length == 'FLos__61yUFKl-VpnmQB4YIg'.length) {
} else if (qsel != '') {
url="//www.rjmprogramming.com.au/HTMLCSS/legend_via_map.php?url=" + encodeURIComponent("http://www.youtube.com/results?search_query=" + encodeURIComponent(qsel));
if (!zhr) {
zhr = getXMLHttpRequest();
} //else {
//zok = 1;
//}

if (zhr != null) {
zhr = zhr;
} else {
try {
zhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
zhr = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
zhr = false;
}
}
}

if (zhr) {
//alert(987);
if (url != '') {
//alert(url);
zok=0;
zhr.open("GET", url, true);
zhr.onreadystatechange = showStuff;
zhr.send(null);
url='';
}
} else {
zok = 1; //alert("Sorry ... no XMLHttpRequest possible");
}
}
}
}

function aout(output) {
var selc='', fosecs=0.0, afosecs=[], ifo=0, fofactor=1.0;
var qqbits=output.split('v=');
var qqtbits=output.split('-describedby='); //'/watch?'); // '"commandMetadata":{"webCommandMetadata":{"url":"/watch'); // '-describedby=');
if (qqtbits.length == 1 && output.indexOf('503 ') != -1) { document.title+=' ... please try again later.'; }
var qdelim=' ', tqbits, ttqqbits='', attqqbits=[], durbits='', adurbits;
var q11=11, preselc='';
var fgs='findings are ', sze='', is_okay=true, jis_okay=0;
//alert(1);
for (var ifgs=1; ifgs<qqtbits.length; ifgs++) {
fosecs=0.0;
fofactor=1.0;
tqbits=qqtbits[eval(-1 + ifgs)].split(' title="');
ttqqbits=qqtbits[eval(-1 + ifgs)].split('v=')[eval(-1 + qqtbits[eval(-1 + ifgs)].split('v=').length)].substring(0,q11);

if (selc == '') { // && document.getElementById('ajax').innerHTML == '') {
// document.title+=' 1 ';
if (ttqqbits.indexOf('<') == -1) {
selc=preselc + "<select" + sze + " title='YouTube videos' id=ajaxs onchange=puty(this);><option id=ominpossible value=>Optionally choose YouTube title below ...</option></select>";
}
}

if (is_okay) {
durbits=' (' + qqtbits[eval(-1 + ifgs)].split(' class="video-time"')[eval(-1 + qqtbits[eval(-1 + ifgs)].split(' class="video-time"').length)].split('<')[0].split('>')[1] + ')';
//selc=selc.replace('</select>','<option value=' + qqbits[eval(2 * ifgs)].substring(0,q11) + '>' + tqbits[eval(-1 + tqbits.length)].split('"')[0] + '</option></select>');
selc=selc.replace('</select>','<option id="' + ttqqbits + '" onclick="oclick(this);" value=' + ttqqbits + '>' + tqbits[eval(-1 + tqbits.length)].split('"')[0] + durbits + '</option></select>');
qdelim=',';
q11=11;
} //else {
//document.title+=' why? ';
//}
}
if (is_okay) {
// <option value=engoPxtSbGk>PM concedes Hawaii holiday during bushfires caused 'great anxiety in Australia' | ABC News (15:20)</option><option value=2_UjJ_jxxuI>Maxwell, Zampa extinguish Heat despite Banton heroics | KFC BBL|09 (6:06)</option><option value=BE-ZEiNg4l4>Terrifying bushfires ravage towns across NSW | Nine News Australia (6:20)</option>

var postselc=selc.replace(selc.split('>')[0] + '>','').replace('</select>','');
//alert('1:' + postselc);
postselc=postselc.replace(postselc.split('</option>')[0] + '</option>','');
//alert('2:' + postselc);
postselc=postselc.replace(/\<\/option\>/g, '~/option~').replace(/\ value\=/g, ' value="');
//alert('3:' + postselc);
var pss=postselc.split(' (');
var ssp;
var sfactor=1, iytr;
var sduris=0;
var iplus=0;
var isok=false;
for (var ipss=1; ipss<pss.length; ipss++) {
isok=false;
if (pss[ipss].split(')')[0].substring(0,1) >= '0' && pss[ipss].split(')')[0].substring(0,1) <= '9') {
isok=true;
iplus++;
sfactor=1;
sduris=0;
ssp=pss[ipss].split(')')[0].split(':');
for (iytr=eval(-1 + ssp.length); iytr>=0; iytr--) {
sduris+=eval(sfactor * eval('' + ssp[iytr]));
sfactor*=60;
}
postselc=postselc.replace('>', '|' + sduris + '|0|' + pss[eval(-1 + ipss)].split('>')[eval(-1 + pss[eval(-1 + ipss)].split('>').length)].replace(/\"/g,'') + '"`').replace(' (' + pss[ipss].split(')')[0] + ')','');
}
}

postselc=postselc.replace(/\"\`/g, '">').replace(/\~\/option\~/g, '</option>');
//alert(postselc);

document.getElementById('sshuffle').innerHTML=document.getElementById('sshuffle').innerHTML.replace('</option>', '</option>' + postselc);
document.getElementById('sshuffle').size=eval(eval(iplus) + eval('' + document.getElementById('sshuffle').size));

//alert(postselc);
location.href='#zshuffle';

dotop();
}
}

function dotop() {
var subta;
if (subtopics != '') {
subta=subtopics.split('`')[0];
if (subta == subtopics) {
subtopics='';
location.href='#ashuffle';
} else {
subtopics=subtopics.replace(subta + '|','');
setTimeout(dotop, 3000);
}
ajaxit(subta);
}
}

function showStuff(evt) {
if (zok == 0 && zhr != null) {
if (zhr.readyState == 4) {
if (zhr.status == 200) {
aout(zhr.responseText);
}
}
}
}


function process(bsin) {
var tdsl=document.getElementsByTagName('td');
var jj=0, mbo='', mlist='', mdelim='', vscnt=0, kk=0;
var sin=document.getElementById(bsin.id.replace('b','s'));
for (var i=0; i<sin.options.length; i++) {
if (sin.options[i].selected) {
if (sin.options[i].value != '') {
kk++;
if (eval(1 + jj) < eval('' + tdsl.length)) {
jj++;
vscnt++;
mbo=sin.options[i].value.split('|')[0];
mlist+=mdelim + sin.options[i].value.split('|')[0];
mdelim=',';
}
}
}
}
if (bsin.id == sin.id) {
return kk;
}
var usuffix='';
if (topics != '') {
usuffix='&topics=' + encodeURIComponent(topics);
}
if (jj == 1) {
location.href=(document.URL.split('#')[0].replace('mustbeone=','mustxxxbeone=') + '&mustbeone=' + encodeURIComponent(mbo)).replace('.html&','.html?').replace('.htm&','.htm?').replace('.php&','.php?').replace('/&','/?') + usuffix;
} else if (jj > 1) {
if (oclickcnt == vscnt) { mlist=olist; }
location.href=(document.URL.split('#')[0].replace('mustbeone=','mustxxxbeone=').replace('videolist=','videoxxxlist=').replace(cbl,'') + '&videolist=' + encodeURIComponent(mlist)).replace('.html&','.html?').replace('.htm&','.htm?').replace('.php&','.php?').replace('/&','/?') + usuffix;
}
oclickcnt=0;
occ=[];
olist='';
odelim='';
return kk;
}

function shuffle(array) { // thanks to https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
var currentIndex = array.length, temporaryValue;
var randomIndex=eval(-9 - eval('' + currentIndex));
var orderedIndex=0;
//var keeporder=false;
//if (eval(2 + eval('' + array.length)) == eval('' + untrimarray.length)) { keeporder=true; }

// While there remain elements to shuffle...
if (('' + hastoinclude) != '') {
for (var ij=0; ij<currentIndex; ij++) {
if (array[ij] == hastoinclude) {
randomIndex=eval(-1 - ij);
keeporder=false;
}
}
hastoinclude='';
}
while (0 !== currentIndex) {

// Pick a remaining element...
if (keeporder) {
randomIndex = orderedIndex;
orderedIndex++;
//alert('randomIndex=' + randomIndex);
} else if (eval('' + randomIndex) >= 0 || eval(1 + eval(('' + randomIndex))) < eval('' + array.length)) {
randomIndex = Math.floor(Math.random() * currentIndex);
} else {
randomIndex = Math.abs(eval(1 + eval('' + randomIndex)));
}
currentIndex -= 1;

// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}

return array;
}

var scont='<option id="oone" value="">Single selections shuffle with your choice first played (for up to 9 slots available), below ...</option>';
var splaycnt=0;
var curplay='';
var oclickcnt=0;
var occ=[];
var mid=-1;
var olist='';
var odelim='';
var precp='';
var precv=0;
var curdur=-1;
var vplayer=[];

var hastoinclude=location.search.split('hastoinclude=')[1] ? decodeURIComponent(location.search.split('hastoinclude=')[1].split('&')[0]) : '';
var orighastoinclude=hastoinclude;

var cbl=location.search.split('videolist=')[1] ? location.search.split('videolist=')[1].split('&')[0] : 'youllneverfindthis';
var yid=['zPv0S1-ETdI','qYf35nBq8Oo','Se3kxManWUY','i7hk-TupE5g','LnK0tnaNUag','dbH4Amzn-Rk','BL-Jg7CyqLQ','0v7Ea7kg2gA','NRjWEE0hmjQ'];
yid=['ARt9HV9T0w8#GG','OAfxs0IDeMs#Heart','huavJMGUbiI#BB'];
// Thanks to https://en.wikipedia.org/wiki/The_Wrecking_Crew_(music)
yid=location.search.split('videolist=')[1] ? eval("['" + decodeURIComponent(location.search.split('videolist=')[1].split('&')[0]).replace(/\,/g,"','") + "']") :
shuffle((location.search.split('alist=')[1] ? ourdecodeURIComponent(location.search.split('alist=')[1].split('&')[0]) : ['6uqPBZncL5Q',
'6bWyhj7siEY',
'aF7V2dSvxpo',
'L0dikX80Ed8',
'ERrwjR4ZlfI',
'jrVbawRPO7I',
'KnPL5OXSBNE',
'z-2_OstpR5c',
'fYxPgFUjDpA',
'uOnYY9Mw2Fg',
'_uSmds1pCKg',
'F5R-_ZUf0wY',
'cUxMupNEno4',
'PYF8Y47qZQY',
'bKTOizdhan8',
'N-aK6JnyFmk',
'qfZVu0alU0I',
'BERd61bDY7k',
'hr21kmI72LU',
'IuNCZfd93bc',
'Eab_beh07HU',
'vAI24i825_E',
'h81Ojd3d2rY',
'jhkIh4x4mmM',
'mzrPs-hLKmM',
'Fd_3EkGr0-4',
'SbyAZQ45uww',
'sukxmZcDGlU',
'UzgpB9xpyT8',
'5akEgsZSfhg',
'7I0vkKy504U',
'Y_t2gNCXYbY',
'1hyJDLyUAoc',
'jBVDBuz4rZw',
'bS3O5zg290k',
'Q8P_xTBpAcY',
'5nZnqtDdsws',
'iplpKwxFH2I',
'9C1BCAgu2I8',
'zcSlcNfThUA',
'QWTa9CE51sA',
'qJFVPxBpezk',
'EEzyrpfrPEI',
'PxoJkDQdNBI',
'06X5HYynP5E',
'kCDPlU6ioZU',
'l3LFML_pxlY',
'jV127kNz0hs',
'MGemtjVtfZM',
'g684wkErOpc',
'2r9UtIhOI8M',
'WrcwRt6J32o',
'dPmbT5XC-q0',
'dLTETaWswCY',
'D-TC8CRCIKM',
'k4X1ks2pKoo',
'21ixwIaN7qw',
'sqkVNHwJfKc',
'GztV3yWNJJw',
'Gmq4WIjQxp0',
'5Ra1DEd1ueA',
'YTaWayUE5XA',
'Z6E98ZRaU1s',
'IaBjY-zm0sI',
'vrQvOvu_eRc',
'RFnkCIwGwiA',
'8kAU3B9Pi_U',
'_QNEf9oGw8o',
'U8TsAh-zYFI']));
var mbo=location.search.split('mustbeone=')[1] ? decodeURIComponent(location.search.split('mustbeone=')[1].split('&')[0]) : '';
var topics=location.search.split('topics=')[1] ? decodeURIComponent(location.search.split('topics=')[1].split('&')[0]) : '';
var topicd='';
var subtopics=topics;
if (topics != '') { topicd='|'; }


if (mbo != '') {
var oyid=[mbo];
for (var iu=0; iu<yid.length; iu++) {
if (yid[iu] != mbo) {
oyid.push(yid[iu]);
}
}
yid=oyid;
}

var curv=0;
var dostop=true;
var done=[];
var stopthese=[];
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');

tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
//var vplayer1, vplayer2;
function onYouTubeIframeAPIReady() {
var tdsl=document.getElementsByTagName('td');
for (var ii=1; ii<=yid.length; ii++) {
if (eval(1 + eval('' + vplayer.length)) < eval('' + tdsl.length)) {
done.push(false);
vplayer.push(eval("new YT.Player('vplayer" + ii + "', { height: '260', width: '33%', videoId: '" + yid[-1 + ii] + "', playerVars: { autoplay: 0, controls: 1, disablekb: 1, loop: 0, modestbranding: 0, showinfo: 0, autohide: 1, color: 'white', iv_load_policy: 3, theme: 'light', rel: 0 }, events: { 'onError': onProblem, 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange }})"));
}
}
}

function onProblem(event) {
console.log(event.target.f);
console.log(event.target.l);
var pvidid='', embedurl='', vtitle='';
//if (event.target.f) {
// alert('preHuh:' + event.target.f.outerHTML);
//}
if (event.target.f.outerHTML.indexOf('embed/') != -1) {
pvidid=event.target.f.outerHTML.split('embed/')[1].split('?')[0];
}
if (pvidid != '') {
if (lastscont.indexOf(pvidid) != -1) {
// D-TC8CRCIKM|194|0|The Grass Roots - Sooner Or Later - [original STEREO]
//alert(lastscont.split(pvidid)[1]);
var vbs=lastscont.split(pvidid)[1].split('|');
if (eval('' + vbs.length) >= 4) {
vtitle='' + vbs[3];
}
}
if (event.target.f.outerHTML.indexOf(' class="player-unavailable"') != -1 || pvidid != '') {
embedurl='http' + event.target.f.outerHTML.split('http')[1].split('"')[0];
if (document.URL.toLowerCase().indexOf('rjmprogramming.com.au/') != -1) {
var zzhr = new XMLHttpRequest();
var zzform=new FormData();
zzform.append('inline', '');
zzform.append('to', 'rmetcalfe@rjmprogramming.com.au');
zzform.append('subj', 'Please find alternative to YouTube ' + pvidid + ' in relevant code ... ' + vtitle);
zzform.append('body', encodeURIComponent('Problem video is first iframe of ... ' + String.fromCharCode(10) + String.fromCharCode(10) + document.URL.split('#')[0].split('?')[0] + '?hastoinclude=' + pvidid + String.fromCharCode(10) + String.fromCharCode(10) + 'Problem YouTube video is ... ' + String.fromCharCode(10) + String.fromCharCode(10) + "https://www.youtube.com/watch?v=" + pvidid));
zzhr.open('post', '//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php', true);
zzhr.send(zzform);
//var remurl='mailto:rmetcalfe@rjmprogramming.com.au?subject=' + encodeURIComponent('Please find alternative to YouTube ' + pvidid + ' in relevant code ... ' + vtitle) + '&body=' + encodeURIComponent('Problem video is first iframe of ... ' + String.fromCharCode(10) + String.fromCharCode(10) + document.URL.split('#')[0].split('?')[0] + '?hastoinclude=' + pvidid + String.fromCharCode(10) + String.fromCharCode(10) + 'Problem YouTube video is ... ' + String.fromCharCode(10) + String.fromCharCode(10) + "https://www.youtube.com/watch?v=" + pvidid);
//if (('' + document.getElementById('badvideo').href).indexOf('mailto') != 0) { document.getElementById('badvideo').href=remurl; document.getElementById('badvideo').click(); }
} else {
var emurl='mailto:rmetcalfe@rjmprogramming.com.au?subject=' + encodeURIComponent('Please find alternative to YouTube ' + pvidid + ' in relevant code ... ' + vtitle) + '&body=' + encodeURIComponent('Problem video is first iframe of ... ' + String.fromCharCode(10) + String.fromCharCode(10) + document.URL.split('#')[0].split('?')[0] + '?hastoinclude=' + pvidid + String.fromCharCode(10) + String.fromCharCode(10) + 'Problem YouTube video is ... ' + String.fromCharCode(10) + String.fromCharCode(10) + "https://www.youtube.com/watch?v=" + pvidid);
if (('' + document.getElementById('badvideo').href).indexOf('mailto') != 0) { document.getElementById('badvideo').href=emurl; document.getElementById('badvideo').click(); }
}
//} else {
//alert('huh:' + ('' + event.target.f));
}
//} else {
//alert('Huh:' + ('' + event.target.f));
}
//alert('http' + ('' + event.target.f).split('http')[1].split('"')[0]);
}

// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
var dis, cti, gvd, uri, jis, prv='', iyi=0, huht='';
if (!lsdone) {
lsdone=true;
scont=scont.replace('</option>', '</option>' + tryls());
//alert(('' + scont.split('</option>').length));
}
uri=event.target.getVideoUrl();
jis=yid.indexOf(uri.split('=')[1].split('&')[0]);
dis=event.target.getDuration();
cti=event.target.getCurrentTime();
gvd=event.target.getVideoData().title;
yid[jis]+='|' + dis + '|' + cti + '|' + gvd;
//alert(yid[jis]);
splaycnt++;
if (splaycnt > 9) {
//if (eval('' + jis) < eval('' + trackid)) {
// alert(yid[jis]);
//} else {
// trackid=eval('' + jis);
//}
// alert('jis=' + jis + ' ' + scont.indexOf(yid[jis]));
if (scont.indexOf(yid[jis]) == -1) {
prv=scont;
if (scont.indexOf('>' + gvd + '<') == -1) { scont=prv.split('</option>')[0] + '</option><option id="' + yid[jis].split('|')[0] + '" onclick="oclick(this);" value="' + yid[jis] + '">' + gvd + '</option>' + prv.replace(prv.split('</option>')[0] + '</option>',''); }
}
} else {
if (scont.indexOf('>' + gvd + '<') == -1) { scont+='<option id="' + yid[jis].split('|')[0] + '" onclick="oclick(this);" value="' + yid[jis] + '">' + gvd + '</option>'; }
if (splaycnt == 9 && yid.length > 9) {
for (iyi=0; iyi<yid.length; iyi++) {
if (scont.indexOf(yid[iyi]) == -1) {
try {
huht=vplayer[splaycnt].getVideoData().title;
prv=scont;
if (scont.indexOf('>' + gvd + '<') == -1) { scont=prv.split('</option>')[0] + '</option><option id="' + yid[iyi].split('|')[0] + '" value="' + yid[iyi] + '" onclick="oclick(this);">' + gvd + '</option>' + prv.replace(prv.split('</option>')[0] + '</option>',''); }
} catch(rtde) {
}
}
}
}
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
event.target.mute();
}
event.target.playVideo();
event.target.mute();
}

function midit() {
if (mid >= 0) {
var imid=mid;
mid=-1;
try {
vplayer[imid].mute();
} catch (htjh) { }
}
}

// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.


function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.BUFFERING) { // && !done) {
curplay=curplay;
} else if (event.data == YT.PlayerState.CUED) { // && !done) {
curplay=curplay;
} else if (event.data == YT.PlayerState.PAUSED) { // && !done) {
//curv=eval(eval(1 + curv) % eval('' + 9));
//alert('' + curv);
if (curplay != '') { precv=curv; precp=curplay; }
curplay='';
//vplayer[curv].playVideo();
} else if (event.data == YT.PlayerState.PLAYING) { // && !done) {
if (dostop) {
stopthese.push(event.target);
setTimeout(stopVideo, 6000);
} else if (curplay == '') {


if (precp == event.target.getVideoUrl().split('=')[1].split('&')[0]) {
//alert(1);
curplay=precp;
curv=precv;
} else if (1 == 6) {
//alert(11);
mid=precv;
if (1 == 2) { vplayer[curv].mute(); }
}

curplay=event.target.getVideoUrl().split('=')[1].split('&')[0];
curdur=eval('' + event.target.getDuration());
for (var ijj=0; ijj<yid.length; ijj++) {
if (yid[ijj].indexOf(curplay + '|') == 0) { curv=ijj; }
}

if (mid >= 0) { setTimeout(midit, 2000); }

//}
//alert(curplay + ' ... ' + curv);
} else {
//console.log('' + eval('' + event.target.getCurrentTime()) + ' >= ' + curdur);
if (eval(2 + eval('' + event.target.getCurrentTime())) >= curdur) {
// alert('ready');
vplayer[curv].mute();
curv=eval(eval(1 + curv) % eval('' + 9));
//alert('' + curv);
//vplayer[curv]=eval("new YT.Player('vplayer" + eval(1 + curv) + "', { height: '260', width: '33%', videoId: '" + yid[curv] + "', events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange }})");
curplay='';
vplayer[curv].seekTo(0,true);
vplayer[curv].unMute();
vplayer[curv].playVideo();
//alert('2:' + curv);
}
}
//done = true;
} else if (curplay != '') {
//console.log('' + eval('' + event.target.getCurrentTime()) + ' >= ' + curdur);
if (eval(2 + eval('' + event.target.getCurrentTime())) >= curdur) {
// alert('Ready');
vplayer[curv].mute();
curv=eval(eval(1 + curv) % eval('' + 9));
//alert('' + curv);
curplay='';
vplayer[curv].seekTo(0,true);
vplayer[curv].unMute();
vplayer[curv].playVideo();
//alert('3:' + curv);
}
}
}



function newonPlayerStateChange(event) {

//YT.PlayerState.ENDED
//YT.PlayerState.PLAYING
//YT.PlayerState.PAUSED
//YT.PlayerState.BUFFERING
//YT.PlayerState.CUED

// const playerState = {
//UNSTARTED: -1,
//ENDED: 0,
//PLAYING: 1,
//PAUSED: 2,
//BUFFERING: 3,
//CUED: 5,
// };

if (event.data == YT.PlayerState.BUFFERING) { // && !done) {
curplay=curplay;
} else if (event.data == YT.PlayerState.CUED) { // && !done) {
curplay=curplay;
} else if (event.data == YT.PlayerState.PAUSED) { // && !done) {
//curv=eval(eval(1 + curv) % eval('' + 9));
//alert('' + curv);
if (curplay != '') { precv=curv; precp=curplay; event.target.mute(); }
curplay='';
//vplayer[curv].playVideo();
} else if (event.data == YT.PlayerState.PLAYING) { // && !done) {
if (dostop) {
stopthese.push(event.target);
setTimeout(stopVideo, 6000);
} else if (curplay == '') {
if (precp == event.target.getVideoUrl().split('=')[1].split('&')[0]) {
curplay=precp;
curv=precv;
} else {
vplayer[curv].mute();
}
curplay=event.target.getVideoUrl().split('=')[1].split('&')[0];
curdur=eval('' + event.target.getDuration());
for (var ijj=0; ijj<yid.length; ijj++) {
if (yid[ijj].indexOf(curplay + '|') == 0) { curv=ijj; }
}
//alert(curplay + ' ... ' + curv);
} else {
if (curplay != '' || precp == event.target.getVideoUrl().split('=')[1].split('&')[0]) {
if (curplay != event.target.getVideoUrl().split('=')[1].split('&')[0]) {
if (curplay == '' && precp == event.target.getVideoUrl().split('=')[1].split('&')[0]) {
curplay=precp;
curv=precv;
} else {
vplayer[curv].mute();
curplay=event.target.getVideoUrl().split('=')[1].split('&')[0];
curdur=eval('' + event.target.getDuration());
for (var ijjx=0; ijjx<yid.length; ijjx++) {
if (yid[ijjx].indexOf(curplay + '|') == 0) { curv=ijjx; }
}
}
}
}
//console.log('' + eval('' + event.target.getCurrentTime()) + ' >= ' + curdur);
if (eval(2 + eval('' + event.target.getCurrentTime())) >= eval('' + curdur)) {
// alert('ready');
document.title+=' .. ' + event.data;
vplayer[curv].mute();
curv=eval(eval(1 + curv) % eval('' + 9));
//alert('' + curv);
//vplayer[curv]=eval("new YT.Player('vplayer" + eval(1 + curv) + "', { height: '260', width: '33%', videoId: '" + yid[curv] + "', events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange }})");
curplay='';
vplayer[curv].unMute();
vplayer[curv].playVideo();
vplayer[curv].seekTo(0,true);
precp='';
//for (var iyx=0; iyx<vplayer.length; iyx++) {
//if (iyx != curv) { vplayer[iyx].mute(); }
//}
//alert('2:' + curv);
}
}
//done = true;
} else if (curplay != '' && event.data == YT.PlayerState.ENDED) {
//console.log('' + eval('' + event.target.getCurrentTime()) + ' >= ' + curdur);
if (eval(2 + eval('' + event.target.getCurrentTime())) >= eval('' + curdur)) {
// alert('Ready');
document.title+=' ... ' + event.data;
vplayer[curv].mute();
curv=eval(eval(1 + curv) % eval('' + 9));
//alert('' + curv);
curplay='';
//if ( player.isMuted() && player.getPlayerState() == 2 && isUnMuted ) {
//}
vplayer[curv].unMute();
vplayer[curv].playVideo();
//if (navigator.userAgent.match(/iPad/i)) {
// document.querySelector('video').webkitEnterFullScreen();
//}
vplayer[curv].seekTo(0,true);
precp='';
//for (var iy=0; iy<vplayer.length; iy++) {
//if (iy != curv) { vplayer[iy].mute(); }
//}
//alert('3:' + curv);
}
}
}

function oclick(opto) {
oclickcnt++;
olist+=odelim + opto.id.split('|')[0];
odelim=',';
if (eval('' + oclickcnt) > 1 && eval('' + oclickcnt) == eval('' + process(document.getElementById('sshuffle')))) {
document.getElementById('bshuffle').value='Ordered as Per Clicks/Touches';
} else {
document.getElementById('bshuffle').value='Shuffle';
}
}

function undostop() {
document.getElementById('sytitle').innerHTML=ddit(yourtwc);
document.getElementById('xshuffle').style.visibility='visible';
bprefix=topics.replace(/\|/g, ', ');
if (bprefix != '') {
var huhb=document.getElementById('wshuffle').innerHTML;
document.getElementById('wshuffle').innerHTML=bprefix + ', ' + huhb;
}
document.getElementById('wshuffle').style.visibility='visible';
document.getElementById('pshuffle').style.visibility='visible';
document.getElementById('qshuffle').style.visibility='visible';
document.getElementById('rshuffle').style.visibility='visible';
if (yid.length > 9 || 1 == 1) {
var tdsl=document.getElementsByTagName('td');
document.getElementById('oone').innerHTML=document.getElementById('oone').innerHTML.replace(' 9 slots available)', ' 9 slots available, ' + tdsl.length + ' total)');
document.getElementById('ashuffle').style.visibility='visible';
document.getElementById('zshuffle').style.visibility='visible';
scont=lessopt(scont);
document.getElementById('sshuffle').size=eval(-1 + eval('' + scont.split('</option>').length));
document.getElementById('sshuffle').innerHTML=scont;
setls(document.getElementById('sshuffle').innerHTML.replace(document.getElementById('sshuffle').innerHTML.split('</option>')[0] + '</option>', ''));
document.getElementById('dshuffle').style.visibility='visible';
}
document.getElementById('rshuffle').focus();
dostop=false;
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
//alert(1);
//const huhss=document.querySelectorAll('video');
//alert(11);
for (var hdiv=0; hdiv<vplayer.length; hdiv++) {
//alert(111);
vplayer[hdiv].unMute();
//alert(hdiv.id);
}
//.webkitEnterFullScreen();
}
//setTimeout(muchlater, 5000);
}

function stopVideo() {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
url=url;
} else {
stopthese[0].stopVideo();
}
stopthese.shift();
}

setTimeout(undostop, 9000);

</script>
<a id=badvideo href='' style='display:none;'>Bad video</a>
</body>
</html>