Javascript Object New Method Creator Primer Tutorial

Javascript Object New Method Creator Primer Tutorial

Javascript Object New Method Creator Primer Tutorial

As with Javascript Microtask Primer Tutorial

  • HTML textarea elements … hosting …
  • Javascript code … we want to pass across via …
  • HTML form method=GET … featuring …
  • onsubmit event function logic (and from here on the two have logic differences) …

    function quickbtoa() {
    document.getElementById('newcode').value='' + window.btoa(document.getElementById('newcode').value);
    document.getElementById('usingcode').value='' + window.btoa(document.getElementById('usingcode').value);
    setTimeout(function(){
    document.getElementById('newcode').value='' + window.atob(document.getElementById('newcode').value);
    document.getElementById('usingcode').value='' + window.atob(document.getElementById('usingcode').value);
    }, 2000);
    document.getElementById('ifresults').style.display='block';
    return true;
    }

    … and …
  • received via …

    var newcodeinbtoaed=location.search.split('newcode=')[1] ? decodeURIComponent(location.search.split('newcode=')[1].split('&')[0]) : '';
    var usingcodeinbtoaed=location.search.split('usingcode=')[1] ? decodeURIComponent(location.search.split('usingcode=')[1].split('&')[0]) : '';
    var tag=null;


    function execute() {

    if (newcodeinbtoaed != '') {
    document.getElementById('newcode').value=window.atob(newcodeinbtoaed);
    }

    if (usingcodeinbtoaed != '') {
    document.getElementById('usingcode').value=window.atob(usingcodeinbtoaed);
    }

    if (newcodeinbtoaed != '') {
    tag = document.createElement('script');
    tag.setAttribute("type", "text/javascript");
    tag.innerHTML = window.atob(newcodeinbtoaed);
    document.body.appendChild(tag);
    document.getElementById('footer').innerHTML+='<hr>New Javascript Code</hr>';
    }

    if (usingcodeinbtoaed != '') {
    tag = document.createElement('script');
    tag.setAttribute("type", "text/javascript");
    tag.innerHTML = window.atob(usingcodeinbtoaed);
    document.body.appendChild(tag);
    document.getElementById('footer').innerHTML+='<hr>Using Javascript Code</hr>';
    }
    }

… same, same but different … we want to facilitate a user driven discovery modus operandi towards exploring Javascript object method usage, with a mind to the user creating …

  • overridden methods … and/or …
  • new methods

… and the example we supply as a default, with thanks to this great webpage whose reworking of …


String.fromCodePoint

… fallback has been used by us for years now.

But, Javascript being that incredibly flexible coding language that it is, based on Object Oriented Programming ( ie. OOP ) as required (think DOM, think OOPs) you can create new methods on the fly very easily (as you do so much with OOP).

Pardon our eternal naivety here, but we always think on this with wonder, because of the “verb” functional way we also think of, when we think of Javascript. To us, it’s like you can be inventing coding language on the fly, rather than just “obeying syntax rules”, if you see what we are getting at here. Javascript has this way of satisfying your needs, no matter how those needs roll! Amazing!

Anyway, we thought you might want to enter …

  • Javascript object method … whether that be new or overriding … along with optional …
  • Javascript using that new or overriding Javascript object method

… to try out our new “proof of concept” new Javascript method creator you might want to try below …


Previous relevant Javascript Microtask Primer Tutorial is shown below.

Javascript Microtask Primer Tutorial

Javascript Microtask Primer Tutorial

Javascript, in “clientside mode”, has many more asynchronous ideas than it used to, say, a decade ago, where it was mainly setTimeout and setInterval timer functions we turned to, in this regard. It used to be that any idea of “waiting for JS” was not on, but that does not have to be the case with the modern web browsers using “modern Javascript”. Today, for example, we’ve written a “proof of concept” web application making use of …


queueMicrotask

… with accompanying description …

A microtask is a short function which is executed after the function or program which created it exits and only if the JavaScript execution stack is empty, but before returning control to the event loop being used by the user agent to drive the script’s execution environment.

… which, as you may surmise, allows for a “jumping order of execution” paradigm with your Javascript.

The example code of the queueMicrotask informational webpage made us happy, thanks, and so we wrapped that into a “shell of user usage” by …

  • writing code in PHP … huh?! … so that …
  • we can use navigation via an HTML form method=POST … allowing for large amounts of user written Javascript code they want to dynamically execute … and …
  • as we mentioned with the recent PHP Tokeniser Primer Tutorial talking about “code as content, teamed with navigation using this code data” …
    1. we leave using Javascript window.btoa
      <?php echo ”

      function doit(tdiho) {
      document.getElementById('jcode').value=window.btoa(tdiho.innerText);
      document.getElementById('mysub').click();
      }

      “; ?>
      … hanging off an HTML td contenteditable=true onblur event logic idea … and …
    2. arrive back using PHP base64_decode
      <?php

      if (isset($_POST['jcode'])) {
      $thejcode=base64_decode($_POST['jcode']);
      }

      ?>

    … so as …

  • to better handle the transference of real “+” characters in your data (as code is apt to have)

… as you can see using today’s proof of concept queueMicrotask using web application you can also try below …

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

YouTube Video API Event Playlist Background Image Tutorial

YouTube Video API Event Playlist Background Image Tutorial

YouTube Video API Event Playlist Background Image Tutorial

Our current project last talked about with YouTube Video API Event Playlist Shuffle and Loop Tutorial started as a …

  • “proof of concept” one to allow for user testing of event.stopPropagation() Javascript event bubbling control usage … and yet, is also a …
  • player of YouTube videos using the YouTube API inhouse interfacing here

… and it is the second functionality we want to emphasize. In such scenarios, we sometimes apply an apt Background Image (we’re applying to all document.body) via


<style>
td { vertical-align: top; }
select { background-color: lightblue; }
option:not(:checked) { background-color: yellow; opacity: 0.5; }
textarea { background-color: #f0f0f0; }
body {
background-image:linear-gradient(rgba(255,255,255,0.8),rgba(255,255,255,0.8)),URL('/retro-music-concept-with-headphones-space.jpg');
background-size:cover;
background-repeat:no-repeat;
}

* { border-radius:10px; border-color:magenta; }
</style>

… and regarding /retro-music-concept-with-headphones-space.jpg we have Freepik to thank for the free headphones background image we found there and downloaded then uploaded into place.

While we’re talking styling another CSS measure we often use to change the aesthetics of a webpage look is to soften some squared off borders via the application of a border-radius.

The meta viewport tag came in handy for this project, as another layer, for mobile platforms, of allowing mobile gestures to genuinely improve the video viewing, for the user …


<meta id='myviewport' name='viewport' content='width=device-width, initial-scale=1, minimum-scale=0.1, maximum-scale=8, user-scalable=yes' >

Another matter with mobile usage and a personalized playlist play scenario was that the use of the Mute and Unmute checkboxes at the “grandparent” level did not amount to a real click at the “grandchild” level, and so we started involving Javascript confirm box querying of users here, and this satisfied as a real user click for mobile platform media play purposes.

Codewise, all of the “the three amigos”, at it again …

… got involved.


Previous relevant YouTube Video API Event Playlist Shuffle and Loop Tutorial is shown below.

YouTube Video API Event Playlist Shuffle and Loop Tutorial

YouTube Video API Event Playlist Shuffle and Loop Tutorial

We left our Song Playing web application in YouTube Video API Event Playlist Save and Recall Tutorial

  • on mobile, needing a lot of “user tap maintenance” to keep the “personalized playlist” (consisting of YouTube ID video) music rolling … hence our …

    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!

    … from a preceeding tutorial … well … we still allow that mode of use, but add to that, the possibility of …

  • on mobile or non-mobile, we now offer the referencing of …
    1. YouTube Playlist IDs (34 characters) … or …
    2. Spotify Playlist IDs (22 characters)

    … so that shuffling and, in the case of YouTube Playlists using the YouTube App (if on mobile), looping can be part of the mix in your Song Plays (now appearing in the web application title … doh!! … yay!!!!)

The way to access this new functionality, above, is via the “now always appearing” 🍪 ( &#127850; Cookie button ) new prompt window arrangement


var xname='';
if (('' + location.hash).replace(/^\#/g,'') != '') {
xname=prompt('Recall name for this playlist. Understand that 34 character words will be seen as YouTube Playlist IDs or 22 character words will be seen as Spotify Playlist IDs for which we will start the ball rolling, and present them ready for you to play. Spaces at front results in a request to us at RJM Programming to host your proposed playlist on our YouTube channel and we will return a 34 character ID you can use yourself in the textbox presented. Add spaces at end also to just attend to that email off to RJM Programming.', '');
} else {
xname=prompt('Please optionally enter a recallable YouTube (34) or Spotify (22) playlist ID we will save for you from here on in optionally suffixed by # hashtag separated playlist title. Understand that 34 character words will be seen as YouTube Playlist IDs or 22 character words will be seen as Spotify Playlist IDs for which we will start the ball rolling, and present them ready for you to play. Our supplied YouTube playlist ID example is Nala and Luna (mainly) but please use Cancel to avoid remembering this playlist into the future.', 'PLjsR7WjAKSPU-6URvzZ552o5cvQ2p2GYE#Nala and Luna');
if (xname != null) { if (eval('' + xname.indexOf('#')) > 0) { btoaname=encodeURIComponent(xname.split('#')[1].replace(/\ /g,'_')); xname=xname.split('#')[0]; } usethisnotlh=xname; }
}

… that is possible when no personalized playlist hashtag data is in the mix. If it is, well, that opens another whole story all the way through to allowing the user to (email) request the creation of their personalized list of YouTube video IDs becoming a public facing YouTube Playlist hosted on the RJM Programming YouTube Channel, whereby we moderate, here, and if all passes muster, we return a 34 character YouTube Playlist ID the user can save from then on as a playlist on mobile or non-mobile capable of shuffling and looping (if the YouTube App is invoked, on mobile).

We’ve allowed those YouTube search results to “linger longer” too, by replicating them at the “grandparent level” at the point of time we wipe them from the “parent level”, the latest set appearing just below those top three options we now have going for both non-mobile and mobile platforms.

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


Previous relevant YouTube Video API Event Playlist Save and Recall Tutorial is shown below.

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.


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

YouTube Video API Event Playlist Shuffle and Loop Tutorial

YouTube Video API Event Playlist Shuffle and Loop Tutorial

YouTube Video API Event Playlist Shuffle and Loop Tutorial

We left our Song Playing web application in YouTube Video API Event Playlist Save and Recall Tutorial

  • on mobile, needing a lot of “user tap maintenance” to keep the “personalized playlist” (consisting of YouTube ID video) music rolling … hence our …

    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!

    … from a preceeding tutorial … well … we still allow that mode of use, but add to that, the possibility of …

  • on mobile or non-mobile, we now offer the referencing of …
    1. YouTube Playlist IDs (34 characters) … or …
    2. Spotify Playlist IDs (22 characters)

    … so that shuffling and, in the case of YouTube Playlists using the YouTube App (if on mobile), looping can be part of the mix in your Song Plays (now appearing in the web application title … doh!! … yay!!!!)

The way to access this new functionality, above, is via the “now always appearing” 🍪 ( &#127850; Cookie button ) new prompt window arrangement


var xname='';
if (('' + location.hash).replace(/^\#/g,'') != '') {
xname=prompt('Recall name for this playlist. Understand that 34 character words will be seen as YouTube Playlist IDs or 22 character words will be seen as Spotify Playlist IDs for which we will start the ball rolling, and present them ready for you to play. Spaces at front results in a request to us at RJM Programming to host your proposed playlist on our YouTube channel and we will return a 34 character ID you can use yourself in the textbox presented. Add spaces at end also to just attend to that email off to RJM Programming.', '');
} else {
xname=prompt('Please optionally enter a recallable YouTube (34) or Spotify (22) playlist ID we will save for you from here on in optionally suffixed by # hashtag separated playlist title. Understand that 34 character words will be seen as YouTube Playlist IDs or 22 character words will be seen as Spotify Playlist IDs for which we will start the ball rolling, and present them ready for you to play. Our supplied YouTube playlist ID example is Nala and Luna (mainly) but please use Cancel to avoid remembering this playlist into the future.', 'PLjsR7WjAKSPU-6URvzZ552o5cvQ2p2GYE#Nala and Luna');
if (xname != null) { if (eval('' + xname.indexOf('#')) > 0) { btoaname=encodeURIComponent(xname.split('#')[1].replace(/\ /g,'_')); xname=xname.split('#')[0]; } usethisnotlh=xname; }
}

… that is possible when no personalized playlist hashtag data is in the mix. If it is, well, that opens another whole story all the way through to allowing the user to (email) request the creation of their personalized list of YouTube video IDs becoming a public facing YouTube Playlist hosted on the RJM Programming YouTube Channel, whereby we moderate, here, and if all passes muster, we return a 34 character YouTube Playlist ID the user can save from then on as a playlist on mobile or non-mobile capable of shuffling and looping (if the YouTube App is invoked, on mobile).

We’ve allowed those YouTube search results to “linger longer” too, by replicating them at the “grandparent level” at the point of time we wipe them from the “parent level”, the latest set appearing just below those top three options we now have going for both non-mobile and mobile platforms.

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


Previous relevant YouTube Video API Event Playlist Save and Recall Tutorial is shown below.

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.


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

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

ImageMagick Postscript Primer Tutorial

ImageMagick Postscript Primer Tutorial

ImageMagick Postscript Primer Tutorial

We could spend a lifetime telling you about the functionality of various ImageMagick guises and usages, further to the recent Imagick PHP Class Primer Tutorial. We’ve decided to live a little separated from ImageMagick, or we just know we would have dreams about command line switches that turn into snakes or command lines turning into congo lines or command lines telling me about ten things I was never meant to do.

The other day, though, we stumbled upon a webpage rekindling interest, which is far easier these days, with ImageMagick installed on our AlmaLinux web server here at RJM Programming. Mind you, we also had it installed on the old CentOS web server, but it was as if, on CentOS, we had never …

Released the Kraken

… with the lack of diskspace there on CentOS, also causing us unrest?! No such problems on AlmaLinux, we give thanks for.

Anyway, that webpage link got us thinking about where …

  • Ghostscript … a PDF conversion specialist suite of software, you’ll often associate with “hardcode” printout functionality … interplays with …
  • ImageMagick

… and the command line had us hooked again. So, we wrote a way you can get hooked too, effectively parsing a favoured ImageMagick “convert” (verb) command into switches, a bit like parsing a language sentence, using PHP.

What?!!!!

Yes, it looks bad, as far as security goes, but we do some checks for malicious usage, in our “proof of concept” ImageMagick command line, via PHP, channeller of Ghostscript ideas image creator web application.


Previous relevant Imagick PHP Class Primer Tutorial is shown below.

Form Target Self Primer Tutorial

Imagick PHP Class Primer Tutorial

We’re talking “class” today. Up until now, regarding the great ImageMagick suite of software, and it’s interactions with PHP, we’ve …

… in a first draft not installed here on CentOS but okay here with AlmaLinux. Am sure most people would concur that this is much more integrated approach for PHP …


<?php
// oil_painting_thumbnail.php
// RJM Programming - August, 2024
// Start using PHP Imagick class
$image=null;
if (!isset($_GET['image']) && !isset($_POST['image'])) {
echo "<html><head><scr" . "ipt type=text/javascript> function ask() { var bsh=prompt('See the default brightness, saturation, hue settings, black point %, white point % and change as desired ... 100,0,100,90,95 is grayscale ... darkest 90% of pixels are turned black, the brightest 5% are made white, and those between 90% and 95% are grey-scaled', document.getElementById('brightness').value + ',' + document.getElementById('saturation').value + ',' + document.getElementById('hue').value + ',' + document.getElementById('blackpoint').value + ',' + document.getElementById('whitepoint').value); if (bsh != null) { if (eval('' + bsh.split(',').length) == 5) { document.getElementById('brightness').value=bsh.split(',')[0]; document.getElementById('saturation').value=bsh.split(',')[1]; document.getElementById('hue').value=bsh.split(',')[2]; document.getElementById('blackpoint').value=bsh.split(',')[3]; document.getElementById('whitepoint').value=bsh.split(',')[4]; } } return true; } </scr" . "ipt></head><body><h1>Imagick Ideas</h1><h3>RJM Programming - August, 2024 ... thanks to https://www.php.net/manual/en/book.imagick.php and https://www.php.net/manual/en/imagick.contraststretchimage.php</h3><br><br><form action='./oil_painting_thumbnail.php' id=myform method=GET><input type=hidden name=brightness value=100 id=brightness></input><input type=hidden name=saturation value=0 id=saturation></input><input type=hidden name=hue value=100 id=hue></input><input type=hidden name=blackpoint value=90 id=blackpoint></input><input type=hidden name=whitepoint value=95 id=whitepoint></input><input style='width:70%;' type=text placeholder='Image to process ...' name=image id=image value=''></input><br><br><input onclick=\" document.getElementById('myform').method='GET'; \" type=submit style=background-color:orange; value=Negate></input> <input style=background-color:yellow; onclick=\" if (ask()) { document.getElementById('myform').method='POST'; } \" type=submit value='Contrast Stretch'></input></form></body></html>";
} else {
if (isset($_GET['image'])) {

header('Content-type: image/jpeg');

//Instantiate a new Imagick object
$image = new Imagick(realpath(urldecode($_GET['image'])));
$image->negateImage(false);

// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);

echo $image;
exit;

} else {
//Instantiate a new Imagick object
$image = new Imagick(realpath(urldecode($_POST['image'])));
list($width, $height) = array_values ($image->getImageGeometry());
$b=(isset($_POST['brightness']) ? $_POST['brightness'] : '100');
$s=(isset($_POST['saturation']) ? $_POST['saturation'] : '0');
$h=(isset($_POST['hue']) ? $_POST['hue'] : '100');
$bp=(isset($_POST['blackpoint']) ? $_POST['blackpoint'] : '90');
$wp=(isset($_POST['whitepoint']) ? $_POST['whitepoint'] : '95');
$image->modulateImage($b, $s, $h);
$image->contrastStretchImage($width * $height * ($bp / 100.0), $width * $height * ($wp / 100.0));
$image->writeImage('example_thumbnail.jpg');
echo "<html><body><p>My Changed Image " . urldecode($_POST['image']) . " ... brightness " . $b . ", saturation " . $s . ", hue " . $h . ", black point % " . $bp . "%, white point % " . $wp . "%</p><br><img src='./example_thumbnail.jpg'></img></body></html>";
exit;

}
}
?>

… to interface to the great ImageMagick image manipulation software.

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, Operating System, Tutorials | Tagged , , , , , , | Leave a comment

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