// macos_say_record.js
// RJM Programming
// Help get, to work, MAMP URLs like HTTP://localhost:8888/macos_say_record.php?andclose=y&docronwork=say%20hello%20there
var wo_ismsr=null;
var wmsrcd=false;
var minusvmsr='';
function cmgdafmsr() {
if (event.target.outerHTML.indexOf(' data-foundcommentary=') > event.target.outerHTML.indexOf('<') && event.target.outerHTML.indexOf(' data-foundcommentary=') < event.target.outerHTML.indexOf('>')) {
wo_ismsr=window.open('HTTP://localhost:8888/macos_say_record.php?andclose=y&docronwork=say' + encodeURIComponent(minusvmsr) + '%20' + encodeURIComponent(event.target.getAttribute('data-foundcommentary')), 'ifh', 'top=50,left=50,width=500,height=500'); //'_blank', 'top=50,left=50,width=500,height=500');
return true;
} else if (event.target.outerHTML.indexOf(' data-commentary=') > event.target.outerHTML.indexOf('<') && event.target.outerHTML.indexOf(' data-commentary=') < event.target.outerHTML.indexOf('>')) {
wo_ismsr=window.open('HTTP://localhost:8888/macos_say_record.php?andclose=y&docronwork=say' + encodeURIComponent(minusvmsr) + '%20' + encodeURIComponent(event.target.getAttribute('data-commentary')), 'ifh', 'top=50,left=50,width=500,height=500'); //'_blank', 'top=50,left=50,width=500,height=500');
return true;
}
return false;
}
function cmfmsr() {
if (!cmgdafmsr()) {
if (('' + event.target.title) != '') {
wo_ismsr=window.open('HTTP://localhost:8888/macos_say_record.php?andclose=y&docronwork=say' + encodeURIComponent(minusvmsr) + '%20Title%20is%20' + encodeURIComponent(event.target.title), 'ifh', 'top=50,left=50,width=500,height=500'); //'_blank', 'top=50,left=50,width=500,height=500');
//alert('Title=' + String.fromCharCode(10) + event.target.title);
} else if (('' + event.target.value).replace(/^undefined$/g,'').replace(/^null$/g,'') != '') {
wo_ismsr=window.open('HTTP://localhost:8888/macos_say_record.php?andclose=y&docronwork=say' + encodeURIComponent(minusvmsr) + '%20Value%20is%20' + encodeURIComponent(event.target.value), 'ifh', 'top=50,left=50,width=500,height=500'); //'_blank', 'top=50,left=50,width=500,height=500');
//alert('Value=' + String.fromCharCode(10) + event.target.value);
} else if (('' + event.target.outerHTML).indexOf('><') == -1 && ('' + event.target.outerHTML).indexOf('') != -1) {
wo_ismsr=window.open('HTTP://localhost:8888/macos_say_record.php?andclose=y&docronwork=say' + encodeURIComponent(minusvmsr) + '%20InnerHTML%20is%20' + encodeURIComponent((event.target.innerText || event.target.contentWindow || event.target.contentDocument)), 'ifh', 'top=50,left=50,width=500,height=500'); //'_blank', 'top=50,left=50,width=500,height=500');
//alert('InnerHTML=' + String.fromCharCode(10) + event.target.innerHTML);
} else {
console.log('OuterHTML=' + String.fromCharCode(10) + event.target.outerHTML);
}
}
}
function qfmsr(invmsr) {
minusvmsr=' -v ' + invmsr.split(String.fromCharCode(32))[1] + ' ';
document.getElementById('msrae').click();
}
function locopencheck() {
if (wo_ismsr) {
//alert(10);
if (!wo_ismsr.closed && !wmsrcd) {
wo_ismsr.close();
wo_ismsr=null;
document.getElementById('msrae').title='Click here so that right click or two finger gesture around webpage performs macOS say audio commentary on target HTML elements. If, on trying that with an underlying macOS or Mac OS X operating system maybe you need to download macos_say_record.php to MAMP Document Root.';
document.getElementById('msrae').style.textShadow='-4px 4px 6px #ff2d95;';
document.getElementById('msrae').style.backgroundColor='lightgreen';
var xsmsr='';
document.getElementById('spansel').innerHTML=xsmsr;
//alert(110);
} else {
wo_ismsr.close();
wo_ismsr=null;
//alert(1110);
}
//} else {
//alert(11110);
}
}
function dostuffmsr() {
var relstrmsr='', exctheremsr=false;
var iels=0, jels=0, kels=0;
var elsare=document.getElementsByTagName('*');
//commentary_array=['.tbanner', 'Tbanner is class', '.bbanner', 'Bbanner is class'];
for (iels=0; iels')) {
relstrmsr=' ' + elsare[iels].outerHTML.split(' class="')[1].split('"')[0] + ' ';
}
if (relstrmsr.indexOf(' ' + commentary_array[jels].substring(1) + ' ') != -1) {
elsare[iels].setAttribute('data-foundcommentary', commentary_array[eval(1 + eval('' + jels))]);
elsare[iels].addEventListener("contextmenu", cmgdafmsr, false);
exctheremsr=true;
console.log('yes more, array');
}
} else if (commentary_array[jels].trim().substring(0,1) == '#') {
relstrmsr='';
if (elsare[iels].outerHTML.indexOf(' id="') > elsare[iels].outerHTML.indexOf('<') && elsare[iels].outerHTML.indexOf(' id="') < elsare[iels].outerHTML.indexOf('>')) {
relstrmsr=' ' + elsare[iels].outerHTML.split(' id="')[1].split('"')[0] + ' ';
}
if (relstrmsr.indexOf(' ' + commentary_array[jels].substring(1) + ' ') != -1) {
elsare[iels].setAttribute('data-foundcommentary', commentary_array[eval(1 + eval('' + jels))]);
elsare[iels].addEventListener("contextmenu", cmgdafmsr, false);
exctheremsr=true;
console.log('yes more, Array');
}
} else {
relstrmsr='';
if (elsare[iels].outerHTML.indexOf(commentary_array[jels]) == 1) {
if (elsare[iels].outerHTML.indexOf(commentary_array[jels] + ' ') == 1) {
elsare[iels].setAttribute('data-foundcommentary', commentary_array[eval(1 + eval('' + jels))]);
elsare[iels].addEventListener("contextmenu", cmgdafmsr, false);
exctheremsr=true;
console.log('yes More, array');
} else if (elsare[iels].outerHTML.indexOf(commentary_array[jels] + '>') == 1) {
elsare[iels].setAttribute('data-foundcommentary', commentary_array[eval(1 + eval('' + jels))]);
elsare[iels].addEventListener("contextmenu", cmgdafmsr, false);
exctheremsr=true;
console.log('Yes more, array');
}
}
}
}
}
}
if (exctheremsr || (elsare[iels].outerHTML.indexOf(' data-foundcommentary=') > elsare[iels].outerHTML.indexOf('<') && elsare[iels].outerHTML.indexOf(' data-foundcommentary=') < elsare[iels].outerHTML.indexOf('>'))) {
iels=iels;
} else if (elsare[iels].outerHTML.indexOf(' data-commentary=') > elsare[iels].outerHTML.indexOf('<') && elsare[iels].outerHTML.indexOf(' data-commentary=') < elsare[iels].outerHTML.indexOf('>')) {
elsare[iels].addEventListener("contextmenu", cmgdafmsr, false);
} else {
elsare[iels].addEventListener("contextmenu", cmfmsr, false);
}
}
}
function huhmsr() {
document.getElementById('msrae').style.display='none';
document.getElementById('spansel').style.display='none';
}
function checkmsr(iois) {
var sfsg=false;
if (iois != null) {
var aconto = (iois.contentWindow || iois.contentDocument);
//alert(11);
if (aconto != null) {
//alert(navigator.platform);
if (iois.src.indexOf('localhost') != -1 && navigator.platform.indexOf("Mac") === 0) { sfsg=true; }
if (!sfsg && iois.src.indexOf('localhost') != -1) {
wo_ismsr.close(); //document.getElementById('macos').style.display='inline-block';
wmsrcd=true;
}
try {
if (aconto.document) { aconto = aconto.document; }
//alert(1111);
if (aconto.body != null) {
//alert(2);
if (aconto.body.innerHTML.indexOf('>') != -1) {
//alert(3);
if (iois.src.indexOf(':8888/') != -1) {
//alert(4);
//if (document.URL.indexOf('via=parenthtml') != -1) {
//alert(5);
if (aconto.body.innerHTML.toLowerCase().indexOf('not found') == -1) {
wo_ismsr.close(); //document.getElementById('macos').style.display='inline-block';
wmsrcd=true;
}
}
//}
}
}
} catch(exxx) {
console.log(exxx.message);
//wo_ismsr.close(); //alert(exxx.message);
//wmsrcd=true;
}
}
}
}
function onlmsr() {
document.body.innerHTML+="💬";
wo_ismsr=window.open('HTTP://localhost:8888/macos_say_record.php?andsoonclose=y&docronwork=ls', 'ifh', 'top=50,left=50,width=500,height=500'); //'_blank', 'top=50,left=50,width=500,height=500');
setTimeout(locopencheck, 1500);
setTimeout(huhmsr, 29000);
}
setTimeout(onlmsr, 2000);