<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Array Work - RJM Programming - September, 2020</title>
<style>
th, tr { text-align: center; vertical-align: top; }
textarea { width: 90%; }
.code { background-color: yellow; }
.asplice { background-color: yellow; }
.gcode { border: 12px solid darkgreen; }
.bcode { border: 12px solid darkblue; }
.pcode { border: 12px solid olive; }
.ocode { border: 12px solid purple; }
button { border-style: dashed !important; }
select { border-style: dashed !important; width: 87px; }
</style>
<script type='text/javascript'>

// 1️⃣

var score=0, goes=0, seconds=0, yay=false;
var clickcnt=0;
var csuff="";
var ticket=Math.floor(Math.random() * 345678);
var removedElements=[];

var acount=0;
var ever=0;
var docz=false;
var latercmd='';

var prevval="";

var allplanets=["Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune","Pluto"];

var names=['Blaire', 'Ash', 'Coco', 'Dean', 'Georgia'];
var popElement="";
var shiftElement="";
var lastcol="white";

var ppsucols=['darkgreen','darkblue','olive','purple'];
var defcard = "../Games/Memories/images/back01.gif";
var mypictures = new Array("../Games/Memories/images/01c.gif",
"../Games/Memories/images/01d.gif",
"../Games/Memories/images/01h.gif",
"../Games/Memories/images/01s.gif",
"../Games/Memories/images/02c.gif",
"../Games/Memories/images/02d.gif",
"../Games/Memories/images/02h.gif",
"../Games/Memories/images/02s.gif",
"../Games/Memories/images/03c.gif",
"../Games/Memories/images/03d.gif",
"../Games/Memories/images/03h.gif",
"../Games/Memories/images/03s.gif",
"../Games/Memories/images/04c.gif",
"../Games/Memories/images/04d.gif",
"../Games/Memories/images/04h.gif",
"../Games/Memories/images/04s.gif",
"../Games/Memories/images/05c.gif",
"../Games/Memories/images/05d.gif",
"../Games/Memories/images/05h.gif",
"../Games/Memories/images/05s.gif",
"../Games/Memories/images/06c.gif",
"../Games/Memories/images/06d.gif",
"../Games/Memories/images/06h.gif",
"../Games/Memories/images/06s.gif",
"../Games/Memories/images/07c.gif",
"../Games/Memories/images/07d.gif",
"../Games/Memories/images/07h.gif",
"../Games/Memories/images/07s.gif",
"../Games/Memories/images/08c.gif",
"../Games/Memories/images/08d.gif",
"../Games/Memories/images/08h.gif",
"../Games/Memories/images/08s.gif",
"../Games/Memories/images/09c.gif",
"../Games/Memories/images/09d.gif",
"../Games/Memories/images/09h.gif",
"../Games/Memories/images/09s.gif",
"../Games/Memories/images/10c.gif",
"../Games/Memories/images/10d.gif",
"../Games/Memories/images/10h.gif",
"../Games/Memories/images/10s.gif",
"../Games/Memories/images/11c.gif",
"../Games/Memories/images/11d.gif",
"../Games/Memories/images/11h.gif",
"../Games/Memories/images/11s.gif",
"../Games/Memories/images/12c.gif",
"../Games/Memories/images/12d.gif",
"../Games/Memories/images/12h.gif",
"../Games/Memories/images/12s.gif",
"../Games/Memories/images/13c.gif",
"../Games/Memories/images/13d.gif",
"../Games/Memories/images/13h.gif",
"../Games/Memories/images/13s.gif");

function laterdo() {
if (latercmd != '') {
eval(latercmd);
latercmd='';
var newsub=document.getElementById('workon').innerHTML;
if (newsub.indexOf(String.fromCharCode(10)) != -1) {
while (newsub.indexOf(String.fromCharCode(10)) != -1) {
newsub=newsub.replace(String.fromCharCode(10),'<br>');
}
document.getElementById('workon').innerHTML=newsub;
}
}
}

function youreval(cont) {
if (1 == 1 || (cont.indexOf("'") == -1 && cont.indexOf('"') == -1)) { if (cont.indexOf("'") == -1 && cont.indexOf('"') == -1) { ever=2; }
var prefcont='';
if (ever == 2) {
latercmd='names = [' + cont.split('[')[eval(-1 + cont.split('[').length)].split(']')[0] + '];';
cont=cont;
setTimeout(laterdo, 1000);
} else if (cont.indexOf("',") != -1) {
prefcont=cont.split("'")[0];
cont=cont.replace(prefcont, '');
wascont=cont.replace(/\'\,/g,'!@#$%^');
wascont=wascont.replace(/\,/g,',');
cont=prefcont + wascont.replace(/\!\@\#\$\%\^/g, "',");
//alert(cont);
} else if (cont.indexOf('",') != -1) {
prefcont=cont.split('"')[0];
cont=cont.replace(prefcont, '');
wascont=cont.replace(/\"\,/g,'!@#$%^');
wascont=wascont.replace(/\,/g,',');
cont=prefcont + wascont.replace(/\!\@\#\$\%\^/g, '",');
}
document.getElementById('workon').innerHTML=commaize(cont.replace(/\'\,/g,"', ").replace(/\"\,/g,'", '));
//alert(cont);
}
return eval(cont);
}

function oureval(cont) {
var prefcont='';
if (ever == 2) {
latercmd='names = [' + cont.split('[')[eval(-1 + cont.split('[').length)].split(']')[0] + '];';
cont=cont;
setTimeout(laterdo, 1000);
} else if (cont.indexOf("',") != -1) {
prefcont=cont.split("'")[0];
cont=cont.replace(prefcont, '');
wascont=cont.replace(/\'\,/g,'!@#$%^');
wascont=wascont.replace(/\,/g,',');
cont=prefcont + wascont.replace(/\!\@\#\$\%\^/g, "',");
//alert(cont);
} else if (cont.indexOf('",') != -1) {
prefcont=cont.split('"')[0];
cont=cont.replace(prefcont, '');
wascont=cont.replace(/\"\,/g,'!@#$%^');
wascont=wascont.replace(/\,/g,',');
cont=prefcont + wascont.replace(/\!\@\#\$\%\^/g, '",');
}
return eval(cont);
}

function considered(numstr, arg2) {
var outstr=numstr;
var wassub='', newsub='[]', prevc=',', thisdelim='', allnum=false, partstr='';
if (ever == 2 && numstr.indexOf('[') != -1 && numstr.indexOf(']') != -1) {
numstr=nocommaize(numstr);
wassub='[' + numstr.split('[')[1].split(']')[0] + ']';
//alert('wassub=' + wassub);
var waschrs=wassub.split('');
for (var iwas=1; iwas<eval(-1 + eval('' + wassub.length)); iwas++) {
if (waschrs[iwas] == ',') {
if (partstr != '') {
//alert('1:' + partstr);
if (allnum && partstr.replace(/\'/g,'').replace(/\"/g,'') != '') { newsub=newsub.replace(']', ' ' + partstr.replace(/\'/g,'').replace(/\"/g,'') + ']'); } else { if (partstr == '') { partstr="''"; } newsub=newsub.replace(']', partstr + ']'); }
}
if (newsub != '[]' && newsub.indexOf(',]') == -1) { newsub=newsub.replace(']', ',]'); }
partstr=''; //+=waschrs[iwas];
} else if (prevc == ',') {
if (partstr != '') {
//alert('2:' + partstr);
if (allnum) { newsub=newsub.replace(']', ' ' + partstr.replace(/\'/g,'').replace(/\"/g,'') + ']'); } else { newsub=newsub.replace(']', partstr + ']'); }
}
if (newsub != '[]' && newsub.indexOf(',]') == -1) { newsub=newsub.replace(']', ',]'); }
allnum=true;
thisdelim='';
if (waschrs[iwas] == "'") { thisdelim="'"; }
if (waschrs[iwas] == '"') { thisdelim='"'; }
//alert('thisdelim=' + thisdelim);
partstr=waschrs[iwas];
} else if (waschrs[iwas] == thisdelim) {
partstr+=waschrs[iwas];
if (allnum && partstr.replace(/\'/g,'').replace(/\"/g,'') != '') { newsub=newsub.replace(']', partstr.replace(/\'/g,'').replace(/\"/g,'') + ']'); } else { if (partstr == '') { partstr="''"; } newsub=newsub.replace(']', partstr + ']'); }
partstr='';
} else if (waschrs[iwas] == '"' || waschrs[iwas] == "'") {
allnum=allnum;
partstr+=waschrs[iwas];
} else if (waschrs[iwas] == '-') {
allnum=allnum;
partstr+=waschrs[iwas];
} else if (waschrs[iwas] >= '0' && waschrs[iwas] <= '9') {
allnum=allnum;
partstr+=waschrs[iwas];
} else if (waschrs[iwas] == '.') {
allnum=allnum;
partstr+=waschrs[iwas];
} else {
allnum=false;
partstr+=waschrs[iwas];
}
prevc=waschrs[iwas];
}
if (partstr != '') {
if (allnum && partstr.replace(/\'/g,'').replace(/\"/g,'') != '') { newsub=newsub.replace(']', ' ' + partstr.replace(/\'/g,'').replace(/\"/g,'') + ']'); } else { if (partstr == '') { partstr="''"; } newsub=newsub.replace(']', partstr + ']'); }
}
if (outstr != numstr) {
//while (newsub.indexOf(String.fromCharCode(10)) != -1) {
// newsub=newsub.replace(String.fromCharCode(10),'<br>');
//}
outstr=numstr.replace(wassub, newsub.replace(/\,/g, ', ').replace('[ ','[').replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',"));
docz=true;
//alert('newsub=' + newsub + ' ... vs ... ' + newsub.replace('[ ','[').replace(/\,\,/g,",'',").replace(/\ \,/g," '',").replace(/\,/g, ', ') + ' outstr=' + outstr);
latercmd=('names = [' + outstr.split('[')[eval(-1 + outstr.split('[').length)].split(']')[0] + '];');
setTimeout(laterdo, 1000);
//alert(arg2 + 'Names = [' + outstr.split('[')[eval(-1 + outstr.split('[').length)].split(']')[0] + ']; ' + names);
} else {
//while (newsub.indexOf(String.fromCharCode(10)) != -1) {
// newsub=newsub.replace(String.fromCharCode(10),'<br>');
//}
outstr=numstr.replace(wassub, newsub.replace(/\,/g, ', ').replace('[ ','[').replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',"));
//alert('newsub=' + newsub + ' Outstr=' + outstr);
latercmd=('names = [' + outstr.split('[')[eval(-1 + outstr.split('[').length)].split(']')[0] + '];');
//alert(arg2 + 'names = [' + outstr.split('[')[eval(-1 + outstr.split('[').length)].split(']')[0] + ']; ' + names);
setTimeout(laterdo, 1000);
}
}
if (ever == 1) { ever=2; }
return outstr;
}

function seccount() {
if (yay) {
document.getElementById('score').innerHTML=' ... Goes (10 good, less very good) ' + goes + ' / ' + seconds + ' Seconds';
var anot=prompt('Well done. ' + document.getElementById('score').innerHTML + ' Another game?', ' ');
if (anot == null) { anot=''; }
if (anot != '') { location.href=document.URL.split('#')[0] + Math.floor(Math.random() * 178654); } else { yay=false; }
}
seconds++;
document.getElementById('score').innerHTML=' ... Goes (10 good, less very good) ' + goes + ' / ' + seconds + ' Seconds';
setTimeout(seccount, 1000);
}

function doit() {
var shuffleresult="names.unshift();", deck=[], proposed='';
var ibutsare=0;
var popsel='<select class=bcode id=selpop onchange=popit(this);><option value="">pop</option><option value="names.pop();">names.pop();</option><option value="popElement=names.pop();">popElement=names.pop();</option></select>';
var shiftsel='<select class=pcode id=selshift onchange=shiftit(this);><option value="">shift</option><option value="names.shift();">names.shift();</option><option value="shiftElement=names.shift();">shiftElement=names.shift();</option></select>';
var unshiftsel="<select class=ocode id=selunshift onchange=unshiftit(this);><option value=\"\">unshift</option><option value=\"names.unshift('Mercury');\">names.unshift('Mercury');</option><option value=\"names.unshift('Venus');\">names.unshift('Venus');</option><option value=\"names.unshift('Earth');\">names.unshift('Earth');</option><option value=\"names.unshift('Mars');\">names.unshift('Mars');</option><option value=\"names.unshift('Jupiter');\">names.unshift('Jupiter');</option><option value=\"names.unshift('Saturn');\">names.unshift('Saturn');</option><option value=\"names.unshift('Uranus');\">names.unshift('Uranus');</option><option value=\"names.unshift('Neptune');\">names.unshift('Neptune');</option><option value=\"names.unshift('Pluto');\">names.unshift('Pluto');</option><option value=\"names.unshift(popElement);\">names.unshift(popElement);</option><option value=\"names.unshift(shiftElement);\">names.unshift(shiftElement);</option></select>";
var pushsel="<select class=gcode id=selpush onchange=pushit(this);><option value=\"\">push</option><option value=\"names.push('Mercury');\">names.push('Mercury');</option><option value=\"names.push('Venus');\">names.push('Venus');</option><option value=\"names.push('Earth');\">names.push('Earth');</option><option value=\"names.push('Mars');\">names.push('Mars');</option><option value=\"names.push('Jupiter');\">names.push('Jupiter');</option><option value=\"names.push('Saturn');\">names.push('Saturn');</option><option value=\"names.push('Uranus');\">names.push('Uranus');</option><option value=\"names.push('Neptune');\">names.push('Neptune');</option><option value=\"names.push('Pluto');\">names.push('Pluto');</option><option value=\"names.push(popElement);\">names.push(popElement);</option><option value=\"names.push(shiftElement);\">names.push(shiftElement);</option></select>";
if (document.URL.indexOf('?cs=') != -1) {
if (document.getElementById('acs')) { document.getElementById('acs').style.textDecoration='none'; }
document.getElementById('tzworkon').innerHTML=document.getElementById('thworkon').innerHTML;
document.getElementById('tzworkon').rowspan=2;
document.getElementById('tznotofinterest').innerHTML='Queue';
document.getElementById('tznotofinterest').title='FIFO';
document.getElementById('tzofinterest').innerHTML='Stack';
document.getElementById('tzofinterest').title='LIFO';
document.getElementById('row0').style.display='table-row';
document.getElementById('row1').innerHTML='<th></th>' + document.getElementById('thunshift').outerHTML.replace('unshift<','unshift <font size=1>(ie. Shuffle)</font><') + (document.getElementById('thshift').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>').replace('shift<','shift <font size=1>(ie. Deal)</font><') + document.getElementById('thpush').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>' + document.getElementById('thpop').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>';
document.getElementById('row2').innerHTML=document.getElementById('tdworkon').outerHTML + document.getElementById('tdunshift').outerHTML + document.getElementById('tdshift').outerHTML + document.getElementById('tdpush').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>' + document.getElementById('tdpop').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>';
document.getElementById('pushcode').value='';
document.getElementById('popcode').value='';
document.getElementById('shiftcode').value='';
document.getElementById('workon').innerHTML="var names = []; // 0️⃣";
proposed=Math.floor(Math.random() * mypictures.length);
names=[];
while (eval(deck.length) < 52) {
while (('' + shuffleresult).indexOf(mypictures[proposed].split('.gif')[0].split('/')[eval(-1 + mypictures[proposed].split('.gif')[0].split('/').length)].replace('01','A').replace('11','J').replace('12','Q').replace('13','K').replace(/^0/g,'')) != -1) {
proposed=Math.floor(Math.random() * mypictures.length);
}
deck.unshift(mypictures[proposed].split('.gif')[0].split('/')[eval(-1 + mypictures[proposed].split('.gif')[0].split('/').length)].replace('01','A').replace('11','J').replace('12','Q').replace('13','K').replace(/^0/g,''));
shuffleresult=shuffleresult.replace("(", "('" + mypictures[proposed].split('.gif')[0].split('/')[eval(-1 + mypictures[proposed].split('.gif')[0].split('/').length)].replace('01','A').replace('11','J').replace('12','Q').replace('13','K').replace(/^0/g,'') + "', ").replace(', )', ')').replace(',)', ')');
}
document.getElementById('unshiftcode').value=shuffleresult;
document.getElementById('unshiftcode').rows=10;
} else if (document.URL.indexOf('?nq=') != -1) {
if (document.getElementById('anq')) { document.getElementById('anq').style.textDecoration='none'; }
//<tr id=row0 style=display:none;><th id=tzworkon></th><th colspan=2 id=tzofinterest></th><th colspan=2 id=tznotofinterest></th></tr>
document.getElementById('tzworkon').innerHTML=document.getElementById('thworkon').innerHTML;
document.getElementById('tzworkon').rowspan=2;
document.getElementById('tzofinterest').innerHTML='Queue';
document.getElementById('tzofinterest').title='FIFO';
document.getElementById('tznotofinterest').innerHTML='Stack';
document.getElementById('tznotofinterest').title='LIFO';
document.getElementById('row0').style.display='table-row';
document.getElementById('row1').innerHTML='<th></th>' + document.getElementById('thpush').outerHTML.replace('push<','push <font size=1>(ie. Take a Ticket Please)</font><') + document.getElementById('thshift').outerHTML.replace('shift<','shift <font size=1>(ie. Calling Ticket)</font><') + document.getElementById('thunshift').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>' + document.getElementById('thpop').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>';
document.getElementById('row2').innerHTML=document.getElementById('tdworkon').outerHTML + document.getElementById('tdpush').outerHTML + document.getElementById('tdshift').outerHTML + document.getElementById('tdunshift').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>' + document.getElementById('tdpop').outerHTML.split('</th>')[0].replace(/\>/g,' disabled>') + '</th>';
document.getElementById('workon').innerHTML="var names = []; // 0️⃣";
document.getElementById('unshiftcode').value='';
//document.getElementById('shiftcode').value='';
document.getElementById('popcode').value='';
//alert(65);
document.getElementById('workon').innerHTML="var names = []; // 0️⃣";
names=[];
document.getElementById('pushcode').value="names.push('" + ticket + "');";
//alert(98);
document.getElementById('bshift').disabled=true;
} else if (document.URL.indexOf('?sspg=') != -1) {
//alert(1);
if (document.getElementById('asspg')) { document.getElementById('asspg').style.textDecoration='none'; }
document.getElementById('sgame').innerHTML=' try to get to <br><font size=1>names = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"];</font>';
var prewoc=(document.getElementById('workon').innerText || document.getElementById('workon').contentWindow || document.getElementById('workon').contentDocument).split('[')[0] + '[';
var woc=prewoc + ']' + (document.getElementById('workon').innerText || document.getElementById('workon').contentWindow || document.getElementById('workon').contentDocument).split(']')[1];
woc=woc.replace('[]', '["' + allplanets[eval(1 + Math.floor(Math.random() * eval(-2 + allplanets.length)))] + '"]');
//alert('5:' + eval(1 + Math.floor(Math.random() * eval(-2 + allplanets.length))));
var another=allplanets[eval(1 + Math.floor(Math.random() * eval(-2 + allplanets.length)))];
//alert(another);
while (woc.indexOf('"' + another + '"') != -1) {
another=allplanets[eval(1 + Math.floor(Math.random() * eval(-2 + allplanets.length)))];
}
//alert(another);
woc=woc.replace('"]', '","' + another + '"]');
while (woc.indexOf('"' + another + '"') != -1) {
another=allplanets[eval(1 + Math.floor(Math.random() * eval(-2 + allplanets.length)))];
}
//alert(another);
woc=woc.replace('"]', '","' + another + '"]');
oureval('names=[' + woc.split('[')[1].split(']')[0] + ']');
document.getElementById('workon').innerHTML=woc;
var butsare=document.getElementsByTagName('button');
for (var ij=0; ij<4; ij++) {
for (ibutsare=0; ibutsare<butsare.length; ibutsare++) {
if (document.getElementById('th' + ('' + butsare[ibutsare].id + ' ').substring(1).trim()).innerHTML.indexOf('<select') == -1) {
butsare[ibutsare].style.visibility='hidden';
document.getElementById(('' + butsare[ibutsare].id + ' ').substring(1).trim() + 'code').value='';
document.getElementById(('' + butsare[ibutsare].id + ' ').substring(1).trim() + 'code').rows=1;
document.getElementById(('' + butsare[ibutsare].id + ' ').substring(1).trim() + 'code').style.visibility='hidden';
document.getElementById('th' + ('' + butsare[ibutsare].id + ' ').substring(1).trim()).innerHTML=eval(('' + butsare[ibutsare].id + ' ').substring(1).trim() + 'sel');
}
}
}
setTimeout(seccount, 1000);
} else {
if (document.getElementById('a')) { document.getElementById('a').style.textDecoration='none'; }
document.getElementById('workon').innerHTML=commaize(document.getElementById('workon').innerHTML);
}
if (document.URL.indexOf('?cs=') != -1 || document.URL.indexOf('?nq=') != -1) {
ticket=ticket;
} else {
eval((document.getElementById('workon').innerText || document.getElementById('workon').contentWindow || document.getElementById('workon').contentDocument));
}
}

function cc(incont) {
var ns="0123456789";
clickcnt++;
csuff=" /" + "/ ";
var ccc='' + clickcnt;
for (var ij=0; ij<ccc.length; ij++) {
csuff+='&#' + eval(48 + eval('' + ns.indexOf(ccc.substring(ij).substring(0,1)))) + ';️⃣';
}
//csuff+='️⃣';
return incont.replace(';', '; ' + csuff);
}

function spliceit(ao) {
var wascont='', prefcont='';
var splicecmd=prompt("Please enter a Splicing command (can add with string arguments, can delete array members with that second numerical argument) feeling free to change as necessary.", "removedElements=names.splice(" + ao.getAttribute('data-namepos') + ",0,'','','')");
if (splicecmd == null) {
ao=ao;
} else if (splicecmd.indexOf('names.splice(') != -1) {
//if ((splicecmd.indexOf('"') != -1 || splicecmd.indexOf("'") != -1) && ever == 2) { ever=1; }
if (splicecmd.indexOf("',") != -1) {
prefcont=splicecmd.split("'")[0];
splicecmd=splicecmd.replace(prefcont,'');
wascont=splicecmd.replace(/\'\,/g,'!@#$%^');
wascont=wascont.replace(/\,/g,',');
splicecmd=prefcont + wascont.replace(/\!\@\#\$\%\^/g, "',");
//alert('newsplicecmd=' + splicecmd);
} else if (splicecmd.indexOf('",') != -1) {
prefcont=splicecmd.split('"')[0];
splicecmd=splicecmd.replace(prefcont,'');
wascont=splicecmd.replace(/\"\,/g,'!@#$%^');
wascont=wascont.replace(/\,/g,',');
splicecmd=prefcont + wascont.replace(/\!\@\#\$\%\^/g, '",');
//alert('new_splicecmd=' + splicecmd);
}
lastcol='black';
oureval(splicecmd);
documentgetElementById('spliceresult',cc("console.log('// ' + names);" + String.fromCharCode(10) + ('/' + '/ ' + names).replace(/\,/g,', ').replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + String.fromCharCode(10) + "console.log('// ' + removedElements);" + String.fromCharCode(10) + ('/' + '/ ' + removedElements).replace(/\,/g,', ') + String.fromCharCode(10)));
documentgetElementById('workon', String.fromCharCode(10) + splicecmd + csuff + String.fromCharCode(10) + document.getElementById('spliceresult'). innerHTML + String.fromCharCode(10) + commaize('names = [' + ("'" + names + "'").replace(/\,/g, "', '").replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + '];' + csuff));
}
}

function nocommaize(instuff) {
var outstuff=instuff;
var contentious=instuff.split('>,</a>');
if (contentious.length > 1) {
outstuff="";
for (var ii=0; ii<contentious.length; ii++) {
if (contentious[ii].indexOf('<a ') != -1) {
outstuff+=contentious[ii].split('<a ')[0] + ',';
} else {
outstuff+=contentious[ii];
}
}
}
//alert(outstuff);
return outstuff;
}

function commaize(instuff) {
var outstuff=instuff, suffb='', bcount=1, prefb='', relbit='', newrelbit='';
if (instuff.indexOf('[') != -1 && instuff.indexOf('//') != -1) {
relbit='[' + instuff.split('[')[eval(-1 + instuff.split('[').length)];
newrelbit=relbit;
// [1, 6, 7, 7, , , , 5]; // 2️⃣
//alert(newrelbit);
while (newrelbit.indexOf(', ') != -1) {
newrelbit=newrelbit.replace(", ", "<a class=asplice onclick=spliceit(this); data-namepos=" + bcount + " id=" + acount + " style='text-decoration:none;cursor:pointer;text-weight:bold;' title='Splice here'>,</a> ");
acount++;
bcount++;
}
outstuff=outstuff.replace(relbit,newrelbit);
} else if (instuff.indexOf('//') != -1) {
suffb=instuff.replace(instuff.split('//')[0], '');
outstuff=instuff.replace(suffb, '');
while (outstuff.indexOf(', ') != -1) {
outstuff=outstuff.replace(", ", "<a class=asplice onclick=spliceit(this); data-namepos=" + bcount + " id=" + acount + " style='text-decoration:none;cursor:pointer;text-weight:bold;' title='Splice here'>,</a> ");
acount++;
bcount++;
}
outstuff+=suffb;
}
return outstuff;
}

function documentgetElementById(elid, cont) {
//alert(cont);
var cprefix='', csuffix='', spanprefix="", spansuffix="", wascont="", nodelim='';
var ipre=0, prework=(document.getElementById('workon').innerText || document.getElementById('workon').contentWindow || document.getElementById('workon').contentDocument);
if (elid == 'workon') {
if (prework.indexOf("',") == -1 && prework.indexOf('",') == -1 && prework.indexOf("['") == -1 && prework.indexOf('["') == -1) {
if (ever == 0) { ever=2; }
}
}
if (elid != 'workon') {
if (document.URL.indexOf('?cs=') != -1) {
if (shiftElement == '') {
spanprefix='<span> <img style=width:35px; src=' + defcard + '></img> ';
spanprefix+='</span>';
} else {
for (var ijk=0; ijk<mypictures.length; ijk++) {
if (shiftElement.substring(0,1) == 'A') {
if (mypictures[ijk].indexOf('01' + shiftElement.substring(1)) != -1) {
spanprefix='<span> <img style=width:35px; src=' + mypictures[ijk] + '></img> ';
spanprefix+='</span>';
}
} else if (shiftElement.substring(0,1) == 'J') {
if (mypictures[ijk].indexOf('11' + shiftElement.substring(1)) != -1) {
spanprefix='<span> <img style=width:35px; src=' + mypictures[ijk] + '></img> ';
spanprefix+='</span>';
}
} else if (shiftElement.substring(0,1) == 'Q') {
if (mypictures[ijk].indexOf('12' + shiftElement.substring(1)) != -1) {
spanprefix='<span> <img style=width:35px; src=' + mypictures[ijk] + '></img> ';
spanprefix+='</span>';
}
} else if (shiftElement.substring(0,1) == 'K') {
if (mypictures[ijk].indexOf('13' + shiftElement.substring(1)) != -1) {
spanprefix='<span> <img style=width:35px; src=' + mypictures[ijk] + '></img> ';
spanprefix+='</span>';
}
} else if (shiftElement.substring(0,1) == '1') {
if (mypictures[ijk].indexOf('10' + shiftElement.substring(2)) != -1) {
spanprefix='<span> <img style=width:35px; src=' + mypictures[ijk] + '></img> ';
spanprefix+='</span>';
}
} else {
if (mypictures[ijk].indexOf('0' + shiftElement.substring(0)) != -1) {
spanprefix='<span> <img style=width:35px; src=' + mypictures[ijk] + '></img> ';
spanprefix+='</span>';
}
}
}
}
}
if (elid.indexOf('push') != -1) {
lastcol=ppsucols[0]; //'lightgreen';
cprefix='<font color=' + lastcol + '>' + spanprefix;
csuffix=spansuffix + '</font>';
} else if (elid.indexOf('pop') != -1) {
lastcol=ppsucols[1]; //'lightblue';
cprefix='<font color=' + lastcol + '>' + spanprefix;
csuffix=spansuffix + '</font>';
} else if (elid.indexOf('unshift') != -1) {
lastcol=ppsucols[3]; //'orange';
cprefix='<font color=' + lastcol + '>' + spanprefix;
csuffix=spansuffix + '</font>';
} else if (elid.indexOf('shift') != -1) {
lastcol=ppsucols[2]; //'pink';
cprefix='<font color=' + lastcol + '>' + spanprefix;
csuffix=spansuffix + '</font>';
}
} else {
cprefix='<font color=' + lastcol + '>' + spanprefix;
csuffix=spansuffix + '</font>';
}
//console.log(elid);
if (('' + document.getElementById(elid).outerHTML).indexOf('<textarea') == 0) {
cprefix='';
csuffix='';
if (elid == 'workon') {
if (ever == 2) {
cont=considered(cont,1);
} else if (nodelim == "'") {
cont=cont.replace(/\'/g,'');
} else if (nodelim == '"') {
cont=cont.replace(/\"/g,'');
}
document.getElementById(elid).value+=cont;
} else {
document.getElementById(elid).value=cont;
}
} else {
while (cont.indexOf(String.fromCharCode(10)) != -1) {
cont=cont.replace(String.fromCharCode(10), '<br>');
}
if (elid == 'workon') {
if (ever == 2) {
cont=considered(cont,2);
} else if (nodelim == "'") {
cont=cont.replace(/\'/g,'');
} else if (nodelim == '"') {
cont=cont.replace(/\"/g,'');
}
if (ever == 0) {
if (cont.indexOf("',") != -1) {
wascont=cont.replace(/\'\,/g,'!@#$%^');
wascont=wascont.replace(/\,/g,',');
cont=wascont.replace(/\!\@\#\$\%\^/g, "',");
} else if (cont.indexOf('",') != -1) {
wascont=cont.replace(/\"\,/g,'!@#$%^');
wascont=wascont.replace(/\,/g,',');
cont=wascont.replace(/\!\@\#\$\%\^/g, '",');
}
}
//if (docz) {
// alert('ever=' + ever + ' and Cont=' + cont);
//}
docz=false;
document.getElementById(elid).innerHTML=nocommaize(document.getElementById(elid).innerHTML) + cprefix + commaize(cont) + csuffix;
} else if (elid == 'spliceresult') {
document.getElementById(elid).innerHTML=cprefix + cont + csuffix;
} else {
document.getElementById(elid).innerHTML+=cprefix + cont + csuffix;
}
}
}

function pushit(obutsel) {
if (('' + obutsel.outerHTML).indexOf('<select') == 0 && obutsel.value != '') {
goes++;
prevval=document.getElementById('pushcode').value + String.fromCharCode(10);
document.getElementById('pushcode').value=obutsel.value;
document.getElementById('pushcode').style.visibility='visible';
} else if (('' + obutsel.outerHTML).indexOf('<select') == 0) {
return;
}
oureval(document.getElementById('pushcode').value);
documentgetElementById('pushresult',cc("console.log('// ' + names);" + String.fromCharCode(10) + ('/' + '/ ' + names).replace(/\,/g,', ').replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + String.fromCharCode(10)));
documentgetElementById('workon',String.fromCharCode(10) + 'names = [' + ("'" + names + "'").replace(/\,/g, "', '").replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + '];' + csuff);
if (('' + obutsel.outerHTML).indexOf('<select') == 0 && obutsel.value != '') {
document.getElementById('pushcode').rows=eval(1 + eval('' + document.getElementById('pushcode').rows));
document.getElementById('pushcode').value=prevval + obutsel.value;
obutsel.value='';
if (('' + names).replace(/\ /g,'') == 'Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune,Pluto') {
yay=true;
}
}
if (document.URL.indexOf('?nq=') != -1) {
document.getElementById('shiftcode').value="shiftElement=names.shift(names[0]);";
ticket++;
if (document.getElementById('bshift').disabled) {
document.getElementById('bshift').disabled=false;
document.getElementById('bshift').innerHTML=document.getElementById('bshift').innerHTML.replace('Ticket)','Ticket ' + names[0] + ')').replace('Ticket ' + eval(-1 + eval('' + names[0])) + ')','Ticket ' + eval(0 + eval('' + names[0])) + ')');
}
document.getElementById('bshift').innerHTML=document.getElementById('bshift').innerHTML.replace('Ticket)','Ticket ' + names[0] + ')').replace('Ticket ' + ticket + ')','Ticket ' + eval(0 + eval('' + names[0])) + ')');
document.getElementById('bpush').innerHTML=document.getElementById('bpush').innerHTML.replace('Take a Ticket Please)','Take Ticket ' + ticket + ')').replace('Ticket)','Ticket ' + ticket + ')').replace('Ticket ' + eval(-1 + ticket) + ')','Ticket ' + ticket + ')');
document.getElementById('pushcode').value=document.getElementById('pushcode').value.replace('' + eval(-1 + ticket) + '','' + ticket + '');
}
}

function popit(obutsel) {
if (('' + obutsel.outerHTML).indexOf('<select') == 0 && obutsel.value != '') {
goes++;
prevval=document.getElementById('popcode').value + String.fromCharCode(10);
document.getElementById('popcode').value=obutsel.value;
document.getElementById('popcode').style.visibility='visible';
} else if (('' + obutsel.outerHTML).indexOf('<select') == 0) {
return;
}
oureval(document.getElementById('popcode').value);
documentgetElementById('popresult',cc("console.log('// ' + names);" + String.fromCharCode(10) + ('/' + '/ ' + names).replace(/\,/g,', ').replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + String.fromCharCode(10) + "console.log('// ' + popElement);" + String.fromCharCode(10) + '/' + '/ ' + popElement + String.fromCharCode(10)));
documentgetElementById('workon',String.fromCharCode(10) + 'names = [' + ("'" + names + "'").replace(/\,/g, "', '").replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + '];' + csuff);
if (('' + obutsel.outerHTML).indexOf('<select') == 0 && obutsel.value != '') {
document.getElementById('popcode').rows=eval(1 + eval('' + document.getElementById('popcode').rows));
document.getElementById('popcode').value=prevval + obutsel.value;
obutsel.value='';
if (('' + names).replace(/\ /g,'') == 'Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune,Pluto') {
yay=true;
}
}
}

function shiftit(obutsel) {
if (('' + obutsel.outerHTML).indexOf('<select') == 0 && obutsel.value != '') {
goes++;
prevval=document.getElementById('shiftcode').value + String.fromCharCode(10);
document.getElementById('shiftcode').value=obutsel.value;
document.getElementById('shiftcode').style.visibility='visible';
} else if (('' + obutsel.outerHTML).indexOf('<select') == 0) {
return;
}
oureval(document.getElementById('shiftcode').value);
documentgetElementById('shiftresult',cc("console.log('// ' + names);" + String.fromCharCode(10) + ('/' + '/ ' + names).replace(/\,/g,', ').replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + String.fromCharCode(10) + "console.log('// ' + shiftElement);" + String.fromCharCode(10) + '/' + '/ ' + shiftElement + String.fromCharCode(10)));
documentgetElementById('workon',String.fromCharCode(10) + 'names = [' + ("'" + names + "'").replace(/\,/g, "', '").replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + '];' + csuff);
if (('' + obutsel.outerHTML).indexOf('<select') == 0 && obutsel.value != '') {
document.getElementById('shiftcode').rows=eval(1 + eval('' + document.getElementById('shiftcode').rows));
document.getElementById('shiftcode').value=prevval + obutsel.value;
obutsel.value='';
if (('' + names).replace(/\ /g,'') == 'Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune,Pluto') {
yay=true;
}
}
if (document.URL.indexOf('?cs=') != -1) {
if (names.length == 0) {
alert('All the cards have been dealt now.');
} else if (document.getElementById('bshift').innerHTML.indexOf('Deal Card ') != -1) {
document.getElementById('bshift').innerHTML=document.getElementById('bshift').innerHTML.replace(document.getElementById('bshift').innerHTML.split('Deal Card ')[1],'' + eval(1 + eval('' + document.getElementById('bshift').innerHTML.split('Deal Card ')[1].split(')')[0])) + ')');
}
} else if (document.URL.indexOf('?nq=') != -1) {
if (names.length == 0) {
document.getElementById('bshift').disabled=true;
//document.getElementById('bshift').innerHTML=document.getElementById('bshift').innerHTML.replace('Ticket)','Ticket ' + names[0] + ')').replace('Ticket ' + eval(-1 + eval('' + names[0])) + ')','Ticket ' + eval(0 + eval('' + names[0])) + ')');
} else {
if (document.getElementById('bshift').disabled) { document.getElementById('bshift').disabled=false; }
document.getElementById('bshift').innerHTML=document.getElementById('bshift').innerHTML.replace('Ticket)','Ticket ' + names[0] + ')').replace('Ticket ' + eval(-1 + eval('' + names[0])) + ')','Ticket ' + eval(0 + eval('' + names[0])) + ')');
}
}
}

function unshiftit(obutsel) {
if (('' + obutsel.outerHTML).indexOf('<select') == 0 && obutsel.value != '') {
goes++;
prevval=document.getElementById('unshiftcode').value + String.fromCharCode(10);
document.getElementById('unshiftcode').value=obutsel.value;
document.getElementById('unshiftcode').style.visibility='visible';
} else if (('' + obutsel.outerHTML).indexOf('<select') == 0) {
return;
}
oureval(document.getElementById('unshiftcode').value);
documentgetElementById('unshiftresult',cc("console.log('// ' + names);" + String.fromCharCode(10) + ('/' + '/ ' + names).replace(/\,/g,', ') + String.fromCharCode(10)));
documentgetElementById('workon',String.fromCharCode(10) + 'names = [' + ("'" + names + "'").replace(/\,/g, "', '").replace(/\,\,/g,",'',").replace(/\,\ \,/g,", '',").replace(/\ \,/g," '',") + '];' + csuff);
if (('' + obutsel.outerHTML).indexOf('<select') == 0 && obutsel.value != '') {
document.getElementById('unshiftcode').rows=eval(1 + eval('' + document.getElementById('unshiftcode').rows));
document.getElementById('unshiftcode').value=prevval + obutsel.value;
obutsel.value='';
if (('' + names).replace(/\ /g,'') == 'Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune,Pluto') {
yay=true;
}
}
if (document.URL.indexOf('?cs=') != -1) {
document.getElementById('bshift').disabled=false;
document.getElementById('bshift').innerHTML=document.getElementById('bshift').innerHTML.replace('Deal)','Deal Card 1)');
document.getElementById('bunshift').disabled=true;
document.getElementById('shiftcode').value="shiftElement=names.shift(names[0]);";
}
}


</script>
</head>
<body onload=" doit(); ">
<h1><a id=a target=_blank href='./array_work.html'>Array Work</a> or <a id=asspg target=_blank href='./array_work.html?sspg=y'>Solar Systems Planet Game</a> or <a id=anq target=_blank href='./array_work.html?nq=y'>Number Queue</a> or <a id=acs target=_blank href='./array_work.html?cs=y'>Card Stack</a></h1>
<h3>RJM Programming - September, 2020<span id=score></span></h3>
<h4>Thanks to <a target=_blank title='Useful link, thanks' href='//www.positronx.io/javascript-array-push-pop-shift-unshift-methods/'>https://www.positronx.io/javascript-array-push-pop-shift-unshift-methods/</a></h4><br><br>

<table style=width:100%; border=25>
<tr id=row0 style=display:none;><th id=tzworkon></th><th colspan=2 id=tzofinterest></th><th style=color:lightgray; colspan=2 id=tznotofinterest disabled></th></tr>
<tr id=row1><th id=thworkon>Work on ...<span id=sgame></span></th><th id=thpush><button id=bpush class=gcode onclick=pushit(this);>push</button></th><th id=thpop><button id=bpop class=bcode onclick=popit(this);>pop</button></th><th id=thshift><button id=bshift class=pcode onclick=shiftit(this);>shift</button></th><th id=thunshift><button id=bunshift class=ocode onclick=unshiftit(this);>unshift</button></th></tr>
<tr id=row2><td id=tdworkon><div onblur="youreval((this.innerText || this.contentWindow || this.contentDocument).replace('var ',''));" contenteditable=true data-rows=25 id=workon>var names = ['Blaire', 'Ash', 'Coco', 'Dean', 'Georgia']; // 0️⃣</div></td><td id=tdpush><textarea class=gcode id=pushcode>names.push('Annie', 'Li');</textarea><br><div data-rows=15 id=pushresult></div></td><td id=tdpop><textarea class=bcode id=popcode>popElement=names.pop();</textarea><br><div data-rows=15 id=popresult></div></td><td id=tdshift><textarea class=pcode id=shiftcode>shiftElement=names.shift();</textarea><br><div data-rows=15 id=shiftresult></div></td><td id=tdunshift><textarea class=ocode id=unshiftcode>names.unshift('Zachary', 'Millicent');</textarea><br><div data-rows=15 id=unshiftresult></div></td></tr>
</table>

<div id=spliceresult style='display:none;'></div>
</body>
</html>