Image Average Colour Primer Tutorial

Image Average Colour Primer Tutorial

Image Average Colour Primer Tutorial

Have you ever wondered whether, regarding an img (ie. image) HTML element …

  • a median RGB colour … and/or …
  • a mode RGB colour … and/or …
  • a mean (ie. average) RGB colour

… are useful concepts?! Well, we tried it, with our new PHP web application, and we’re doubtful … end of tutorial.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Well … alright … we’ll “play the game”. Yes … it was interesting. Yes … we learnt a lot. Yes, there were tea and bikkies afterwards. Yes … Collingwood will rise again!!!!!

Yes … in all seriousness to us it depends how we define these ideas. What we said was …

  • median colour is the one where you line up pixels in order of the (modal) list starting with the more popular one through to the least popular one, and the middle RGB colour value of these we’ll call “the median colour” …
  • mode colour is easy … the most popular colour (ie. most numerous) … which we had huge help from this great link regarding its suggested PHP GD based code to help, thanks … and …
  • mean (ie. average) colour is calculated as the rgb(r,g,b) whereby r=moving average of Red pixel “strengths” encountered and g=moving average of Green pixel “strengths” encountered and b=moving average of Blue pixel “strengths” encountered

You can try our “proof of concept” Image Average Colour web application, below, also …

Thinking philosophically here, as we intimated we might with yesterday’s HTML/Javascript Binary to Hexadecimal Base Game Tutorial, though, and not reaching for Wikipedia for once straight away, in terms of the colour system here …

Why couldn’t a colour system be …
pfoa([pink amount 0 up to 255], [fuchsia amount 0 up to 255]], [olive amount 0 up to 255], [transparency amount 0 to 1]);
?

Well, yes, there are lots of colour systems? There’s one with Cyan and Magenta and something else, but, guess we’re wondering if there is a transference mechanism (in mathematics, like)? And, “is your Red” like “my Red”, is curious with all this?! Anyway, enough philosophy!


Previous relevant HTML/Javascript Binary to Hexadecimal Base Game Tutorial is shown below.

HTML/Javascript Binary to Hexadecimal Base Game Tutorial

HTML/Javascript Binary to Hexadecimal Base Game Tutorial

Remember being pointed out, at school, in mathematics, how you could have numerical counting systems that weren’t base 10, and it blowing my tiny little mind! Then, in high school, imaginary numbers … wow! Still don’t know what they’re useful for?! But, for us, the point is, it can unhinge you to be thrown into, say, what we’d call “a dimensional thing” that you are just not used to.

The next few days we’re devoting to a little more of this sort of thing, with …

  • today, extending on from the base 2 (binary) and base 8 (octal) and base 16 (hexadecimal) themes of the quiz game of HTML/Javascript Binary/Octal/Hexadecimal Game Tutorial to allow for base numbers you set all the way from 2 to 16 (and please don’t ask me, yet, about fractional (ie. mantissaish) real number representations) … and …
  • tomorrow, though we really wanted to break open colour Red/Green/Blue (ie. RGB) thinking to other “base thoughts”, for now, because we haven’t found any suitable lead ins yet, we’re settling on the exploration of PHP image “average colour” themes

In today’s quiz work we melded those new base modes of play into the Hexadecimal Way (turn left at Station Street, up High Street, down Lowdown Crook, straight into Park Lane, hard right at Mayfair, and take the Town Drain home or away) where we started adjusting dropdown (ie. select) element innards so as to show blank options, then resurrect them, rather then reinventing 12? wheels …


function thenstuff() {
var sih='', sv='';
var parts=[], wasbit='', nowbit='', subparts=[], isp=0, numtodo='';
var sels=document.getElementsByTagName('select');
for (var isels=0; isels<sels.length; isels++) {
sv=sels[isels].value;
if (('' + sels[isels].id) != 'base') {
sih=sels[isels].innerHTML;
parts=sih.split(' value="' + ('' + eval(1 + maxnum)).replace('10','a').replace('11','b').replace('12','c').replace('13','d').replace('14','e').replace('15','f') + '"');
if (eval('' + parts.length) > 1) {
wasbit=parts[1];
nowbit=wasbit;
subparts=wasbit.split('</option');
for (isp=eval(-2 + subparts.length); isp>=0; isp--) {
numtodo=subparts[isp].split('>')[eval(-1 + subparts[isp].split('>').length)];
nowbit=nowbit.replace('>' + numtodo + '<', '><');
}
}
if (sih.indexOf(wasbit) != -1) {
sels[isels].innerHTML=sih.replace(wasbit, nowbit).replace('>' + ('' + eval(1 + maxnum)).replace('10','a').replace('11','b').replace('12','c').replace('13','d').replace('14','e').replace('15','f') + '<', '><');
sels[isels].value=sv;
} else {
sels[isels].innerHTML=sih.replace(wasbit, nowbit).replace('>' + ('' + eval(1 + maxnum)).replace('10','a').replace('11','b').replace('12','c').replace('13','d').replace('14','e').replace('15','f') + '<', '><');
sels[isels].value=sv;
//alert('oops ' + sih + ' ... ' + wasbit);
}
}
}
}

function hidestuff() {
var sih='', sv='';
var parts=[], wasbit='', nowbit='', subparts=[], isp=0, numtodo='';
var sels=document.getElementsByTagName('select');
//if (1 == 1) {
// restorestuff();
//}
for (var isels=0; isels<sels.length; isels++) {
sv=sels[isels].value;
if (('' + sels[isels].id) != 'base') {
sih=sels[isels].innerHTML;
parts=sih.split(' value="00"><');
if (eval('' + parts.length) > 1) {
wasbit=parts[1];
nowbit=wasbit;
subparts=wasbit.split('</option');
for (isp=eval(-2 + subparts.length); isp>=0; isp--) {
numtodo=subparts[isp].split(' value="')[1].split('"')[0];
nowbit=nowbit.replace(' value="' + numtodo + '"><', ' value="' + numtodo + '">' + numtodo + '<');
//alert(subparts[isp] + ' ... regarding ' + numtodo);
}
if (nowbit != wasbit) {
//alert(nowbit + ' via ' + wasbit);
if (sih.indexOf(wasbit) != -1) {
sih=sih.replace(wasbit, nowbit);
} //else {
//alert('ooPs ' + wasbit);
//}
}
}
//alert(maxnum);

wasbit='youllneverfindthis';

if (1 == 1) {
if (sih != '') {
sels[isels].innerHTML=sih;
sels[isels].value=sv;
}
} else {
parts=sih.split(' value="' + ('' + eval(1 + maxnum)).replace('10','a').replace('11','b').replace('12','c').replace('13','d').replace('14','e').replace('15','f') + '"');
if (eval('' + parts.length) > 1) {
wasbit=parts[1];
nowbit=wasbit;
subparts=wasbit.split('</option');
for (isp=eval(-2 + subparts.length); isp>=0; isp--) {
numtodo=subparts[isp].split('>')[eval(-1 + subparts[isp].split('>').length)];
nowbit=nowbit.replace('>' + numtodo + '<', '><');
}
}
if (sih.indexOf(wasbit) != -1) {
sels[isels].innerHTML=sih.replace(wasbit, nowbit);
sels[isels].value=sv;
} else {
sels[isels].innerHTML=sih;
sels[isels].value=sv;
//alert('oops ' + sih + ' ... ' + wasbit);
}
}
}
}

setTimeout(thenstuff, 800);
}

function restorestuff() {
var sv='';
var parts=[], wasbit='', nowbit='', subparts=[], isp=0, numtodo='';
if (1 == 2) {
var opts=document.getElementsByTagName('options');
for (var iopts=0; iopts<opts.length; iopts++) {
if (opts[iopts].value != '00') {
if (opts[iopts].innerText != opts[iopts].value) {
opts[iopts].Text=opts[iopts].value;
}
}
}
}

var sels=document.getElementsByTagName('select');
for (var isels=0; isels<sels.length; isels++) {
sv=sels[isels].value;
if (('' + sels[isels].id) != 'base') {
parts=sels[isels].innerHTML.split(' value="00"><');
if (eval('' + parts.length) > 1) {
wasbit=parts[1];
nowbit=wasbit;
subparts=wasbit.split('</option');
for (isp=eval(-2 + subparts.length); isp>=0; isp--) {
numtodo=subparts[isp].split(' value="')[1].split('"')[0];
nowbit=nowbit.replace(' value="' + numtodo + '"><', ' value="' + numtodo + '">' + numtodo + '<');
//alert(subparts[isp] + ' ... regarding ' + numtodo);
}
if (nowbit != wasbit) {
//alert(nowbit + ' via ' + wasbit);
sels[isels].innerHTML=sels[isels].innerHTML.replace(wasbit, nowbit);
sels[isels].value=sv;
}
}
}
}
}


function display() {
if (!document.getElementById(mode)) {
document.getElementById('hexadecimal').style.display = 'block';
//restorestuff();
setTimeout(hidestuff, 500);
} else {

document.getElementById(mode).style.display = 'block';
setTimeout(restorestuff, 500);
}


if (mode == 'binary') {
mnum = 255;
cshort ='b';
filledin = [0, 0, 0, 0, 0];
maxnum = 1;
numsels = 8;
document.getElementById('octal').style.display = 'none';
document.getElementById('hexadecimal').style.display = 'none';
} else if (mode == '3') {
mnum = 8;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 2;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == '4') {
mnum = 15;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 3;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == '5') {
mnum = 24;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 4;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == '6') {
mnum = 35;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 5;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == '7') {
mnum = 48;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 6;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';

} else if (mode == 'octal') {
mnum = 4095;
cshort ='o';
filledin = [0, 0, 0, 0, 0];
maxnum = 7;
numsels = 4;
document.getElementById('binary').style.display = 'none';
document.getElementById('hexadecimal').style.display = 'none';

} else if (mode == '9') {
mnum = 80;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 8;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'A') {
mnum = 99;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 9;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'B') {
mnum = 120;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 10;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'C') {
mnum = 143;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 11;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'D') {
mnum = 168;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 12;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'E') {
mnum = 195;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 13;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'F') {
mnum = 224;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 14;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';


} else if (mode == 'hexadecimal') {
mnum = 255;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 15;
numsels = 2;
document.getElementById('octal').style.display = 'none';
document.getElementById('binary').style.display = 'none';
}
startoff();
}

… in the extended binary_quiz.htm Base Quiz Game you can also try below …

Did you know?

My head hurts thinking about what we’d have had to do to make the other base that we use a lot around here, work! That base is 64, used a lot with webpage information encoding and decoding these days. Think …

Fair point, ex teacher …

But you haven’t explained any usages!

Okay, here’s one you’ll like if you’ve ever …

  • used an HTML form …
  • to pass across data that is programming language … ie. bound to contain some + characters … being that + is also used to encode a space character … how do you tell the difference between these guises at the other end? … well, lately, we’ve been …
  • introducing a form onsubmit event where, maybe just for the few seconds needed, the textbox or textarea content is changed to base64 via window.btoa and at some time after the return true; that finishes the event logic you might want to revert back (ie. use combination of setTimeout and window.atob to revert back, for this purpose) … and at the receiving end …
  • for HTML/Javascript (or PHP, for that matter) use window.atob (only) or for PHP use base64_decode (only)
  • to better preserve real + characters in the transfer

… as explained when we presented Javascript Microtask Primer Tutorial.


Previous relevant HTML/Javascript Binary/Octal/Hexadecimal Game Tutorial HTML/Javascript Binary to Hexadecimal Base Game Tutorial is shown below.

HTML/Javascript Binary/Octal/Hexadecimal Game Tutorial

HTML/Javascript Binary/Octal/Hexadecimal Game Tutorial

Are you feeling transformational? Maybe calculating? Perhaps didactic? Witheringly logical? You can test how you feel, in a mathematical sense, by playing our “Binary/Octal/Hexadecimal” game today.

The study of bases other than (decimal) 10 in mathematics is very interesting and it is used a lot in computing, a simple example of which is notation like #ffffff to describe the colour white, which lots of us were taught at school as the colour that contains the lot, hence all the 255 (hexadecimal ff) of Red and 255 (hexadecimal ff) of Green and 255 (hexadecimal ff) of Blue in the RGB colour model system. You might think that a computer would be able to work faster with the smaller amounts of data of hexadecimal, but, basically, the computer will, eventually, go and turn this into binary because at the bottom of its design it understands on and off, as you would understand voltage on a Bugs Bunny cartoon if you were the Coyote just missing the Roadrunner, running into an electrical socket running an Eat at Joes sign being switched off, on (sizzle), off, on (sizzle), off, on (sizzled Coyote, meet Daffy Duck?!).

Anyway, see how you go with this game that asks you to solve 5 problems as quickly as possible. One way around you can cheat the system, and this is fine by me, in the sense that the intention is just to put that picture in your head of the powers of 2 involved to get a little bit familiar with them. Another way to do this is to access a text editor that can simultaneously display a hexadecimal view (or dump) of that data. UltraEdit on Windows can do this.

Here is a link to some downloadable HTML (with Javascript) programming code you could rename to binary_quiz.html and a live run.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Tutorials | Tagged , , , , , , , | Leave a comment

HTML/Javascript Binary to Hexadecimal Base Game Tutorial

HTML/Javascript Binary to Hexadecimal Base Game Tutorial

HTML/Javascript Binary to Hexadecimal Base Game Tutorial

Remember being pointed out, at school, in mathematics, how you could have numerical counting systems that weren’t base 10, and it blowing my tiny little mind! Then, in high school, imaginary numbers … wow! Still don’t know what they’re useful for?! But, for us, the point is, it can unhinge you to be thrown into, say, what we’d call “a dimensional thing” that you are just not used to.

The next few days we’re devoting to a little more of this sort of thing, with …

  • today, extending on from the base 2 (binary) and base 8 (octal) and base 16 (hexadecimal) themes of the quiz game of HTML/Javascript Binary/Octal/Hexadecimal Game Tutorial to allow for base numbers you set all the way from 2 to 16 (and please don’t ask me, yet, about fractional (ie. mantissaish) real number representations) … and …
  • tomorrow, though we really wanted to break open colour Red/Green/Blue (ie. RGB) thinking to other “base thoughts”, for now, because we haven’t found any suitable lead ins yet, we’re settling on the exploration of PHP image “average colour” themes

In today’s quiz work we melded those new base modes of play into the Hexadecimal Way (turn left at Station Street, up High Street, down Lowdown Crook, straight into Park Lane, hard right at Mayfair, and take the Town Drain home or away) where we started adjusting dropdown (ie. select) element innards so as to show blank options, then resurrect them, rather then reinventing 12? wheels …


function thenstuff() {
var sih='', sv='';
var parts=[], wasbit='', nowbit='', subparts=[], isp=0, numtodo='';
var sels=document.getElementsByTagName('select');
for (var isels=0; isels<sels.length; isels++) {
sv=sels[isels].value;
if (('' + sels[isels].id) != 'base') {
sih=sels[isels].innerHTML;
parts=sih.split(' value="' + ('' + eval(1 + maxnum)).replace('10','a').replace('11','b').replace('12','c').replace('13','d').replace('14','e').replace('15','f') + '"');
if (eval('' + parts.length) > 1) {
wasbit=parts[1];
nowbit=wasbit;
subparts=wasbit.split('</option');
for (isp=eval(-2 + subparts.length); isp>=0; isp--) {
numtodo=subparts[isp].split('>')[eval(-1 + subparts[isp].split('>').length)];
nowbit=nowbit.replace('>' + numtodo + '<', '><');
}
}
if (sih.indexOf(wasbit) != -1) {
sels[isels].innerHTML=sih.replace(wasbit, nowbit).replace('>' + ('' + eval(1 + maxnum)).replace('10','a').replace('11','b').replace('12','c').replace('13','d').replace('14','e').replace('15','f') + '<', '><');
sels[isels].value=sv;
} else {
sels[isels].innerHTML=sih.replace(wasbit, nowbit).replace('>' + ('' + eval(1 + maxnum)).replace('10','a').replace('11','b').replace('12','c').replace('13','d').replace('14','e').replace('15','f') + '<', '><');
sels[isels].value=sv;
//alert('oops ' + sih + ' ... ' + wasbit);
}
}
}
}

function hidestuff() {
var sih='', sv='';
var parts=[], wasbit='', nowbit='', subparts=[], isp=0, numtodo='';
var sels=document.getElementsByTagName('select');
//if (1 == 1) {
// restorestuff();
//}
for (var isels=0; isels<sels.length; isels++) {
sv=sels[isels].value;
if (('' + sels[isels].id) != 'base') {
sih=sels[isels].innerHTML;
parts=sih.split(' value="00"><');
if (eval('' + parts.length) > 1) {
wasbit=parts[1];
nowbit=wasbit;
subparts=wasbit.split('</option');
for (isp=eval(-2 + subparts.length); isp>=0; isp--) {
numtodo=subparts[isp].split(' value="')[1].split('"')[0];
nowbit=nowbit.replace(' value="' + numtodo + '"><', ' value="' + numtodo + '">' + numtodo + '<');
//alert(subparts[isp] + ' ... regarding ' + numtodo);
}
if (nowbit != wasbit) {
//alert(nowbit + ' via ' + wasbit);
if (sih.indexOf(wasbit) != -1) {
sih=sih.replace(wasbit, nowbit);
} //else {
//alert('ooPs ' + wasbit);
//}
}
}
//alert(maxnum);

wasbit='youllneverfindthis';

if (1 == 1) {
if (sih != '') {
sels[isels].innerHTML=sih;
sels[isels].value=sv;
}
} else {
parts=sih.split(' value="' + ('' + eval(1 + maxnum)).replace('10','a').replace('11','b').replace('12','c').replace('13','d').replace('14','e').replace('15','f') + '"');
if (eval('' + parts.length) > 1) {
wasbit=parts[1];
nowbit=wasbit;
subparts=wasbit.split('</option');
for (isp=eval(-2 + subparts.length); isp>=0; isp--) {
numtodo=subparts[isp].split('>')[eval(-1 + subparts[isp].split('>').length)];
nowbit=nowbit.replace('>' + numtodo + '<', '><');
}
}
if (sih.indexOf(wasbit) != -1) {
sels[isels].innerHTML=sih.replace(wasbit, nowbit);
sels[isels].value=sv;
} else {
sels[isels].innerHTML=sih;
sels[isels].value=sv;
//alert('oops ' + sih + ' ... ' + wasbit);
}
}
}
}

setTimeout(thenstuff, 800);
}

function restorestuff() {
var sv='';
var parts=[], wasbit='', nowbit='', subparts=[], isp=0, numtodo='';
if (1 == 2) {
var opts=document.getElementsByTagName('options');
for (var iopts=0; iopts<opts.length; iopts++) {
if (opts[iopts].value != '00') {
if (opts[iopts].innerText != opts[iopts].value) {
opts[iopts].Text=opts[iopts].value;
}
}
}
}

var sels=document.getElementsByTagName('select');
for (var isels=0; isels<sels.length; isels++) {
sv=sels[isels].value;
if (('' + sels[isels].id) != 'base') {
parts=sels[isels].innerHTML.split(' value="00"><');
if (eval('' + parts.length) > 1) {
wasbit=parts[1];
nowbit=wasbit;
subparts=wasbit.split('</option');
for (isp=eval(-2 + subparts.length); isp>=0; isp--) {
numtodo=subparts[isp].split(' value="')[1].split('"')[0];
nowbit=nowbit.replace(' value="' + numtodo + '"><', ' value="' + numtodo + '">' + numtodo + '<');
//alert(subparts[isp] + ' ... regarding ' + numtodo);
}
if (nowbit != wasbit) {
//alert(nowbit + ' via ' + wasbit);
sels[isels].innerHTML=sels[isels].innerHTML.replace(wasbit, nowbit);
sels[isels].value=sv;
}
}
}
}
}


function display() {
if (!document.getElementById(mode)) {
document.getElementById('hexadecimal').style.display = 'block';
//restorestuff();
setTimeout(hidestuff, 500);
} else {

document.getElementById(mode).style.display = 'block';
setTimeout(restorestuff, 500);
}


if (mode == 'binary') {
mnum = 255;
cshort ='b';
filledin = [0, 0, 0, 0, 0];
maxnum = 1;
numsels = 8;
document.getElementById('octal').style.display = 'none';
document.getElementById('hexadecimal').style.display = 'none';
} else if (mode == '3') {
mnum = 8;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 2;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == '4') {
mnum = 15;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 3;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == '5') {
mnum = 24;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 4;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == '6') {
mnum = 35;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 5;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == '7') {
mnum = 48;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 6;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';

} else if (mode == 'octal') {
mnum = 4095;
cshort ='o';
filledin = [0, 0, 0, 0, 0];
maxnum = 7;
numsels = 4;
document.getElementById('binary').style.display = 'none';
document.getElementById('hexadecimal').style.display = 'none';

} else if (mode == '9') {
mnum = 80;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 8;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'A') {
mnum = 99;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 9;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'B') {
mnum = 120;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 10;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'C') {
mnum = 143;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 11;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'D') {
mnum = 168;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 12;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'E') {
mnum = 195;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 13;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';
} else if (mode == 'F') {
mnum = 224;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 14;
numsels = 2;
document.getElementById('binary').style.display = 'none';
//document.getElementById('hexadecimal').style.display = 'none';
document.getElementById('octal').style.display = 'none';


} else if (mode == 'hexadecimal') {
mnum = 255;
cshort ='h';
filledin = [0, 0, 0, 0, 0];
maxnum = 15;
numsels = 2;
document.getElementById('octal').style.display = 'none';
document.getElementById('binary').style.display = 'none';
}
startoff();
}

… in the extended binary_quiz.htm Base Quiz Game you can also try below …

Did you know?

My head hurts thinking about what we’d have had to do to make the other base that we use a lot around here, work! That base is 64, used a lot with webpage information encoding and decoding these days. Think …

Fair point, ex teacher …

But you haven’t explained any usages!

Okay, here’s one you’ll like if you’ve ever …

  • used an HTML form …
  • to pass across data that is programming language … ie. bound to contain some + characters … being that + is also used to encode a space character … how do you tell the difference between these guises at the other end? … well, lately, we’ve been …
  • introducing a form onsubmit event where, maybe just for the few seconds needed, the textbox or textarea content is changed to base64 via window.btoa and at some time after the return true; that finishes the event logic you might want to revert back (ie. use combination of setTimeout and window.atob to revert back, for this purpose) … and at the receiving end …
  • for HTML/Javascript (or PHP, for that matter) use window.atob (only) or for PHP use base64_decode (only)
  • to better preserve real + characters in the transfer

… as explained when we presented Javascript Microtask Primer Tutorial.


Previous relevant HTML/Javascript Binary/Octal/Hexadecimal Game Tutorial HTML/Javascript Binary to Hexadecimal Base Game Tutorial is shown below.

HTML/Javascript Binary/Octal/Hexadecimal Game Tutorial

HTML/Javascript Binary/Octal/Hexadecimal Game Tutorial

Are you feeling transformational? Maybe calculating? Perhaps didactic? Witheringly logical? You can test how you feel, in a mathematical sense, by playing our “Binary/Octal/Hexadecimal” game today.

The study of bases other than (decimal) 10 in mathematics is very interesting and it is used a lot in computing, a simple example of which is notation like #ffffff to describe the colour white, which lots of us were taught at school as the colour that contains the lot, hence all the 255 (hexadecimal ff) of Red and 255 (hexadecimal ff) of Green and 255 (hexadecimal ff) of Blue in the RGB colour model system. You might think that a computer would be able to work faster with the smaller amounts of data of hexadecimal, but, basically, the computer will, eventually, go and turn this into binary because at the bottom of its design it understands on and off, as you would understand voltage on a Bugs Bunny cartoon if you were the Coyote just missing the Roadrunner, running into an electrical socket running an Eat at Joes sign being switched off, on (sizzle), off, on (sizzle), off, on (sizzled Coyote, meet Daffy Duck?!).

Anyway, see how you go with this game that asks you to solve 5 problems as quickly as possible. One way around you can cheat the system, and this is fine by me, in the sense that the intention is just to put that picture in your head of the powers of 2 involved to get a little bit familiar with them. Another way to do this is to access a text editor that can simultaneously display a hexadecimal view (or dump) of that data. UltraEdit on Windows can do this.

Here is a link to some downloadable HTML (with Javascript) programming code you could rename to binary_quiz.html and a live run.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Use iPhone as Webcam for Nearby macOS Tutorial

Apple iPad to New iPad Bluetooth Assisted Setup Tutorial

Use iPhone as Webcam for Nearby macOS Tutorial

The way the functionality style of today’s Use iPhone as Webcam for Nearby macOS signature procedure mentions …

… is close to …

… regarding a prerequisite to how this Webcam functionality functions, made me think, in a similar ilk to the previous Apple iPad to New iPad Bluetooth Assisted Setup Tutorial‘s role for bluetooth, we were actually needing bluetooth again, though none of the install setup mentioned it. But, more and more, clever functionality can happen between Apple devices (whether they be iOS or macOS … like our iPhone and MacBook Air featuring today) either sharing …

  • the same WiFi network … a possibility here too … and/or …
  • bluetooth

… technology. Anyway, irrespective of the innards of how it works, the idea is pretty interesting, perhaps as a great way to document the action of a procedure, that needs tactile explanation, as distinct from screenshots being able to explain the procedure. If totally a tactile thing, we can see it as extremely useful. As a programmer explaining code though, we’ll want to duck out of Webcam mode and into and out of Screenshot mode. Mind you, with practice, a webcam can do it all, we’re sure. It just takes practice!


Previous relevant Apple iPad to New iPad Bluetooth Assisted Setup Tutorial is shown below.

Apple iPad to New iPad Bluetooth Assisted Setup Tutorial

Apple iPad to New iPad Bluetooth Assisted Setup Tutorial

As with the install qualities bluetooth helped out with during Apple TV Setup via WiFi and Bluetooth Tutorial, the other day we had occasion to setup a new iPad (preferably the same as an ailing old iPad) and, again, bluetooth came to the rescue making an Apple install or setup a very easy and enjoyable experience.

For more than 90% of the setup, including the absorption of a myriad of app installs and password rememberings, the simple steps of …

  1. hold the old iPad near the new iPad … and …
  2. patience (while bluetooth assisted install takes place)

… were all that was required to get up and going with the new iPad in about fifteen minutes from unwrapping! Cute, huh?!


Previous relevant Apple TV Setup via WiFi and Bluetooth Tutorial is shown below.

Apple TV Setup via WiFi and Bluetooth Tutorial

Apple TV Setup via WiFi and Bluetooth Tutorial

We’re following up on the previous Apple TV Primer Tutorial with an upgrade because it is far more functional today, with its live television options (doing away with the need for television aerials for live streaming alternative), and we want to admire the Apple TV setup’s adroitness combining …

  • WiFi … and …
  • Bluetooth

… those two “giants” of modern personal computing networking functionality.

Those two appearing together all the time in Settings scenarios, we’ve often wondered how best to combine their talents, and the recent Apple TV version’s setup used them effectively (though optionally) to our minds.

At a certain point in the setup a choice that could make use of WiFi and Bluetooth together saved us having to remember Apple ID passwords and other such matters. At this point you could bring your other Apple device up close to the Apple TV device during the setup and arrange that Bluetooth was on, and it proceeded as if to suck the useful setting data out of the iPad device we offered up to the “Apple TV God”.

Very savvy indeed, and take a look at some Apple TV stream of consciousness here.

Did you know?

Do you like the jiggle? Let me explain. In iOS land you can delete mobile apps, effectively, by holding a touch down for a while, and waiting for all the icons to jiggle, and (re)touch any you want to delete. Well, the Apple TV operating system can work the same way. Also the same mobile app Install and Open arrangements, so the setup will be familiar to many, am sure.


Previous relevant Apple TV Primer Tutorial is shown below.

Apple TV Primer Tutorial

Apple TV Primer Tutorial

Do you own Apple devices like iPads and iPhones? Do you have a home WiFi wireless router? And do you have a reasonable modern television, or other home-theater device?

Three yes (or yes, no, yes might still work (with AirPlay) on reading here), here, and if you don’t already (have it and working), you might be interested in a product called Apple TV, a hardware product consisting of a “box” and a remote control.

With Apple TV, whatever you can do with video, and/or streaming services, on the iPad or iPhone can often be “projected” (or (Apple says) “mirrored”) onto that much bigger television screen, so that a presentation or piece of entertainment can be shared with others.

The setup is easy, as you can see from this link from Apple …

To start over at any time, unplug your device from power, then plug back in.

  1. Plug into power. Plug your Apple TV into power. …
  2. Connect to your home-theater devices. … with an HDMI cable …
  3. Turn on your television to find the setup screen. …
  4. Connect your remote. …
  5. Pick language settings. …
  6. Choose how to finish setup.

Much more amazing than that “old days” feeling of a Windows desktop being projected onto multiple screens at once!

Today’s tutorial picture shows Apple TV in action around our way.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Animation, eLearning, Hardware, iOS, Photography, Tutorials | Tagged , , , , , , , , | Leave a comment

YouTube Video API Event Playlist Save and Recall Tutorial

YouTube Video API Event Playlist Save and Recall Tutorial

YouTube Video API Event Playlist Save and Recall Tutorial

Meanwhile, back at the wishlist, with our recent YouTube API interfacing web application project …

st*_st* way to set mute straight away via $_GET[‘mute’] and/or blanks in duration get and a hashtag way to temporarily mute
Save a playlist for later via window.localStorage
Share a playlist
Radio and Oneatatime with a straight hashtag URL
Mute and unmute dynamically
Turn “-” into a reset link

Amalgamate entries searched for into IP address and raw character sets (perhaps collected in top.document.title)

… it is the olive ideas we’ve made a start on today. We say “we’ve made a start on” only because, when it comes to programming, it doesn’t pay to close off alternate ideas as you go about looking for solutions. Take “Amalgamate entries searched for into IP address and raw character sets (perhaps collected in top.document.title)(for some reason we’re nicknaming “innerHTML” … who wrote this script)

… well, yes, that would be nice, but, more to the point, we started involving top.document.title in solution making but then, along the way, started incorporating just plain and simple Javascript get/set functionality


var ajaxs_ih='';


function get_ajaxs_ih() {
return ajaxs_ih;
}


function set_ajaxs_ih(wht) {
ajaxs_ih=wht;
}

parent.get_ajaxs_ih() and parent.set_ajaxs_ih(strIn) references from the “parent” level referencing the “grandparent” level (of code above) and being able to populate those YouTube search dropdowns more efficiently. This get/set paradigm is “a classic” methodology in a lot of OOP work, further to the recent YouTube Video API Event Radio Play Sharing Tutorial.

Codewise, again, “the three amigos” were at it again …


Previous relevant YouTube Video API Event Radio Play Sharing Tutorial is shown below.

YouTube Video API Event Radio Play Sharing Tutorial

YouTube Video API Event Radio Play Sharing Tutorial

Wishful thinking with today’s tasklist regarding our current YouTube Video API Event Radio Play Idea Tutorial YouTube API interfacing web application project, where the blue ideas were started …

st*_st* way to set mute straight away via $_GET[‘mute’] and/or blanks in duration get and a hashtag way to temporarily mute
Save a playlist for later via window.localStorage
Share a playlist
Radio and Oneatatime with a straight hashtag URL
Mute and unmute dynamically
Turn “-” into a reset link

Amalgamate entries searched for into IP address and raw character sets (perhaps collected in top.document.title)

… further to yesterday’s YouTube Video API Event Radio Play Idea Tutorial

And yes, we want to try to get a mobile Radio scenario working for mobile, perhaps, by researching YouTube API (their) playlists … no guarantees, as you’d imagine!

Of interest, here, might be the “emoji means” and top.document.title means by which we tackle the Mute and unmute dynamically issue. Why use top.document.title here? Well, a grandchild of the grandparent is best placed to …

  • tell the grandparent the non-muted volume (which seems to always be 100, as you control what 100 means with the actual volume you have for your speakers) … as well as …
  • obey a grandparent edict to either …
    1. mute
    2. unmute

    … the volume as our way to say “keep playing the radio but shush while I take this phone call” in certain scenarios that might happen

… meaning that all the grandparent has to do, effectively “broadcasting” to any “grandchildren YouTube video players”, is “the emoji flagging work” and adjusting (what it knows as) document.title to perform this functionality for the two new input type=checkboxes (appended by an empty span element and nested in a span id=smute element) we add into the HTML design mix via onchange event function Javascript …


function domute(thiscbo) {
if (thiscbo.checked) {
thiscbo.style.backgroundColor='yellow';
document.getElementById('cbunmute').style.backgroundColor='white';
document.getElementById('smute').innerHTML=document.getElementById('smute').innerHTML.replace('>Mute' + document.getElementById('smute').innerHTML.split('>Mute')[1].split('<')[0] + '<', '>Mute ' + '&#10004;<').replace('>Unmute' + document.getElementById('smute').innerHTML.split('>Unmute')[1].split('<')[0] + '<', '>Unmute<');
if (document.title.indexOf('volume:') != -1) {
var rest='volume:' + document.title.split('volume:')[1];
document.title=document.title.replace(rest, rest.replace(document.title.split('volume:')[1].toLowerCase().replace(/^\ /g,'').replace(/^\ /g,'').replace(/^\ /g,'').split(' ')[0].split(',')[0].split(';')[0].split('|')[0], 'mute'));
} else {
thiscbo.style.backgroundColor='white';
document.title+=' volume:mute';
}
thiscbo.checked=false;
}
}

function dounmute(thiscbo) {
if (thiscbo.checked) {
thiscbo.style.backgroundColor='yellow';
document.getElementById('cbmute').style.backgroundColor='white';
document.getElementById('smute').innerHTML=document.getElementById('smute').innerHTML.replace('>Unmute' + document.getElementById('smute').innerHTML.split('>Unmute')[1].split('<')[0] + '<', '>Unmute ' + '&#10004;<').replace('>Mute' + document.getElementById('smute').innerHTML.split('>Mute')[1].split('<')[0] + '<', '>Mute<');
if (document.title.indexOf('volume:') != -1) {
var rest='volume:' + document.title.split('volume:')[1];
document.title=document.title.replace(rest, rest.replace(document.title.split('volume:')[1].toLowerCase().replace(/^\ /g,'').replace(/^\ /g,'').replace(/^\ /g,'').split(' ')[0].split(',')[0].split(';')[0].split('|')[0], 'unmute'));
} else {
thiscbo.style.backgroundColor='white';
document.title+=' volume:unmute';
}
thiscbo.checked=false;
}
}

It is this complex because (we found out) input type=checkbox CSS styling, as a subject, is a “bit of a closed book” matter!

Codewise, also regarding email and SMS (radio) playlist sharing functionality, amongst other changes, involved …


Previous relevant YouTube Video API Event Stop Propagation Idea Tutorial is shown below.

YouTube Video API Event Stop Propagation Idea Tutorial

YouTube Video API Event Stop Propagation Idea Tutorial

We’re back using the YouTube API video playing themes of YouTube Video API Interfacer Audio Play Tutorial as a means to setting up a web application that may help explain …


event.stopPropagation();

… Javascript event control of it’s “bubbling” (up through an element hierarchy), in other words, depending where you place this, stopping it’s “bubbling up” at that element concerned …

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on links are still processed. If you want to stop those behaviors, see the preventDefault() method. It also does not prevent propagation to other event-handlers of the current element. If you want to stop those, see stopImmediatePropagation().

We find, around here, we don’t know we’ve created a need for event.stopPropagation() usage until we’ve stumbled onto it, most of the time, so trying to get in ahead of it with today’s proof of concept to event.stopPropagation() or not to event.stopPropagation() web application feels a bit novel to us, in a good way.

This means by which to toggle that mode of use was more straightforward than “data control” with our musical YouTube API video functionality allowing a user to choose and slot in their own video ideas via either …

  • YouTube video ID … 11 characters long … or …
  • search string to try to select a video, via a programmatically populated dropdown, with an 11 character long YouTube video ID

… asking us to do a fair bit of tweaking to our inhouse interfacing …

… you might want to try out, yourself, to see what we’re getting at here, below …


Previous relevant YouTube Video API Interfacer Audio Play Tutorial is shown below.

YouTube Video API Interfacer Audio Play Tutorial

YouTube Video API Interfacer Audio Play Tutorial

The recent Making Of Earth Scanner Legs Tutorial set us to thinking about how to offer a toggling arrangement between our inhouse YouTube Embedded Iframe API playing of …

  • video … with an incarnation of this that plays …
  • audio … “sort of” only (but able to be toggled back to video playing)

… and it got us wondering how to “dull out” a video. We chose the CSS …

<style>

iframe { filter: invert(45%); }

</style>

If you want a “complete dull out” try filter: invert(50%); … but we wanted to see controls down the bottom, still useful for audio only playing.

You can try this all out in the changed karaoke_youtube_api.htm inhouse YouTube video interfacer.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

AlmaLinux Apache Status Report Inspiration Tutorial

AlmaLinux Apache Status Report Inspiration Tutorial

AlmaLinux Apache Status Report Inspiration Tutorial

Examining the RJM Programming’s Apache web server’s cPanel‘s …


Apache Status

… report, showing RJM Programming URL accesses in real time, can be very eye opening. Among recent surprises we got there were accesses ( regarding PHP $_SERVER[‘REQUEST_URI’] … ie. the stuff after www.rjmprogramming.com.au ) starting with …

Starting
with …
… then. Our initial response … The action we took …
/wiki/ Sai_Baba_of_Shirdi What the …? Who are those guys? Redirected to English
relevant Wikipedia webpage …
404.shtml (in Apache
Document Root) change

function onPageLoad() {
if (document.URL.indexOf('/currency/') != -1) {
location.href='//www.rjmprogramming.com.au/PHP/country_currency_quiz.php#showcur=' + document.URL.split('/currency/')[1];
}

if (document.URL.indexOf('/wiki/') != -1) {
location.href='//wikipedia.org/wiki/' + document.URL.split('/wiki/')[1];
}

// rest of code follows
}
/currency/ lbp-lebanese-pound We’re officially gobsmacked! 404.shtml (in Apache
Document Root) change … then …
country_currency_quiz.php
(with this live run link),
featuring these changes

… that last one today’s work, borne out of Apache Status Fascination!

Making something out of nothing?! We’ve got nothing to lose, and we may surprise some user out there (perhaps just mucking around).

And so, with similar themes to HTML5 Time Tag Timeline AlmaLinux Debug Tutorial we set out to make something out of nothing here, and we’ve closely documented what we did regarding today’s animated GIF presentation.


Previous relevant HTML5 Time Tag Timeline AlmaLinux Debug Tutorial is shown below.

HTML5 Time Tag Timeline AlmaLinux Debug Tutorial

HTML5 Time Tag Timeline AlmaLinux Debug Tutorial

Another day, another use for (in our case Google Chrome web browser) web inspector functionality. Yes, even if the source of the issue is PHP (which we moved on from a CentOS starting with 5 version to an AlmaLinux version starting with an 8) we’re yet to see an issue that could not be resolved with the help of a clientside web inspector debugging arrangement. Of course, the simpler the PHP the more likely this is to happen, but we can’t emphasise enough how useful these web inspectors are.

Today’s case in point revisits the use_time.htm clientside web application we talked about at HTML5 Time Tag Timeline Tutorial. Moving to AlmaLinux, and revisiting it on trying …

… as a reason we should add to the list (of two we talked about at PHP Migration Software Strategies Tutorial) …

  • fgrep … preemptive approach … and/or …
  • error_log … reactive approach
  • examining Apache Status log every now and then … via (now AlmaLinux cPanel but used to also be on CentOS cPanel) Apache Status report we talked about at CentOS Web Server cPanel Apache Status Tutorial

… as a “what the users are trying” resource available for AlmaLinux (cPanel using) web masters to keep in touch with goings on … was fun.

The fix, again, was to do with our “assumptive” PHP5 associative array logics … will Nala ever learn?!

And so, though our Time Tag clientside web application did not change, the underlying Google Chart Timeline Chart interfacing timeline_chart.php‘s web application did!


Previous relevant HTML5 Time Tag Timeline Tutorial is shown below.

HTML5 Time Tag Timeline Tutorial

HTML5 Time Tag Timeline Tutorial

The recent HTML5 Time Tag Primer Tutorial introduced the time tag, an HTML5 initiative, into our frame of reference here at this blog. As soon as date and/or time come into the picture the “when” of life comes into focus, and the use of the fourth dimension. As such, this HTML time tag can be the launching pad for interfacing to other “when” based web applications we’ve developed here.

With this in mind we …

With changes like this it can be important to leave the door open for people to not access this new Timeline (in an HTML iframe element), in terms of backward compatibility “friendliness”, and we allow for that via either/both bold (part of) ways below …

But we are of the view that interfacing to other web applications with synergies is generally a good thing to do, and can inspire other ideas to develop regarding improvements to functionality.


Previous relevant HTML5 Time Tag Primer Tutorial is shown below.

HTML5 Time Tag Primer Tutorial

HTML5 Time Tag Primer Tutorial

You might be forgiven reading this webpage about the time tag introduced with HTML5 that it is not of much use, because it doesn’t show any distinguishing feature yet, in any of the web browsers.

But you can tailor the use of it yourself, and to show this we took the HTML lacking a <head></head> section and not change this HTML at all, but add our own CSS and Javascript (DOM) <head></head> section to embellish its functionality considerably.

We use a combination of …

  • CSS ::after { content: ‘blah blah’; } pseudo-element
  • CSS :hover selector
  • window.onload = init; // Javascript onload functionality
  • document.body.innerHTML+=styles; // Javascript where styles variable contains dynamically constructed <body></body> section CSS <style></style> (an important thing to remember you can do (at a document.body onload event Javascript function, for example)) … and for this we used …
  • dynamically classed HTML time elements and moving on the onclick event (for mobile device use) as per …

    times[iw].onclick = function() { };
    times[iw].className+=' atime' + iw; // the times array which is derived via

  • var times=document.getElementsByTagName('time');
  • to be able to dynamically populate that styles variable as per codelines like …

    styles=styles.replace("</style>"," .atime" + iw + ":hover::after { content: ' is " + sin(yyyy2,4) + "/" + sin(mm2,2) + "/" + sin(dd2,2) + " " + sin(hh2,2) + ":" + sin(minm2,2) + ":" + sin(ss2,2) + "'; } </style>");

Here is a link to some downloadable HTML programming source code which you may want to rename to use_time.html for this live run link.

Stop Press

If you were an “early bird” reading the early editions of this blog post, sorry, but you will have missed this, perhaps, and then again, maybe I am wasting my time pointing this out, but, since those early editions we’ve added a couple of iw links that harness some new functionality we have in our “highlighting” armoury (shall we say) making use of the new HTML5 mark tag, which we’ll be detailing more about in tomorrow’s blog posting. Clicking these links effectively does a web browser “View Page Source” type of functionality, but also highlights and positions (to first find), in situations like the “iw” one, where it is just a counter, but is unexplained, so we leave it up to curious users to find out something about its context.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Tutorials | Tagged , , , , , , , , , , , , , , | Leave a comment

YouTube Video API Event Radio Play Sharing Tutorial

YouTube Video API Event Radio Play Sharing Tutorial

YouTube Video API Event Radio Play Sharing Tutorial

Wishful thinking with today’s tasklist regarding our current YouTube Video API Event Radio Play Idea Tutorial YouTube API interfacing web application project, where the blue ideas were started …

st*_st* way to set mute straight away via $_GET[‘mute’] and/or blanks in duration get and a hashtag way to temporarily mute
Save a playlist for later via window.localStorage
Share a playlist
Radio and Oneatatime with a straight hashtag URL
Mute and unmute dynamically
Turn “-” into a reset link

Amalgamate entries searched for into IP address and raw character sets (perhaps collected in top.document.title)

… further to yesterday’s YouTube Video API Event Radio Play Idea Tutorial

And yes, we want to try to get a mobile Radio scenario working for mobile, perhaps, by researching YouTube API (their) playlists … no guarantees, as you’d imagine!

Of interest, here, might be the “emoji means” and top.document.title means by which we tackle the Mute and unmute dynamically issue. Why use top.document.title here? Well, a grandchild of the grandparent is best placed to …

  • tell the grandparent the non-muted volume (which seems to always be 100, as you control what 100 means with the actual volume you have for your speakers) … as well as …
  • obey a grandparent edict to either …
    1. mute
    2. unmute

    … the volume as our way to say “keep playing the radio but shush while I take this phone call” in certain scenarios that might happen

… meaning that all the grandparent has to do, effectively “broadcasting” to any “grandchildren YouTube video players”, is “the emoji flagging work” and adjusting (what it knows as) document.title to perform this functionality for the two new input type=checkboxes (appended by an empty span element and nested in a span id=smute element) we add into the HTML design mix via onchange event function Javascript …


function domute(thiscbo) {
if (thiscbo.checked) {
thiscbo.style.backgroundColor='yellow';
document.getElementById('cbunmute').style.backgroundColor='white';
document.getElementById('smute').innerHTML=document.getElementById('smute').innerHTML.replace('>Mute' + document.getElementById('smute').innerHTML.split('>Mute')[1].split('<')[0] + '<', '>Mute ' + '&#10004;<').replace('>Unmute' + document.getElementById('smute').innerHTML.split('>Unmute')[1].split('<')[0] + '<', '>Unmute<');
if (document.title.indexOf('volume:') != -1) {
var rest='volume:' + document.title.split('volume:')[1];
document.title=document.title.replace(rest, rest.replace(document.title.split('volume:')[1].toLowerCase().replace(/^\ /g,'').replace(/^\ /g,'').replace(/^\ /g,'').split(' ')[0].split(',')[0].split(';')[0].split('|')[0], 'mute'));
} else {
thiscbo.style.backgroundColor='white';
document.title+=' volume:mute';
}
thiscbo.checked=false;
}
}

function dounmute(thiscbo) {
if (thiscbo.checked) {
thiscbo.style.backgroundColor='yellow';
document.getElementById('cbmute').style.backgroundColor='white';
document.getElementById('smute').innerHTML=document.getElementById('smute').innerHTML.replace('>Unmute' + document.getElementById('smute').innerHTML.split('>Unmute')[1].split('<')[0] + '<', '>Unmute ' + '&#10004;<').replace('>Mute' + document.getElementById('smute').innerHTML.split('>Mute')[1].split('<')[0] + '<', '>Mute<');
if (document.title.indexOf('volume:') != -1) {
var rest='volume:' + document.title.split('volume:')[1];
document.title=document.title.replace(rest, rest.replace(document.title.split('volume:')[1].toLowerCase().replace(/^\ /g,'').replace(/^\ /g,'').replace(/^\ /g,'').split(' ')[0].split(',')[0].split(';')[0].split('|')[0], 'unmute'));
} else {
thiscbo.style.backgroundColor='white';
document.title+=' volume:unmute';
}
thiscbo.checked=false;
}
}

It is this complex because (we found out) input type=checkbox CSS styling, as a subject, is a “bit of a closed book” matter!

Codewise, also regarding email and SMS (radio) playlist sharing functionality, amongst other changes, involved …


Previous relevant YouTube Video API Event Stop Propagation Idea Tutorial is shown below.

YouTube Video API Event Stop Propagation Idea Tutorial

YouTube Video API Event Stop Propagation Idea Tutorial

We’re back using the YouTube API video playing themes of YouTube Video API Interfacer Audio Play Tutorial as a means to setting up a web application that may help explain …


event.stopPropagation();

… Javascript event control of it’s “bubbling” (up through an element hierarchy), in other words, depending where you place this, stopping it’s “bubbling up” at that element concerned …

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on links are still processed. If you want to stop those behaviors, see the preventDefault() method. It also does not prevent propagation to other event-handlers of the current element. If you want to stop those, see stopImmediatePropagation().

We find, around here, we don’t know we’ve created a need for event.stopPropagation() usage until we’ve stumbled onto it, most of the time, so trying to get in ahead of it with today’s proof of concept to event.stopPropagation() or not to event.stopPropagation() web application feels a bit novel to us, in a good way.

This means by which to toggle that mode of use was more straightforward than “data control” with our musical YouTube API video functionality allowing a user to choose and slot in their own video ideas via either …

  • YouTube video ID … 11 characters long … or …
  • search string to try to select a video, via a programmatically populated dropdown, with an 11 character long YouTube video ID

… asking us to do a fair bit of tweaking to our inhouse interfacing …

… you might want to try out, yourself, to see what we’re getting at here, below …


Previous relevant YouTube Video API Interfacer Audio Play Tutorial is shown below.

YouTube Video API Interfacer Audio Play Tutorial

YouTube Video API Interfacer Audio Play Tutorial

The recent Making Of Earth Scanner Legs Tutorial set us to thinking about how to offer a toggling arrangement between our inhouse YouTube Embedded Iframe API playing of …

  • video … with an incarnation of this that plays …
  • audio … “sort of” only (but able to be toggled back to video playing)

… and it got us wondering how to “dull out” a video. We chose the CSS …

<style>

iframe { filter: invert(45%); }

</style>

If you want a “complete dull out” try filter: invert(50%); … but we wanted to see controls down the bottom, still useful for audio only playing.

You can try this all out in the changed karaoke_youtube_api.htm inhouse YouTube video interfacer.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

WordPress Oembed Integration Primer Tutorial

WordPress Oembed Integration Primer Tutorial

WordPress Oembed Integration Primer Tutorial

Do a list of URLs mean anything in our WordPress blog’s preparatory textarea element?

https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.gif
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.jpg
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.php
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.php——GETME
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.php—–GETME
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.php—-GETME
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.php—GETME
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.php–GETME
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.php-GETME
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper.php_GETME
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper_common.jpg
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper_iframe.jpg
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_helper_sorting.jpg
https://www.rjmprogramming.com.au/PHP/start_word_for_wordle_revisit.gif

Oops, nothing … and why? They are not videos nor audios … so how about …

//www.rjmprogramming.com.au/bear-191995.mp3
//www.rjmprogramming.com.au/beep.mp3
//www.rjmprogramming.com.au/bluetooth_movie.mp4
//www.rjmprogramming.com.au/crunch-80936.mp3
//www.rjmprogramming.com.au/please_sign.mp4
//www.rjmprogramming.com.au/school_activities_vd.mp4
//www.rjmprogramming.com.au/speech6.mp3
//www.rjmprogramming.com.au/squidgy.mp4
//www.rjmprogramming.com.au/temp.mp3
//www.rjmprogramming.com.au/test.mp3
//www.rjmprogramming.com.au/test2.mp3
//www.rjmprogramming.com.au/xz.mp4

Oops, still nothing … and why? They need the protocol mentioned on separated textarea element lines … so how about …

https://www.rjmprogramming.com.au/bear-191995.mp3
https://www.rjmprogramming.com.au/beep.mp3
https://www.rjmprogramming.com.au/bluetooth_movie.mp4
https://www.rjmprogramming.com.au/crunch-80936.mp3
https://www.rjmprogramming.com.au/please_sign.mp4
https://www.rjmprogramming.com.au/school_activities_vd.mp4
https://www.rjmprogramming.com.au/speech6.mp3
https://www.rjmprogramming.com.au/squidgy.mp4
https://www.rjmprogramming.com.au/temp.mp3
https://www.rjmprogramming.com.au/test.mp3
https://www.rjmprogramming.com.au/test2.mp3
https://www.rjmprogramming.com.au/xz.mp4

? Yes … as you can see “fleshed out” in “oembed” created HTML iframe elements below …



https://www.rjmprogramming.com.au/crunch-80936.mp3 https://www.rjmprogramming.com.au/speech6.mp3 https://www.rjmprogramming.com.au/temp.mp3 https://www.rjmprogramming.com.au/test.mp3 https://www.rjmprogramming.com.au/test2.mp3

Interesting, huh? So what’s the “fleshing out for that first bear-191995.mp3 video, for instance?


<div id="mep_0" class="mejs-container mejs-container-keyboard-inactive wp-audio-shortcode mejs-audio" tabindex="0" role="application" aria-label="Audio Player" style="width: 638px; height: 40px; min-width: 241px;"><div class="mejs-inner"><div class="mejs-mediaelement"><mediaelementwrapper id="audio-71053-1"><audio class="wp-audio-shortcode" id="audio-71053-1_html5" preload="none" style="width: 100%; height: 100%;" src="https://www.rjmprogramming.com.au/bear-191995.mp3?_=1"><source type="audio/mpeg" src="https://www.rjmprogramming.com.au/bear-191995.mp3?_=1"><a href="https://www.rjmprogramming.com.au/bear-191995.mp3">https://www.rjmprogramming.com.au/bear-191995.mp3</a></audio></mediaelementwrapper></div><div class="mejs-layers"><div class="mejs-poster mejs-layer" style="display: none; width: 100%; height: 100%;"></div></div><div class="mejs-controls"><div class="mejs-button mejs-playpause-button mejs-play"><button type="button" aria-controls="mep_0" title="Play" aria-label="Play" tabindex="0"></button></div><div class="mejs-time mejs-currenttime-container" role="timer" aria-live="off"><span class="mejs-currenttime">00:00</span></div><div class="mejs-time-rail"><span class="mejs-time-total mejs-time-slider" role="slider" tabindex="0" aria-label="Time Slider" aria-valuemin="0" aria-valuemax="0" aria-valuenow="0" aria-valuetext="00:00"><span class="mejs-time-buffering" style="display: none;"></span><span class="mejs-time-loaded"></span><span class="mejs-time-current"></span><span class="mejs-time-hovered no-hover"></span><span class="mejs-time-handle"><span class="mejs-time-handle-content"></span></span><span class="mejs-time-float"><span class="mejs-time-float-current">00:00</span><span class="mejs-time-float-corner"></span></span></span></div><div class="mejs-time mejs-duration-container"><span class="mejs-duration">00:00</span></div><div class="mejs-button mejs-volume-button mejs-mute"><button type="button" aria-controls="mep_0" title="Mute" aria-label="Mute" tabindex="0"></button></div><a class="mejs-horizontal-volume-slider" href="javascript:void(0);" aria-label="Volume Slider" aria-valuemin="0" aria-valuemax="100" aria-valuenow="100" role="slider"><span class="mejs-offscreen">Use Up/Down Arrow keys to increase or decrease volume.</span><div class="mejs-horizontal-volume-total"><div class="mejs-horizontal-volume-current" style="left: 0px; width: 100%;"></div><div class="mejs-horizontal-volume-handle" style="left: 100%;"></div></div></a></div></div></div>

Yesterday’s Speech to Text YouTube SubRip Subtitles Tutorial


Previous relevant Speech to Text YouTube SubRip Subtitles Tutorial is shown below.

Speech to Text YouTube SubRip Subtitles Tutorial

Speech to Text YouTube SubRip Subtitles Tutorial

Do you remember some way back with Text to Speech macOS Say Large Data Tutorial

So far, it seems, until today, and we were surprised, we’d only been thinking ….

  • Text to Speech macOS say … usage, and expecting success with … Small Amounts of Data … but today, with a future plan in mind we announce …
  • Text to Speech macOS say Large Data Mark I

… an idea we had was the motivation for the recent Text to Speech work? Part of that “set of ideas” was work to do with Speech to Text we only allow functionality interfacing with …

  • non-mobile
  • Google Chrome
  • https: protocol
  • top window

… environments. Today, as a sidestep to the work of yesterday’s Text to Speech macOS Say Large Data Local Web Server Tutorial, but all part of that same set of ideas, we’re not there, but starting down that “integration road” inspired by the great Google Web Speech Demonstration.

Codewise that involved …


Previous relevant Text to Speech macOS Say Large Data Local Web Server Tutorial is shown below.

Text to Speech macOS Say Large Data Local Web Server Tutorial

Text to Speech macOS Say Large Data Local Web Server Tutorial

Are all kludges coming from the “optimistic side of the mind equation“? Today, we did one regarding integrating “say” (which is macOS based only) in our changed macos_say_record.php PHP Voiceover inhouse web application to a local macOS Apache/PHP/MySql web server such as MAMP to see where we are going with all this, when choosing one of the “say” dropdown options, public website “button integration” via Safari web browser …

Where we ran out of options on server and client sides, and just optimistically presented a button in hope, with the understanding we had insufficient proof that clicking on that button would result in navigation to a legitimate local web server URL such as is on a macOS MAMP local web server environment

… and wonder whether this is the case?!

Today’s “work remit” was really simple. On any of the (non argumentative) simplest public website incarnation calls of our Voiceover inhouse web application we wanted to …

  • not present any popup windows (improving on very kludgy efforts of the past) presenting …
  • an evidence based logic offering of a (newly presented) “say” button, the click of which navigates the user to a (so far just macOS local Apache/PHP/MySql web server MAMP port 8888 based) URL able to reach that user’s local operating system “say” command via PHP exec or passthru calls because they’ve got MAMP installed locally along with having macos_say_record.php local system positioning equate to

    HTTP://localhost:8888/macos_say_record.php

Ajax ideas, at document.body onload …

<?php echo ”

var errct=-1, saythere=0;

function lhchk() {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('saysub').style.backgroundColor='lightblue';
} else {
document.getElementById('saymode').size='3';
}
if (('' + document.URL + '#' + decodeURIComponent(('' + location.hash))).indexOf('media=') != -1) {
var duisb=(" . strlen($knownow) . " > 0 ? '" . $knownow . "' : decodeURIComponent(('' + document.URL + '#' + decodeURIComponent(('' + location.hash))).split('media=')[1].split('&JUNKET&')[0].split('#JUNKET#')[0]).replace(/\ /g,'+'));
if (duisb.indexOf('audio/') != -1) {
//alert(duisb);
//var woa=window.open('', '_blank', 'top=50,left=50,height=400,width=800');
//woa.document.write('<html><body>' + '<br><audio controls><source type=audio/' + duisb.split('audio/')[1].split(';')[0] + ' src=\"' + duisb + '\"></source></audio><br>');
document.getElementById('daudiolater').innerHTML+='<br><audio controls data-preload=none><source type=audio/' + duisb.split('audio/')[1].split(';')[0] + ' src=\"' + duisb + '\" data-onerror=\"playerError();\"></source></audio><br><br><br>';
} else if (duisb.indexOf('video/') != -1) {
document.getElementById('daudiolater').innerHTML+='<br><video controls data-preload=none><source type=video/' + duisb.split('video/')[1].split(';')[0] + ' src=\"' + duisb + '\" data-onerror=\"playerError();\"></source></video><br><br><br>';
} else if (duisb.indexOf('image/') != -1) {
document.getElementById('daudiolater').innerHTML+='<br><img src=\"' + duisb + '\"></img><br>';
} else if (duisb.indexOf('_macoshelp_') != -1) {
document.getElementById('daudiolater').innerHTML+='<br><audio controls data-preload=none><source type=audio/" . $nowknow . " src=\"' + duisb + '\" data-onerror=\"playerError();\"></source></audio><br><br><br>';
}
} else if (('' + document.URL + '#' + decodeURIComponent(('' + location.hash))).indexOf('residue=') != -1) {
document.getElementById('tempidue').value=decodeURIComponent(document.URL.split('tempidue=')[1].split('&')[0].split('#')[0]);
document.getElementById('residue').value=decodeURIComponent(('' + location.hash)).split('residue=')[1].replace(/\ /g,'+');
document.getElementById('trsbut').click();
}

if (document.URL.indexOf('//localhost') == -1 && document.URL.indexOf('?') == -1 && document.URL.indexOf('&') == -1 && document.URL.indexOf('#') == -1) {
if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
if ('notpost' == '" . $notpost . "') {
//opi=window.open('HTTP://localhost:8888/macos_say_record.php?areyou=there', 'theproofif');
zhr = new XMLHttpRequest();
zform=new FormData();
zform.append('areyou', 'there');
zhr.open('get', 'HTTP://localhost:8888/macos_say_record.php', true);
//zhr.setRequestHeader('Access-Control-Allow-Headers', '*');
//zhr.setRequestHeader('Access-Control-Allow-Origin', '*');
//zhr.setRequestHeader('Access-Control-Allow-Methods', 'GET');
zhr.addEventListener('error', errmampshowStuff);
zhr.onreadystatechange = mampshowStuff;
//document.title=' ';
errct=0;
zhr.send(zform);

setTimeout(maybehthree, 5000);
}
}
} else if (document.URL.indexOf('rjmprogramming.com.au/macos_say_record.php') != -1 && document.URL.indexOf('?areyou=there') != -1) {
saythere=saythere; //opi=window.open('//www.rjmprogramming.com.au/macos_say_record.php?there=youare', 'theproofif');
} else if (document.URL.indexOf('//localhost') != -1 && document.URL.indexOf('?') == -1 && document.URL.indexOf('#') == -1) {
saythere=7; //opi=window.open('HTTP://localhost:8888/macos_say_record.php?areyou=there', 'theproofif');
}
}


function errmampshowStuff(evt) {
//document.title+=' ' + zhr.readyState + '|' + zhr.status + '|' + zhr.statusText;
//alert(('response error:', evt.currentTarget.response));
//console.warn(evt);
errct++;
}

function mampshowStuff(evt) {
//document.title+=' ' + zhr.readyState + '/' + zhr.status + '/' + zhr.statusText;
if (zhr.readyState == 4) {
if (zhr.status == 200) {
if (1 == 2) { alert(zhr.responseText); }
}
}
}

“; ?>

… supply the tenuous “evidence based logic” to then try directly calling the macOS MAMP port 8888 based URL into an iframe …


<iframe data-onerror=alert(564); onload=resproof(this); name=theproofif id=theproofif style=display:none; src='/About_Us.html'></iframe>

via


function tosay() {
saythere=6;
location.href='HTTP://localhost:8888/macos_say_record.php';
}

function tosayw() {
saythere=5;
opi=window.open('HTTP://localhost:8888/macos_say_record.php', '_blank');
}

function tosayp() {
saythere=4;
opi=window.open('HTTP://localhost:8888/macos_say_record.php', '_blank', 'top=100,left=' + eval(-800 + screen.width) + ',width=800,height=800');
}

function maybehthree() {
if (errct >= 0 && errct < 3) { console.warn('Errct=' + errct + ' ' + navigator.userAgent); if (navigator.userAgent.indexOf('Safari') != -1) { document.getElementById('myh3').innerHTML+=' ++';
} else {
document.getElementById('myh3').innerHTML+=' ';
}
try {
if (navigator.userAgent.indexOf('Safari') != -1) {
window.open('HTTP://localhost:8888/macos_say_record.php?areyou=there', 'theproofif');
} else {
document.getElementById('theproofif').src='HTTP://localhost:8888/macos_say_record.php?areyou=there';
}
} catch(rteqwe) {
if (1 == 4) { alert('iferr'); }
}

saythere=1;
} else {
console.warn('errct=' + errct + ' ' + navigator.userAgent);
}
}

function resproof(iois) {
if (iois != null) {
console.warn('erRct=' + errct + ' ' + navigator.userAgent);
//alert(1);
var aconto = (iois.contentWindow || iois.contentDocument);
//alert(2);
console.warn('erRCt=' + errct + ' ' + navigator.userAgent);
if (aconto != null) {
//alert(3);
//document.getElementById('myh3').innerHTML+='=';
console.warn('ErRct=' + errct + ' ' + navigator.userAgent);
if (document.getElementById('locbutone') && ('' + iois.src).replace('_proof','_record.php').indexOf('/macos_say_record.php') != -1 && ('' + iois.src).indexOf('//localhost') != -1) {
//document.getElementById('myh3').innerHTML+='+';
console.warn('ErRcT=' + errct + ' ' + navigator.userAgent);
if (document.URL.indexOf('//localhost') == -1 && iois.src.indexOf('//localhost') != -1 && iois.src.indexOf('?areyou=there') != -1) {
//alert('here ' + iois.src);
console.warn('ERRCT = ' + errct + ' ' + navigator.userAgent);
document.getElementById('locbutone').style.display='inline-block';
document.getElementById('locbuttwo').style.display='inline-block';
document.getElementById('locbutthree').style.display='inline-block';
saythere=2;
}
}
if (aconto.document) { aconto = aconto.document; }
//alert(4);
//document.getElementById('myh3').innerHTML+='-';
console.warn('ErRCt=' + errct + ' ' + navigator.userAgent);
if (aconto.body != null) {
//document.getElementById('myh3').innerHTML+='@';
console.warn('ERRct=' + errct + ' ' + navigator.userAgent);
//alert(5);
if (('' + iois.src).replace('_proof','_record.php').indexOf('/macos_say_record.php') != -1 && ('' + iois.src).indexOf('//localhost') != -1) {
//document.getElementById('myh3').innerHTML+='+';
console.warn('ERRCt=' + errct + ' ' + navigator.userAgent);
if (document.getElementById('locbutone') && document.URL.indexOf('//localhost') == -1 && ('' + iois.src).replace('_proof','_record.php').indexOf('/macos_say_record.php') != -1 && iois.src.indexOf('?areyou=there') != -1) {
console.warn('ERRCT=' + errct + ' ' + navigator.userAgent);
//alert('here ' + iois.src);
document.getElementById('locbutone').style.display='inline-block';
document.getElementById('locbuttwo').style.display='inline-block';
document.getElementById('locbutthree').style.display='inline-block';
saythere=3;
}
}
}
}
}
}

… adding this idea onto the progress of yesterday’s Text to Speech macOS Say Large Data Sharing Tutorial.

Satisfying not resorting to kludgy popup window involvement, but only sidestepping CORS issues working with a cross-domain scenario, rather than a scientific and rigorous solution. Sometimes needs must?!


Previous relevant Text to Speech macOS Say Large Data Sharing Tutorial is shown below.

Text to Speech macOS Say Large Data Sharing Tutorial

Text to Speech macOS Say Large Data Sharing Tutorial

Part of improving a web application regarding “large data” is offering some sharing functionality for “large data” scenarios, but this project we have learnt, it being unique regarding the “macOS only say” aspects to it, have taught us not to go overboard trying to cater for everything here. Yesterday’s Text to Speech macOS Say Large Data Tutorial got us started regarding “large data” scenarios where it was just designed for the single user usage. This does not require the transfer of data from that macOS local web browser environment up to a pubic website (Linux) web server environment, involving audio files that can become too large for comfort, often, here.

Our biggest dilemma in this work was, so far in testing we found, only the Firefox web browser would accept either of …

  • “a” “mailto:” link of too big a length involving the audio data URI contained in a hashtag, initiated from localhost MAMP environment
  • call of public website version of macos_say_record.php involving the audio data URI contained in a hashtag, initiated from localhost MAMP environment

… else the all too common …


about:blank#blocked

… would stymie our efforts in “large data” scenarios, where audio data URIs appear within the email link URL hashtag part. Guess we just lost 80% of the audience (except if we tell you now we rely less on audio data URIs appearing within the email link URL hashtag part). But we really wish users would not get spooked by seeing “about:blank#blocked” and think there is anything sinister necessarily, but rather try new web browsers, and try new ways of using free tools. What we are trying to show here, in a free way, is a bit of a way in to some aspects of what people refer to as “artificial intelligence” coming “out of the box” from an operating system. No service fee … just what should be happening from big players down to users on the Internet. It should be applauded, rather than suspected regarding “kludginess”, because the software basis is free, in contrast to the squillions of services popping up that are far from free.

Anyway, you can try downloading our changed macos_say_record.php PHP Voiceover inhouse web application to a local macOS Apache/PHP/MySql web server such as MAMP to see where we are going with all this, when choosing one of the “say” dropdown options, via …


HTTP://localhost:8888/macos_say_record.php

… say?!


Previous relevant Text to Speech macOS Say Large Data Tutorial is shown below.

Text to Speech macOS Say Large Data Tutorial

Text to Speech macOS Say Large Data Tutorial

So far, it seems, until today, and we were surprised, we’d only been thinking ….

  • Text to Speech macOS say … usage, and expecting success with … Small Amounts of Data … but today, with a future plan in mind we announce …
  • Text to Speech macOS say Large Data Mark I

… where you feed the wonderful macOS say command a whole block of code, say?! We did this in all innocence earlier today and … gasp … it failed.

Since then though, we’ve chipped away at some of the issues and discovered two ideas …

  1. for huge amounts of data the macOS say command has a useful …

    -f [inputFileName]

    … switch idea and for …
  2. command lines avoiding the use of ” or ‘ initial delimitation we can use backslash character escaping for those ascii characters less than (32 for) space

There’s more to “large data” issues in this our changed macos_say_record.php PHP Voiceover inhouse web application (that we last talked about with Haiku Image Tutorial) than this start today, but it is an encouraging start for our idea’s progression.

Why do we mention macOS when our public web server is Linux, in terms of operating systems? Yes, this work presupposes you have a macOS operating system in your life, because that is where you see the …


say

… command in its natural environment. Not a pretty sight at times …

Down, I say. “Say”, I down.

… but if you stick to the correct feeding times, well … you may just reap the benefits on a local Apache/PHP/MySql web server environment such as MAMP where we have our macos_say_record.php accessing passthru or exec accessing say via URL …


HTTP://localhost:8888/macos_say_record.php

… where the macOS “out of the box” say command, among other Voiceover ideas, is in play as the great Text to Speech tool that it is.


Previous relevant Haiku Image Tutorial is shown below.

Haiku Image Tutorial

Haiku Image Tutorial

Were you around when Python Cowsay API Cartoon Speech Media Tutorial‘s “genesis tutorial” called Python Cowsay API Primer Tutorial intimated …

… with an integration purpose in mind

? And then, sometime between then and now were you a “Doubting Thomas” thinking we’d forgotten about that statement? And while we’re at it, where were you on February 6, 2025 03:01 AEST?

I’m conflicted if your answers are “No” and “Robbing a bank” but, be that as it may, “we did have an integration purpose in mind” and we’ve come back to it via Haiku poetry, and a web application we wrote some time ago regarding them, and it interfaced to the theme of “the integration purpose in mind” … well you had to be there, said Putricia?!

Yes, it’s the case that hoping for the umpteenth re-researching whether anything manageable Linux wise can match what the great macOS say command has done for Speech to Text relations since Audrey Hepburn’s speech … and coming back with a “No” yet again … we started looking at it a bit more laterally and thought 😜😜 …

But what would the Cow say?

But seriously, no, we just stumbled onto the wonderful cowsay Python API / Command-line tool and wanted to … thinking laterally … have “cowsay” smarts be included into our changed macos_say_record.php PHP Voiceover inhouse web application, itself interfaced to by our changed haiku_animated_gif.html Haiku creating inhouse web application you can also try below …

… so that our changed latest draft can interface in a popup window scenario.


Previous relevant Python Cowsay API Cartoon Speech Media Tutorial is shown below.

Python Cowsay API Cartoon Speech Media Tutorial

Python Cowsay API Cartoon Speech Media Tutorial

As soon as a web application talks about image slides, as we have been dealing with allowing for the creation of cartoons with our recent cowsay Python API / Command-line tool interfacing PHP web application, maybe as Louis Lumière did many years ago, it brings out media thoughts regarding “moving pictures”. We use, here, at our RJM Programming AlmaLinux web server, the great Open Source ffmpeg to help create such media, in today’s case …

  • video
  • animated GIF

… productions using those image slides created via the (again, Open Source) cowsay Python API / Command-line tool …

<?php

if (isset($_GET['getvideo'])) {
$lenv='1';
if (isset($_GET['len'])) {
$lenv=$_GET['len'];
}
if ($_GET['getvideo'] == '1' && $lenv == '0') {
echo "<html><body onload=\" if (parent.document.getElementById('divvideo')) { parent.document.getElementById('divvideo').innerHTML='<video id=myvideo controls><source id=mysource type=video/mp4 src=' + String.fromCharCode(39) + 'data:video/mp4;base64," . base64_encode(file_get_contents('/tmp/video' . server_remote_addr() . '.mp4')) . "' + String.fromCharCode(39) + '></source></video>'; } else if (parent.document.getElementById('mysource')) { parent.document.getElementById('mysource').src='data:video/mp4;base64," . base64_encode(file_get_contents('/tmp/video' . server_remote_addr() . '.mp4')) . "'; } else { parent.document.getElementById('divmedia').innerHTML+='<br><br><p id=pvd>Video version below ... <a style=display:inline-block; href=#myh1>Back to top ...</a></p><br><div id=divvideo><video id=myvideo controls><source id=mysource type=video/mp4 src=' + String.fromCharCode(39) + 'data:video/mp4;base64," . base64_encode(file_get_contents('/tmp/video' . server_remote_addr() . '.mp4')) . "' + String.fromCharCode(39) + '></source></video></div>'; } setTimeout(function(){ parent.document.getElementById('pvd').scrollIntoView(); }, 2000); \"></body></html>";
} else {
if (file_exists('/tmp/video' . server_remote_addr() . '.mp4')) {
unlink('/tmp/video' . server_remote_addr() . '.mp4');
}
exec('ffmpeg -framerate 2 -i /tmp/slide_' . server_remote_addr() . '-%03d.png -vcodec libx264 -crf 22 /tmp/video' . server_remote_addr() . '.mp4');
echo "<html><body onload=\" if (parent.document.getElementById('divvideo')) { parent.document.getElementById('divvideo').innerHTML='<video id=myvideo controls><source id=mysource type=video/mp4 src=' + String.fromCharCode(39) + 'data:video/mp4;base64," . base64_encode(file_get_contents('/tmp/video' . server_remote_addr() . '.mp4')) . "' + String.fromCharCode(39) + '></source></video>'; } else if (parent.document.getElementById('mysource')) { parent.document.getElementById('mysource').src='data:video/mp4;base64," . base64_encode(file_get_contents('/tmp/video' . server_remote_addr() . '.mp4')) . "'; } else { parent.document.getElementById('divmedia').innerHTML+='<br><br><p id=pvd>Video version below ... <a style=display:inline-block; href=#myh1>Back to top ...</a></p><br><div id=divvideo><video id=myvideo controls><source id=mysource type=video/mp4 src=' + String.fromCharCode(39) + 'data:video/mp4;base64," . base64_encode(file_get_contents('/tmp/video' . server_remote_addr() . '.mp4')) . "' + String.fromCharCode(39) + '></source></video></div>'; } setTimeout(function(){ parent.document.getElementById('pvd').scrollIntoView(); }, 2000); \"></body></html>";
}
exit;
} else if (isset($_GET['getagif'])) {
$lenv='1';
if (isset($_GET['len'])) {
$lenv=$_GET['len'];
}
if ($_GET['getvideo'] == '1' && $lenv == '0') {
echo "<html><body onload=\" if (parent.document.getElementById('mygif')) { parent.document.getElementById('mygif').src='data:image/gif;base64," . base64_encode(file_get_contents('/tmp/agif' . server_remote_addr() . '.gif')) . "'; } else { parent.document.getElementById('divmedia').innerHTML+='<br><br><p id=pag>Animated GIF version below ... <a style=display:inline-block; href=#myh1>Back to top ...</a></p><br><img id=mygif src=data:image/gif;base64," . base64_encode(file_get_contents('/tmp/agif' . server_remote_addr() . '.gif')) . "></img>'; } setTimeout(function(){ parent.document.getElementById('pag').scrollIntoView(); }, 2000); \"></body></html>";
} else {
if (file_exists('/tmp/agif' . server_remote_addr() . '.gif')) {
unlink('/tmp/agif' . server_remote_addr() . '.gif');
}
exec('ffmpeg -framerate 2 -i /tmp/slide_' . server_remote_addr() . '-%03d.png /tmp/agif' . server_remote_addr() . '.gif');
echo "<html><body onload=\" if (parent.document.getElementById('mygif')) { parent.document.getElementById('mygif').src='data:image/gif;base64," . base64_encode(file_get_contents('/tmp/agif' . server_remote_addr() . '.gif')) . "'; } else { parent.document.getElementById('divmedia').innerHTML+='<br><br><p id=pag>Animated GIF version below ... <a style=display:inline-block; href=#myh1>Back to top ...</a></p><br><img id=mygif src=data:image/gif;base64," . base64_encode(file_get_contents('/tmp/agif' . server_remote_addr() . '.gif')) . "></img>'; } setTimeout(function(){ parent.document.getElementById('pag').scrollIntoView(); }, 2000); \"></body></html>";
}
exit;
}

?>

… as a new optional piece of additional functionality offered in our changed “fifth draft” (picking up from Python Cowsay API Cartoon Speech Content Tutorial‘s fourth draft, and further to yesterday’s Text to Image via ImageMagick Primer Tutorial) Cartoon creation and email sharing capable PHP web application you can also try below.


Previous relevant Text to Image via ImageMagick Primer Tutorial is shown below.

Text to Image via ImageMagick Primer Tutorial

Text to Image via ImageMagick Primer Tutorial

Why would a “Primer” tutorial point at a “well along the way” one? Well, a few reasons really …

Yes, the great ImageMagick (and we’re using it’s command line “convert” command here to make this happen) can convert text to images (ie. HTML img elements). Now, we’re not saying you always get perfect matches here, but it is akin to mere mortal dreamers think of as “intelligent scanning”. So, we wanted to have this sidetrack, and we will be resuming “normal transmission” shortly?!

We’ll leave you with some cowsay.php new relevant PHP code to ponder …

<?php

if (isset($_GET['fontlist'])) {
$selpop='';
if (!file_exists('/tmp/imfl.txt')) {
exec('convert -list font > /tmp/imfl.txt');
}
$fcont=file_get_contents('/tmp/imfl.txt');
if (strpos($fcont, 'family: ') !== false) {
$fcs=explode('family: ', $fcont);
for ($iuy=1; $iuy<sizeof($fcs); $iuy++) {
if (strpos($selpop, '>' . explode("\n", $fcs[$iuy])[0] . '<') === false) {
$selpop.="\n selo.innerHTML+='<option value=' + String.fromCharCode(39) + '" . explode("\n", $fcs[$iuy])[0] . "' + String.fromCharCode(39) + '>" . explode("\n", $fcs[$iuy])[0] . "</option>'; \n";
}
}
if ($selpop != '') {
echo "<html><body onload=\" var selos=parent.document.getElementsByTagName('select'); if (eval('' + selos.length) > 0) { var selo=selos[eval(-1 + selos.length)]; " . $selpop . " selo.style.display='inline-block'; selo.style.backgroundColor='#f0f0f0'; } \"></body></html>";
}
}
exit;
} else if (isset($_POST['text'])) {
$perlemoji='';
$emojilabbit="@- "; // vs perl
$iex='png';
$fnt='Courier';
$wdt='800';
$hgt='800';
$psiz='36';
$fcol='black';
$bcol='white';
if (isset($_POST['ext'])) { $iex=str_replace('+',' ',urldecode($_POST['ext'])); }
if (isset($_POST['ffam'])) { $fnt=str_replace('+',' ',urldecode($_POST['ffam'])); }
if (isset($_POST['width'])) { $pwdt=str_replace('+',' ',urldecode($_POST['width'])); }
if (isset($_POST['height'])) { $hgt=str_replace('+',' ',urldecode($_POST['height'])); }
if (isset($_POST['ptsize'])) { $psiz=str_replace('+',' ',urldecode($_POST['ptsize'])); }
if (isset($_POST['fcol'])) { $fcol=str_replace('+',' ',urldecode($_POST['fcol'])); }
if (isset($_POST['bcol'])) { $bcol=str_replace('+',' ',urldecode($_POST['bcol'])); }
$slidename='/tmp/imagerequest_' . server_remote_addr() . '-0.' . $iex;
file_put_contents('/tmp/imagerequest_' . server_remote_addr() . '-0.txt', str_replace('+',' ',urldecode($_POST['text'])));
file_put_contents('/tmp/maybeemojisP.txt', htmlspecialchars(str_replace('+',' ',urldecode($_POST['text'])), ENT_COMPAT,'UTF-8', true));
// yes no &#129684;
if (strpos(str_replace('+',' ',urldecode($_POST['text'])), '&#') !== false || strpos(str_replace('+',' ',urldecode($_POST['text'])), '&#') !== false) { // thanks to https://usage.imagemagick.org/text/#unicode
$outsofar=''; // '\x{201C}Unicode \x{2018}\x{263A}\x{2019} Please\x{201D}'
if (strpos(str_replace('+',' ',urldecode($_POST['text'])), '&#') !== false) {
$outs=explode('&#', str_replace('+',' ',urldecode($_POST['text'])));
$outsofar=$outs[0];
for ($ivx=1; $ivx<sizeof($outs); $ivx++) {
$decis=explode(';', $outs[$ivx])[0];
if (str_replace('0','',str_replace('1','',str_replace('2','',str_replace('3','',str_replace('4','',str_replace('5','',str_replace('6','',str_replace('7','',str_replace('8','',str_replace('9','',$decis)))))))))) != '') {
if (substr(strtolower($decis),0,1) == 'x') {
$outsofar.="\\x{" . substr($decis,1) . "}";
} else {
$outsofar.="\\x{" . $decis . "}";
}
} else {
$outsofar.="\\x{" . dechex($decis) . "}";
}
$outsofar.=substr($outs[$ivx],strlen($decis . ';'));
}
} else if (strpos(str_replace('+',' ',urldecode($_POST['text'])), '&#') !== false) {
$outs=explode('&#', str_replace('+',' ',urldecode($_POST['text'])));
$outsofar=$outs[0];
for ($ivx=1; $ivx<sizeof($outs); $ivx++) {
$decis=explode(';', $outs[$ivx])[0];
if (str_replace('0','',str_replace('1','',str_replace('2','',str_replace('3','',str_replace('4','',str_replace('5','',str_replace('6','',str_replace('7','',str_replace('8','',str_replace('9','',$decis)))))))))) != '') {
if (substr(strtolower($decis),0,1) == 'x') {
$outsofar.="\\x{" . substr($decis,1) . "}";
} else {
$outsofar.="\\x{" . $decis . "}";
}
} else {
$outsofar.="\\x{" . dechex($decis) . "}";
}
$outsofar.=substr($outs[$ivx],strlen($decis . ';'));
}
}
$labbit=$emojilabbit;
$perlemoji="perl -e 'binmode(STDOUT, \":utf8\"); print \"" . str_replace("\n", "\x{000A}", $outsofar) . '";' . "' | ";
}
if (strpos(str_replace('+',' ',urldecode($_POST['text'])), "\\") !== false) {
if ($perlemoji == '') { $labbit='"$(cat /tmp/imagerequest_' . server_remote_addr() . '-0.txt | ' . " sed '/\\\\/s//\\\\\\\\/g')" . '" '; }
file_put_contents('/tmp/imag.cmd', $perlemoji . 'convert -background "' . $bcol . '" -fill "' . $fcol . '" -size ' . $wdt . 'x' . $hgt . ' -font ' . $fnt . ' -pointsize ' . $psiz . ' label:' . $labbit . ' ' . $slidename);
exec($perlemoji . 'convert -background "' . $bcol . '" -fill "' . $fcol . '" -size ' . $wdt . 'x' . $hgt . ' -font ' . $fnt . ' -pointsize ' . $psiz . ' label:' . $labbit . ' ' . $slidename);
exec('chmod 777 ' . $slidename);
} else {
if ($perlemoji == '') { $labbit='"$(cat /tmp/imagerequest_' . server_remote_addr() . '-0.txt)' . '" '; }
file_put_contents('/tmp/imaG.cmd', $perlemoji . 'convert -background "' . $bcol . '" -fill "' . $fcol . '" -size ' . $wdt . 'x' . $hgt . ' -font ' . $fnt . ' -pointsize ' . $psiz . ' label:' . $labbit . ' ' . $slidename . ' ; chmod 777 ' . $slidename);
exec($perlemoji . 'convert -background "' . $bcol . '" -fill "' . $fcol . '" -size ' . $wdt . 'x' . $hgt . ' -font ' . $fnt . ' -pointsize ' . $psiz . ' label:' . $labbit . ' ' . $slidename);
exec('chmod 777 ' . $slidename);
}
if (isset($_POST['raw'])) {
header('Content-Type: image/' . $iex);
echo file_get_contents($slidename);
unlink($slidename);
unlink('/tmp/imagerequest_' . server_remote_addr() . '-0.txt');
exit;
} else {
echo "<html>
<body onload=\"
if (window.parent != window.self) {
var cnvs=parent.document.getElementsByTagName('canvas');
if (eval('' + cnvs.length) > 0) {
var imgsis=new Image();
imgsis.onload=function(event){
var canvasis=cnvs[0];
var cntxis=canvasis.getContext('2d');
cntxis.drawImage(event.target, 0, 0);
};
imgsis.src='data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "';
} else {
var imgs=parent.document.getElementsByTagName('img');
if (eval('' + imgs.length) > 0) {
imgs[0].src='data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "';
} else if (document.body.innerHTML == '') {
document.body.innerHTML='<img src=data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "></img><style> * { margin:0 0 0 0; padding:0 0 0 0; } img { border-top: 8px solid " . $bcol . "; }</style>';
} else {
document.body.innerHTML+='<br><img src=data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "></img>';
}
}
} else if (document.body.innerHTML == '') {
document.body.innerHTML='<img src=data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "></img><style> * { margin:0 0 0 0; padding:0 0 0 0; } img { border-top: 8px solid " . $bcol . "; }</style>';
} else {
document.body.innerHTML+='<br><img src=data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "></img>';
}
\"></body></html>";
unlink('/tmp/imagerequest_' . server_remote_addr() . '-0.txt');
try {
unlink($slidename);
} catch(Exception $esdw) { }
}
exit;
} else if (isset($_GET['text'])) {
$perlemoji='';
$emojilabbit="@- "; // vs perl
$iex='png';
$fnt='Courier';
$wdt='800';
$hgt='800';
$psiz='36';
$fcol='black';
$bcol='white';
if (isset($_GET['ext'])) { $iex=str_replace('+',' ',urldecode($_GET['ext'])); }
if (isset($_GET['ffam'])) { $fnt=str_replace('+',' ',urldecode($_GET['ffam'])); }
if (isset($_GET['width'])) { $pwdt=str_replace('+',' ',urldecode($_GET['width'])); }
if (isset($_GET['height'])) { $hgt=str_replace('+',' ',urldecode($_GET['height'])); }
if (isset($_GET['ptsize'])) { $psiz=str_replace('+',' ',urldecode($_GET['ptsize'])); }
if (isset($_GET['fcol'])) { $fcol=str_replace('+',' ',urldecode($_GET['fcol'])); }
if (isset($_GET['bcol'])) { $bcol=str_replace('+',' ',urldecode($_GET['bcol'])); }
$slidename='/tmp/imagerequest_' . server_remote_addr() . '-0.' . $iex;
file_put_contents('/tmp/imagerequest_' . server_remote_addr() . '-0.txt', str_replace('+',' ',urldecode($_GET['text'])));
file_put_contents('/tmp/maybeemojisG.txt', htmlspecialchars(str_replace('+',' ',urldecode($_GET['text'])), ENT_COMPAT,'UTF-8', true));
// yes no &#129684;
if (strpos(str_replace('+',' ',urldecode($_GET['text'])), '&#') !== false || strpos(str_replace('+',' ',urldecode($_GET['text'])), '&#') !== false) { // thanks to https://usage.imagemagick.org/text/#unicode
$outsofar=''; // '\x{201C}Unicode \x{2018}\x{263A}\x{2019} Please\x{201D}'
if (strpos(str_replace('+',' ',urldecode($_GET['text'])), '&#') !== false) {
$outs=explode('&#', str_replace('+',' ',urldecode($_GET['text'])));
$outsofar=$outs[0];
for ($ivx=1; $ivx<sizeof($outs); $ivx++) {
$decis=explode(';', $outs[$ivx])[0];
if (str_replace('0','',str_replace('1','',str_replace('2','',str_replace('3','',str_replace('4','',str_replace('5','',str_replace('6','',str_replace('7','',str_replace('8','',str_replace('9','',$decis)))))))))) != '') {
if (substr(strtolower($decis),0,1) == 'x') {
$outsofar.="\\x{" . substr($decis,1) . "}";
} else {
$outsofar.="\\x{" . $decis . "}";
}
} else {
$outsofar.="\\x{" . dechex($decis) . "}";
}
$outsofar.=substr($outs[$ivx],strlen($decis . ';'));
}
} else if (strpos(str_replace('+',' ',urldecode($_GET['text'])), '&#') !== false) {
$outs=explode('&#', str_replace('+',' ',urldecode($_GET['text'])));
$outsofar=$outs[0];
for ($ivx=1; $ivx<sizeof($outs); $ivx++) {
$decis=explode(';', $outs[$ivx])[0];
if (str_replace('0','',str_replace('1','',str_replace('2','',str_replace('3','',str_replace('4','',str_replace('5','',str_replace('6','',str_replace('7','',str_replace('8','',str_replace('9','',$decis)))))))))) != '') {
if (substr(strtolower($decis),0,1) == 'x') {
$outsofar.="\\x{" . substr($decis,1) . "}";
} else {
$outsofar.="\\x{" . $decis . "}";
}
} else {
$outsofar.="\\x{" . dechex($decis) . "}";
}
$outsofar.=substr($outs[$ivx],strlen($decis . ';'));
}
}
$labbit=$emojilabbit;
$perlemoji="perl -e 'binmode(STDOUT, \":utf8\"); print \"" . str_replace("\n", "\x{000A}", $outsofar) . '";' . "' | ";
}
if (strpos(str_replace('+',' ',urldecode($_GET['text'])), "\\") !== false) {
if ($perlemoji == '') { $labbit='"$(cat /tmp/imagerequest_' . server_remote_addr() . '-0.txt | ' . " sed '/\\\\/s//\\\\\\\\/g')" . '" '; }
//file_put_contents('/tmp/imag.cmd', 'convert -background "' . $bcol . '" -fill "' . $fcol . '" -size ' . $wdt . 'x' . $hgt . ' -font ' . $fnt . ' -pointsize ' . $psiz . ' label:"$(cat /tmp/imagerequest_' . server_remote_addr() . '-0.txt | ' . " sed '/\\\\/s//\\\\\\\\/g')" . '" ' . $slidename . ' ; chmod 777 ' . $slidename);
exec($perlemoji . 'convert -background "' . $bcol . '" -fill "' . $fcol . '" -size ' . $wdt . 'x' . $hgt . ' -font ' . $fnt . ' -pointsize ' . $psiz . ' label:' . $labbit . ' ' . $slidename);
exec('chmod 777 ' . $slidename);
} else {
if ($perlemoji == '') { $labbit='"$(cat /tmp/imagerequest_' . server_remote_addr() . '-0.txt)' . '" '; }
exec($perlemoji . 'convert -background "' . $bcol . '" -fill "' . $fcol . '" -size ' . $wdt . 'x' . $hgt . ' -font ' . $fnt . ' -pointsize ' . $psiz . ' label:' . $labbit . ' ' . $slidename);
exec('chmod 777 ' . $slidename);
}
if (isset($_GET['raw'])) {
header('Content-Type: image/' . $iex);
echo file_get_contents($slidename);
unlink($slidename);
unlink('/tmp/imagerequest_' . server_remote_addr() . '-0.txt');
exit;
} else {
echo "<html>
<body onload=\"
if (window.parent != window.self) {
var cnvs=parent.document.getElementsByTagName('canvas');
if (eval('' + cnvs.length) > 0) {
var imgsis=new Image();
imgsis.onload=function(event){
var canvasis=cnvs[0];
var cntxis=canvasis.getContext('2d');
cntxis.drawImage(event.target, 0, 0);
};
imgsis.src='data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "';
} else {
var imgs=parent.document.getElementsByTagName('img');
if (eval('' + imgs.length) > 0) {
imgs[0].src='data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "';
} else if (document.body.innerHTML == '') {
document.body.innerHTML='<img src=data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "></img><style> * { margin:0 0 0 0; padding:0 0 0 0; } img { border-top: 8px solid " . $bcol . "; }</style>';
} else {
document.body.innerHTML+='<br><img src=data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "></img>';
}
}
} else if (document.body.innerHTML == '') {
document.body.innerHTML='<img src=data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "></img><style> * { margin:0 0 0 0; padding:0 0 0 0; } img { border-top: 8px solid " . $bcol . "; }</style>';
} else {
document.body.innerHTML+='<br><img src=data:image/" . $iex . ";base64," . base64_encode(file_get_contents($slidename)) . "></img>';
}
\"></body></html>";
unlink('/tmp/imagerequest_' . server_remote_addr() . '-0.txt');
try {
unlink($slidename);
} catch(Exception $esdw) { }
}
exit;
}

?>


Previous relevant Python Cowsay API Cartoon Speech Content Tutorial is shown below.

Python Cowsay API Cartoon Speech Content Tutorial

Python Cowsay API Cartoon Speech Content Tutorial

If you were to ask most people what is more onerous filling in online web forms on the way to making something happen …

  • we’re guessing, rather than saying button presses
  • we’re guessing, they’re more likely to say typing out text …

… with it’s associated tabbing out to negotiate as well. But, supposing we could offer you a “speech to text” approach to performing “typing out text” in our latest cowsay Python API / Command-line tool interfacing PHP web application?

For some years now, we’ve interfaced to a …

  • non-mobile
  • Google Chrome
  • secure URL via https: protocol
  • allowing access to microphone

… means by which we normally access via a “top” hierarchy level call to our inhouse Google Speech to Text API interfacing web application helper.

Isn’t a popup window awkward here? Well, you might think so, but today, we discovered with the Google Chrome browser we used on macOS …

  • we initially call our inhouse Google Speech to Text API interfacing web application helper as a popup sitting in front of the cowsay interfacing parent window …
    <?php echo ”

    function anop() {
    if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
    topwo=window_open('https://www.google.com/intl/en/chrome/demos/speech.html','_blank','top=120,left=' + eval(eval('' + screen.width) - 690) + ',width=690,height=550');
    setTimeout(function(){ topwo.scrollTo(0,0); topwo.document.getElementById('tdm').style.opacity='0.0'; }, 6000);
    setInterval(function(){ if (!topwo.closed) { topwo.focus(); } topwo.location.href='https://www.rjmprogramming.com.au/PHP/speech_supervisor.php?rand=' + Math.floor(Math.random() * 1987967) + '&mode=4'; setTimeout(function(){ topwo.scrollTo(0,0); topwo.document.getElementById('tdm').style.opacity='0.0'; }, 6000); }, 30000);
    } else {
    topwo=window.open('https://www.rjmprogramming.com.au/PHP/speech_supervisor.php?rand=' + Math.floor(Math.random() * 1987967) + '&mode=4','_blank','top=120,left=' + eval(eval('' + screen.width) - 690) + ',width=690,height=550');
    setTimeout(function(){ topwo.scrollTo(0,0); topwo.document.getElementById('tdm').style.opacity='0.0'; }, 6000);
    setInterval(function(){ if (!topwo.closed) { topwo.focus(); } topwo.location.href='https://www.rjmprogramming.com.au/PHP/speech_supervisor.php?rand=' + Math.floor(Math.random() * 1987967) + '&mode=4'; setTimeout(function(){ topwo.scrollTo(0,0); topwo.document.getElementById('tdm').style.opacity='0.0'; }, 6000); }, 30000);
    }
    }

    “; ?>
  • and found that it was visible until any click or focus back to the cowsay interfacing parent window … normally an annoyance …
  • but not if …
    1. we semi regularly reload the our inhouse Google Speech to Text API interfacing web application helper … to refresh it’s red “recording” button instigation … and then …
    2. even if it remains hidden, it is still apparent to the focussed cowsay interfacing parent window on account of an orange “microphone on recording” icon appearing for the Google Chrome web browser user up at it’s Menu Bar … and …
    3. audio being “sight independent” the user does not have to refocus our inhouse Google Speech to Text API interfacing web application helper, just talk into the microphone just after that new icon appears … so that …
    4. the Google Speech to Text smarts help transfer that resultant text over to the textarea of the cowsay interfacing parent window, even avoiding any need to tab out of that textarea element … ahead of …
    5. the rest of the dropdown selections and button presses needed to achieve the user aim of establishing a new slide, perhaps for a Cartoon being created

… you can see happening with today’s animated GIF presentation on top of the work of yesterday’s Python Cowsay API Cartoon Tutorial in our changed “fourth draft” Cartoon creation and email sharing capable PHP web application you can also try below.


Previous relevant Python Cowsay API Cartoon Tutorial is shown below.

Python Cowsay API Cartoon Tutorial

Python Cowsay API Cartoon Tutorial

We’ve long been interested in online web application ideas that end up with a half decent cartoon the user can create, and share, themselves. “Half decent” becomes “fully decent” with a user who has a great imagination. And so, onto yesterday’s Python Cowsay API Primer Tutorial‘s start with interfacing to the great cowsay Python API / Command-line tool we access via the PHP exec method conduit to our AlmaLinux Apache/PHP/MySql Linux web server, today we’ve extended that …

  • “proof of concept” thinking … onto …
  • cartoon creation “smarts” … starting with (also egged on here by mobile platform problems with monospaced fonts, it seems like)
  • allowing a tabular display of our cowsay components … into …
  • table cells horizontally aligned (and so, less vulnerable to monospacing inaccuracies) … also allowing …
  • within any table cell there is a topmost th table cell wording part above a cowsay character td cell lower part …
  • “half decent” looking via static CSS
    <?php echo ”

    <style>
    margin: 0 0 0 0;
    padding: 0 0 0 0;
    tr { vertical-align: top; }
    td { vertical-align: top; }
    th { vertical-align: top; }

    * { font-family:'Courier New',Courier,monospace; }
    .img-hor { // thanks to https://stackoverflow.com/questions/32875695/flip-mirror-an-image-horizontally-vertically-with-css
    -moz-transform: scaleX(-1);
    -o-transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    transform: scaleX(-1);
    filter: FlipH;
    -ms-filter: 'FlipH';
    }
    .img-ver { // thanks to https://stackoverflow.com/questions/32875695/flip-mirror-an-image-horizontally-vertically-with-css
    -moz-transform: scaleY(-1);
    -o-transform: scaleY(-1);
    -webkit-transform: scaleY(-1);
    transform: scaleY(-1);
    filter: FlipV;
    -ms-filter: 'FlipV';
    }

    .glow {
    -webkit-animation: glow 1s linear infinite alternate;
    -moz-animation: glow 1s linear infinite alternate;
    animation: glow 1s linear infinite alternate;
    }

    /* Thanks to https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_glowing_text */

    @-webkit-keyframes glow {
    from {
    box-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #e60073, 0 0 9px #e60073, 0 0 11px #e60073, 0 0 13px #e60073, 0 0 15px #e60073;
    }

    to {
    box-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #ff4da6, 0 0 10px #ff4da6, 0 0 12px #ff4da6, 0 0 14px #ff4da6, 0 0 16px #ff4da6;
    }
    }

    th[id$='0'] {
    background: rgba(224,240,240,0.6); //#e0f0f0;
    }

    th[id$='1'] {
    background: rgba(225,241,241,0.6); //#e1f1f1;
    }

    th[id$='2'] {
    background: rgba(226,242,242,0.6); //#e2f2f2;
    }

    th[id$='3'] {
    background: rgba(227,243,243,0.6); //#e3f3f3;
    }

    th[id$='4'] {
    background: rgba(228,244,244,0.6); //#e4f4f4;
    }

    th[id$='5'] {
    background: rgba(229,245,245,0.6); //#e5f5f5;
    }

    th[id$='6'] {
    background: rgba(230,246,246,0.6); //#e6f6f6;
    }

    th[id$='7'] {
    background: rgba(231,247,247,0.6); //#e7f7f7;
    }

    th[id$='8'] {
    background: rgba(232,248,248,0.6); //#e2f2f2;
    }

    th[id$='9'] {
    background: rgba(233,249,249,0.6); //#e9f9f9;
    }

    td[id$='0'] {
    background: rgba(240,240,240,0.3); //#f0f0f0;
    text-shadow:-1px 1px 1px #ff2d90;
    }

    td[id$='1'] {
    background: rgba(241,241,241,0.3); //#f1f1f1;
    text-shadow:-1px 1px 1px #ff2d91;
    float: bottom;
    }

    td[id$='2'] {
    background: rgba(242,242,242,0.3); //#f2f2f2;
    text-shadow:-1px 1px 1px #ff2d92;
    }

    td[id$='3'] {
    background: rgba(243,243,243,0.3); //#f3f3f3;
    text-shadow:-1px 1px 1px #ff2d93;
    }

    td[id$='4'] {
    background: rgba(244,244,244,0.3); //#f4f4f4;
    text-shadow:-1px 1px 1px #ff2d94;
    }

    td[id$='5'] {
    background: rgba(245,245,245,0.3); //#f5f5f5;
    text-shadow:-1px 1px 1px #ff2d95;
    }

    td[id$='6'] {
    background: rgba(246,246,246,0.3); //#f6f6f6;
    text-shadow:-1px 1px 1px #ff2d96;
    }

    td[id$='7'] {
    background: rgba(247,247,247,0.3); //#f7f7f7;
    text-shadow:-1px 1px 1px #ff2d97;
    }

    td[id$='8'] {
    background: rgba(248,248,248,0.3); //#f8f8f8;
    text-shadow:-1px 1px 1px #ff2d98;
    }

    td[id$='9'] {
    background: rgba(249,249,249,0.3); //#f9f9f9;
    text-shadow:-1px 1px 1px #ff2d99;
    }

    table tbody tr:first-child {
    background: transparent; //#f6f6e6;
    }
    </style>

    “; ?>
    … and then …
  • whenever new cell content happens padding-top adding CSS Javascript DOM nuanced display logic via …
    <?php echo ”

    function paddingtopit() {
    var maxtwo=0, thistwo=0;
    var thhs=[], tdhs=[], it=0;
    var thdids=[];
    //trthtd1
    //trtdtd1
    var tds=document.getElementsByTagName('td');
    for (it=0; it<tds.length; it++) {
    if (('' + tds[it].id).indexOf('trtdtd') != -1) {
    if (('' + tds[it].style.paddingTop).replace(/^null/g,'').replace(/^undefined/g,'').trim() != '') {
    tds[it].style.paddingTop='0px';
    }
    }
    }
    for (it=0; it<tds.length; it++) {
    if (('' + tds[it].id).indexOf('trtdtd') != -1) {
    tdhs.push(eval('' + tds[it].getBoundingClientRect().height));
    thdids.push('' + tds[it].id);
    }
    }
    var ths=document.getElementsByTagName('th');
    for (it=0; it<ths.length; it++) {
    if (('' + ths[it].id).indexOf('trthtd') != -1) {
    thhs.push(eval('' + ths[it].getBoundingClientRect().height));
    thistwo=eval(thhs[it] + tdhs[it]);
    if (thistwo > maxtwo) { maxtwo=thistwo; }
    }
    }
    for (it=0; it<tdhs.length; it++) {
    thistwo=eval(thhs[it] + tdhs[it]);
    if (thistwo < maxtwo) {
    document.getElementById(thdids[it]).style.paddingTop='' + eval(maxtwo - thistwo) + 'px';
    }
    }
    }

    “; ?>
    … so that …
  • cartoons present with “speech bubble” wording aligned to the top in our “cells” (ie. th contenteditable=true editable wording on top of td horizontal flip (double click) and/or vertical flop (right click) editable lower part) with those characters aligned to the bottom

… in our changed “third draft” Cartoon creation and email sharing capable PHP web application you can also try below.


Previous relevant Python Cowsay API Primer Tutorial is shown below.

Python Cowsay API Primer Tutorial

Python Cowsay API Primer Tutorial

We discovered an interesting Open Source Python API / Command-line tool called cowsay which we installed up at our AlmaLinux web server via …


pip install cowsay

… with an integration purpose in mind, so thanks. Before many readers’ time indeed, but some may remember those cute banner printouts that told you who owned the next printout on a spooling “crude graphics” printout in the late 70’s … well cowsay encapsulates those heady days (and who can forget punch cards)?! Before integration, though, we want to test it via a new PHP supervisor on exec method Linux command line interfacings to cowsay.

So we started, with this “first draft” getting places and then this “second draft” with a little more sophistication to leave the day with this interfacer

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Not Categorised | Leave a comment

YouTube Video API Event Radio Play Idea Tutorial

YouTube Video API Event Radio Play Idea Tutorial

YouTube Video API Event Radio Play Idea Tutorial

The transistor radio is still out there and useful. Some radio stations still play continuous music for long periods of time, and, today …

… that loops through that playlist hundreds of times, as needed, for the user.

It’s likely, as a user of this web application, you’d want to add your own YouTube video interests ahead of setting any …

  • Radio … or …
  • One at a Time

… modes of use we turn on event.stopPropagation() for.

Why not do this for mobile?

The mobile platform adage “Play only occurs after a real user tap” makes the whole idea above too simplistic, at least for now, in our thinking …


function lhfind() {
var prevdelay=0, detbit='', karbit='', ijk=0, iijk=0, kji=0, randis=Math.floor(Math.random() * 1987865);
var lhparts=[], nextclose='', randiss=[randis], jjkk=0;
var detidtoclick='';
if (mode != '' && mode == mode.trim()) {
if (('' + location.hash).replace(/^\#/g,'').indexOf('#') != -1) {
mode+=' ';
lhparts=('' + location.hash).replace(/^\#/g,'').split('#');
switch (lhparts[0].toLowerCase()) {
case 'radio':
radioscr='';
//document.title='' + (lhparts.length);
//alert(lhparts.length);
for (ijk=1; ijk<lhparts.length; ijk+=3) {
if (lhparts[eval(2 + ijk)].trim() == '') { lhparts[eval(2 + ijk)]=lhparts[eval(0 + ijk)]; }
if (detidtoclick == '') {
detidtoclick='detbtobnine' + randis;
//issueoid.push('ifbtobnine' + randis);
radioscr=" document.getElementById(preregit('" + detidtoclick + "')).setAttribute('open',true); document.getElementById('" + detidtoclick.replace('det','if') + "').src= document.getElementById(regit('" + detidtoclick.replace('det','if') + "')).src.replace('c0=off','c0=on'); document.getElementById('" + detidtoclick.replace('det','if') + "').click(); ";
nextclose=" document.getElementById('" + detidtoclick + "').setAttribute('open', false); document.getElementById('" + detidtoclick + "').open=false; ";
prevdelay+=Math.round(eval(1000 * eval('' + lhparts[eval(1 + ijk)])));
} else {
//issueoid.push('ifbtobnine' + randis);
radioscr+=" setTimeout(function(){ " + nextclose + " document.getElementById(preregit('" + 'detbtobnine' + randis + "')).setAttribute('open',true); document.getElementById('" + 'ifbtobnine' + randis + "').src=document.getElementById(regit('" + 'ifbtobnine' + randis + "')).src.replace('c0=off','c0=on'); document.getElementById('" + 'ifbtobnine' + randis + "').click(); }, " + prevdelay + "); ";
nextclose=" document.getElementById('" + 'detbtobnine' + randis + "').setAttribute('open', false); document.getElementById('" + 'detbtobnine' + randis + "').open=false; ";
prevdelay+=Math.round(eval(1000 * eval('' + lhparts[eval(1 + ijk)])));
if (eval(3 + ijk) >= eval('' + lhparts.length)) {
for (kji=0; kji<200; kji++) {
jjkk=0;
for (iijk=1; iijk<lhparts.length; iijk+=3) {
radioscr+=" setTimeout(function(){ " + nextclose + " document.getElementById(preregit('" + 'detbtobnine' + randiss[eval(0 + jjkk)] + "')).setAttribute('open',true); document.getElementById('" + 'ifbtobnine' + randiss[eval(0 + jjkk)] + "').src=document.getElementById(regit('" + 'ifbtobnine' + randiss[eval(0 + jjkk)] + "')).src.replace('c0=off','c0=on'); document.getElementById('" + 'ifbtobnine' + randiss[eval(0 + jjkk)] + "').click(); }, " + prevdelay + "); ";
nextclose=" document.getElementById('" + 'detbtobnine' + randiss[eval(0 + jjkk)] + "').setAttribute('open', false); ";
prevdelay+=Math.round(eval(1000 * eval('' + lhparts[eval(1 + iijk)])));
jjkk++;
}
}
}
}
if (detbit == ' ') {
detbit+='<details onclick="document.getElementById(' + String.fromCharCode(39) + 'ifbtobnine' + randis + String.fromCharCode(39) + ').src=document.getElementById(regit(' + String.fromCharCode(39) + 'ifbtobnine' + randis + String.fromCharCode(39) + ')).src.replace(' + String.fromCharCode(39) + 'c0=off' + String.fromCharCode(39) + ',' + String.fromCharCode(39) + 'c0=on' + String.fromCharCode(39) + '); " id=detbtobnine' + randis + '><summary id=sumbtobnine' + randis + '><font size=2>' + decodeURIComponent(decodeURIComponent(lhparts[eval(2 + ijk)])) + '</font></summary><p><iframe onclick="event.stopPropagation();" style="width:100%;height:900px;" id="ifbtobnine' + randis + '" onload=" cif(this); if (top.document.URL.indexOf(' + String.fromCharCode(39) + 'showit=' + String.fromCharCode(39) + ') != -1) { document.getElementById(' + String.fromCharCode(39) + 'divsp' + String.fromCharCode(39) + ').style.display=' + String.fromCharCode(39) + 'block' + String.fromCharCode(39) + '; } " src="/HTMLCSS/karaoke_youtube_api.htm?youtubeid=' + lhparts[eval(0 + ijk)] + '&youtube_duration=' + ('' + lhparts[eval(1 + ijk)]).split('.')[0] + '.000&email=&email=&emoji=on&c0=on&i0=0&j0=' + ('' + lhparts[eval(1 + ijk)]).split('.')[0] + '&i1=&j1=&i2=&j2=&i3=&j3=&i4=&j4=&i5=&j5=&i6=&j6=&i7=&j7=&i8=&j8=&i9=&j9=&i10=&j10=&i11=&j11=&i12=&j12=&i13=&j13=&i14=&j14=&i15=&j15=&i16=&j16=&i17=&j17=&i18=&j18=&i19=&j19=&i20=&j20=&i21=&j21=&i22=&j22=&i23=&j23=&i24=&j24=&i25=&j25=&i26=&j26=&i27=&j27=&i28=&j28=&i29=&j29="></iframe><br></p></details>';
} else {
detbit+='<details onclick="document.getElementById(' + String.fromCharCode(39) + 'ifbtobnine' + randis + String.fromCharCode(39) + ').src=document.getElementById(regit(' + String.fromCharCode(39) + 'ifbtobnine' + randis + String.fromCharCode(39) + ')).src.replace(' + String.fromCharCode(39) + 'c0=off' + String.fromCharCode(39) + ',' + String.fromCharCode(39) + 'c0=on' + String.fromCharCode(39) + '); " id=detbtobnine' + randis + '><summary id=sumbtobnine' + randis + '><font size=2>' + decodeURIComponent(decodeURIComponent(lhparts[eval(2 + ijk)])) + '</font></summary><p><iframe onclick="event.stopPropagation();" style="width:100%;height:900px;" id="ifbtobnine' + randis + '" onload=" cif(this); if (top.document.URL.indexOf(' + String.fromCharCode(39) + 'showit=' + String.fromCharCode(39) + ') != -1) { document.getElementById(' + String.fromCharCode(39) + 'divsp' + String.fromCharCode(39) + ').style.display=' + String.fromCharCode(39) + 'block' + String.fromCharCode(39) + '; } " src="/HTMLCSS/karaoke_youtube_api.htm?youtubeid=' + lhparts[eval(0 + ijk)] + '&youtube_duration=' + ('' + lhparts[eval(1 + ijk)]).split('.')[0] + '.000&email=&email=&emoji=on&c0=off&i0=0&j0=' + ('' + lhparts[eval(1 + ijk)]).split('.')[0] + '&i1=&j1=&i2=&j2=&i3=&j3=&i4=&j4=&i5=&j5=&i6=&j6=&i7=&j7=&i8=&j8=&i9=&j9=&i10=&j10=&i11=&j11=&i12=&j12=&i13=&j13=&i14=&j14=&i15=&j15=&i16=&j16=&i17=&j17=&i18=&j18=&i19=&j19=&i20=&j20=&i21=&j21=&i22=&j22=&i23=&j23=&i24=&j24=&i25=&j25=&i26=&j26=&i27=&j27=&i28=&j28=&i29=&j29="></iframe><br></p></details>';
}
karbit=backiurl.replace('rand=', 'rand=' + Math.floor(Math.random() * 1987865));
randis=Math.floor(Math.random() * 1987865);
randiss.push(randis);
}
break;


case 'oneatatime':
radioscr='';
//document.title='' + (lhparts.length);
//alert(lhparts.length);
for (ijk=1; ijk<lhparts.length; ijk+=3) {
if (lhparts[eval(2 + ijk)].trim() == '') { lhparts[eval(2 + ijk)]=lhparts[eval(0 + ijk)]; }
if (detidtoclick == '') {
detidtoclick='detbtobnine' + randis;
//issueoid.push('ifbtobnine' + randis);
radioscr=" document.getElementById(preregit('" + detidtoclick + "')).setAttribute('open',true); document.getElementById('" + detidtoclick.replace('det','if') + "').src= document.getElementById(regit('" + detidtoclick.replace('det','if') + "')).src.replace('c0=off','c0=on'); document.getElementById('" + detidtoclick.replace('det','if') + "').click(); ";
nextclose=" document.getElementById('" + detidtoclick + "').setAttribute('open', false); document.getElementById('" + detidtoclick + "').open=false; ";
prevdelay+=Math.round(eval(1000 * eval('' + lhparts[eval(1 + ijk)])));
} else {
//issueoid.push('ifbtobnine' + randis);
radioscr+=" setTimeout(function(){ " + nextclose + " document.getElementById(preregit('" + 'detbtobnine' + randis + "')).setAttribute('open',true); document.getElementById('" + 'ifbtobnine' + randis + "').src=document.getElementById(regit('" + 'ifbtobnine' + randis + "')).src.replace('c0=off','c0=on'); document.getElementById('" + 'ifbtobnine' + randis + "').click(); }, " + prevdelay + "); ";
nextclose=" document.getElementById('" + 'detbtobnine' + randis + "').setAttribute('open', false); document.getElementById('" + 'detbtobnine' + randis + "').open=false; ";
prevdelay+=Math.round(eval(1000 * eval('' + lhparts[eval(1 + ijk)])));
if (eval(3 + ijk) >= eval('' + lhparts.length)) {
for (kji=0; kji<200; kji++) {
jjkk=0;
for (iijk=1; iijk<lhparts.length; iijk+=3) {
radioscr+=" setTimeout(function(){ " + nextclose + " document.getElementById(preregit('" + 'detbtobnine' + randiss[eval(0 + jjkk)] + "')).setAttribute('open',true); document.getElementById('" + 'ifbtobnine' + randiss[eval(0 + jjkk)] + "').src=document.getElementById(regit('" + 'ifbtobnine' + randiss[eval(0 + jjkk)] + "')).src.replace('c0=off','c0=on'); document.getElementById('" + 'ifbtobnine' + randiss[eval(0 + jjkk)] + "').click(); }, " + prevdelay + "); ";
nextclose=" document.getElementById('" + 'detbtobnine' + randiss[eval(0 + jjkk)] + "').setAttribute('open', false); ";
prevdelay+=Math.round(eval(1000 * eval('' + lhparts[eval(1 + iijk)])));
jjkk++;
}
}
}
}
if (detbit == ' ') {
detbit+='<details onclick="document.getElementById(' + String.fromCharCode(39) + 'ifbtobnine' + randis + String.fromCharCode(39) + ').src=document.getElementById(regit(' + String.fromCharCode(39) + 'ifbtobnine' + randis + String.fromCharCode(39) + ')).src.replace(' + String.fromCharCode(39) + 'c0=off' + String.fromCharCode(39) + ',' + String.fromCharCode(39) + 'c0=on' + String.fromCharCode(39) + '); " id=detbtobnine' + randis + '><summary id=sumbtobnine' + randis + '><font size=2>' + decodeURIComponent(decodeURIComponent(lhparts[eval(2 + ijk)])) + '</font></summary><p><iframe onclick="event.stopPropagation();" style="width:100%;height:900px;" id="ifbtobnine' + randis + '" onload=" cif(this); if (top.document.URL.indexOf(' + String.fromCharCode(39) + 'showit=' + String.fromCharCode(39) + ') != -1) { document.getElementById(' + String.fromCharCode(39) + 'divsp' + String.fromCharCode(39) + ').style.display=' + String.fromCharCode(39) + 'block' + String.fromCharCode(39) + '; } " src="/HTMLCSS/karaoke_youtube_api.htm?youtubeid=' + lhparts[eval(0 + ijk)] + '&youtube_duration=' + ('' + lhparts[eval(1 + ijk)]).split('.')[0] + '.000&email=&email=&emoji=on&c0=on&i0=0&j0=' + ('' + lhparts[eval(1 + ijk)]).split('.')[0] + '&i1=&j1=&i2=&j2=&i3=&j3=&i4=&j4=&i5=&j5=&i6=&j6=&i7=&j7=&i8=&j8=&i9=&j9=&i10=&j10=&i11=&j11=&i12=&j12=&i13=&j13=&i14=&j14=&i15=&j15=&i16=&j16=&i17=&j17=&i18=&j18=&i19=&j19=&i20=&j20=&i21=&j21=&i22=&j22=&i23=&j23=&i24=&j24=&i25=&j25=&i26=&j26=&i27=&j27=&i28=&j28=&i29=&j29="></iframe><br></p></details>';
} else {
detbit+='<details onclick="document.getElementById(' + String.fromCharCode(39) + 'ifbtobnine' + randis + String.fromCharCode(39) + ').src=document.getElementById(regit(' + String.fromCharCode(39) + 'ifbtobnine' + randis + String.fromCharCode(39) + ')).src.replace(' + String.fromCharCode(39) + 'c0=off' + String.fromCharCode(39) + ',' + String.fromCharCode(39) + 'c0=on' + String.fromCharCode(39) + '); " id=detbtobnine' + randis + '><summary id=sumbtobnine' + randis + '><font size=2>' + decodeURIComponent(decodeURIComponent(lhparts[eval(2 + ijk)])) + '</font></summary><p><iframe onclick="event.stopPropagation();" style="width:100%;height:900px;" id="ifbtobnine' + randis + '" onload=" cif(this); if (top.document.URL.indexOf(' + String.fromCharCode(39) + 'showit=' + String.fromCharCode(39) + ') != -1) { document.getElementById(' + String.fromCharCode(39) + 'divsp' + String.fromCharCode(39) + ').style.display=' + String.fromCharCode(39) + 'block' + String.fromCharCode(39) + '; } " src="/HTMLCSS/karaoke_youtube_api.htm?youtubeid=' + lhparts[eval(0 + ijk)] + '&youtube_duration=' + ('' + lhparts[eval(1 + ijk)]).split('.')[0] + '.000&email=&email=&emoji=on&c0=off&i0=0&j0=' + ('' + lhparts[eval(1 + ijk)]).split('.')[0] + '&i1=&j1=&i2=&j2=&i3=&j3=&i4=&j4=&i5=&j5=&i6=&j6=&i7=&j7=&i8=&j8=&i9=&j9=&i10=&j10=&i11=&j11=&i12=&j12=&i13=&j13=&i14=&j14=&i15=&j15=&i16=&j16=&i17=&j17=&i18=&j18=&i19=&j19=&i20=&j20=&i21=&j21=&i22=&j22=&i23=&j23=&i24=&j24=&i25=&j25=&i26=&j26=&i27=&j27=&i28=&j28=&i29=&j29="></iframe><br></p></details>';
}
karbit=backiurl.replace('rand=', 'rand=' + Math.floor(Math.random() * 1987865));
randis=Math.floor(Math.random() * 1987865);
randiss.push(randis);
}
break;


default:
break;
}


if (detbit != '') {
document.getElementById('predivsp').innerHTML='';
document.getElementById('postdivsp').innerHTML=detbit;
if (karbit != '') { document.getElementById('karit').src=karbit; } //document.getElementById('karit').src.split('rand=')[0] + 'rand=' + Math.floor(Math.random() * 1987865);
document.getElementById('tacode').value=document.getElementById('divsp').outerHTML;
setTimeout(function(){ lastta=document.getElementById('tacode').value; }, 2000);
if (radioscr != '') {
//var xx=prompt(radioscr,radioscr);
setTimeout(function(){ eval('' + radioscr); }, 1000);
}
}
}
}
}

… further to yesterday’s YouTube Video API Event Stop Propagation Idea Tutorial.


Previous relevant YouTube Video API Event Stop Propagation Idea Tutorial is shown below.

YouTube Video API Event Stop Propagation Idea Tutorial

YouTube Video API Event Stop Propagation Idea Tutorial

We’re back using the YouTube API video playing themes of YouTube Video API Interfacer Audio Play Tutorial as a means to setting up a web application that may help explain …


event.stopPropagation();

… Javascript event control of it’s “bubbling” (up through an element hierarchy), in other words, depending where you place this, stopping it’s “bubbling up” at that element concerned …

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on links are still processed. If you want to stop those behaviors, see the preventDefault() method. It also does not prevent propagation to other event-handlers of the current element. If you want to stop those, see stopImmediatePropagation().

We find, around here, we don’t know we’ve created a need for event.stopPropagation() usage until we’ve stumbled onto it, most of the time, so trying to get in ahead of it with today’s proof of concept to event.stopPropagation() or not to event.stopPropagation() web application feels a bit novel to us, in a good way.

This means by which to toggle that mode of use was more straightforward than “data control” with our musical YouTube API video functionality allowing a user to choose and slot in their own video ideas via either …

  • YouTube video ID … 11 characters long … or …
  • search string to try to select a video, via a programmatically populated dropdown, with an 11 character long YouTube video ID

… asking us to do a fair bit of tweaking to our inhouse interfacing …

… you might want to try out, yourself, to see what we’re getting at here, below …


Previous relevant YouTube Video API Interfacer Audio Play Tutorial is shown below.

YouTube Video API Interfacer Audio Play Tutorial

YouTube Video API Interfacer Audio Play Tutorial

The recent Making Of Earth Scanner Legs Tutorial set us to thinking about how to offer a toggling arrangement between our inhouse YouTube Embedded Iframe API playing of …

  • video … with an incarnation of this that plays …
  • audio … “sort of” only (but able to be toggled back to video playing)

… and it got us wondering how to “dull out” a video. We chose the CSS …

<style>

iframe { filter: invert(45%); }

</style>

If you want a “complete dull out” try filter: invert(50%); … but we wanted to see controls down the bottom, still useful for audio only playing.

You can try this all out in the changed karaoke_youtube_api.htm inhouse YouTube video interfacer.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , | Leave a comment