Walking Trip …

Walking Trip

Walking Trip

Offenbach's Suite ... Warts 'n All

Offenbach's Suite ... Warts 'n All

 📅  

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

Posted in Photography, Trips | Tagged , , | 34 Comments

Navigator Window Object Property Tutorial

Navigator Window Object Property Tutorial

Navigator Window Object Property Tutorial

The navigator object …

The navigator object contains information about the browser.

The navigator object is a property of the window object.

The navigator object is accessed with:

window.navigator or just navigator

… we’ve accessed mainly regarding it’s navigator.geolocation property we used, for instance, in the Earth Bearing Distance Missing Two Mobile Ring Revisit Tutorial‘s Missing Two web application, amongst several, helping it determine the user’s current position’s latitude and longitude.

Another web browser navigator object property still active (ie. many properties are becoming deprecated) is the …


navigator.language

… property. We tried it for the macOS Google Chrome web browser and it returned the locale …


en-US

… which would go back to the way the installation procedure installed it, we’re thinking, because we can’t remember tweaking any language settings within this Google Chrome browser. Other web browser brands showed locales en-GB and en-AU … so there you are!

We saw this as useful on our PHP RJM Programming Landing Page as a useful way to interface to Google Translate optional language translation (of the webpage as a whole barring iframe element content) for users, even English ones, because we set the translate from argument to a value auto (ie. “detect language”) in our Google Chrome (use of this) …


https://www-rjmprogramming-com-au.translate.goog/index.php?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=nui

… URL which can establish a new window, via the click/tap of a new lowish left overlayed div element labelled with the relevant locale, offering RJM Programming english based and changed …

HTML

<div id=gtview></div>
Javascript

<script>

function mywoit() {
var towhatlang=xowhatlang;
var twt=xwt;
window.open('https://www-rjmprogramming-com-au.translate.goog/index.php?_x_tr_sl=auto&_x_tr_tl=' + towhatlang + '&_x_tr_hl=' + twt + '&_x_tr_pto=nui', '_blank', 'height=' + eval(-40 + eval('' + screen.height)) + ',width=' + eval(-40 + eval('' + screen.width)) + ',left=20,top=20');
}

function orflag(thiscc) {
var dri=['127462','127463','127464','127465','127466','127467','127468','127469','127470','127471','127472','127473','127474','127475','127476','127477','127478','127479','127480','127481','127482','127483','127484','127485','127486','127487'];
var lri='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var ccsuff='', ccchar=' ', cde='';
for (var iccsuff=0; iccsuff<thiscc.length; iccsuff++) {
ccchar=thiscc.substring(iccsuff, eval(1 + eval('' + iccsuff))).toUpperCase();
ccsuff+=String.fromCodePoint(dri[eval('' + lri.indexOf(ccchar))]); //'&#' + dri[eval('' + lri.indexOf(ccchar))] + ';';
cde='.';
}
return ccsuff;
}

if (('' + navigator.language).indexOf('-') != -1 && ('' + navigator.language + ' ').substring(0,2) != 'EN' && document.URL.indexOf('rjmprogramming.com.au') != -1) {
setTimeout(function(){
var recti=null;
if (document.getElementById('myimg3')) {
recti=document.getElementById('myimg3').getBoundingClientRect();
document.getElementById('gtview').style.top='' + eval(-60 + eval('' + recti.bottom)) + 'px';
} else if (document.getElementById('dwrp')) {
recti=document.getElementById('dwrp').getBoundingClientRect();
document.getElementById('gtview').style.top='' + eval(-60 + eval('' + recti.top)) + 'px';
}
if (recti) {
document.getElementById('gtview').style.position='absolute';
document.getElementById('gtview').style.left='' + recti.left + 'px';
document.getElementById('gtview').style.width='60px';
document.getElementById('gtview').style.height='60px';
document.getElementById('gtview').style.zIndex='1111';
document.getElementById('gtview').style.cursor='pointer';
document.getElementById('gtview').style.backgroundColor='orange';
document.getElementById('gtview').style.textAlign='center';
document.getElementById('gtview').innerHTML='<br>' + ('' + navigator.language);
xowhatlang='' + navigator.language.split('-')[0];
xwt='' + navigator.language;
document.getElementById('gtview').setAttribute('data-letters', '' + navigator.language.split('-')[1]);
document.getElementById('gtview').setAttribute('data-flag', orflag('' + navigator.language.split('-')[1]));
document.getElementById('gtview').title='Google Translate this English written webpage to language code ' + xowhatlang;
document.getElementById('gtview').onclick=function(event){ mywoit(); };
document.getElementById('gtview').ontouchmove=function(event){ alert(event.target.title); };
setInterval(function(){ if (document.getElementById('gtview').innerHTML.indexOf('-' + document.getElementById('gtview').getAttribute('data-letters')) != -1) { document.getElementById('gtview').innerHTML=document.getElementById('gtview').innerHTML.replace('-' + document.getElementById('gtview').getAttribute('data-letters'),' ' + document.getElementById('gtview').getAttribute('data-flag')); } else { document.getElementById('gtview').innerHTML=document.getElementById('gtview').innerHTML.replace(' ' + document.getElementById('gtview').getAttribute('data-flag'),'-' + document.getElementById('gtview').getAttribute('data-letters')); } }, 10000);
}
}, 5000);
}
</script>

… index.php Landing Page content translations to language code en (ie. English), and then once opened, offers other language translation choices as per Google Translate’s capabilities.


Previous relevant Earth Bearing Distance Missing Two Mobile Ring Revisit Tutorial is shown below.

Earth Bearing Distance Missing Two Mobile Ring Revisit Tutorial

Earth Bearing Distance Missing Two Mobile Ring Revisit Tutorial

As well as mobile platform work regarding yesterday’s Earth Bearing Distance Missing Two Mobile Compass Revisit Tutorial‘s …

  • What is in the distance on the horizon? … via “telescope” 🔭 (&#128301;) emoji … and there is also the …
  • Show me a ring of places a set distance around a given one

… mobile (or non-mobile (just by entering 0.0000001 as the bearing)) functionality to simplify for the user knowing there is such functionality existing. And there is not much better than a new emoji “ring” 🛟 (&#128735;) emoji button to tap as revealed, within the user’s eyesight to help the user out.

On the iPhone size devices, in particular, with their virtual keyboards, ahead of that we can help by making the “up arrow” ⬆ (&#11014;) emoji that predates the “ring” emoji be within the user’s eyeline, where, at an opportune time we execute the Javascript …


setTimeout(function(){
location.href='#latf'; //document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=0.5, minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
setTimeout(function(){
var ris=document.getElementById('tdmid').getBoundingClientRect();
var newihis=document.getElementById('odntable').innerHTML; //.replace('ntable','mtable');
if (1 == 1) {
document.getElementById('odntable').innerHTML='';
} else {
document.getElementById('arrowup').style.visibility='hidden';
document.getElementById('arrowup').id='wasarrowup';
}
document.getElementById('tdmid').innerHTML=newihis; //document.getElementById('ntable').outerHTML.replace('ntable','mtable');
document.getElementById('ntable').style.visibility='hidden';
try {
document.getElementById('brg').setAttribute('data-ybrg', '' + eval(eval(720.0 + eval(0 * eval('' + wor)) + eval(1 * eval('' + dorbrg))) % 360.0));
} catch(rter) { }
//document.getElementById('ntable').style.position='fixed';
//document.getElementById('ntable').style.zIndex='786';
//document.getElementById('ntable').style.top='' + ris.top;
//document.getElementById('ntable').style.left='' + ris.left;
}, 2000);
}, 1000);

… where, as you can surmise, we went for relative positioning (for our “mobile only” issue), using a table cell of interest as a content “innerHTML” positioning means, rather than fighting what is often a lost course on mobile platforms, the non-relative positioning options of fixed or absolute (but don’t get the impression these are never useful … they are hugely useful to “overlay”).

Two new Javascript functions help out …


function brgblur() { // What is in the distance on the horizon?
document.getElementById('nodisplay').innerHTML='<input type=hidden name=nodis id=nodis value=y></input>';
tplacen+=String.fromCharCode(32); if (fplacen.trim().length != 0 && tplacen.trim().length == 0) { document.getElementById('brg').style.backgroundColor='pink'; cwhat[3]=false; cwhat[2]=false; if (!decided) { decided=true; } fillablemaybe(document.getElementById('brg')); } //document.getElementById('brg').click();
document.getElementById('brg').style.backgroundColor="pink"; cwhat[3]=false; cwhat[2]=false; if (!decided) { decided=true; } fillablemaybe(idms(idms(document.getElementById('brg')))); //document.getElementById('brg').blur();
document.getElementById('latf').readOnly=true;
setTimeout(function(){ document.getElementById('latf').readOnly=false; }, 8000);
document.getElementById('latf').focus();
}

function distblur() { // Show me a ring of places a set distance around a given one.
document.getElementById('nodisplay').innerHTML='<input type=hidden name=nodis id=nodis value=y></input>';
var adist=prompt('What is the ring distance you want to show, in meters ... if 0.0 we will calculate horizon distance as this value? As needed then tap Fill button to perform Ring Distance calculations.', '0.0');
if (adist == null) { adist=''; }
if (adist == '0.0' || (adist.trim() != '' && adist.trim().replace(/0/g,'').replace(/\./g,'').replace(/\-/g,'').replace(/\+/g,'') != '')) {
document.getElementById('brg').value='0.0000001';
document.getElementById('brg').style.backgroundColor='white';
if (adist != '0.0') {
document.getElementById('dist').value='' + adist.trim().replace(/\+/g,'');
} else {
document.getElementById('dist').focus();
if (1 == 1) { // assume 2m elevation ... thanks to https://en.wikipedia.org/wiki/Horizon
document.getElementById('dist').value='' + Math.floor(Math.pow(eval(eval(2.0 * eval('' + elev)) * 6371000.0), 0.5)) + '.000';
} else {
document.getElementById('dist').value='5000.000';
}
elev=2.0;
document.getElementById('dist').focus();
}
document.getElementById('dist').style.backgroundColor='yellow';
if (1 == 1) {
document.getElementById('ifill').type='submit';
document.getElementById('ifill').click();
} else {
dfillablemaybe(document.getElementById('dist')); //document.getElementById('ifill').click();
}
}
}

… in a changed missing_two.html‘s “Missing Two” web application


Previous relevant Earth Bearing Distance Missing Two Mobile Compass Revisit Tutorial is shown below.

Earth Bearing Distance Missing Two Mobile Compass Revisit Tutorial

Earth Bearing Distance Missing Two Mobile Compass Revisit Tutorial

Since the work of Earth Bearing Distance Missing Two Hashtagged Mailto Sharing Tutorial regarding …

  • it’s mobile (iPhone) gyroscope based compass logic … we were never quite sure regarding, with our old iPhone 6 … and so …
  • with an iPhone 13

… we’re using at the moment, it feels like it’s a happening thaing!

And so, it was time to revisit our inhouse Earth Bearing Distance Missing Two web application, which, for mobile users, wanted to help with the question …

What’s out there on the horizon in that direction?

… hopefully ahead of them running into a tree, running in that direction.

To make this process more straightforward an emoji “eye” 👁 button appears, along with associated x2 to respectively update yellow bearing and calculate in designated direction to horizon …


function dostuff(evt) {
var tis='';
evt.stopPropagation();
if (('' + evt.target.title) == 'What is out there?') {
brgblur();
} else {
tis=document.getElementById('arrowup').title;
document.getElementById('brg').value='' + document.getElementById('brg').getAttribute('data-ybrg');
document.getElementById('brg').style.backgroundColor='yellow';
if (!explained) {
evt.target.innerHTML='&#128065; <span onclick="event.stopPropagation(); brgblur();">x2</span>';
evt.target.title='What is out there?';
evt.target.ondblclick=function(){ brgblur(); };
}
explained=true;
alert(tis);
}
}

See a changed missing_two.html‘s “Missing Two” web application to try for yourself.


Previous relevant Earth Bearing Distance Missing Two Hashtagged Mailto Sharing Tutorial is shown below.

Earth Bearing Distance Missing Two Hashtagged Mailto Sharing Tutorial

Earth Bearing Distance Missing Two Hashtagged Mailto Sharing Tutorial

We’re returning to our Missing Two web application, after …

  • the recent Earth Bearing Distance Missing Two Earth Scanner Integration Tutorial Earth Scanner integration … because, today …
  • it becomes our “guinea pig” web application helping out the …
    1. Ajax … and …
    2. FormData … methodologies we use a lot around here in the past …
    3. calling PHP emailhtml.php … to send …
    4. emails containing (HTML perhaps) inline content or attachments … that being the “old way” being helped out by …
    5. intervention in the codes so that an “a” link “mailto:” with hashtagging scenario can augment this (ie. back it up)

    … approaches we use with lots of our web application sharing functionalities

We found, in a “first draft” look at this there were three parts to the solution.

At the PHP code of emailhtml.php PHP mail based email creator code add this near the end …
<?php

if ($mailto != '') {
echo "<ht" . "ml>
<he" . "ad>
<scr" . "ipt type='text/javascript'>
function mto() {
document.getElementById('amto').click();
}
</scr" . "ipt>
</he" . "ad>
<bo" . "dy onload=mto();>
<a target=_top style=display:none; href='" . $mailto . "' id=amto>Email</a>
</bo" . "dy></ht" . "ml>";
}


?>
… helped out by, at the correct place …
<?php

$mailto='mailto:' . $to . '?subject=' . str_replace('+','%20',urlencode($subject));
$mailto.='&body=https://www.rjmprogramming.com.au/htmlemail.html?rand=' . ('' . time());
$mailto.='#' . base64_encode(urlencode($hcont)); // base64_encode($hcont);


?>
… in the changed emailhtml.php PHP mail email inhouse interfacer
A totally new HTML/Javascript inhouse simple reader of hashtag data to display webpage data …

<html>
<head>
<title>Display Hashtagged HTML Data - RJM Programming - March, 2024</title>
<script type='text/javascript'>
var lh=(('' + location.hash).replace(/^null/g,'').replace(/^undefined/g,'')).replace(/^\#/g,'');
if (lh != '') {
if (lh.indexOf('JTNDY') == 0) {
lh=decodeURIComponent(window.atob(decodeURIComponent(lh))).replace(/\+/g,' ');
} else if (lh.indexOf(window.btoa('<')) == 0 || lh.indexOf('PGJ') == 0) {
lh=window.atob(lh).replace(/\+/g,' ');
} else {
lh=decodeURIComponent(lh).replace(/\+/g,' ');
}
}
var lhdatas=lh.split('data:');
var prefixer='"';
var bodyis='<body></body>', headis='';

for (var ilh=1; ilh<lhdatas.length; ilh++) {
prefixer=lhdatas[eval(-1 + ilh)].slice(-1).replace('(',')').replace('[',']').replace('{','}');
if (lhdatas[ilh].split(prefixer)[0].indexOf(' ') != -1) {
lh=lh.replace(lhdatas[ilh].split(prefixer)[0], lhdatas[ilh].split(prefixer)[0].replace(/\ /g,'+'));
}
}

if (lh.indexOf('</body>') != -1 && lh.indexOf('<body') != -1) {
bodyis='<body' + lh.split('<body')[1].split('</html>')[0];
} else if (lh.trim() != '' && lh.indexOf('<head') == -1) {
bodyis=lh;
}

if (lh.indexOf('</head>') != -1 && lh.indexOf('<head') != -1) {
headis='<head' + lh.split('<head')[1].split('</head>')[0] + '</head>';
document.write(headis.replace(/https\:\/\//g,'//').replace(/http\:\/\//g,'//') + bodyis.replace(/https\:\/\//g,'//').replace(/http\:\/\//g,'//'));
} else if (bodyis != '<body></body>') {
document.write(bodyis.replace(/https\:\/\//g,'//').replace(/http\:\/\//g,'//'));
}

</script>
</head>
<body>
</body>
</html>

… in htmlemail.html Hashtag Email Data Reader and Display “first draft”
Missing Two web application (as an example of what others will try to achieve, as time goes on) this way …

var xzhr=null;

xzhr = new XMLHttpRequest();
var xform=new FormData();
xform.append('inline','');
xform.append('to',em.trim());
if (em.trim() != em) {
xform.append('subj','Missing Two');
//var cbgtd=document.getElementById('tdlook').getBoundingClientRect();
xform.append('body','<body>' + document.body.innerHTML.replace(/\ id\=\"mysel\"/g, ' name="mysel" id="mysel"').replace(/\ size\=\"3\"/g, ' size="4"').replace(/\ data\-href\=/g, ' target=_blank href=').replace('</form>', '<br><br><input style=background-color:lightgreen; type=submit value=Solve></input></form>').replace('DISPLAY:table-row','DISPLAY:none').replace(lastfis,lasttis).replace(lasteis,lastenow).replace(lasteis2,lastenow2).replace(lastsis,lastsnow).replace(lastsis2,lastsnow2).replace('absolute;','absolute;display:none;').replace(flatf,tlatf).replace(flongf,tlongf).replace(flatt,tlatt).replace(flongt,tlongt).replace(fbrg,tbrg).replace(fdist,tdist) + '</body>');
} else {
xform.append('subj','Missing Two');
xform.append('body','<body>' + document.body.innerHTML.replace(/\ id\=\"mysel\"/g, ' name="mysel" id="mysel"').replace(/\ size\=\"3\"/g, ' size="4"').replace(/\ data\-href\=/g, ' target=_blank href=').replace('</form>', '<br><br><input style=background-color:lightgreen; type=submit value=Solve></input></form>').replace('DISPLAY:table-row','DISPLAY:none').replace(lastfis,lasttis).replace(lasteis,lastenow).replace(lasteis2,lastenow2).replace(lastsis,lastsnow).replace(lastsis2,lastsnow2).replace('absolute;','absolute;display:none;').replace(flatf,tlatf).replace(flongf,tlongf).replace(flatt,tlatt).replace(flongt,tlongt).replace(fbrg,tbrg).replace(fdist,tdist) + '</body>');
}
xzhr.onreadystatechange=stateChanged;
xzhr.open('post','//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php',true);
xzhr.send(xform);

… Ajax calling of …

function stateChanged() {
if (xzhr.readyState == 4) {
if (xzhr.status == 200) {
//alert(xzhr.response);
if (xzhr.response.indexOf('</a>') != -1) {
document.getElementById('mtodiv').innerHTML='<a' + xzhr.response.split('<a')[eval(-1 + xzhr.response.split('<a').length)].split('</a>')[0] + '</a>';
var alista=document.getElementsByTagName('a');
alista[eval(-1 + alista.length)].click();
}
}
}
}


… in a changed missing_two.html‘s “Missing Two” web application

The hashtagging email story continues!

Stop Press

A tweaked missing_two.html‘s “Missing Two” web application prioritizes timezone place name geolocations over other placename ideas.

Stop Press … 24/2/2025 …

A tweaked missing_two.html‘s “Missing Two” web application fixes up some gyroscope miscalculations, and sorry for the delay!


Previous relevant Earth Bearing Distance Missing Two Earth Scanner Integration Tutorial is shown below.

Earth Bearing Distance Missing Two Earth Scanner Integration Tutorial

Earth Bearing Distance Missing Two Earth Scanner Integration Tutorial

Today we’re combining precedents from …

… where we integrate the first into the second. Yes, you can code for a web application, to start with, normally, as a “topmost” one, but when it is asked to be “called upon” as a tool for another web application, lots of surprises can happen. Our surprise in this integration above, a bit different to a lot we do, was …

  • the Earth Scanner performs well in a popup window … but …
  • the Earth Scanner does not perform well in an iframe

… we guess, because of those calculations for the variables screenwidth and screenheight which are so crucial to the scrolling required for that Earth Scanner.

At first we thought we’d just whack into a popup window from the Missing Two host, a URL to the Earth Scanner relevant to the two places in the Missing Two web application. But then we had some time to think about it, and remembered how the work of Earth Scanner Map Image Margin Tutorial introduced …

  • a sliver of margin applied to the map image (big img element) … and we wondered “who owns that sliver?” … so, in case it was the document.body element, as we hoped, we’d try …
  • img element onclick event arrangement amendment …

    document.getElementById('myimg').onclick=function(event) { event.stopPropagation(); movesallowed=false; gmovesallowed=false; if (gdefv != '') { askfor=ourprompt(event,'Earth Scanner - RJM Programming - February, 2024 ... ' + String.fromCharCode(10) + 'Thanks to https://github.com/nvkelso/natural-earth-raster/blob/master/50m_rasters/HYP_50M_SR_W/HYP_50M_SR_W.README.html ... ' + String.fromCharCode(10) + 'Currently top left of screen is (Longitude,Latitude) ' + '(' + eval(-180 + xp * 360 / 100) + ',' + eval(90 - yp * 180 / 100) + ') and bottom right is (' + eval(-180 + screenlong + xp * 360 / 100) + ',' + eval(90 - screenlat - yp * 180 / 100) + ') and around the middle is (' + eval(-180 + eval(screenlong / 2) + xp * 360 / 100) + ',' + eval(90 - eval(screenlat / 2) - yp * 180 / 100) + ').' + String.fromCharCode(10) + 'Where do you want middle of screen to be in terms of Longitude,Latitude? Suffix with space to show meridians and/or prefix with space to not show meridians.', gdefv); gdefv=''; } else { askfor=ourprompt(event,'Earth Scanner - RJM Programming - February, 2024 ... ' + String.fromCharCode(10) + 'Thanks to https://github.com/nvkelso/natural-earth-raster/blob/master/50m_rasters/HYP_50M_SR_W/HYP_50M_SR_W.README.html ... ' + String.fromCharCode(10) + 'Currently top left of screen is (Longitude,Latitude) ' + '(' + eval(-180 + xp * 360 / 100) + ',' + eval(90 - yp * 180 / 100) + ') and bottom right is (' + eval(-180 + screenlong + xp * 360 / 100) + ',' + eval(90 - screenlat - yp * 180 / 100) + ') and around the middle is (' + eval(-180 + eval(screenlong / 2) + xp * 360 / 100) + ',' + eval(90 - eval(screenlat / 2) - yp * 180 / 100) + ').' + String.fromCharCode(10) + 'Where do you want middle of screen to be in terms of Longitude,Latitude? Suffix with space to show meridians and/or prefix with space to not show meridians.', ''); } if (('' + askfor).replace('(','').replace(')','').replace('[','').replace(']','').indexOf(',') != -1) {
    ameridian='';
    acircleoflatitude='';
    enforcedlong=false;
    enforcedxp=-999; } movesallowed=true; gmovesallowed=true; };

    … augmented by …
  • positive action around the “equivalent of document.body onload event” for the Earth Scanner …

    var thecss='';
    var earth_scanner_css=location.search.split('css=')[1] ? (decodeURIComponent(location.search.split('css=')[1].split('&')[0]).replace(/\+/g,' ')) : '';
    thecss=earth_scanner_css;
    var atendest='<input type=hidden id=posturl style=display:none; value=""></input><input type=button id=dbutton onclick=checkforstt(); style=display:none;></input>';
    var atend='<br><br><div id=dc><canvas title="" id=ourcanvas width=' + ('' + eval(-15 + (window.orientation == 0 ? window.screen.height: window.screen.width)) + 'px').replace('pxpx','').replace('px','') + ' height=660 style="width:' + ('' + eval(-15 + (window.orientation == 0 ? window.screen.height: window.screen.width)) + 'px').replace('pxpx','px') + ';height:660px;border:1px solid red;background-color:' + bcol + ';' + extrastyle + '"></canvas></div><div id=xdscriptstuff></div><div id=xdstylestuff></div><textarea id=myta style=display:none; value=""></textarea><iframe onload=scranal(this); id=scrmytaif style=display:none; src=></iframe><iframe onload=styanal(this); id=stymytaif style=display:none; src=></iframe><iframe class="spag" scrolling="no" data-onload="iifopen(this);" id="cbi" frameborder="0" style="position:fixed;top:0px;left:150px;width:173px;height:218px;margin-top:-204px;display:none;" src="/HTMLCSS/client_browsing.htm?straighttext=312160562686"></iframe><textarea id=result1 style=display:none;></textarea><textarea id=result2 style=display:none;></textarea>' + exdstylestuff + exdscriptstuff + atendest;
    var parentiframe='';
    var iol='';
    if (window.opener) {
    var pu=window.opener.document.URL;
    if (pu.indexOf('#') == -1 && ('' + window.opener.location.hash).replace(/^null/g,'').replace(/^undefined/g,'') != '') {
    pu+=('#' + ('' + window.opener.location.hash)).replace(/^\#\#/g, '#');
    }
    thecss+='display:block;';
    parentiframe='<br><iframe id=mtif style="width:100%;height:800px;z-index:987;margin:0 0 0 0;margin-left:10px;margin-top:10px;background-color:rgba(0,0,255,0.5);" src="' + pu + '"></iframe><div id=dhiddens style=display:none;><div id=goagain></div><input type=hidden id=ltf value=></input><input type=hidden id=lgf value=></input><input type=hidden id=ltt value=></input><input type=hidden id=lgt value=></input><div id=slong></div><iframe id=niframe src=></iframe></div>';

    iol=' onload="document.body.onclick=function(){ document.getElementById(' + "'myimg'" + ').style.display=document.getElementById(' + "'myimg'" + ').style.display.replace(' + "'block','NONE'" + ').replace(' + "'none','block'" + ').replace(' + "'NONE','none'" + '); if (1 == 2) { document.getElementById(' + "'dstyle'" + ').style.display=document.getElementById(' + "'dstyle'" + ').style.display.replace(' + "'visible','HIDDEN'" + ').replace(' + "'hidden','visible'" + ').replace(' + "'HIDDEN','hidden'" + '); } if (document.getElementById(' + "'myimg'" + ').style.display == ' + "'none'" + ') { window.scrollTo(0,0); document.body.style.backgroundColor=' + "'rgba(255,0,0,0.5)'" + '; } else { window.scrollTo(cspx, cspy); document.body.style.backgroundColor=' + "'rgba(0,0,255,0.5)'" + '; } } " ';
    setInterval(getcsp, 5000);
    }

    document.write("<img" + iol + " src='/HTMLCSS/HYP_50M_SR_W.jpg' id=myimg width=" + eval(zoomf * 10800) + " height=" + eval(zoomf * 5400) + " style='margin:0 0 0 0;margin-left:10px;margin-top:10px;" + thecss + "'></img><div id=dstyle style=visibility:visible;></div><input id=sdtitle type=hidden value='Earth Scanner'></input><input id=sdtext type=hidden value='Earth Scanner - RJM Programming'></input><input id=sdurl type=hidden value='" + document.URL.split('#')[0] + ('' + location.hash).replace(/^null/g,'').replace(/^undefined/g,'') + "'></input><iframe scrolling=no farmeborder=0 style='z-index:3456;position:fixed;top:55px;left:15px;width:30px;height:24px;' onload='storeshare(this);' src='/HTMLCSS/web_share_api_test.html?emojize=128231'></iframe><input type=hidden id=itworked value=''></input><iframe onload=coordit(this); id=wif style=display:none;margin-left:50px; src='//wikipedia.org/wiki/Saint_George,_Antigua_and_Barbuda'></iframe><iframe onload=coordittwo(this); id=wiftwo style=display:none; src=></iframe><input type=hidden id=placegeo title='' value=''></input>" + atend + parentiframe);

    … calling …

    var cspx=0, cspy=0;

    function getcsp() {
    // Thanks to https://stackoverflow.com/questions/31712287/get-scroll-position-in-javascript
    var ourcspx = eval('' + (document.body.scrollX || document.body.scrollLeft || document.getElementsByTagName("html")[0].scrollLeft));
    var ourcspy = eval('' + (document.body.scrollY || document.body.scrollTop || document.getElementsByTagName("html")[0].scrollTop));
    if (ourcspx > 100) {
    cspx=ourcspx;
    cspy=ourcspy;
    }
    //document.title='cspx=' + cspx + ' and cspy=' + cspy + ' ourcspx=' + ourcspx + ' and ourcspy=' + ourcspy;
    }

… surprising us regarding how much could be done at the “child” to make this popup window arrangement be fitting into the integration so that …

  • user calls the “parent” Missing Two web application …
  • user fills in the two places … now a clickable details/summary “reveal” “Earth Scanner …” arrangement, if clicked …
  • opens new Earth Scanner popup window with the calling URL hosted in a popup window iframe element below it … so that …
  • clicking in the left hand “document.body” element’s “sliver” which might involve “user scrolling to”, to find (and yes, that is where the ownership lies, luckily) toggles the Earth Scanner topmost with Missing Two “clone” topmost …
  • with the scrolling remembered (our testing shows … “for the main part”) … or the user can choose to …
  • close the popup window in order to fall back to calling “parent” Missing Two web application window, only (still with the “Earth Scanner …” details/summary “reveal” arrangement showing)

Codewise …


Previous relevant Earth Bearing Distance Missing Two Trip Geolocation Elevation Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Geolocation Elevation Tutorial

Earth Bearing Distance Missing Two Trip Geolocation Elevation Tutorial

Onto yesterday’s Earth Bearing Distance Missing Two Trip Geolocation Tutorial and its Geolocation progress we started the day with a different course of action to how we ended it. The day’s motivation was to automate a Place Name elevation knowledge in order to help with that …

What’s out there in the distance?

… thinking we talked about, first, at Earth Bearing Distance Missing Two Place Name and Horizon Tutorial.

We suspected that we were naive in our thinking because Google searches lead to nothing with our theory, that theory being that we could combine …

… could derive for us a semi reliable elevation value. There’s theory, though, and then there’s empirical application, and we could not get the application of the former match the aims with the latter, but will leave you with our Javascript attempt via …


function elevviaz(inlat) { // thanks to https://www.physicsclassroom.com/class/circles/Lesson-3/The-Value-of-g
var dsq=0.0, ddsql=0.0;
if (eval('' + zalpha) != 0) {
var cone=0.0000000000667430;
var mone=5980000000000000000000000.0;
var rone=get_radius_at_lat(inlat); //6380000.0000;
//for (var ii=1; ii<=24; ii++) {
// mone*=10.0;
//}
dsq=eval('' + mone);
alert('dsq(1 is big const)=' + dsq);
dsq*=eval('' + cone);
alert('dsq(2 times small const vs 398600441800000.0)=' + dsq);
dsq=398600441800000.0;
dsq/=9.8; //eval('' + zalpha);
alert('dsq(3 divide by iphone ' + zalpha + ')=' + dsq);
dsq=Math.pow(dsq, 0.5);
alert('dsq(4 square root)=' + dsq);
rone=dsq; //dsq-=rone;
alert('dsq(5 minus sea level earth radius ' + rone + ')=' + dsq);

dsq=eval('' + mone);
alert('dsq(1 is big const)=' + dsq);
dsq*=eval('' + cone);
alert('dsq(2 times small const vs 398600441800000.0)=' + dsq);
dsq=398600441800000.0;
dsq/=eval('' + zalpha);
alert('dsq(3 divide by iphone ' + zalpha + ')=' + dsq);
dsq=Math.pow(dsq, 0.5);
alert('dsq(4 square root)=' + dsq);
dsq-=rone;
alert('dsq(5 minus sea level earth radius ' + rone + ')=' + dsq);

}
return dsq;
}

After abandoning this approach, sadly, later in the day some sporadically happier news was that we discovered that the Geolocation API can sometimes pass across a decent elevation value, which we applied as below into our code’s thinking in our changed missing_two.html‘s “Missing Two” web application.


var appendz="";
var iinb=0;


function showPosition(position) {
if (userlatitude == 0.0 && userlongitude == 0.0) {
userlatitude=eval('' + position.coords.latitude);
userlongitude=eval('' + position.coords.longitude);
//alert('' + position.coords.heading);
if (('' + position.coords.altitude).replace('null','') != '' && iinb == -1) {
appendz=";" + ('' + position.coords.altitude).replace('null','');
}

if (userlatitude != 0.0 || userlongitude != 0.0) {
//document.getElementById('you').innerHTML='(0,0)';
if (document.getElementById('spfr').innerHTML.indexOf('rom') != -1) {
if (document.getElementById('latf') && document.getElementById('longf')) {
document.getElementById('latf').focus();
document.getElementById('latf').value=userlatitude;
document.getElementById('longf').focus();
document.getElementById('longf').value=userlongitude;
document.getElementById('latf').focus();
userlatitude=0.0;
userlongitude=0.0;
document.getElementById('ssf').innerHTML='Here';
if (appendz != '') {
fplacen='Here (elevation ' + appendz.substring(1) + ' m)';
document.getElementById('ssf').innerHTML=fplacen;
} else {

fplacen='Here';
}
gllentry='' + document.getElementById('latf').value + ',' + document.getElementById('longf').value + ',' + fplacen;
askit();
//document.getElementById('spfr').innerHTML='to';
}
} else {
if (document.getElementById('latt') && document.getElementById('longt')) {
document.getElementById('latt').focus();
document.getElementById('latt').value=userlatitude;
document.getElementById('longt').focus();
document.getElementById('longt').value=userlongitude;
document.getElementById('latt').focus();
userlatitude=0.0;
userlongitude=0.0;
document.getElementById('sst').innerHTML='Here';
if (appendz != '') {
tplacen='Here (elevation ' + appendz.substring(1) + ' m)';
document.getElementById('sst').innerHTML=tplacen;
} else {

tplacen='Here';
}
gllentry='' + document.getElementById('latt').value + ',' + document.getElementById('longt').value + ',' + tplacen;
askit();
}
}
}
}
}

function getLocation(inb) {
iinb=inb.indexOf(';');
if (navigator.geolocation) {
try {
navigator.geolocation.getCurrentPosition(showPosition);
//setTimeout(later, 1000);
if (appendz != "" && iinb != -1) { appendz=""; }
if (inb != inb.trim() && document.getElementById('spfr').innerHTML.indexOf('rom') != -1) { fplacen+=' '; }
if (inb != inb.trim() && document.getElementById('spfr').innerHTML.indexOf('rom') == -1) { tplacen+=' '; }
if (document.getElementById('spfr').innerHTML.indexOf('rom') != -1) {
document.getElementById('ipn').value=fplacen;
} else {
document.getElementById('ipn').value=tplacen;
}
gid = navigator.geolocation.watchPosition(gsuccess, gerror, goptions);
return false;
} catch(err) {
//setTimeout(later, 1000);
}
} else if (userlatitude != 0.0 || userlongitude != 0.0) {
//document.getElementById('you').innerHTML='(0,0)';
if (document.getElementById('spfr').innerHTML.indexOf('rom') != -1) {
if (document.getElementById('latf') && document.getElementById('longf')) {
document.getElementById('latf').focus();
document.getElementById('latf').value=userlatitude;
document.getElementById('longf').focus();
document.getElementById('longf').value=userlongitude;
document.getElementById('latf').focus();
userlatitude=0.0;
userlongitude=0.0;
document.getElementById('ssf').innerHTML='Here';
if (appendz != '') {
fplacen='Here (elevation ' + appendz.substring(1) + ' m)';
document.getElementById('ssf').innerHTML=fplacen;
} else {

fplacen='Here';
}
gllentry='' + document.getElementById('latf').value + ',' + document.getElementById('longf').value + ',' + fplacen;
askit();
//document.getElementById('spfr').innerHTML='to';
return false;
}
} else {
if (document.getElementById('latt') && document.getElementById('longt')) {
document.getElementById('latt').focus();
document.getElementById('latt').value=userlatitude;
document.getElementById('longt').focus();
document.getElementById('longt').value=userlongitude;
document.getElementById('latt').focus();
userlatitude=0.0;
userlongitude=0.0;
document.getElementById('sst').innerHTML='Here';
if (appendz != '') {
tplacen='Here (elevation ' + appendz.substring(1) + ' m)';
document.getElementById('sst').innerHTML=tplacen;
} else {

tplacen='Here';
}
gllentry='' + document.getElementById('latt').value + ',' + document.getElementById('longt').value + ',' + tplacen;
askit();
return false;
}
}
}
return true;
}


Previous relevant Earth Bearing Distance Missing Two Trip Geolocation Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Geolocation Tutorial

Earth Bearing Distance Missing Two Trip Geolocation Tutorial

Okay, it’s the day where gobsmacked readers of Earth Bearing Distance Missing Two Trip Compass Tutorial and (all) users of its “Missing Two” web application can be relieved of their “gobsmackederhood“?! Yes …

  • on top of our Wikipedia way to glean Latitude and Longitude for a Place Name … today (oh, but the shame of it all, the shame, leaving it for so long … oh, the shame of“okay, that’s it … pull yourself together”) we finally get around to …
  • “Here” Place Name based HTML5 Geolocation API (should the user be allowing Location Services (into their frightfully busy lives) for their web browser of use) … yayyyyyyyy!

… is flagged to the user via that top textbox’s “placeholder” blurb being adjusted (for 7 seconds) as a user focuses there via changed HTML …


<h1 id=myh1 style='display:block;'>Missing Two (<font size=1>optional</font> <span onclick="this.innerHTML=this.innerHTML.replace('to','From').replace('from','to').replace('From','from'); document.getElementById('ipn').focus(); " id=spfr title='Click me to toggle between from and to' style='cursor:pointer;'>from</span> <input onfocus='hereit(this,"");' title='Optionally semicolon separate an elevation affecting horizon distance used for Place Name/Bearing (where Compass app might show you this elevation value) input scenarios. Note that a Place Name/Distance scenario shows a Locality Distance Ring map. Append space for gyroscope bearing.' onblur='lkwk(this,"");' style='display:inline-block;width:280px;' placeholder='Place Name' id=ipn value='' type=text></input>) in Table Column <span data-onfocus="document.getElementById('semail').innerHTML='';" data-title='Email to (append a space to just show the table cell with the gradient)?' data-contenteditable=true data-onblur=preemail(this.innerHTML); onclick=emailit(''); id=semail title=Email>&#128231;</span> <span data-onfocus="document.getElementById('semail').innerHTML='';" data-title='SMS to?' data-contenteditable=true data-onblur=preemail(this.innerHTML); onclick=toize(''); id=ssms title=SMS>&#128223;</span><div id=dntable style=display:none;>    <table border=1 id=ntable style="background-color:pink;display:inline-block;font-size:10px;"><tr><td>N</td></tr><tr><td>&#11014;</td></tr></table>    <div style='display:inline-block;cursor:pointer;' id=arrowup title='To Portrait Up ... line up, parallel, with compass N to face North the ideal way' onclick='alert(this.title);'>&#11014;</div></div></h1>

… calling on new Javascript …


var oiqplaceholder='';

function oiqit() {
if (oiqplaceholder != '') {
hereit(document.getElementById('ipn'), oiqplaceholder);
oiqplaceholder='';
} else if (document.getElementById('ipn')) {
if (('' + document.getElementById('ipn').placeholder).indexOf('"Here" ') == 0 && ('' + document.getElementById('ipn').placeholder).indexOf(' Longitude. ') != -1) {
document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split(' Longitude. ')[1];
}
}
}

function hereit(oiq, twopis) {
var wasp='';
if (twopis != '') {
if (('' + oiq.placeholder).indexOf('"Here"') == -1) {
wasp=('' + oiq.placeholder);
oiq.placeholder='"Here" uses Geolocation derived Latitude, Longitude. ' + wasp;
setTimeout(oiqit, 7000);
}
document.getElementById('myh1').style.cursor='pointer';
} else if (oiq.value == '' && document.URL.toLowerCase().indexOf('https') == 0) {
if (('' + oiq.placeholder).indexOf('"Here"') == -1) {
wasp=('' + oiq.placeholder);
oiqplaceholder='"Here" uses Geolocation derived Latitude, Longitude. ' + wasp;
document.getElementById('myh1').style.cursor='progess';
setTimeout(oiqit, 500);
}
}
}

… and if the user types in the Here  we are looking for …


function lkwk(oiis, twop) {
var doi=true;
if (oiis.value.trim() != '') {
if ((('' + oiis.value).replace(/\"/g,'').replace(/\'/g,'').replace(';',' ') + ' ').toLowerCase().indexOf('here ') == 0) { doi=false; if (1 == 2) { oiis.value=''; } doi=getLocation(); if (1 == 2) { return ''; } }
if (document.getElementById('tdmid')) {
if (document.getElementById('tdmid').innerHTML.toLowerCase().indexOf('<iframe') != -1) {
if (document.getElementById('spfr')) {
if (document.getElementById('spfr').innerHTML.toLowerCase().indexOf('rom') != -1) {
location.href=document.URL.split('#')[0].split('?')[0] + '?ipn=' + encodeURIComponent(oiis.value);
}
}
}
}
if (oiis.value.trim() != oiis.value) { tplacen=tplacen.trim(); } else { tplacen+=String.fromCharCode(32); }
var ois=oiis.value.trim().split(';');
if (doi) { document.getElementById('ifplacegeo').src=document.getElementById('ifplacegeo').src.split('?')[0].split('#')[0] + '?placegeo=' + encodeURIComponent(ois[0]); }
if (eval('' + ois.length) > 1) { elev=eval('' + ois[1]); evel=Math.max(elev, 2.0); }
if (twop == '') { oiis.value=''; }
if (doi) { document.body.style.cursor='progress'; }
}
}

… new Geolocation API Javascript code swings into action …


var userlatitude=0.0, userlongitude=0.0;

function getLocation() {
if (navigator.geolocation) {
try {
navigator.geolocation.getCurrentPosition(showPosition);
//setTimeout(later, 1000);
return false;
} catch(err) {
//setTimeout(later, 1000);
}
} else if (userlatitude != 0.0 || userlongitude != 0.0) {
//document.getElementById('you').innerHTML='(0,0)';
if (document.getElementById('spfr').innerHTML.indexOf('rom') != -1) {
if (document.getElementById('latf') && document.getElementById('longf')) {
document.getElementById('latf').focus();
document.getElementById('latf').value=userlatitude;
document.getElementById('longf').focus();
document.getElementById('longf').value=userlongitude;
document.getElementById('latf').focus();
userlatitude=0.0;
userlongitude=0.0;
document.getElementById('ssf').innerHTML='Here';
gllentry='' + document.getElementById('latf').value + ',' + document.getElementById('longf').value + ',Here';
askit();
//document.getElementById('spfr').innerHTML='to';
fplacen='Here';
return false;
}
} else {
if (document.getElementById('latt') && document.getElementById('longt')) {
document.getElementById('latt').focus();
document.getElementById('latt').value=userlatitude;
document.getElementById('longt').focus();
document.getElementById('longt').value=userlongitude;
document.getElementById('latt').focus();
userlatitude=0.0;
userlongitude=0.0;
document.getElementById('sst').innerHTML='Here';
gllentry='' + document.getElementById('latt').value + ',' + document.getElementById('longt').value + ',Here';
askit();
tplacen='Here';
return false;
}
}
}
return true;
}


function showPosition(position) {
if (userlatitude == 0.0 && userlongitude == 0.0) {
userlatitude=eval('' + position.coords.latitude);
userlongitude=eval('' + position.coords.longitude);
if (userlatitude != 0.0 || userlongitude != 0.0) {
//document.getElementById('you').innerHTML='(0,0)';
if (document.getElementById('spfr').innerHTML.indexOf('rom') != -1) {
if (document.getElementById('latf') && document.getElementById('longf')) {
document.getElementById('latf').focus();
document.getElementById('latf').value=userlatitude;
document.getElementById('longf').focus();
document.getElementById('longf').value=userlongitude;
document.getElementById('latf').focus();
userlatitude=0.0;
userlongitude=0.0;
document.getElementById('ssf').innerHTML='Here';
gllentry='' + document.getElementById('latf').value + ',' + document.getElementById('longf').value + ',Here';
askit();
//document.getElementById('spfr').innerHTML='to';
fplacen='Here';
}
} else {
if (document.getElementById('latt') && document.getElementById('longt')) {
document.getElementById('latt').focus();
document.getElementById('latt').value=userlatitude;
document.getElementById('longt').focus();
document.getElementById('longt').value=userlongitude;
document.getElementById('latt').focus();
userlatitude=0.0;
userlongitude=0.0;
document.getElementById('sst').innerHTML='Here';
gllentry='' + document.getElementById('latt').value + ',' + document.getElementById('longt').value + ',Here';
askit();
tplacen='Here';
}
}
}
}
}

… into our changed missing_two.html‘s “Missing Two” web application.

What a programmer’s relief!


Previous relevant Earth Bearing Distance Missing Two Trip Compass Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Compass Tutorial

Earth Bearing Distance Missing Two Trip Compass Tutorial

The recent Earth Bearing Distance Missing Two Trip North Point Tutorial set up a …

  • mobile device “North point” additional functionality … and today …
  • more compass use helpers to guide user towards facing North … as well as …
  • allow for Degrees Minutes Seconds as alternative angular method of entry harnessing changed HTML … exemplified by …

    Latitude (decimal degrees): <input title='' style='width:90px;display:inline-block;' onchange='this.style.backgroundColor="pink";cwhat[0]=false; cwhat[1]=false; if (!decided) { if (!cwhat[5]) { cwhat[5]=true; } if (!cwhat[4]) { cwhat[4]=true; } decided=true; } top.document.getElementById("ltf").value=this.value; ' onblur='this.style.backgroundColor="pink"; cwhat[0]=false; cwhat[1]=false; if (!decided) { if (!cwhat[5]) { cwhat[5]=true; } if (!cwhat[4]) { cwhat[4]=true; } decided=true; } top.document.getElementById("ltf").value=mdms(this.value,this); ' id=latf name=latf type=number onfocus='ati=0; atic=[]; atis=[];' onkeydown='couldbedms(event);' min=-90.0000000 max=90.0000000 step=0.0000010 value='0.0000000'></input><br>

    … helped out by new Javascript …

    var ati=0, atis=[], atic=[];

    function mdms(tvis, otvis) {
    var altvl=0.0, dvr=1.0, isv=0;
    if (eval('' + atic.length) >= 1) {
    //alert('ov=' + otvis.value + ' and atic[0]=' + atic[0]);
    if (atic[0].indexOf('-') != -1 && otvis.value.indexOf('-') == -1) {
    isv++;
    } else if (atic[0].indexOf('+') != -1 && otvis.value.indexOf('+') == -1) {
    isv++;
    } else if (eval('' + atis.length) >= 2) {
    if (eval('' + atis[1]) > 60) { isv++; }
    }
    }
    if (eval('' + atic.length) > 1) {
    //alert('Here ' + atic.length + ' last is=' + atic[eval(-1 + atic.length)]);
    for (var ijh=0; ijh<atic.length; ijh++) {
    if (atic[ijh].trim() != '') {
    isv++;
    if (atic[0].indexOf('-') != -1) {
    altvl-=eval(eval('' + dvr) * eval(atic[ijh].replace('-','')));
    } else {
    altvl+=eval(eval('' + dvr) * eval(atic[ijh].replace('-','')));
    }
    //alert('Here ' + altvl);
    dvr/=60.0;
    }
    }
    if (isv > 1) {
    tvis='' + altvl;
    otvis.value='' + altvl;
    }
    }
    ati=0;
    atic=[];
    atis=[];
    return tvis;
    }

    function idms(otvis) {
    var altvl=0.0, dvr=1.0, isv=0;
    if (eval('' + atic.length) >= 1) {
    //alert('Ov=' + otvis.value + ' and Atic[0]=' + atic[0]);
    if (atic[0].indexOf('-') != -1 && otvis.value.indexOf('-') == -1) {
    isv++;
    } else if (atic[0].indexOf('+') != -1 && otvis.value.indexOf('+') == -1) {
    isv++;
    } else if (eval('' + atis.length) >= 2) {
    if (eval('' + atis[1]) > 60) { isv++; }
    }
    }
    if (eval('' + atic.length) > 1) {
    //alert('here ' + atic.length + ' last is=' + atic[eval(-1 + atic.length)]);
    for (var ijh=0; ijh<atic.length; ijh++) {
    if (atic[ijh].trim() != '') {
    isv++;
    if (atic[0].indexOf('-') != -1) {
    altvl-=eval(eval('' + dvr) * eval(atic[ijh].replace('-','').replace('+','')));
    } else {
    altvl+=eval(eval('' + dvr) * eval(atic[ijh].replace('-','').replace('+','')));
    }
    //alert('here ' + altvl);
    dvr/=60.0;
    }
    }
    if (isv > 1) {
    otvis.value='' + altvl;
    }
    }
    ati=0;
    atic=[];
    atis=[];
    return otvis;
    }

    function couldbedms(event) {
    var wasc='';
    if (eval('' + event.keyCode) == 69 || eval('' + event.keyCode) == 78 || eval('' + event.keyCode) == 87 || eval('' + event.keyCode) == 83 || eval('' + event.keyCode) == 187 || eval('' + event.keyCode) == 189 || eval('' + event.keyCode) == 190 || (eval('' + event.keyCode) >= 48 && eval('' + event.keyCode) <= 57)) {
    if (ati == 0) { atis=[]; atis.push(0); atic.push(''); } else if (ati < 0) { ati=0; }
    ati++;
    atis[eval(-1 + atis.length)]=ati;
    if (eval('' + event.keyCode) == 87 || eval('' + event.keyCode) == 83) {
    if (atic[0].indexOf('-') == -1) { wasc=atic[0]; atic[0]='-' + wasc; }
    } else if (eval('' + event.keyCode) == 69 || eval('' + event.keyCode) == 78) {
    if (atic[0].indexOf('+') == -1) { wasc=atic[0]; atic[0]='+' + wasc; }
    } else if (eval('' + event.keyCode) != 187) {
    atic[eval(-1 + atic.length)]+=String.fromCharCode(eval(eval('' + event.keyCode) % 144));
    }
    } else {
    ati=-1;
    if (eval('' + event.keyCode) >= 65 && eval('' + event.keyCode) <= 90) {
    atis.push(eval('' + event.keyCode));
    } else {
    atis.push(0);
    }
    atic.push('');
    }
    }

… improving the functionality and ease of use of our changed missing_two.html‘s “Missing Two” web application when using a mobile platform.


Previous relevant Earth Bearing Distance Missing Two Trip North Point Tutorial is shown below.

Earth Bearing Distance Missing Two Trip North Point Tutorial

Earth Bearing Distance Missing Two Trip North Point Tutorial

We build on the recent Earth Bearing Distance Missing Two Trip Tap Orientation Tutorial and help out those “what’s out there in the distance” dreamers of Earth Bearing Distance Missing Two Trip Details Orientation Tutorial by, today adding a “North point” (HTML table element) to …

… on some mobile platforms, such as the iOS iPad we tested, adding compass like new functionality, as per the new HTML …


<h1 id=myh1 style='display:block;'>Missing Two (<font size=1>optional</font> <span onclick="this.innerHTML=this.innerHTML.replace('to','From').replace('from','to').replace('From','from'); document.getElementById('ipn').focus(); " id=spfr title='Click me to toggle between from and to' style='cursor:pointer;'>from</span> <input title='Optionally semicolon separate an elevation affecting horizon distance used for Place Name/Bearing (where Compass app might show you this elevation value) input scenarios. Note that a Place Name/Distance scenario shows a Locality Distance Ring map. Append space for gyroscope bearing.' onblur='lkwk(this);' style='display:inline-block;width:280px;' placeholder='Place Name' id=ipn value='' type=text></input>) in Table Column <span data-onfocus="document.getElementById('semail').innerHTML='';" data-title='Email to (append a space to just show the table cell with the gradient)?' data-contenteditable=true data-onblur=preemail(this.innerHTML); onclick=emailit(''); id=semail title=Email>&#128231;</span> <span data-onfocus="document.getElementById('semail').innerHTML='';" data-title='SMS to?' data-contenteditable=true data-onblur=preemail(this.innerHTML); onclick=toize(''); id=ssms title=SMS>&#128223;</span><div id=dntable style=display:none;>    <table border=1 id=ntable style="background-color:pink;display:inline-block;font-size:10px;"><tr><td>N</td></tr><tr><td>&#11014;</td></tr></table>    &#11014;</div></h1>

… and Javascript …


var wasthisso='' + (screen.msOrientation || screen.mozOrientation || (screen.orientation || {}).type); //"portrait";
var wasangle=eval(180 - eval('' + window.orientation));


if (1 == 1) {
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
wasangle=eval(180 - eval('' + window.orientation));
var thisso='' + screen.msOrientation || screen.mozOrientation || (screen.orientation || {}).type;
if (('' + thisso) == 'undefined') {
var mql=window.matchMedia("(orientation: portrait)");
// If there are matches, we're in portrait
if (mql.matches) {
thisso="Portrait"; // Portrait orientation
} else {
thisso="Landscape"; // Landscape orientation
}
}


if (thisso != wasthisso) {
wasthisso=thisso;
//alert('ori');
}
}, false);
}

if (window.DeviceOrientationEvent) {
if (1 == 2) { alert(1); }
// Listen for orientation changes ... thanks to https://davidwalsh.name/orientation-change
// Listen for the deviceorientation event and handle the raw data
window.addEventListener('deviceorientation', function(eventData) {
// gamma is the left-to-right tilt in degrees, where right is positive
if (1 == 2) { alert(11); }
if (document.getElementById('ipn')) {
//if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and face north for gyroscope bearing.') == -1) {
if (('' + document.getElementById('ipn').placeholder).indexOf(' and ') == -1) {
document.getElementById('ipn').className='ph';
document.getElementById('ipn').placeholder+='. Append space and portrait face north for gyroscope bearing.';
document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=1.5, minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
setTimeout(asafn, 5000);
}
}
//eventData.absolute=true;


var eventDataalpha = eval(360.0 - eval('' + eventData.alpha)); // lalpha)); //
if (eventData.absolute !== true && +eventData.webkitCompassAccuracy > 0 && +eventData.webkitCompassAccuracy < 50) {
eventDataalpha = eval('' + eventData.webkitCompassHeading || 0);
if (document.getElementById('dntable')) { document.getElementById('dntable').style.display='inline-block'; }
}

if (!datstart) { eventDataalpha-=initial_yaw; }


tiltLeftToRight = eval('' + eventData.gamma);

// beta is the front-to-back tilt in degrees, where front is positive
tiltFrontToBack = eval('' + eventData.beta);

// alpha is the compass direction the device is facing in degrees
lastalpha='' + eventData.alpha; // lalpha; //
dorbrg = eval('' + eventDataalpha); //compassHeading(eval('' + eventDataalpha), tiltFrontToBack, tiltLeftToRight);
if (1 == 2) { alert(dorbrg); }
if (document.URL.indexOf('aleJUNKrt=') != -1) {
alert(dorbrg);
}
if (document.URL.indexOf('upJUNKdate=') != -1 || (fplacen != '' && tplacen == '')) {
if (eventData.absolute || 1 == 1) {
//document.getElementById('brg').value='' + eval(eval(540.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + eval(eval(720.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + dorbrg;
if (eval(dcnt % 10) == 0) {
document.getElementById('brg').value='' + eval(eval(720.0 + eval('' + dorbrg)) % 360.0);
document.getElementById('brg').style.backgroundColor='yellow';
}
dcnt++;
}
}


if (datstart && (fplacen != '' && tplacen == '')) {
datstart=false;
//initial_yaw=eval(360.0 - eval('' + lalpha)); //eventData.alpha));
//alert('0:' + initial_yaw);
if (!eventData.absolute) {
initial_yaw=eval(360.0 - eval('' + eventData.alpha)); // lalpha)); //
}
//alert('' + initial_yaw);
initial_pitch=Math.round(tiltFrontToBack);
initial_roll=Math.round(tiltLeftToRight);
//alert(initial_yaw + ',' + initial_pitch + ',' + initial_roll);
}


if (document.getElementById('ntable')) {
var ts=450;
if (wasangle != 0) {
ts+=wasangle;
}
try { document.getElementById('ntable').style.webkitTransform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e10) { }
try { document.getElementById('ntable').style.MozTransform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e1000) { }
try { document.getElementById('ntable').style.msTransform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e100) { }
try { document.getElementById('ntable').style.OTransform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e10000) { }
try { document.getElementById('ntable').style.transform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e1) { }
}



handleOrientationEvent(tiltFrontToBack, tiltLeftToRight, dorbrg, eventData.absolute);

if ((fplacen != '' && tplacen == '') && document.getElementById('ipn')) {
//if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and face north for gyroscope bearing.') != -1) {
if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and ') != -1) {
document.getElementById('ipn').style.backgroundColor='#f0f0f0';
//document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and face north for gyroscope bearing.')[0] + ' Now swivel to direction of interest then tap yellow textbox.';
document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and ')[0] + ' Now swivel to direction of interest then tap yellow textbox.';
document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=1.2, minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
//window.scrollBy(0,50); //location.href='#brg';
}
}


}, false);
}


Previous relevant Earth Bearing Distance Missing Two Trip Tap Orientation Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Details Tap Tutorial

Earth Bearing Distance Missing Two Trip Tap Orientation Tutorial

That window.DeviceOrientationEvent event work of the recent Earth Bearing Distance Missing Two Trip Details Orientation Tutorial was missing an important point. We learnt about this point by debugging on an iOS (iPhone 7) Google Chrome web browser, as we showed with yesterday’s Google Chrome on iOS Web Browser Debug Tutorial. That tutorial’s finding lead us to the Google search for …


ERROR NotAllowedError Requesting device

… and onto the excellent How to requestPermission for devicemotion and deviceorientation events in iOS 13+ …

One more thing

One more thing to keep in mind is that requestPermission could only be called on a user gesture (e.g. click). This is reasonable UX too as we would want to tell users why we are asking for such permissions and let them confirm before prompting them so that they see it coming.

Otherwise you would get this error:

Console error: NotAllowedError: Requesting device orientation or motion access requires a user gesture to prompt

… where we needed to shift our oft-used document.body onload event code placement thinking to allow for this thinking, plus the provision of a button for the user to tap, as required, should the “permission” popup window be required to seek permission to, effectively, access that device’s gyroscope measurements via that window.DeviceOrientationEvent and/or window.DeviceMotionEvent event(s).

This is a similar Apple requirement, as it applies to iOS playing audio files, which we have mentioned quite a bit at this blog. One could say …

We should have known.

… and luckily two is too polite to say …

You blockhead!

… to which we are infinitely grateful, and will install for the rest of the day, that …

Two is our favourite number (for the rest of today, that is).

But it’s not only …

… for you to try for yourself, perhaps there on your mobile device with an accessible gyroscope on a compatible web browser such as Google Chrome (or others, now) on iOS.


Previous relevant Earth Bearing Distance Missing Two Trip Details Orientation Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Details Orientation Tutorial

Earth Bearing Distance Missing Two Trip Details Orientation Tutorial

Humans, particularly before the advent of the mobile devices, were probably (as a whole) more skilled regarding navigation via “landmarks” or “sunmarks” or “moonmarks” working out …

In which direction is North?

Well, the irony here, today, is that the better you have been hanging onto these skills you are, the better you can use our new …

  • mobile phone …
  • containing a gyroscope … but …
  • not an accessible compass (or if so, the knowledge of where North is becomes superfluous below) …
  • using a compatible web browser such as Google Chrome …
  • a good indication your scenario is compatible being that at some stage you answer “Allow” to a prompt as below …

    … at some point … using …
  • today’s changed missing_two.html‘s live run link modifications … using …
    1. window.DeviceOrientationEvent event … and perhaps you could use …
    2. window.DeviceMotionEvent event

    …

  • software detection to offer that user …

… the chance to mix technology with human navigational instincts to answer that perennial question similarly asked in Earth Bearing Distance Missing Two Place Name and Horizon Tutorial …

What’s out there in the distance?

… via …

  1. using a compatible web browser such as Google Chrome … live run …
  2. point your mobile phone in portrait to North (or at least arrange to do this just before tapping the Done link in step below) …
  3. enter in a Place Name into that top textbox (to which, it’s good, as known, to append semicolon elevation) and add a space, and because you are on a mobile device, tap the Done link
  4. bearing text will start being updated with bearing of your mobile device portrait mode top pointing direction … so …
  5. when you’ve swivelled the mobile device to be pointing (in portrait) to the (What’s out there in the distance?) direction of interest, tap that yellow bearing textbox, then tap the Done link … resulting in …
  6. Google Chart Map Chart showing your Place Name and (the calculated) Horizon Position in that direction of your choosing

… meaning the combination of …

  • your mobile device’s gyroscope’s angle measuring talent (akin to those theodolite talents Land Surveyors are using) … and …
  • your navigational talents knowing where North is

… save you having to know that awkward “bearing” (in degrees) textbox answer to What’s out there in the distance? Perhaps see what we mean viewing today’s animated GIF presentation.

Onto yesterday’s Earth Bearing Distance Missing Two Trip Details Styling Tutorial and since the last time we ventured into the wooooorrrrrlllldddd of “window.DeviceOrientationEvent” logic we’ve gotten great help Javascript coding for the permissions side to the handling of this event, as per …


if ((navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || document.URL.indexOf('alert=') != -1) && document.URL.toLowerCase().indexOf('https:') != 0) {
location.href=document.URL.replace('http:','https:') + '&random=' + Math.floor(Math.random() * 174765654);
}
if ((navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || document.URL.indexOf('update=') != -1) && document.URL.toLowerCase().indexOf('https:') != 0) {
location.href=document.URL.replace('http:','https:') + '&random=' + Math.floor(Math.random() * 174765654);
}

// Thanks to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await and
// https://gist.github.com/Ajasra/ddd616505013a4309c0dda8a8ba626cb

async function myfunction() {
console.log('Inside of myfunction');
//alert(0);
if (window.DeviceOrientationEvent && typeof(DeviceOrientationEvent.requestPermission) === "function") {
//alert(4);
const permissionState = await DeviceOrientationEvent.requestPermission().then(response => {
if (response === 'granted') {
if (1 == 2) { alert('GrAnted'); }
//window.addEventListener('deviceorientation', OrientationHandler, true);
dorh();
} else if (result.state === 'prompt') {
if (1 == 2) { alert("Need prompt!"); }
} else {
if (1 == 2) { alert("Not Supported!"); }
}
}).catch(console.error);

//if (permissionState === "granted") {
// alert('granted');
//} else {
// alert('denied');
//}
} else if (window.DeviceOrientationEvent) {
//alert(44);
dorh();
}

if (window.DeviceMotionEvent && typeof(DeviceMotionEvent.requestPermission) === "function") {
//alert(24);
const permissionStateM = await DeviceMotionEvent.requestPermission().then(response => {
if (response === 'granted') {
if (1 == 2) { alert('GranTed'); }
window.addEventListener('devicemotion', function(event) {
lalpha='' + event.rotationRate.alpha;
});
//window.addEventListener('deviceorientation', OrientationHandler, true);
} else if (result.state === 'prompt') {
if (1 == 2) { alert("NeeD prompt!"); }
} else {
if (1 == 2) { alert("NoT Supported!"); }
}
}).catch(console.error);

//if (permissionStateM === "granted") {
// alert('Granted');
//} else {
// alert('Denied');
//}
} else if (window.DeviceMotionEvent) {
//alert(244);
window.addEventListener('devicemotion', function(event) {
lalpha='' + event.rotationRate.alpha;
});
}

}

// Here we wait for the myfunction to finish
// and then returns a promise that'll be waited for aswell
// It's useless to wait the myfunction to finish before to return
// we can simply returns a promise that will be resolved later

// Also point that we don't use async keyword on the function because
// we can simply returns the promise returned by myfunction
function start() {
return myfunction();
}

// Call start
(async() => {
console.log('before start');

await start();


console.log('after start');
})();

var degtorad = Math.PI / 180; // Degree-to-Radian conversion ... thanks to https://www.w3.org/TR/orientation-event/#worked-example

function dorh() {
//let laSensor = new LinearAccelerationSensor({frequency: 60});

//laSensor.addEventListener('reading', e => {
// console.log("Linear acceleration along the X-axis " + laSensor.x);
// console.log("Linear acceleration along the Y-axis " + laSensor.y);
// console.log("Linear acceleration along the Z-axis " + laSensor.z);
//});
//laSensor.start();


//window.addEventListener('devicemotion', function(event) {
// alert(event.rotationRate.alpha + ' m/s2');
//});


if (1 == 3) {
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
var thisso='' + screen.msOrientation || screen.mozOrientation || (screen.orientation || {}).type;
if (('' + thisso) == 'undefined') {
var mql=window.matchMedia("(orientation: portrait)");
// If there are matches, we're in portrait
if (mql.matches) {
thisso="Portrait"; // Portrait orientation
} else {
thisso="Landscape"; // Landscape orientation
}
}


if (thisso != wasthisso) {
wasthisso=thisso;
alert('ori');
}
}, false);
}

if (window.DeviceOrientationEvent) {
if (1 == 2) { alert(1); }
// Listen for orientation changes ... thanks to https://davidwalsh.name/orientation-change
// Listen for the deviceorientation event and handle the raw data
window.addEventListener('deviceorientation', function(eventData) {
// gamma is the left-to-right tilt in degrees, where right is positive
if (1 == 2) { alert(11); }
if (document.getElementById('ipn')) {
//if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and face north for gyroscope bearing.') == -1) {
if (('' + document.getElementById('ipn').placeholder).indexOf(' and ') == -1) {
document.getElementById('ipn').className='ph';
document.getElementById('ipn').placeholder+='. Append space and portrait face north for gyroscope bearing.';
document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=1.5, minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
setTimeout(asafn, 5000);
}
}
//eventData.absolute=true;


var eventDataalpha = eval(360.0 - eval('' + eventData.alpha)); // lalpha)); //
if (!datstart) { eventDataalpha-=initial_yaw; }


tiltLeftToRight = eval('' + eventData.gamma);

// beta is the front-to-back tilt in degrees, where front is positive
tiltFrontToBack = eval('' + eventData.beta);

// alpha is the compass direction the device is facing in degrees
lastalpha='' + eventData.alpha; // lalpha; //
dorbrg = eval('' + eventDataalpha); //compassHeading(eval('' + eventDataalpha), tiltFrontToBack, tiltLeftToRight);
if (1 == 2) { alert(dorbrg); }
if (document.URL.indexOf('aleJUNKrt=') != -1) {
alert(dorbrg);
}
if (document.URL.indexOf('upJUNKdate=') != -1 || (fplacen != '' && tplacen == '')) {
if (eventData.absolute || 1 == 1) {
//document.getElementById('brg').value='' + eval(eval(540.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + eval(eval(720.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + dorbrg;
if (eval(dcnt % 10) == 0) {
document.getElementById('brg').value='' + eval(eval(720.0 + eval('' + dorbrg)) % 360.0);
document.getElementById('brg').style.backgroundColor='yellow';
}
dcnt++;
}
}


if (datstart && (fplacen != '' && tplacen == '')) {
datstart=false;
//initial_yaw=eval(360.0 - eval('' + lalpha)); //eventData.alpha));
//alert('0:' + initial_yaw);
if (!eventData.absolute) {
initial_yaw=eval(360.0 - eval('' + eventData.alpha)); // lalpha)); //
}
//alert('' + initial_yaw);
initial_pitch=Math.round(tiltFrontToBack);
initial_roll=Math.round(tiltLeftToRight);
//alert(initial_yaw + ',' + initial_pitch + ',' + initial_roll);
}


handleOrientationEvent(tiltFrontToBack, tiltLeftToRight, dorbrg, eventData.absolute);

if ((fplacen != '' && tplacen == '') && document.getElementById('ipn')) {
//if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and face north for gyroscope bearing.') != -1) {
if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and ') != -1) {
document.getElementById('ipn').style.backgroundColor='#f0f0f0';
//document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and face north for gyroscope bearing.')[0] + ' Now swivel to direction of interest then tap yellow textbox.';
document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and ')[0] + ' Now swivel to direction of interest then tap yellow textbox.';
document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=1.2, minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
//window.scrollBy(0,50); //location.href='#brg';
}
}


}, false);
}
}

var handleOrientationEvent = function(tiltFrontToBack, tiltLeftToRight, dorbrg, absis) {
// do something amazing
if (1 == 2) { alert(dorbrg); }
if (document.URL.indexOf('alJUNKert=') != -1) {
alert(dorbrg);
}
if (document.URL.indexOf('upJUNKdate=') != -1 || (fplacen != '' && tplacen == '')) {
if (absis || 1 == 1) {
//document.getElementById('brg').value='' + eval(eval(540.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + eval(eval(720.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + dorbrg;
if (eval(dcnt % 10) == 0) {
document.getElementById('brg').value='' + eval(eval(720.0 + eval('' + dorbrg)) % 360.0);
document.getElementById('brg').style.backgroundColor='yellow';
}
dcnt++;
}
}
};


function asafn() {
if (document.getElementById('ipn')) {
//if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and face north for gyroscope bearing.') == -1) {
if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and portrait face north for ') != -1) {
document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and ')[0] + 'Append space and portrait face north onto ;elevation(m)?';
setTimeout(asafn, 5000);
} else if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and ') != -1) {
document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and ')[0] + 'Append space and portrait face north for horizon bearing.';
setTimeout(asafn, 5000);
}
}
}

Today we added a meta viewport, and for the first time that we can recall, we started styling the “placeholder” of that top textbox as per (thanks to https://stackoverflow.com/questions/44679144/how-to-make-input-placeholder-font-size-different-from-input-value-font-size) …


<meta id="myviewport" name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.1, maximum-scale=8, user-scalable=yes" >
<style>
summary { background-color: #f0f0f0; }

.ph::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: red;
opacity: 1; /* Firefox */
font-size: 8px;
}

.ph:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: red;
font-size: 8px;
}

.ph::-ms-input-placeholder { /* Microsoft Edge */
color: red;
font-size: 8px;
}

</style>


Previous relevant Earth Bearing Distance Missing Two Trip Details Styling Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Details Styling Tutorial

Earth Bearing Distance Missing Two Trip Details Styling Tutorial

On top of the recent Earth Bearing Distance Missing Two Trip Details Reveal Tutorial, today we discuss styling strategies a little. When and where do you style your webpage? We think you do it all along, but for us, we like “little spurts” at it too, so we might let a web application project progress in a practical approach not worrying about aesthetics too much until we do a “little spurt” bubble of activity regarding styling. Often times ideas for that can be developed away from the laptop you might write the code on. For example, today’s changed missing_two.html‘s live run link modifications were directed by an email we sent to ourselves …

Jobs

Robert Metcalfe
Sun, Sep 12, 8:16 PM (5 days ago)
to me

Vertical-align: top
I frame too high
To after horizon leaves horizon I frame title
Lat long display online-block
Coloured summary background colour
Th header cells text-align center

Sent from my iPhone

… “mind map” type ideas that may or may not be followed through to fruition, depending on …

  • where possible
  • where feasible
  • where wise

This strategy above is for your small projects, else if much bigger, or involving multiple people to produce, or being written to a specification, or being written for a third party, you’d be much better placed to think about styling issues from the start, in a plan. You might want to use wireframes?

On these small projects we also don’t mind just involving the one HTML (or PHP writing HTML) source file and use a combination of …

  • inline <style> CSS styling goes here </style> within the webpage <head></head> header section … or …
  • in amongst the HTML via “style” attribute … eg. <p id=”myp” style=” CSS styling for p element goes here “> Content for p element goes here </p>

… or Javascript DOM code such as …


document.getElementById('myp').style.fontSize='18px';

… and it is very rare, with these small projects, though very good in organizational terms, to write all your CSS styling in an external CSS (styling file) arrangement such as …


<head>
<link href='./my_styling.css' rel='stylesheet' type='text/css'>
</head>

There are many ways to … well, you know what I mean … a cat! Not only were “no cats harmed in the making of this tutorial” but no cats were even roughed up?!


Previous relevant Earth Bearing Distance Missing Two Trip Details Reveal Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Details Reveal Tutorial

Earth Bearing Distance Missing Two Trip Details Reveal Tutorial

Yes, there’s only so long you can use the wonderful details/summary HTML element combination as with the recent Earth Bearing Distance Missing Two Trip Details Summary Tutorial‘s …

we often use to “reveal”, or not, webpage “real estate”, but today we default to the “open” look

… just using that “open” element mode of use, and not want to make use of its “reveal” talents. How so? Well, a bit like the dropdown element, we find that the details/summary combination allows for the containment of lots of data for a controlled amount of “reveal”. In this day and age of responsiveness to limited screen sizes, that is a big advantage.

Today, then, with our changed missing_two.html‘s live run link, we have …

  1. that first (at first) “open” details/summary nesting a Google Chart Map Chart iframe summarizing the entirety of your Trip … today …
  2. festooned with up arrow emoji (⬆) “button” links which, when clicked, zero in (into a new topmost “only open” details/summary nesting Google Chart Map Chart iframe set of data) on any one “leg” of your trip, displaying its own crow fly distance and Google Maps Directions information link, as well as new …
  3. accommodation (🛌) links ala accommodation in Springwood, New South Wales Google image search style links

… to enhance a Trip Planner’s user experience. Perhaps best to explain a bit codewise is to say “follow the Javascript variable interesting in code below” …


function askit() {
var ourdist=0.0, ourbrg=0.0;
//alert(gllentry);
if (gllentry.indexOf(',') != -1) {
if ((1 == 2 && gllonesuffix == 'f') || document.getElementById('spfr').innerHTML == 'from') {
tpurl=origtpurl;
document.getElementById('latf').focus();
document.getElementById('latf').value=gllentry.split(',')[0];
//var mu="//www.rjmprogramming.com.au/PHP/Map/map.php?title=London&label=['Lat',&value='Lon','Name']&data=,[51.5072,-0.1275,~London~]";
mu=mu.replace('[51.5072,','[' + gllentry.split(',')[0] + ',');
document.getElementById('longf').focus();
document.getElementById('longf').value=gllentry.split(',')[1];
mu=mu.replace(',-0.1275,',',' + gllentry.split(',')[1] + ',');
document.getElementById('latf').focus();
gllonesuffix = 't';
document.getElementById('spfr').innerHTML=document.getElementById('spfr').innerHTML.replace('from','to<input type=hidden name=fplacen value="' + gllentry.split(',')[2].replace(/\;/g,',') + '"></input>');
fplacen=gllentry.split(',')[2].replace(/\;/g,',');
document.getElementById('ssf').innerHTML=' ' + gllentry.split(',')[2].replace(/\;/g,',');
mu=mu.replace('=LonJunkdon','=' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,','))).replace(',~London~]',',~' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '~],[051.5072,-00.1275,~LonDon~]');
tpurl=tpurl.replace("Sydney+NSW,+Australia",encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')));
if (document.getElementById('sftif') && document.getElementById('iftif')) {
document.getElementById('iftif').src=document.getElementById('iftif').src.replace('&',encodeURIComponent(' from ' + gllentry.split(',')[2].replace(/\;/g,',')) + '&') + ',[' + gllentry.replace(',' + gllentry.split(',')[1] + ',', ',' + gllentry.split(',')[1] + ',~').replace(/\ /g,'%20') + '~]';
document.getElementById('sftif').innerHTML+=' <a target=_blank title=Accomodation onclick=woit(this); data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')).replace(/\%20/g,'+')) + '">from &#128716;</a> <a target=_blank title="' + gllentry.split(',')[2].replace(/\;/g,',') + '" href="//en.wikipedia.org/wiki/' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '">' + gllentry.split(',')[2].replace(/\;/g,',') + '</a>';
document.getElementById('brg').value='0.0000000';
document.getElementById('dist').value='0.000';
document.getElementById('brg').style.backgroundColor='white';
document.getElementById('dist').style.backgroundColor='white';
cwhat=[false,false,true,true,false,false];
ourdist=great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value);
document.getElementById(eles[3]).value='' + ourdist;

//Let ā€˜R’ be the radius of Earth,
//ā€˜L’ be the longitude,
//ā€˜Īøā€™ be latitude,
//ā€˜Ī²ā€˜ be Bearing.


//Bearing from point A to B, can be calculated as,

//β = atan2(X,Y),

//where, X and Y are two quantities and can be calculated as:

//X = cos Īøb * sin āˆ†L

//Y = cos Īøa * sin Īøb – sin Īøa * cos Īøb * cos āˆ†L


ourbrg=eval(eval(360.0 + eval(eval(eval(180.0 / Math.PI) * Math.atan2(
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value))))),
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value)))))
)))) % 360.0);


document.getElementById('mysel').value='2';
document.getElementById(eles[2]).value='' + ourbrg;
document.getElementById(eles[2]).style.backgroundColor='lightgreen';
document.getElementById(eles[3]).style.backgroundColor='lightgreen';
}
} else {
var interesting=false, waslatt='', waslongt='', wasfplacen='';
if (gllonesuffix == 'f') {
interesting=true;
waslatt=document.getElementById('latt').value;
waslongt=document.getElementById('longt').value;
if (documentURL == document.URL) {
wasfplacen=location.search.split('tplacen=')[1] ? (' ' + decodeURIComponent(location.search.split('tplacen=')[1].split('&')[0]).replace(/\+/g,' ')) : ''; //document.getElementById('tplacen').value;
} else {
wasfplacen=decodeURIComponent(documentURL.split('tplacen=')[eval(-1 + documentURL.split('tplacen=').length)].split('&')[0]);
}
//alert('interesting');
}

mu=mu.replace('=London','=' + encodeURIComponent(fplacen));
document.getElementById('brg').focus();
document.getElementById('dist').focus();
document.getElementById('latt').focus();
document.getElementById('latt').value=gllentry.split(',')[0];
mu=mu.replace('[051.5072,','[' + gllentry.split(',')[0] + ',');
document.getElementById('longt').focus();
document.getElementById('longt').value=gllentry.split(',')[1];
mu=mu.replace(',-00.1275,',',' + gllentry.split(',')[1] + ',');
document.getElementById('latt').focus();
gllonesuffix = 'f';
if (interesting) {
document.getElementById('spfr').innerHTML=document.getElementById('spfr').innerHTML.replace('to','from<input type=hidden id=tplacen name=tplacen value="' + gllentry.split(',')[2].replace(/\;/g,',') + '"></input>');
} else {
document.getElementById('spfr').innerHTML=document.getElementById('spfr').innerHTML.replace('to','from<input type=hidden id=tplacen name=tplacen value="' + gllentry.split(',')[2].replace(/\;/g,',') + '"></input>');
}
document.getElementById('ifill').value='Map Trip';
document.getElementById('sst').innerHTML=' ' + gllentry.split(',')[2].replace(/\;/g,',');
mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '~]');
tpurl=tpurl.replace("Brisbane+QLD,+Australia",encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')));
if (document.getElementById('sftif') && document.getElementById('iftif')) {
if (document.getElementById('addafirst')) { document.getElementById('addafirst').style.display='inline-block'; }
if (document.getElementById('addacc')) { document.getElementById('addacc').style.display='inline-block'; }
document.getElementById('iftif').src=document.getElementById('iftif').src.replace('&',encodeURIComponent(' to ' + gllentry.split(',')[2].replace(/\;/g,',')) + '&') + ',[' + gllentry.replace(',' + gllentry.split(',')[1] + ',', ',' + gllentry.split(',')[1] + ',~').replace(/\ /g,'%20') + '~]';
//if (interesting) {
// alert('interesting ... fplacen=' + fplacen);
//}
if (interesting) {
document.getElementById('sftif').innerHTML+=(' from <a target=_blank title="' + wasfplacen + '" href="//en.wikipedia.org/wiki/' + encodeURIComponent(wasfplacen) + '">' + wasfplacen + '</a> ').substring(0,1) + '<a target=_blank title=Accomodation onclick=woit(this); data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(wasfplacen).replace(/\%20/g,'+')) + '">&#128716;</a>' + '<a target=_blank title="Google Maps Directions" href="' + tpurl.replace('https:','') + '">to</a><a title="Map of this trip leg" class="adda" onclick="addto(this);" data-from="' + (wasfplacen ? wasfplacen : fplacen) + '" data-to="' + gllentry.split(',')[2].replace(/\;/g,',') + '" style="display:inline-block;cursor:pointer;" data-latf=' + (waslatt ? waslatt : document.getElementById('latf').value) + ' data-longf=' + (waslongt ? waslongt : document.getElementById('longf').value) + ' data-latt=' + document.getElementById('latt').value + ' data-longt=' + document.getElementById('longt').value + ' data-gcd=' + eval(eval('' + great_circle_distance((waslatt ? waslatt : document.getElementById(eles[0]).value),(waslongt ? waslongt : document.getElementById(eles[1]).value),document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + '>&#11014;<a> <a target=_blank title="' + gllentry.split(',')[2].replace(/\;/g,',') + '" href="//en.wikipedia.org/wiki/' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '">' + gllentry.split(',')[2].replace(/\;/g,',') + '</a> (' + '<a target=_blank title=Accomodation onclick=woit(this); data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')).replace(/\%20/g,'+')) + '">&#128716;</a> ' + eval(eval('' + great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + ' kilometres)';
//alert('interesting ... fplacen=' + wasfplacen);
} else {

document.getElementById('sftif').innerHTML+=' <a target=_blank title="Google Maps Directions" href="' + tpurl.replace('https:','') + '">to</a><a title="Map of this trip leg" class="adda" onclick="addto(this);" data-from="' + (wasfplacen ? wasfplacen : fplacen) + '" data-to="' + gllentry.split(',')[2].replace(/\;/g,',') + '" style="display:inline-block;cursor:pointer;" data-latf=' + (waslatf ? waslatf : document.getElementById('latf').value) + ' data-longf=' + (waslongf ? waslongf : document.getElementById('longf').value) + ' data-latt=' + document.getElementById('latt').value + ' data-longt=' + document.getElementById('longt').value + ' data-gcd=' + eval(eval('' + great_circle_distance((waslatf ? waslatf : document.getElementById(eles[0]).value),(waslongf ? waslongf : document.getElementById(eles[1]).value),document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + '>&#11014;<a> <a target=_blank title="' + gllentry.split(',')[2].replace(/\;/g,',') + '" href="//en.wikipedia.org/wiki/' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '">' + gllentry.split(',')[2].replace(/\;/g,',') + '</a> (' + '<a target=_blank title=Accomodation onclick=woit(this); data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')).replace(/\%20/g,'+')) + '">&#128716;</a> ' + eval(eval('' + great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + ' kilometres)';
}
document.getElementById('brg').style.backgroundColor='white';
document.getElementById('dist').style.backgroundColor='white';
documentURL+='&tplacen=' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,','));
cwhat=[false,false,true,true,false,false];
ourdist=great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value);
document.getElementById(eles[3]).value='' + ourdist;

//Let ā€˜R’ be the radius of Earth,
//ā€˜L’ be the longitude,
//ā€˜Īøā€™ be latitude,
//ā€˜Ī²ā€˜ be Bearing.


//Bearing from point A to B, can be calculated as,

//β = atan2(X,Y),

//where, X and Y are two quantities and can be calculated as:

//X = cos Īøb * sin āˆ†L

//Y = cos Īøa * sin Īøb – sin Īøa * cos Īøb * cos āˆ†L


ourbrg=eval(eval(360.0 + eval(eval(eval(180.0 / Math.PI) * Math.atan2(
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value))))),
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value)))))
)))) % 360.0);


document.getElementById('mysel').value='2';
document.getElementById(eles[2]).value='' + ourbrg;
document.getElementById(eles[2]).style.backgroundColor='lightgreen';
document.getElementById(eles[3]).style.backgroundColor='lightgreen';


if (interesting) {
document.getElementById('spfr').innerHTML='to';
document.getElementById('ipn').focus();
}

}
}
document.getElementById('ipn').placeholder=gllentry.split(',')[2].replace(/\;/g,',');
}
gllentry='';
document.getElementById('placegeo').value='';
}


Previous relevant Earth Bearing Distance Missing Two Trip Details Summary Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Details Summary Tutorial

Earth Bearing Distance Missing Two Trip Details Summary Tutorial

The recent Earth Bearing Distance Missing Two Locality Distance Ring Tutorial coalesced “From” Place name functionality for …

  • defined bearing … deriving horizon place
  • defined distance … deriving ring of positions … and today we consider …
  • Trip functionality thoughts via “To” Place name definitions supplementing the already entered “From” Place name

We say “Trip Details Summary” in our blog posting title today as a hint about how we present a nester of Google Chart Map Chart display data.

The details/summary HTML element combination we often use to “reveal”, or not, webpage “real estate”, but today we default to the “open” look and add Wikipedia links and crowfly distance and Google Maps Directions information into the summary tag, for extra interest with your Trip planning.

The user can access this functionality with our changed missing_two.html‘s live run link …

  1. user enters “From” Place Name via new textbox … eg. “Lawson, New South Wales”
  2. user enters “To” Place Name via new textbox … eg. “Katoomba”
  3. user clicks/taps the “Fill” button
  4. optionally the user can add more places to the Map Chart by adding more “From” and/or “To” Place Name definitions


Previous relevant Earth Bearing Distance Missing Two Locality Distance Ring Tutorial is shown below.

Earth Bearing Distance Missing Two Locality Distance Ring Tutorial

Earth Bearing Distance Missing Two Locality Distance Ring Tutorial

The corollary to yesterday’s Earth Bearing Distance Missing Two Place Name and Horizon Tutorial‘s …

  • locality and bearing derivation of a “place on horizon” position … is, today …
  • locality and distance derivation of a “locality distance ring” set of positions

… again, combining the geodata talents of Wikipedia and a Google Chart Map Chart, we figure.

And so a user accessing this functionality with our changed missing_two.html‘s live run link …

  1. user enters “From” Place Name via new textbox … eg. “Lawson, New South Wales”
  2. user enters “Distance” (eg. “5000.000” metres) and tabs out … we use the “onblur” event …

    var dok=true;

    function dfillablemaybe(brgo) {
    if (!dok) { return ''; }
    var i, ourbrg=0.0, ourdist=0.0, j, dvlat='', dvlong='';
    if (('' + brgo.value).replace(/0/g,'').replace('.','') != '') {
    //alert('356:' + document.getElementById('dist').value);
    if (('' + document.getElementById('dist').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
    //alert(456);
    if (('' + document.getElementById('latt').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
    //alert(556);
    if (('' + document.getElementById('longt').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
    //alert(656);
    if (('' + document.getElementById('ssf').innerHTML) != '') {
    //alert(756);
    if (!viastart) {
    //document.getElementById('brg').focus();
    document.getElementById('brg').value='0.0000001';
    //brgo.focus();
    }
    if (mu.indexOf('[051.5072,') != -1) {
    //alert(856);
    if (!viastart) {
    //alert(1);
    document.getElementById('ifill').click();
    //alert(11);
    }
    mu=mu.replace('[051.5072,','[' + eval('' + document.getElementById('latt').value).toFixed(3) + ',');
    mu=mu.replace(',-00.1275,',',' + eval('' + document.getElementById('longt').value).toFixed(3) + ',');
    if (('' + brgo.value).indexOf('000.000') != -1) {
    //mu=mu.replace(encodeURIComponent('looking out North'), encodeURIComponent(('' + brgo.value).split('000.000')[0] + 'km Ring'));
    mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(fplacen + ' looking North') + '~]');
    mu=mu.replace('=London','=' + encodeURIComponent(fplacen + (' ' + brgo.value).split('000.000')[0] + 'km Ring'));
    } else {
    mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(fplacen + ' looking North') + '~]');
    mu=mu.replace('=London','=' + encodeURIComponent(fplacen + ' looking out North'));
    }
    //mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(fplacen + ' looking North') + '~]');
    //mu=mu.replace('=London','=' + encodeURIComponent(fplacen + ' looking out North'));
    //alert('956:' + mu);
    //document.getElementById('hplacen').innerHTML='<input type=hidden name=fplacen value="' + mu + '"></input>';
    //document.getElementById('tdmid').innerHTML='<iframe src="' + mu + '" style="width:100%;height:700px;"></iframe>';
    if (viastart) {
    for (var dbrg=30; dbrg<=330; dbrg+=30) {
    //document.getElementById('brg').value='' + dbrg + '.0000000';

    if (('' + document.getElementById('mysel').value) == '2') {
    ourbrg=eval(eval(540.0 + 180.0 + eval('' + document.getElementById(eles[2]).value)) % 360.0);
    } else {
    ourbrg=eval('' + document.getElementById(eles[2]).value);
    }
    ourbrg=eval('' + dbrg);
    for (j=eval(3 - eval(('' + document.getElementById('mysel').value))); j>=1; j--) {
    ourdist=eval('' + document.getElementById(eles[3]).value);

    //Let first point latitude be la1,
    ///longitude as lo1,
    //d be distance,
    //R as radius of Earth,
    //Ad be the angular distance i.e d/R and.
    //Īø be the bearing,

    //Here is the formula to find the second point, when first point, bearing and distance is known:

    //latitude of second point = la2 = asin(sin la1 * cos Ad + cos la1 * sin Ad * cos Īø), and
    //longitude of second point = lo2 = lo1 + atan2(sin Īø * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)


    dvlat='' +
    eval(eval(eval(180.0 / Math.PI) * Math.asin(
    Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)) *
    Math.cos(eval(eval('' + ourdist) / 6371000.0)) +
    Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)) *
    Math.sin(eval(eval('' + ourdist) / 6371000.0)) *
    Math.cos(eval(Math.PI / 180.0) * eval('' + ourbrg)))));

    //Let first point latitude be la1,
    //longitude as lo1,
    //d be distance,
    //R as radius of Earth,
    //Ad be the angular distance i.e d/R and
    //Īø be the bearing,
    // longitude of second point = lo2 = lo1 + atan2(sin Īø * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)

    dvlong='' + eval(eval(180.0 / Math.PI) * eval(eval(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[1]).value)) +
    Math.atan2(
    eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + ourbrg)) *
    eval('' + Math.sin(eval(eval('' + ourdist) / 6371000.0)))) *
    eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)))),
    eval(eval('' + Math.cos(eval(eval('' + ourdist) / 6371000.0))) -
    eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)))) *
    eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))))));
    mu+=',[' + eval('' + dvlat).toFixed(3) + ',' + eval('' + dvlong).toFixed(3) + ',~' + dbrg + '~]';


    }

    }
    document.getElementById('tdmid').innerHTML='<iframe src="' + mu + '" style="width:100%;height:700px;"></iframe>';
    fplacen='';
    }
    }

    }
    }
    }
    }
    }
    }

    … logic of that occurrence to say it is this scenario and above … so …
  3. set bearing to value “0.0000001” (ie. start the locality distance ring looking North)
  4. we programmatically click the yellow “Fill” button
  5. a Google Chart Map Chart is displayed with both …
    • observer position … and this approximate calculated …
    • locality distance ring set of positions at 30 degree intervals around the ring whose radius is the Distance value (in metres) entered by the user


Previous relevant Earth Bearing Distance Missing Two Place Name and Horizon Tutorial is shown below.

Earth Bearing Distance Missing Two Place Name and Horizon Tutorial

Earth Bearing Distance Missing Two Place Name and Horizon Tutorial

Yesterday’s Earth Bearing Distance Missing Two Place Name Tutorial left off with …

We hope so, and there is another reason for this preparatory work that will be explained tomorrow. Stay tuned!

Well, today’s “tomorrow”. Let me ask first, did you read our Compass iOS App Primer Tutorial? Well, the use of the Compass iOS (and am sure Android would have their own version of) mobile app fits into our scenario whereby …

  • we had occasion to be looking at a long distance view into the distance down a road both …
    1. during the day … and also seeing …
    2. lights at night

    … which set us (being of the “where are we” looking curious set) wondering …

  • where are we looking?
  • whipping out the iPhone’s Compass app gave us all of …
    1. bearing to distant view …
    2. elevation in metres … interesting …
    3. latitude, longitude of where we were (though we think we’ll get help from Wikipedia here, thanks)

    … meaning …

  • we could offer the user of our changed missing_two.html‘s live run link the chance to involve data items 1 and 2 above directly and 3 (via Wikipedia) … to have it that …
    1. user enters “From” Place Name via new textbox (and add the Compass app elevation (in metres) as a semicolon separated data item) … eg. “Lawson, New South Wales;740”
    2. user enters “Bearing” (eg. “185” (off the Compass app)) and tabs out … we use the “onblur” event …

      var dok=true;

      function fillablemaybe(brgo) {
      if (('' + brgo.value).replace(/0/g,'').replace('.','') != '') {
      //alert('356:' + document.getElementById('dist').value);
      if (('' + document.getElementById('dist').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
      //alert(456);
      if (('' + document.getElementById('latt').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
      //alert(556);
      if (('' + document.getElementById('longt').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
      //alert(656);
      if (('' + document.getElementById('ssf').innerHTML) != '') {
      //alert(756);
      if (!viastart) {
      dok=false;
      document.getElementById('dist').focus();
      if (1 == 1) { // assume 2m elevation ... thanks to https://en.wikipedia.org/wiki/Horizon
      document.getElementById('dist').value='' + Math.floor(Math.pow(eval(eval(2.0 * eval('' + elev)) * 6371000.0), 0.5)) + '.000';
      } else {
      document.getElementById('dist').value='5000.000';
      }
      elev=2.0;
      brgo.focus();
      }
      if (mu.indexOf('[051.5072,') != -1) {
      //alert(856);
      if (!viastart) {
      document.getElementById('ifill').click();
      }
      mu=mu.replace('[051.5072,','[' + document.getElementById('latt').value + ',');
      mu=mu.replace(',-00.1275,',',' + document.getElementById('longt').value + ',');
      mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(fplacen + ' looking out at bearing ' + brgo.value + ' degrees towards horizon') + '~]');
      mu=mu.replace('=London','=' + encodeURIComponent(fplacen + ' looking out at bearing ' + brgo.value + ' degrees towards horizon'));
      //alert('956:' + mu);
      //document.getElementById('hplacen').innerHTML='<input type=hidden name=fplacen value="' + mu + '"></input>';
      document.getElementById('tdmid').innerHTML='<iframe src="' + mu + '" style="width:100%;height:700px;"></iframe>';
      if (viastart) {
      fplacen='';
      }
      }
      }
      }
      }
      }
      }
      }

      … logic of that occurrence to say it is this scenario and above … so compute …
    3. the distance to horizon is computed via square root of two times elevation (in meters) times radius of earth (in meters) … then …
    4. we programmatically click the yellow “Fill” button
    5. a Google Chart Map Chart is displayed with both …
      1. observer position … and this approximate calculated …
      2. horizon position

      … to help you un-nut “where are we looking?” … we hope

… which you can see the gist of with today’s animated GIF presentation.

Bit like relaxed orienteering, would you say?!


Previous relevant Earth Bearing Distance Missing Two Place Name Tutorial is shown below.

Earth Bearing Distance Missing Two Place Name Tutorial

Earth Bearing Distance Missing Two Place Name Tutorial

It’s often a good news story in I.T. when you can replace or supplement numbers with names (without being too nosy about it, that is!) And so, extending the functionality of our “Missing Two” web application talked about, last, with Earth Bearing Distance Missing Two Trip Share Tutorial we allow the user to enter in Place Names as an alternative to entering in the Latitude and Longitude co-ordinates of that place’s position on the earth, especially apt for any web application purporting to be helpful regarding “trip” functionality.

Being suckers for “the where of life” web applications out there, we’re tickled pink to be offering this “red zone” special extension to functionality, and all because you asked for it (well, that’s my story, and am sticking with it).

As we went along coding for this change, and implications of this into the future, we realized we needed to allow for two more (GET argument) data items to be catered for, the codelines below responsible for “reading them in” …


var fplacen=location.search.split('fplacen=')[1] ? (' ' + decodeURIComponent(location.search.split('fplacen=')[1].split('&')[0]).replace(/\+/g,' ')) : '';
var tplacen=location.search.split('tplacen=')[1] ? (' ' + decodeURIComponent(location.search.split('tplacen=')[1].split('&')[0]).replace(/\+/g,' ')) : '';

… and allowed for within the (static) HTML’s form element‘s HTML as per …


<h1 id=myh1 style='display:block;'>Missing Two (<font size=1>optional</font> <span id=spfr>from</span> <input onblur='lkwk(this);' style='display:inline-block;' placeholder='Place Name' id=ipn value='' type=text></input>) in a Table Column <span data-onfocus="document.getElementById('semail').innerHTML='';" data-title='Email to (append a space to just show the table cell with the gradient)?' data-contenteditable=true data-onblur=preemail(this.innerHTML); onclick=emailit(''); id=semail title=Email>&#128231;</span> <span data-onfocus="document.getElementById('semail').innerHTML='';" data-title='SMS to?' data-contenteditable=true data-onblur=preemail(this.innerHTML); onclick=toize(''); id=ssms title=SMS>&#128223;</span></h1>

… and …


<tr id=trhead style='display:table-row;'><th style='width:30%;text-align:left;background-color:#f0e0d0;'><a title='Show nearest TimeZone places' id=afrom onclick=mapit(this); style='cursor:pointer;text-decoration:underline;'>From</a><span id=ssf></span>> <div id=dfrom style='display:none;'></div></th><th style='width:30%;text-align:left;background-color:#e0d0f0;'> ... On The Way ...</th><th style='text-align:left;background-color:#d0f0e0;'><a title='Show nearest TimeZone places' id=ato onclick=mapit(this); style='cursor:pointer;text-decoration:underline;'>To</a><span id=sst></span> <div id=dto style='display:none;'></div></th></tr>

… and populated via supportive “onload” event based Javascript DOM “Wikipedia (thanks) based” logic as per …


if (fplacen != '') {
document.getElementById('ssf').innerHTML=fplacen;
fplacen='';
}
if (tplacen != '') {
document.getElementById('sst').innerHTML=tplacen;
tplacen='';
}

… as the incoming code paradigm, living with the outgoing paradigm’s work based on that “lkwk(this);” Javascript function …


var gllentry='';

function askit() {
//alert(gllentry);
if (gllentry.indexOf(',') != -1) {
if (gllonesuffix == 'f') {
document.getElementById('latf').focus();
document.getElementById('latf').value=gllentry.split(',')[0];
document.getElementById('longf').focus();
document.getElementById('longf').value=gllentry.split(',')[1];
document.getElementById('latf').focus();
gllonesuffix = 't';
document.getElementById('spfr').innerHTML=document.getElementById('spfr').innerHTML.replace('from','to<input type=hidden name=fplacen value="' + gllentry.split(',')[2].replace(/\;/g,',') + '"></input>');
document.getElementById('ssf').innerHTML=' ' + gllentry.split(',')[2].replace(/\;/g,',');
} else {
document.getElementById('brg').focus();
document.getElementById('dist').focus();
document.getElementById('latt').focus();

document.getElementById('latt').value=gllentry.split(',')[0];
document.getElementById('longt').focus();
document.getElementById('longt').value=gllentry.split(',')[1];
document.getElementById('latt').focus();
gllonesuffix = 'f';
document.getElementById('spfr').innerHTML=document.getElementById('spfr').innerHTML.replace('to','from<input type=hidden name=tplacen value="' + gllentry.split(',')[2].replace(/\;/g,',') + '"></input>');
document.getElementById('sst').innerHTML=' ' + gllentry.split(',')[2].replace(/\;/g,',');
}
document.getElementById('ipn').placeholder=gllentry.split(',')[2].replace(/\;/g,',');
}
gllentry='';
document.getElementById('placegeo').value='';
}

function lookforg() {
if (document.getElementById('placegeo').value != '') {
gllentry=document.getElementById('placegeo').value + ',' + decodeURIComponent(document.getElementById('ifplacegeo').src.split('?placegeo=')[1]).replace(/\,/g,';');
askit();
} else {
setTimeout(lookforg,1000);
}
}

function checkit(iois) {
if (iois != null) {
if (iois.src.indexOf('?placegeo=') != -1) {
//alert(1);
var aconto = (iois.contentWindow || iois.contentDocument);
//alert(11);
if (aconto != null) {
//alert(111);
if (aconto.document) { aconto = aconto.document; }
//alert(1111);
if (aconto.body != null) {
//alert(2);
document.body.style.cursor='pointer';
if (document.getElementById('placegeo').value != '') {
//alert(3);
gllentry=document.getElementById('placegeo').value + ',' + decodeURIComponent(iois.src.split('?placegeo=')[1]).replace(/\,/g,';');
askit();
} else {
//alert(8);
setTimeout(lookforg,1000);
}
}
}
}
}
}


function lkwk(oiis) {
if (oiis.value.trim() != '') {
document.getElementById('ifplacegeo').src=document.getElementById('ifplacegeo').src.split('?')[0].split('#')[0] + '?placegeo=' + encodeURIComponent(oiis.value);
oiis.value='';
document.body.style.cursor='progress';
}

}

… supporting the relevant (new static) HTML …


<iframe onload='checkit(this);' style='display:none;' id=ifplacegeo src='../PHP/fgc/index.php'></iframe>
<input type=hidden id=placegeo value=''></input>

Believe it or not, with this web application, it is important what input type=text textboxes are “visited”, and up until today, we had no concerns with that “ordering” issue very much, because we only coded for “real user” interactive input, but today’s place name functionality modifications mean that we feel we need to programmatically force the order somewhat in these place name entry scenarios, but we were not sure whether our non-mobile only (and slightly kludgy feeling) [input type=text element].focus(); interventions would/could work. But they did, happily, at least for non-mobile platforms! This means input type=text element “onblur” events must have been triggered, we figure, which is an interesting finding (well, you had to be there, didn’t you?!)

Perhaps, then, the changed missing_two.html‘s live run link will spark your interest? We hope so, and there is another reason for this preparatory work that will be explained tomorrow. Stay tuned!


Previous relevant Earth Bearing Distance Missing Two Trip Share Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Share Tutorial

Earth Bearing Distance Missing Two Trip Share Tutorial

When Ajax came on the scene, HTML form navigation got that bit daggier. But as time has gone on, we’ve started appreciating those more traditional HTML form navigation methodologies more for a few major reasons …

  1. the FormData in the Ajax/FormData combination of navigational methodologies simulates static HTML form element functionality
  2. we’ve grown to really admire “Inline HTML Email” sharing via PHP mail to the email and back again out to the “www” wooooorrrrrlllllddd via an “Inline HTML Email Form” (as widens the scope of use for today’s web application)
  3. we’ve grown to really admire a static HTML form element’s “onsubmit” event to massage an HTML form element’s content on the way through to accepting the “action” form navigational destination, or reject that
  4. we’ve grown to really admire the concept of multiple submit button elements without or with an associated name attribute to be able to detect which submit button was clicked/touched

… and it seems to me there are now in the web application wooooorrrrrllllddd a plethora of navigational functionality choices for programmers out there. Yayyyyy!

And so, onto Earth Bearing Distance Missing Two Trip Tutorial today we add two sharing conduit …

  • email
  • SMS

… means of functionality which call on …


function preemailit(ine) {
if (ine.indexOf('@') != -1) {
emailit(ine);
} else if (ine != '') {
toize(ine);
}
}

function dummyencodeURIComponent(invl) {
return invl;
}

function emailit(defe) {
//document.getElementById('ih').value=document.getElementById('tdlook').innerHTML.replace(/\<br\>/g,String.fromCharCode(10));
var lastfis='youllneverfindthis';
var lasttis='';
var lasteis='youllneverfindthis';
var lastenow='';
var lastsis='youllneverfindthis';
var lastsnow='';
var lasteis2='youllneverfindthis';
var lastenow2='';
var lastsis2='youllneverfindthis';
var lastsnow2='';
var em='';
var suffbits='?latf=' + encodeURIComponent(document.getElementById('latf').value) + '&longf=' + encodeURIComponent(document.getElementById('longf').value) + '&latt=' + encodeURIComponent(document.getElementById('latt').value) + '&longt=' + encodeURIComponent(document.getElementById('longt').value) + '&brg=' + encodeURIComponent(document.getElementById('brg').value) + '&dist=' + encodeURIComponent(document.getElementById('dist').value);
if (defe.indexOf('@') != -1) {
em=defe
} else {
em=prompt('Email to? (all uppercase uses client email else sends an Inline HTML Email Form)', '');
}
if (em == null) { em=''; }
if (em.indexOf('@') != -1) {
//document.getElementById('from').value=em;
if (document.URL.toLowerCase().indexOf('rjmprogramming.com.au') != -1 && em != em.toUpperCase()) {
var xzhr = new XMLHttpRequest();
var xform=new FormData();
xform.append('inline','');
xform.append('to',em.trim());
var flatf=document.getElementById('latf').outerHTML;
var flongf=document.getElementById('longf').outerHTML;
var flatt=document.getElementById('latt').outerHTML;
var flongt=document.getElementById('longt').outerHTML;
var fbrg=document.getElementById('brg').outerHTML;
var fdist=document.getElementById('dist').outerHTML;
var tlatf='<input type=text name=latf id=latf value="' + document.getElementById('latf').value + '"></input>';
var tlongf='<input type=text name=longf id=longf value="' + document.getElementById('longf').value + '"></input>';
var tlatt='<input type=text name=latt id=latt value="' + document.getElementById('latt').value + '"></input>';
var tlongt='<input type=text name=longt id=longt value="' + document.getElementById('longt').value + '"></input>';
var tbrg='<input type=text name=brg id=brg value="' + document.getElementById('brg').value + '"></input>';
var tdist='<input type=text name=dist id=dist value="' + document.getElementById('dist').value + '"></input>';
//if (from.indexOf('@') != -1) { xform.append('cc',from.trim()); }
console.log('tdfrom');
faux=true;
mapit(document.getElementById('tdfrom'));
console.log(document.getElementById('afrom').href);
console.log('tdto');
faux=true;
mapit(document.getElementById('tdto'));
console.log(document.getElementById('ato').href);
if (document.body.innerHTML.indexOf('<tr id="trfoot"') != -1) {
lastfis='<tr id="trfoot"' + document.body.innerHTML.split('<tr id="trfoot"')[1].split('</tr>')[0] + '</tr>';
if (document.getElementById('asms').href.indexOf('sms:') != -1) {
lasteis='<span ';
lastenow='<a target=_blank href="mailto:?subject=' + dummyencodeURIComponent(encodeURIComponent('Missing%20Two')) + '&body=' + dummyencodeURIComponent(encodeURIComponent(document.getElementById('asms').href.split('&body=')[1])) + '" ';
lasteis2='</span>';
lastenow2='</a>';
lastsis='<span ';
lastsnow='<a target=_blank href="' + document.getElementById('asms').href.split('&')[0] + '&body=' + dummyencodeURIComponent(encodeURIComponent(document.getElementById('asms').href.split('&body=')[1])) + '" ';
lastsis2='</span>';
lastsnow2='</a>';
} else if (document.getElementById('asms').href.indexOf('mailto:') != -1) {
lastsis='<span ';
lastsis=document.getElementById('ssms').outerHTML.split('>')[0] + '>';
lastsnow='<a target=_blank href="sms:&body=' + dummyencodeURIComponent(encodeURIComponent(document.getElementById('asms').href.split('&body=')[1])) + '" ';
lastsnow='<input type=submit title=SMS name=sms id=ssms value="';
lastsis2='</span>';
lastsnow2='</a>';
lastsnow2='"></input>';
lasteis='<span ';
lastenow='<a target=_blank href="mailto:' + em.trim() + '?subject=' + dummyencodeURIComponent(encodeURIComponent('Missing%20Two')) + '&body=' + dummyencodeURIComponent(encodeURIComponent(document.getElementById('asms').href.split('&body=')[1])) + '" ';
lasteis2='</span>';
lastenow2='</a>';
}
}
if (em.trim() != em) {
xform.append('subj','Missing Two');
//var cbgtd=document.getElementById('tdlook').getBoundingClientRect();
xform.append('body','<body>' + document.body.innerHTML.replace(/\ id\=\"mysel\"/g, ' name="mysel" id="mysel"').replace(/\ size\=\"3\"/g, ' size="4"').replace(/\ data\-href\=/g, ' target=_blank href=').replace('</form>', '<br><br><input style=background-color:lightgreen; type=submit value=Solve></input></form>').replace('DISPLAY:table-row','DISPLAY:none').replace(lastfis,lasttis).replace(lasteis,lastenow).replace(lasteis2,lastenow2).replace(lastsis,lastsnow).replace(lastsis2,lastsnow2).replace('absolute;','absolute;display:none;').replace(flatf,tlatf).replace(flongf,tlongf).replace(flatt,tlatt).replace(flongt,tlongt).replace(fbrg,tbrg).replace(fdist,tdist) + '</body>');
} else {
xform.append('subj','Missing Two');
xform.append('body','<body>' + document.body.innerHTML.replace(/\ id\=\"mysel\"/g, ' name="mysel" id="mysel"').replace(/\ size\=\"3\"/g, ' size="4"').replace(/\ data\-href\=/g, ' target=_blank href=').replace('</form>', '<br><br><input style=background-color:lightgreen; type=submit value=Solve></input></form>').replace('DISPLAY:table-row','DISPLAY:none').replace(lastfis,lasttis).replace(lasteis,lastenow).replace(lasteis2,lastenow2).replace(lastsis,lastsnow).replace(lastsis2,lastsnow2).replace('absolute;','absolute;display:none;').replace(flatf,tlatf).replace(flongf,tlongf).replace(flatt,tlatt).replace(flongt,tlongt).replace(fbrg,tbrg).replace(fdist,tdist) + '</body>');
}
xzhr.open('post','//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php',true);
xzhr.send(xform);
} else {
document.getElementById('asms').href='mailto:' + em.trim() + '?subject=' + encodeURIComponent('Missing Two') + '&body=' + encodeURIComponent(document.URL.split('#')[0].split('?')[0] + suffbits); // + '?missingtwo=' + encodeURIComponent(encodeURIComponent(document.getElementById('dfix').innerHTML.replace('background: ','').replace('background:','').replace(');',')').replace(';',''))));
document.getElementById('asms').click();
}
}
}

… in the changed missing_two.html‘s live run link.


Previous relevant Earth Bearing Distance Missing Two Trip Tutorial is shown below.

Earth Bearing Distance Missing Two Trip Tutorial

Earth Bearing Distance Missing Two Trip Tutorial

If we were to nominate an “onions of the 4th dimension” improvement on top of the work of Earth Bearing Distance Missing Two Context Tutorial we’d nominate … anyone, anyone … yes, tenticle 5 of The Kraken … we’d want to allow our “Missing Two Geographical places via Bearing and Distance” web application be turned into a trip planner by allowing for multiple legs, perhaps of a trip, to be “represented” by our new incarnation of the web application. As per usual, with extensions of functionality, here, it is optional, and manifested by … anyone, anyone … yes, tenticle 9 3/4 of The Kraken … turning a hardcoded piece of (webpage) text into an HTML element with action logic behind it … our TAHPOWTIAHEWALBI moment, you could say?!

Seriously though, it is rare that a sizeable trip happens as a one leg with the one bearing and distance component, so we turn our old web application into a …

… type of web application, in order to do that other thing we like to do, and that is to have the one (in this case just HTML/Javascript/CSS) codeset handle both simple and (optional) complex usage functionalities.

How do we differentiate a “top.document” parent from an (HTML) iframe (element) child? We use …

  • address bar URL ? and & argument (?latf=[previousToLatitude]&longf=[previousToLongitude]) usage (and analysis) via … checked for via …
  • <body onload=’moremaybe();’>

  • function moremaybe() {
    var latto=location.search.split('latf=')[1] ? decodeURIComponent(location.search.split('latf=')[1].split('&')[0]) : '';
    var longto=location.search.split('longf=')[1] ? decodeURIComponent(location.search.split('longf=')[1].split('&')[0]) : '';
    if (latto != '' && longto != '') {
    nextplease();
    top.document.getElementById('goagain').style.display='block';
    document.getElementById('latf').value=latto;
    document.getElementById('latf').style.backgroundColor="pink";
    cwhat[0]=false;
    cwhat[1]=false;
    if (!decided) {
    if (!cwhat[5]) {
    cwhat[5]=true;
    }
    if (!cwhat[4]) {
    cwhat[4]=true;
    }
    decided=true;
    }
    top.document.getElementById("ltf").value=latto;
    document.getElementById('longf').value=longto;
    document.getElementById('longf').style.backgroundColor="pink";
    cwhat[0]=false;
    cwhat[1]=false;
    if (!decided) {
    if (!cwhat[5]) {
    cwhat[5]=true;
    }
    if (!cwhat[4]) {
    cwhat[4]=true;
    }
    decided=true;
    }
    top.document.getElementById("lgf").value=longto;
    document.getElementById('dtop').style.display='none';
    document.getElementById('trhead').style.display='none';
    document.getElementById('trfoot').style.display='none';
    document.getElementById('myt').border=0;
    var recti=parent.document.getElementById('niframe').getBoundingClientRect();
    parent.document.getElementById('niframe').height=eval(200 + eval(('' + recti.height).replace('px',''))) + 'px';
    if (parent.document.getElementById('niframe') != top.document.getElementById('niframe')) {
    var trecti=top.document.getElementById('niframe').getBoundingClientRect();
    top.document.getElementById('niframe').height=eval(200 + eval(('' + trecti.height).replace('px',''))) + 'px';
    }
    setTimeout(checkfill, 500);
    parent.document.getElementById("slong").innerHTML=":";
    parent.document.getElementById("slong").title="";
    parent.document.getElementById("slong").style.textDecoration="none";
    //top.document.title+=' started ';
    }
    }

… where you can see that “top.document” (top) parent is just that … top.document … and that a parent of an (HTML) iframe (element) trip leg is referred to via … parent.document … and what is being done in the here and now of a simple scenario (just in the (top) parent) or a complex (non (top) parent leg) … document … references come into play. That parent.document.getElementById(“slong”) refers to the dynamically changed method of adding legs, by turning the …

  • hardcoded “:” (text) of the To longitude textbox labelling … into a clickable and onclick event working …

  • document.getElementById('slong').style.cursor='pointer';
    document.getElementById('slong').style.textDecoration='underline';
    document.getElementById('slong').title='Click for another leg of a trip, perhaps?';
    document.getElementById('slong').innerHTML='+';

    … optionally used, and dynamic extension to functionality … our “onions of the 4th dimension” moment … who said we don’t care about your health here?!

… so that top.document.getElementById(‘niframe’) is the representation of that “top.document” parent’s first (HTML) iframe (element) child.

Why ask that previous question? To have the one codebase service all the scenarios, we need (the code) to know “where it is at”, so to speak.

The changed missing_two.html‘s live run link can have you planning your own “where of life” trip itinerary of interest yourself.


Previous relevant Earth Bearing Distance Missing Two Context Tutorial is shown below.

Earth Bearing Distance Missing Two Context Tutorial

Earth Bearing Distance Missing Two Context Tutorial

Mapping and navigational apps wouldn’t be as popular as they are without …

  • satellite based geodata available to our mobile and laptop (and cars etcetera) devices and their software … and …
  • the human urge to want to know where they are

… and so to leave yesterday’s Earth Bearing Distance Missing Two Primer Tutorial “proof of concept” web application the way it was, not showing much context to the latitude and longitude form “asks” would be a missed opportunity.

In this sense, we’ve decided to interface this web application to …

… to give the changed missing_two.html‘s live run link that optional map (or visual) extra context. This is accessible off links applied to the previously hardcoded “From” and “To” table headers. Please feel free to give it a go to see what we mean.


Previous relevant Earth Bearing Distance Missing Two Primer Tutorial is shown below.

Earth Bearing Distance Missing Two Primer Tutorial

Earth Bearing Distance Missing Two Primer Tutorial

Get in a conversation with a Land Surveyor, and drop in your sentence, close to each other, the words “bearing” and “distance” and in all likelihood you’ll get a smile. Is it a curved smile? Maybe, they are interested in the geodesic aspects to these two terms. You see, the rules of Euclidean geometry are all fine and good and used by Land Surveyors for small distances involving local mapping or small area mapping, where the curvature of the Earth is not really a factor. In fact, in the early days of Land Surveying, the plotting of an area might have been done using a table resting on a tripod, which hopefully made that table level (all good terrestrial surveying wants you to be perpendicular to the imaginary plumb bob hanging from your instrument, and hanging down in accordance with gravity’s laws). Geodesic interest for Land Surveyors tries to take into account the curvature of the Earth, which we’ll assume for today, is a sphere, though in reality it takes on a spheroidal shape that is not quite a sphere.

Polar co-ordinate designations are an alternative “view” to placing yourself, as distinct from grid co-ordinates, or geographical latitude and longitude.

We talked about some of what we have written a proof of concept web application for today with the PHP Google Map Chart Bearing Distance Tutorial some time back, and revisited its excellent …

very useful link that talks about the Haversine distance formula, as well

… and rereading this excellent webpage, realized that two sets of formulae there (plus the great circle distance calculations before) could help us piece together a useful navigational web application that, out of …

From Latitude, Longitude Bearing, Distance To Latitude, Longitude

… we could get the user to fill out 2 of 3 columns of information above, and calculate the missing one for them.

How is this useful? Well, sometimes you want to know …

  • We are at X. We are crow flying to Y. In which direction do we set out? How far is it?
  • We are at X. That looks like a nice direction to head, so what compass reading is that? If I go however far, where do I end up?

Second one for those dreamers and adventurers (or perhaps, orienteerers) methinks. Anyway, feel free to try the HTML and Javascript ‘s live run link, or down below …


Previous relevant PHP Google Map Chart Bearing Distance Tutorial is shown below.

PHP Google Map Chart Bearing Distance Tutorial

PHP Google Map Chart Bearing Distance Tutorial

There have been three recent things going on, for us, involving software integration of our interface to the great Google Chart Map Chart …

As a worker with a background in Land Surveying, of course, the words “bearing” and “distance” were part of the “bread and butter” of this job. The modern day equipment can, at the observer’s tripod, and given the chainperson’s placement of equipment, deal with both of these “measures” at once, but you can still use the old theodolites and distance measuring chains if you like. You take your measurements and use calculations like those underlying the workings of the web application of HTML and Javascript and CSS Survey Traverse Tutorial which are all fine and dandy if the distances are relatively small, because we can think “planar geometry” as we mostly learn at school. But if the measurements involve long enough distances, you need to take into account that Earth is, basically, round … meanwhile, on the phone ….

You don’t say. You don’t say. You don’t say.

…

“What’d they say?” …

They didn’t say.

When distances are this large we need to turn towards “geodesic calculations” and today …

Here are some “live runs” …

… and here’s the changed PHP map.php changed in this way.


Previous relevant PHP Wikipedia Australian List Integration Tutorial is shown below.

PHP Wikipedia Australian List Integration Tutorial

PHP Wikipedia Australian List Integration Tutorial

Yesterday’s PHP Wikipedia Australian List Makeover Tutorial got us thinking more about “where of life” functionality integration possibilities.

For us, with many “where of life” web applications, the Google Charts Map Chart is a core part of the functionality, as the receptacle, and more and more often as time goes on, also a launching pad out to other concepts, such as …

  • TimeZone … and …
  • Weather

… two of the concepts hovering about our “Other Side of the World” web application we last talked about with Other Side of the World Google Chart Tutorial, whose supervisory HTML other_side_of_the_world.htm‘s live run, changed in this way to tweak the the linking of …

  • latitude and longitude and (anywhere) placename … to …
  • TimeZone place(s) … and then (with great help from Weather Underground (thanks)) onto …
  • direct or nearby weather predictions

… coming off a new Map Chart Google Chart and its select event menu option …

  • Nearest TimeZone=Z (and onto Other Side of the World and Weather)
  • YouTube=Y (looking for placename)

… the latter integrating us with YouTube API for Iframe embedded videos interface HTML/Javascript “parent” web application called karaoke_youtube_api.htm HTML iframe elements in another direction additional to yesterday’s usage. Along the way, we tweak the Google Map=G menu option, adding more map type options and zooming in a little less by default, and with the Nearby Airports=A option making the default be a search for 3 (rather than 4) nearby airports. A lot of this all happens because of the changes to …

… which all got changed to allow for an “Animate” feature, allowing for an automated right to left “animation” (via hashtagging) of the Wikipedia based slides near the top of this suite of web application’s webpages. We hope you get to try all this out for yourself.


Previous relevant PHP Wikipedia Australian List Makeover Tutorial is shown below.

PHP Wikipedia Australian List Makeover Tutorial

PHP Wikipedia Australian List Makeover Tutorial

Some time back we linked a Wikipedia “list” webpage to the Google Charts Map Chart functionality with PHP Modularization for Lighthouses in Australia Tutorial.

We’re revisiting, and finding some “peer” web applications, linked by a dropdown, that all …

  • access a relevant Wikipedia “list” webpage for Australian “things” and mentioning latitude and longitude … which link to …
  • Google Charts Map Chart

… for all of …

We were inspired to take on this “makeover” of “where of life” functionalities because earlier on today we discovered a stupendous online resource for Australian geography enthusiasts, the Bonzle Digital Atlas of Australia, with incredibly detailed and flexible search mechanisms, thanks heaps!

We’ve decided to include extra buttons (to those already linking to Google Maps links and to the relevant Wikipedia webpage) for that suite of web applications above for …

Great for research and “surfing the Australian world”! Lose yourself!

What happened Javascript (australian_lighthouses.js changed this way) and PHP wise?


Previous relevant PHP Modularization for Lighthouses in Australia Tutorial is shown below.

PHP Modularization for Lighthouses in Australia Tutorial

PHP Modularization for Lighthouses in Australia Tutorial

Today we want to try two more things …

  1. continuing on with our PHP code (you could call australian_lighthouses.php) for our Australian Lighthouses project
  2. talk about PHP glob and its modularization sensibilities

… so let’s talk about the second one first … it’s south of north … chortle, chortle.

What does PHP’s glob do? It is doing functionality like the “underworkings” of any browse button you would see would do when you have a hard disk (in your life) … unfortunately, this is no longer a given (with mobile technology and the “cloud” challenging this thinking, sometimes). Give glob a file specification and a directory to start with, and it will happily (if you were both “globular” and “modular” you would be, too) provide you with a list of filenames, so that we use it to construct this PHP function for use with our lighthouses web application …


function selcreate($def) {
$ret=$def;
$selstr='<select onchange=" window.location=this.value; "><option value="' . str_replace(" ", "_", strtolower($def)) . '_lighthouses.php">' . $def . '</option>';
$cnt=0;
foreach (glob("*_lighthouses.php") as $filename) {
if (strpos(($filename . "*"), (str_replace(" ", "_", strtolower($def)) . '_lighthouses.php*')) === false) {
$cnt++;
$newidea=str_replace("_", " ", str_replace("_lighthouses.php", "", strtolower($filename)));
$newideas=explode(" ", $newidea);
$ideas=strtoupper(substr($newideas[0],0,1)) . strtolower(substr($newideas[0],1));
for ($ii=1; $ii<sizeof($newideas); $ii++) {
$ideas.=(" " . strtoupper(substr($newideas[$ii],0,1)) . strtolower(substr($newideas[$ii],1)));
}
$selstr.='<option value="' . $filename . '">' . $ideas . '</option>';
}
}
if ($cnt > 0) return $selstr . "</select>";
return $ret;
}

… and hope you can see that glob could be used for PHP code to self-detect sibling variation programs, so that, for instance, if we “plonked” (ie. eg. (s)ftp it) an egypt_lighthouses.php (probably with an egypt_lighthouses.js accompanying Javascript file) into the same directory as our …

… it would automatically be added into the functionality of its siblings without you having to change any code of those siblings … and that egypt_lighthouses.php is free to be a web application with a totally different method of functionality … cute, huh?!

As a matter of fact ireland_lighthouses.php is quite different, and if you examine the code, you will see that the Javascript putElement(s)By via PHP Relative URLs Tutorial is more apt to a discussion of its workings.

You see, there are so many many different ways to “skin a cat” in Information Technology, quite often … not always … but “quite often” … and why be cornered into thinking there is only one way to do things?

The other thing you’ll find is that even though ireland_lighthouses.php differs a lot to its nearest matching sibling (in terms of methodology), new_zealand_lighthouses.php the Javascript corresponding codesets called ireland_lighthouses.js and new_zealand_lighthouses.js are only superficially different … in other words our PHP coalesces concepts into a similar “client” look … a “modularization” of sorts … not everybody’s sort, but a sort none the less … and this begs a question?

Why is “modularization” a good thing? Well, to me, you don’t have to have any “modularization” going on at all, and this is fine by me, but you must deal with issues that allow you to modify many many codesets efficiently and accurately in vastly different ways to be efficient, or be “modular” and be able to, perhaps, even, automate your changes, because of these “modular” patterns you’ve created … many people find “modularization” blissful … and often it suits the work patterns for teams of programmers. Perhaps you want to read about MVC (and its like) as a coding modularization idea for PHP (or many other programming languages, for that matter).


Previous releveant PHP/Javascript Asynchronous Lighthouses in Australia Tutorial is shown below.

PHP/Javascript Asynchronous Lighthouses in Australia Tutorial

PHP/Javascript Asynchronous Lighthouses in Australia Tutorial

Today we want to try two things …

  1. continuing on with our PHP code (you could call australian_lighthouses.php) for our Australian Lighthouses project
  2. talk about Javascript asynchronous script tag option

… so let’s talk about the second one first … it’s south … chortle, chortle.

Why should you be interested in the HTML’s script tag attributes …

  • asynch=”asynch”
  • defer=”defer”

? Well, we want our web pages to load as fast as possible. Yaaaaaa?! So if there was the mechanism to do more than one bit of ((client) Javascript) thinking at a time would you avail yourself of the opportunity … or would you pick what’s behind door 3?

Do you want to hear more on this theory wise? It seems to me, there are web application mission critical parts, and there are embellishments, quite often … “nice to haves” but not “mission critical” … well, if those “nice to haves” could be arranged not to hog all the web application designated CPU that would be good, wouldn’t it?! Yaaaaaaaaaaa?!

So, that, in theory, is y why.

Now back to the project at hand … Australian Lighthouses … don’t you think some geographical sorting options and place name sorting options might be useful? Yaaaaaaaaaaaaaaaaa?! But for us it doesn’t feel mission critical … so we …

  • place the logic in some external Javascript called australian_lighthouses.js
  • we load it from the PHP via
    <script type=”text/javascript” src=”australian_lighthouses.js” async=”async”></script>

    … and this amounts to the only change to today’s PHP code from yesterday as per this link

… and this becomes a way to modularize your thinking regarding a project … please don’t think there are not a myriad of other ways … this is just one idea here.

With regard to how we approached our external Javascript we did not demand anything (much) of our parent PHP and this may not be the fastest way to approach this. What we mean by that is that, perhaps, as a general rule, external Javascript can perform faster with the parent PHP or HTML leaving it with a lot more HTML element id=”[elementId]” to hang its hats on, so to speak … instead, here, we acted innocently with our Javascript and used lots of calls to the Javascript DOM method getElementsByTagName() (which results in an array return value). Perhaps calls to getElementById() via (parent) arranged id=”[elementId]” would be faster?! Today, as with the previous Static HTML Javascript Primer Tutorial we concentrated on the “modular” feel to additional external Javascript code ideas.

So try a live run to see what we mean.


Previous relevant PHP Lighthouses in Australia Primer Tutorial is shown below.

PHP Lighthouses in Australia Primer Tutorial

PHP Lighthouses in Australia Primer Tutorial

Today we examine some of the methodology behind a project idea.

Projects need …

  • an idea … ours came from listening to the radio and hearing about Lighthouses, and how the technologies had changed what they look like and how they function these days … to quote Wikipedia with respect to Australian Lighthouses (thanks) …

    The first lighthouse was Macquarie Lighthouse, which was lit in 1793 as a tripod mounted wood and coal fired beacon. The last manned lighthouse was Maatsuyker Island Lighthouse, off the south coast of Tasmania, which was automated in 1996.

  • a means to access information … much easier these days with the search engines … we went with a Google Search as per list of lighthouse positions … which led to …
  • the information source(s) … we settled, and were not surprised about the source, for Wikipedia’s List of lighthouses and lightvessels in Australia – Wikipedia … then, once happy about the quality of the source information, analyzed …
  • the source data format … initially, at least, via View->Page Source, relative to the webpage … to get ideas for how to parse the data … so that we can determine a …
  • programming language of choice … which is PHP … no surprise here … will need a server-side language … and a method like PHP’s file_get_contents() … from there …
  • PHP coding to parse the data and put it into another format that value adds … otherwise why do it, as the Wikipedia information is fine as is … that is where we determine that we should …
  • include an iframe that uses the Google Chart Map Chart to add that extra overall positional view of Lighthouses … a definite asset to the reader’s understanding of the subject … definitely a “where” web application … and in doing this we notice that …
  • Google Chart Map Chart map.php web application needed to be able to handle much larger input data streams than it could in its previous incarnation of only allowing PHP $_GET[] parameters … so we change it to allow $_POST[] parameters … maybe you noticed this with yesterday’s PHP/Javascript/HTML Google Chart Map Onclick Tutorial as shown below … as this meant that …
  • we need an HTML form that POSTs to the iframe with the Google Chart Map Chart map.php web application allowable because we are on the same domain with this thinking … and using an HTML textarea element to store the huge string of Lighthouse data that will be passed across via urldecode($_POST[‘data’]) at map.php … using PHP’s urldecode() and urlencode() methods and Javascript’s decodeURIComponent() method … as well as utilizing …
  • Google Chart Map Chart map.php web application onclick and tooltip functionality we’ve been working on lately … hence the talk about this below … working out what (component) tools could do with a “makeover” is an extremely important part of any project and can be a useful compartmentalizing of the project

… and so we end up with our live run behind which is the PHP programming source code you could call australian_lighthouses.php for your perusal.


Previous relevant PHP/Javascript/HTML Google Chart Map Onclick Tutorial is shown below.

PHP/Javascript/HTML Google Chart Map Onclick Tutorial

PHP/Javascript/HTML Google Chart Map Onclick Tutorial

They say “the knee bone’s connected to the thigh bone” then they say “the thigh bone’s connected to the … hip bone” then they say “let’s call the whole thing off” … sometimes.

Today we say “the onmouseover event is connected to the onclick event” then we say “the onclick event is connected to the online woooooorld” … “do … the hokey pokey” x3 … “that’s what the onclick event preceeded by the onmouseover event within the environs you are encountering … is all about”.

That news is pretty good actually, because it means mobile users are not missing out on much not having easy access to any onmouseover (ie. hover) functionality … they’ll still reach any onclick logic you present them, in the default case of events where onclick is a valid “touch” event as well.

So the data structure of arrangements to allow for this onclick functionality is intrinsically the same as allowed for yesterday with the PHP/Javascript/HTML Google Chart Map Tooltips Tutorial as shown below, but we just check for some more delimitation issue matters, and our updated prompting window logic gets quite “blurby” as per the Javascript (via PHP) …



echo " datalinesuffix = prompt('Enter decimal Latitude,Longitude ' + thisline + extra + ' (for no more hit Cancel button and append with ' + '\\n\\n' + ',\"A tooltip and clicking link for Google Map of <a target=_blank href=https://www.google.com.au/maps/place/' + encodeURIComponent(dlp2) + '>' + dlp2 + '</a>\" ' + '\\n\\n' + ' or maybe perhaps ' + '\\n\\n' + ',\"A tooltip and clicking link for Google Map based on latitude and longitude of <a target=_blank href=https://maps.google.com.au/maps?' + encodeURIComponent('z=15&t=m&q=loc:') + '{latitude}{longitude}>' + dlp2 + '</a>\"' + '\\n\\n' + ' optionally (as (just) two examples of what is possible with HTML included (activates with onclick bit not onmouseover))', thisdef); " . "\n";
echo ' if (datalinesuffix != null) { if (datalinesuffix.indexOf("{latitude}") != -1) { dlsa=datalinesuffix.split(","); if (dlsa[0].indexOf("-") == -1) { datalinesuffix=datalinesuffix.replace("{latitude}",encodeURIComponent("+" + dlsa[0])); } else { datalinesuffix=datalinesuffix.replace("{latitude}",encodeURIComponent(dlsa[0])); } } if (datalinesuffix.indexOf("{longitude}") != -1) { dlsa=datalinesuffix.split(","); if (dlsa.length > 1) { if (dlsa[1].indexOf("-") == -1) { datalinesuffix=datalinesuffix.replace("{longitude}",encodeURIComponent("+" + dlsa[1])); } else { datalinesuffix=datalinesuffix.replace("{longitude}",encodeURIComponent(dlsa[1])); } } } } ' . "\n";

… as again we are making use of $_GET[] parameters coming into the PHP at the server side.

The bigger picture plan for how this helps something else we are trying will become apparent over time … in the fullness of time … at the appropriate juncture of juxtapositions.

Let’s see some PHP code in live action for this tutorial where you define your map characteristics and data.

Link to Google Chart Tools “spiritual home” … via Google.
Link to Google Chart Tools Map information … via Google.
Link to Google Chart tooltips information … via Google.

Link to some downloadable PHP programming code … rename to map.php which changed from yesterday as per this link.


Previous relevant PHP/Javascript/HTML Google Chart Map Tooltips Tutorial is shown below.

PHP/Javascript/HTML Google Chart Map Tooltips Tutorial

PHP/Javascript/HTML Google Chart Map Tooltips Tutorial

Here is a tutorial that is revisiting Google Graphs API, or Google Chart Tools, and its Map functionality, which we first talked about with PHP/Javascript/HTML Google Chart Map Tutorial as shown below. Please read …

Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.

Why are we revisiting? Well, we are interested in the interactive side to this wonderful product. We are going to start with a look into “tooltips”. Tooltips are those optional informational features of some webpages that happen when hovering over an HTML element, principally through the filling out of an HTML element’s title global attribute.. Google Charts functionality amounts to the use of Javascript, and, these days, SVG HTML elements, so “tooltips” are very relevant to the “user experience” when using Google Charts. With the Map Chart, the latitude, laongitude set is combined with a title, which can be the default “tooltip” shown, as this is all fine for many usages, but we want to extend it so that that title doesn’t have to be the tooltip.

The integration of this added functionality into the Google Chart Map Chart involves adding an extra “string” column to the data table as per the bold bits of the new Javascript (via PHP) snippet …



if (isset($_GET['value']) && (isset($_GET['tooltip']) || strpos($GETdata, "'") !== false)) {
echo " var data = new google.visualization.DataTable(); /" . "/" . $GETlabel . $GETvalue . " \n";
echo " data.addColumn('number', '" . str_replace("'","",str_replace(",","",str_replace("['","",$GETlabel))) . "'); \n";
echo " data.addColumn('number', " . str_replace(",", "); data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}}); data.addColumn('string', ", str_replace("]","",$GETvalue)) . "); \n";
echo " data.addRows([ \n";
echo str_replace("''" . "''", "''", str_replace("~", "'", substr($GETdata,1)));
echo " ]); \n";
} else {

echo ' var data = google.visualization.arrayToDataTable([ ' . "\n";
echo " " . $GETlabel . $GETvalue . " \n";
echo str_replace("''" . "''", "''", str_replace("~", "'", $GETdata));
echo " ]);\n";
}

… making use of $_GET[] parameters coming into the PHP at the server side … you’ll find that Javascript loves to work with PHP as one of those Fred and Ginger relationships of the programming world … you’ll be happier writing Javascript from your PHP too … try it and you’ll see the advantages time and again and again and again … did we leave out one? … and again.

The bigger picture plan for how this helps something else we are trying will hopefully become apparent over time.

Let’s see some PHP code in live action for this tutorial where you define your map characteristics and data.

Link to Google Chart Tools “spiritual home” … via Google.
Link to Google Chart Tools Map information … via Google.
Link to Google Chart tooltips information … via Google.

Link to some downloadable PHP programming code … rename to map.php which changed from the days of Google Charts Emailing Primer Tutorial as per this link.


Previous relevant PHP/Javascript/HTML Google Chart Map Tutorial is shown below.

PHP/Javascript/HTML Google Chart Map Tutorial

PHP/Javascript/HTML Google Chart Map Tutorial

Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its Map functionality.

Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.

Let’s see some PHP code in live action for this tutorial where you define your map characteristics and data.

Link to Google Chart Tools “spiritual home” … via Google.
Link to Google Chart Tools Map information … via Google.

Link to some downloadable PHP programming code … rename to map.php.

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.


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.


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

Exim Mail Server on AlmaLinux Apache PHP Dedicated Web Server Tutorial

Exim Mail Server on AlmaLinux Apache PHP Dedicated Web Server Tutorial

Exim Mail Server on AlmaLinux Apache PHP Dedicated Web Server Tutorial

Back in 2020, when we published Colour Systems Inline HTML Email Collaboration Tutorial the setup with the RJM Programming web server IP address teed up with the RJM Programming IP address (ie. to do with shared services) involved with mail to allow …


the sending of emails involving very simple Inline HTML to Gmail recipients

… seemed relatively easy. Since then, for various reasons …

  • future RJM Programming VPS web server IP addresses became separated from the RJM Programming IP address (ie. to do with shared services) involved with mail moving on from shared servicing hosting to dedicated virtual server servicing hosting
  • Gmail started asking for DMARC (for sure) and (maybe) SPF and DKIM relevant DNS records that teed up with the IP addresses and DNS names involved
  • our calls to PHP mail() were lacking a fifth argument to legitimize the rearrangements our web hosters, Crazy Domains, was able to establish after seeing Exim mail server logs ( in our case that being /var/log/exim_mainlog ) of failures (we’d been bypassing to mailto: mail messages by monitoring Exim logs, in those intervening years (along with our burgeoning regard for hashtag mailto: link communications))

… we gave up on the possibility of sending such emails containing very simple Inline HTML until recently we enlisted the help of our great hosters, Crazy Domains. Their expertise with the DNS involved in DMARC and SPF and DKIM records is beyond me, but we’re hoping the involvement of monitoring …


Exim mail server logs

… while DNS changes go through (sometimes over days) and testing the web applications from my end and tweaking the PHP mailing out web applications at my end, is a collaboration, where hopefully, finally, some of the concepts sink in a bit for yours truly.

As such, you might want to retry CMYK to or from RGB to or from HSL Colour Systems web application also shown below …

Stop Press

Think back in 2020 we got into our heads, either that or it used to be the case, that within inline HTML that ends up being used within an email, if it has a form that may navigate you back to a web browser webpage, it needed to just use a form action attribute pointing at an http: protocol URL?! Tests on a revisit to this in a further changed cmyk_rgb.html CMYK to or from RGB to or from HSL Colour Systems seem to indicate that use of a form action attribute pointing at an https: protocol URL is fine to use as an email recipient clicks/taps one of the three submit buttons of such a form.


Previous relevant Colour Systems Inline HTML Email Collaboration Tutorial is shown below.

Colour Systems Inline HTML Email Collaboration Tutorial

Colour Systems Inline HTML Email Collaboration Tutorial

Yesterday’s Colour Systems Inline HTML Email Tutorial featured Inline HTML Email functionality, that we find very useful, but almost denuded of personalization. We think adding personalization aspects to a web application should never be mandatory to its functionality, but on the flipside, if you want a web application with “collaboration” thoughts we figure for …

  • the scenario that the rjmprogramming.com.au mail server serves as an “honest broker” between …
  • an emailee (as we established yesterday) … and …
  • an emailer (we allow the user to define (and so not have to bother the users again regarding email addresses), optionally, starting today) … teamed with …
  • a comment or feedback textbox (new today), to add some personalization, into the colour discussion and collaboration and sharing experience (… what’s come over me!)

… meaning, though, that collaboration can occur between collaborators through (straight at your face content) email.

Today, also, we’ve added another HSL (Hue/Saturation/Lightness) Colour System, and would like to thank this useful link regarding the formulae needed to make this happen.

Try collaboration via the changed cmyk_rgb.html live run link yourself, and with a colourful friend!


Previous relevant Colour Systems Inline HTML Email Tutorial is shown below.

Colour Systems Inline HTML Email Tutorial

Colour Systems Inline HTML Email Tutorial

In undertaking the makeover for the Colour Systems web application of Colour Systems Primer Tutorial we were integrating Inline HTML Email functionality via Ajax/FormData techniques (entrenched as a favourite “midair” feeling email conduit approach) when we were surprised trying something that we did not expect to work. We have intimated that as far as email clients go it is touch and go whether much HTML5 works nor CSS3 when you try to get something going, so when we tried integrating …

  • inline HTML email … with …
  • HTML input type=”color” as per …

    <input onchange="findc(this.value);" style='display:INLINE-BLOCK;' type="color" name="cinput" id="cinput" value="#000000"></input>

… we were really expecting “tears before bedtime” rather than an approach using the HTML input type=”color” element above that really made it good at the emailee end, in particular, as we …

  • have an emailer start the ball rolling (with the changed cmyk_rgb.html) at this link … then …
  • set up a colour of interest via any of the following approaches …
    1. fill out Red, Green, Blue … 0 to 255 … RGB Colour System numbers
    2. fill out Cyan, Magenta, Yellow, Key … 0.0000 to 1.0000 … CMYK Colour System numbers
    3. click our new HTML input type=”color” element and follow your nose
  • and then, optionally, collaborate (or just share) with an emailee (textbox) they fill out and press the “Email to …” button … setting off …
  • Ajax/FormData functionality sends off the document.body.innerHTML (heavily amended) HTML data directed via our Inline HTML Email “emailhtml.php” (usual PHP) helper …
  • email arrives for the emailee who sees a lot of what the emailer last saw … and …
    1. we highly recommend clicking our new HTML input type=”color” element, then follow your nose (picking a colour , not your … ?) then … click RGB to CMYK button
    2. fill out Red, Green, Blue … 0 to 255 … RGB Colour System numbers … click RGB to CMYK button
    3. fill out Cyan, Magenta, Yellow, Key … 0.0000 to 1.0000 … CMYK Colour System numbers … click CMYK to RGB button

    … optionally adjusting the return email (as the original emailer’s email address, more than likely) … back out to “the net” with …

  • the emailee’s web browser arrives at the same colour systems web application ready to, optionally, send more collaboration or sharing back to the emailer, as required

Colourful discussions can ensue! And don’t we know, lots of people have opinions about colour, even its spelling!


Previous relevant Colour Systems Primer Tutorial is shown below.

Colour Systems Primer Tutorial

Colour Systems Primer Tutorial

We want to talk, today, about Colour (Space) Systems. There are, at least …

  • additive colour systems … used in science … often used to define web colours … red, green and blue are the primary colours
  • subtractive colour systems … used by artists (and often the way we learn colours in early school) … often used with regard to printing … red, yellow and blue are the primary colours
  • the CMYK colour system … used by printing industry … cyan, magenta, yellow and black are the primary colours

You can read more about the comparisons and a description of these three at Colour Systems – RGB and CYMK.

We’ve got a small HTML and Javascript conversion program we call cmyk_rgb.html (and that you can use as a live run) which you can use today to convert a given colour to and from RGB and CYMK colour systems.

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

Emoji Circuit Quiz Scoring Tutorial

Emoji Circuit Scoring Tutorial

Emoji Circuit Quiz Scoring Tutorial

If you are …

  • an avid pinball player, perhaps with limited flair …
  • an avid gamer of a pretty difficult game …
  • sporting tragic …
  • overly competitive

… you’ll know …

The score is just about everything!

… and while playing you may not need to be doing any squinting to monitor the score which may affect your play.

That thinking occurred to us on a revisit to the Sushi Train (for 4 players) game of Emoji Circuit Quiz Animated Emoji Tutorial and how it was handling the display of scores for the 4 players … too squinty!

This revisit corresponded to a day of CSS perusal where at one point we stumbled upon CSS display:flex (with it’s accompanying) justify-content:center and flex-grow property usage ideas we’re deploying today to help the scoring be far more obvious with today’s changed circuit.htm Sushi Train game, and then onto today’s changed circuit.htm Emoji Circuit game where the changes could fall into the categories of …

HTML

<br><br><br><br><br><br>
<div class="container">
<div id=ds1 style="flex-grow: 0"><font size=1>Player 1 score</font></div>
<div id=ds2 style="flex-grow: 0"><font size=1>Player 2 score</font></div>
<div id=ds3 style="flex-grow: 0"><font size=1>Player 3 score</font></div>
<div id=ds4 style="flex-grow: 0"><font size=1>Player 4 score</font></div>
</div>
… styled by CSS …

<style>
.container {
display: flex;
background-color: dodgerblue;
justify-content: center;
}

.container div {
background-color: #f1f1f1;
color:#000;
width: 100px;
margin: 10px;
padding: 10px;
text-align: center;
font-size: 30px;
}
</style>
… and dynamically worked by Javascript …

var ccarr=['coral','lightblue','orange','pink'];

function dcontit() {
for (var ii=1; ii<=4; ii++) {
document.getElementById('ds' + ii).innerHTML='<font size=1>' + document.getElementById('pyr' + ii).value + ' ' + document.getElementById('div' + ii).innerText + '</font>';
}

if (eval('' + ccarr.length) >= 4) {
for (var iii=1; iii<=4; iii++) {
document.getElementById('pyr' + iii).style.backgroundColor='' + ccarr[eval(-1 + iii)];
document.getElementById('ds' + iii).style.backgroundColor='' + ccarr[eval(-1 + iii)];
}
ccarr=[];
}
}

setInterval(dcontit, 2000);


Previous relevant Emoji Circuit Quiz Animated Emoji Tutorial is shown below.

Emoji Circuit Animated Emoji Tutorial

Emoji Circuit Quiz Animated Emoji Tutorial

Ever since we got some “animated emojis” working, when we presented Mind Map and Flowchart and Venn Diagram Tutorial we’ve been wondering where we could apply it in a less gimmicky way. Half way to non-gimmicky, we figured, was in a game or quiz, and then we remembered the web application underlying the relatively recent Emoji Circuit Quiz Genericization Tutorial, with its …

  • Flag emoji
  • Animal emoji
  • Food emoji

… categories, being the basis for the extension to functionality of …

… doing a lot of doubling up of arrays and a randomization of the order of the biggest array, “biggest” to give the chance to all members to “make the grade” within the smallest array (of the two) involved being the “range of interest” to have no “index out of range” type errors with the Javascript code … as per (as distinct from the original non-animated emoji) …


for (ii=0; ii<20; ii++) {
if (foodtocountry.length == 0) {
foodtocountry.push(Math.floor(Math.random() * Math.min(countrynames.length,contentbits.length)));
astyle=astyle.replace("</style>", " .f" + ii + ":before { content: '" + contentbits[eval('' + foodtocountry[0])].replace(' ','\\'.substring(0,1)).replace(' ','\\'.substring(0,1)) + "' } </style>");
countrytofood+='' + foodtocountry[0] + ',';
} else {
aguess='';
while (countrytofood.indexOf(',' + aguess + ',') != -1 || aguess == '') {
aguess='' + Math.floor(Math.random() * Math.min(contentbitstwo.length,Math.min(countrynamestwo.length,Math.min(countrynames.length,contentbits.length))));
}
foodtocountry.push(eval(aguess));
astyle=astyle.replace("</style>", " .f" + ii + ":before { content: '" + contentbits[eval(aguess)].replace(' ','\\'.substring(0,1)).replace(' ','\\'.substring(0,1)) + "' } </style>");
if (flag.trim() == '') {
astyle=astyle.replace("</style>", " .g" + ii + ":before { content: '" + contentbitstwo[eval(aguess)].replace(' ','\\'.substring(0,1)).replace(' ','\\'.substring(0,1)) + "' } </style>");
}

countrytofood+='' + aguess + ',';
}
}

… also of note in the Javascript code snippet above the extra dynamic CSS class definition Javascript code.

The table cell (td) element contents differ between non-animated emoji (ie. original) and animated emoji (ie. extra functionality) usage, as per …


var animated=location.search.split('animated=')[1] ? true : false;
var leftopacity='0.6', rightopacity='0.4';

if (!animated) {
tds[eval(huhx[jj])].className+=' ' + foods[huh[jj]];
} else {
tds[eval(huhx[jj])].innerHTML='<span style="opacity:' + leftopacity + ';" class=' + foods[huh[jj]] + '></span><span style="opacity:' + rightopacity + ';margin-left:-40px;" class=' + foods[huh[jj]].replace('f','g') + '></span>';
}

… that “animated emoji (ie. extra functionality)” usage fitting in with the …


<body style='background-color: white;' onload=' if (animated) { document.getElementById("selan").value="ae"; document.getElementById("mysubject").value=location.search.split("combo=")[1] ? decodeURIComponent(location.search.split("combo=")[1].split("&")[0]) : " "; } thisplayer=Math.floor(Math.random() * 4); times[thisplayer]=six; setTimeout(timeit,1000); placefood(); throbbingspans(); '>

… very similar to Mind Map and Flowchart and Venn Diagram Tutorial‘s Javascript code related to keeping the “animated” in “animated emoji” as per (the span element pairs “overlay” usual suspect “opacity” (and negative “margin-left”) methodology) …


function throbbingspans() {
var isps, jsps;
if (tgsps.length == 0) {
var sps=document.getElementsByTagName('span');
for (isps=0; isps<sps.length; isps++) {
if (('' + sps[isps].style.opacity) != '') {
if (eval('' + sps[isps].style.opacity) < 1.0) {
tgsps.push(sps[isps]);
tgspsop.push(eval('' + sps[isps].style.opacity));
tgspsopwhat.push(eval('0.10'));
}
}
}
}
if (tgsps.length != 0) {
for (jsps=0; jsps<tgsps.length; jsps+=2) {
if (tgspsop[jsps] > 0.12 && tgspsop[jsps] < 0.88 && tgspsop[1 + jsps] > 0.12 && tgspsop[1 + jsps] < 0.88) { // && tgspsop[jsps] >= tgspsop[1 + jsps]) {
tgspsop[jsps]+=tgspsopwhat[jsps];
tgspsop[1 + jsps]-=tgspsopwhat[1 + jsps];
tgsps[jsps].style.opacity='' + tgspsop[jsps];
tgsps[1 + jsps].style.opacity='' + tgspsop[1 + jsps];
leftopacity='' + tgspsop[jsps];
rightopacity='' + tgspsop[1 + jsps];
} else if (tgspsop[jsps] > 0.12 && tgspsop[jsps] < 0.88 && tgspsop[1 + jsps] > 0.12 && tgspsop[1 + jsps] < 0.88) { // && tgspsop[jsps] <= tgspsop[1 + jsps]) {
tgspsop[jsps]-=tgspsopwhat[jsps];
tgspsop[1 + jsps]+=tgspsopwhat[1 + jsps];
tgsps[jsps].style.opacity='' + tgspsop[jsps];
tgsps[1 + jsps].style.opacity='' + tgspsop[1 + jsps];
leftopacity='' + tgspsop[jsps];
rightopacity='' + tgspsop[1 + jsps];
} else if (tgspsop[jsps] > 0.88) {
tgspsop[jsps]-=0.1;
tgspsop[1 + jsps]+=0.1;
tgsps[jsps].style.opacity='' + tgspsop[jsps];
tgsps[1 + jsps].style.opacity='' + tgspsop[1 + jsps];
tgspsopwhat[jsps]=-tgspsopwhat[jsps];
tgspsopwhat[1 + jsps]=-tgspsopwhat[1 + jsps];
leftopacity='' + tgspsop[jsps];
rightopacity='' + tgspsop[1 + jsps];
} else if (tgspsop[1 + jsps] > 0.88) {
tgspsop[jsps]+=0.1;
tgspsop[1 + jsps]-=0.1;
tgsps[jsps].style.opacity='' + tgspsop[jsps];
tgsps[1 + jsps].style.opacity='' + tgspsop[1 + jsps];
tgspsopwhat[jsps]=-tgspsopwhat[jsps];
tgspsopwhat[1 + jsps]=-tgspsopwhat[1 + jsps];
leftopacity='' + tgspsop[jsps];
rightopacity='' + tgspsop[1 + jsps];
} else if (tgspsop[1 + jsps] < 0.12) {
tgspsop[jsps]-=0.1;
tgspsop[1 + jsps]+=0.1;
tgsps[jsps].style.opacity='' + tgspsop[jsps];
tgsps[1 + jsps].style.opacity='' + tgspsop[1 + jsps];
tgspsopwhat[jsps]=-tgspsopwhat[jsps];
tgspsopwhat[1 + jsps]=-tgspsopwhat[1 + jsps];
leftopacity='' + tgspsop[jsps];
rightopacity='' + tgspsop[1 + jsps];
} else if (tgspsop[jsps] < 0.12) {
tgspsop[jsps]+=0.1;
tgspsop[1 + jsps]-=0.1;
tgsps[jsps].style.opacity='' + tgspsop[jsps];
tgsps[1 + jsps].style.opacity='' + tgspsop[1 + jsps];
tgspsopwhat[jsps]=-tgspsopwhat[jsps];
tgspsopwhat[1 + jsps]=-tgspsopwhat[1 + jsps];
leftopacity='' + tgspsop[jsps];
rightopacity='' + tgspsop[1 + jsps];
}
}
setTimeout(throbbingspans, 200);
}
}

We’ve also long been interested in HTML select (dropdown) element option (subelement) disabling and/or hiding (statically or dynamically (as with today’s Javascript work)), and today, for the first time for us, we put this into action (and thank this useful link for “heads up” advice here) in the way we …

  1. added a new simple HTML select (dropdown) element next to the main HTML select (dropdown) element …

    <select onchange=' if (this.value.trim().length == 0) { animated=true; } else { animated=false; } resume();' id='mysubject'><option value='flag'>Flag</option><option value='food'>Food</option><option value='animal'>Animal</option><option value=' '>Flag Food</option><option value=' '>Flag Animal</option><option value=' '>Animal Food</option></select> <select id=selan onchange="if (this.value.trim().length != 0) { animated=false; } else { animated=true; } limitopts(); "><option value="">Emoji</option><option value="ae">Animated Emoji</option></select>
  2. some new simple HTML select (dropdown) element “onchange” event logic …

    function limitopts() {
    var optsare=document.getElementsByTagName('option');
    for (var ioptsare=0; ioptsare<optsare.length; ioptsare++) {
    if (optsare[ioptsare].outerHTML.replace(' value="ae"',' value=""').indexOf(' value=""') == -1) {
    if (animated) {
    if (optsare[ioptsare].outerHTML.replace(' value="ae"',' value=""').indexOf(' value=" ') == -1) {
    if (optsare[ioptsare].outerHTML.indexOf(' disabled') != -1) { optsare[ioptsare].removeAttribute('disabled'); }
    if (optsare[ioptsare].outerHTML.indexOf(' hidden') != -1) { optsare[ioptsare].removeAttribute('hidden'); }
    } else {
    optsare[ioptsare].setAttribute('disabled', true);
    optsare[ioptsare].setAttribute('hidden', true);
    }
    } else {
    if (optsare[ioptsare].outerHTML.replace(' value="ae"',' value=""').indexOf(' value=" ') != -1) {
    if (optsare[ioptsare].outerHTML.indexOf(' disabled') != -1) { optsare[ioptsare].removeAttribute('disabled'); }
    if (optsare[ioptsare].outerHTML.indexOf(' hidden') != -1) { optsare[ioptsare].removeAttribute('hidden'); }
    } else {
    optsare[ioptsare].setAttribute('disabled', true);
    optsare[ioptsare].setAttribute('hidden', true);
    }
    }
    }
    }
    }

You can try this live run link and which has the underlying HTML and CSS and Javascript flagquiz.htm source code changed in this way for the purposes of adding new “animated emoji” dropdown option functionality


Previous relevant Emoji Circuit Quiz Genericization Tutorial is shown below.

Emoji Circuit Genericization Tutorial

Emoji Circuit Quiz Genericization Tutorial

As we “flagged” (tee hee) there are rich possibilities genericizing …

  • “circuit” web design basis … with …
  • “quiz” games … and …
  • “emoji” content

… and in realizing this, we want to go over step by step a “content” approach to involving emojis in “sets of content” (such as “flags” and “food” and “animals”) that we have in today’s extended “Emoji Circuit Quiz” web application that you can try at this live run link and which has the underlying HTML and CSS and Javascript flagquiz.htm source code changed in this way for the purposes of genericizing the previous Emoji Flags Circuit Quiz Primer Tutorial …

  • as a basis of content we highly recommend visiting full emoji list
  • in web browser View -> Page Source …
  • okay, taking you to the other end of what we are trying to achieve is two arrays we’ll talk about soon and a CSS look like (for Andorra’s flag, for example) …

    .f1:before { content: '\01F1E6\01F1E9' }

    …
  • search for “>Andorra<” and you will see around where it takes you …

    <tr><td class='rchars'>2364</td>
    <td class='code'><a href='#1f1e6_1f1e9' name='1f1e6_1f1e9'>U+1F1E6 U+1F1E9</a></td>
    ...
    ...
    <td class='name'>Andorra</td>
    </tr>
  • which you’ll notice boldly derives its form from the website’s table’s Code second column by you substituting “U+” for “\0” and getting rid of all spaces to create CSS “content” emoji entities for either single or multiple mode emojis
  • the two arrays we talk about link this “static” feeling CSS to a dynamic scenario by involving …
    1. Javascript DOM additional CSS styling (initially appended) into the “body” element (at the “body” onload event) whereby the “className” property (and a few others) of elements is controlled by …
    2. contents of those two arrays we’ll talk more about below
  • how best to explain now in terms of “genericization” is that we haven’t told how Andorra fits into things … well Andorra to our web application “represents” (good generic word) the value of a “flag” concept (the others, so far, for us, today, being “food” and “animals”) … so we have in our web application 3 sets of those two array (subsets, if you like) … constructed, in the case of the “Andorra” flag …
  • the two arrays look like …

    var countrynames=['Andorra','United Arab Emirates','Afghanistan', ... ];
    var contentbits=[' 01F1E6 01F1E9',' 01F1E6 01F1EA',' 01F1E6 01F1EB', ... ];

    … in the case of the “guinea pig” and “first cab off the rank” “flag” concept … which beggars the question why no “\0” … well, you “C” programmers out there can probably hint at why … “\0” can mean ascii 0 (null) which stuffs things up, and we’ll let our web application “time” its insertion of “\0” via Javascript replace usage at the ideal timing …
  • and so for other “concepts” you just gather similar data into (code like) …

    var flag=location.search.split('subject=')[1] ? decodeURIComponent(location.search.split('subject=')[1].split('&')[0]) : 'flag';
    if (flag != "flag") {
    if (flag == "food") {
    countrynames=['shortcake','bento box','rice cracker', ...];
    contentbits=[' 01F370',' 01f371',' 01f358', ...];
    } else if (flag == "animal") {
    contentbits=[' 01F412',' 01F98D',' 01F415', ... ];
    countrynames=['monkey','gorilla','dog', ... ];
    }
    }

    … to make “food” and/or “animals” HTML select element dropdown option choices “map” themselves into the initial “guinea pig” “first cab off the rank” “flag” concept logic from previous times … voila … genericization

Previous relevant Emoji Flags Circuit Quiz Primer Tutorial is shown below.

Emoji Flags Circuit Quiz Primer Tutorial

Emoji Flags Circuit Quiz Primer Tutorial

What have sushi and flags got in common? It’s hard to say really, at least for us, but in terms of our “circuit” based work of recent times, there are big synergies between sushi and flags.

Building on the previous Sushi Train Circuit Game Currency Tutorial‘s …

  • use of emojis (though, then, they were not “multiple emojis” as are our flag emojis today)
  • use of a “circuit” underlying HTML web elements design
  • use of an anticlockwise rotation of the emojis via a HTML element className property adjustment

… there’s more in common than not … a bit like every human on Earth when you think of it that way. We prefer that “positive” collaborative approach to software quite often, in that we often base a new web application, by cloning an existing one as a first step, as you can see from the differences inherent in these changes that went towards creating our “first phase” “Emoji Flags Circuit Quiz” flagquiz.html HTML and CSS and Javascript source code.

So how are you at identifying flags back to what they represent? Thanking this great resource for the means by which we construct “multiple flag emojis”, via CSS, such as Andorra’s (flag) …


.f1:before { content: '\01F1E6\01F1E9' }

Try it yourself at this live run link.


Previous relevant Sushi Train Circuit Game Currency Tutorial is shown below.

Sushi Train Circuit Game Currency Tutorial

Sushi Train Circuit Game Currency Tutorial

We’re combining and integrating the blog postings from the last couple of days, today, they being …

… the latter’s web application of which is called in an HTML iframe “child” window of the “parent” Sushi Train Game window. In that way if possible, the …

Language Culture Codes (BCP 47 language tags (is locales above)) to determine an International Keyboard character set to use

… of the latter, correlating to which International Keyboard was defined for the setup of the web browser you are currently using, is accessed via (Javascript code like) …


function getLang() { // thanks to https://stackoverflow.com/questions/673905/best-way-to-determine-users-locale-within-browser
if (!navigator.language && navigator.browserLanguage) return navigator.browserLanguage;
return (navigator.languages && navigator.languages.length) ? navigator.languages[0] : navigator.language;
}

From this, sometimes, but not always, the Javascript code can tee this up with that latter’s …

Currency Codes (ISO 4217 currency codes (is part of options above))

… to derive a likely Currency Code (ISO 4217 currency code) that can “localize” the representation of the Sushi Train Itemised Food Prices (eg. A$2.85 dango (for our default Australian Dollars, from the install of the Safari web browser, set up for the en-AU keyboard, used, today)) presented in the game.

The other improvements concern the latter’s functionality “standing alone” including …

  • now show a “localized” current date and time
  • those default Currency Code functionality thoughts above will default in this mode of use also, as applicable
  • setting changes more often automatically update the look of your currency numbering above, straight away

What changed for all this saw new HTML and CSS and Javascript “Sushi Train Game” parent circuit.htm (changed this way) and associated with this live run link today, supervising the HTML iframe child HTML and Javascript (changed this way) localized_currency.html‘s live run link, that you can again try yourself.


Previous relevant Sushi Train Circuit Game Tutorial is shown below.

Sushi Train Circuit Game Tutorial

Sushi Train Circuit Game Tutorial

In today’s Sushi Train Circuit Game we use yesterday’s Circuit Webpage Primer Tutorial as the underlying webpage design basis.

Many things in life are based on circuits. Think electronics, think racing, think cycling velodromes, think roller derby, think ice skating, think round trips, think lunch … think Sushi Train.

Think Sushi Train … think (in particular) Asian food emojis, we reckon. Are you hungry yet?

So what were the challenges making this game?

  • marrying the order of td element cells with the different order of a Sushi Train “circuit” (which would be clockwise, or anticlockwise) … resulting in us using “array mapped indexing” (ie. array indexes which map to the “reorderings” required)
  • making a game out of the Sushi Train scenario … so we have a “lame” 4 player game, where the player with the most expensive tastes wins
  • using multiple class techniques (CSS functionality involving :before and :after (selectors) and content: exemplified by …

    .f1:before { content: '\01f371' }

    ) to make the Sushi Train go around (ie. shuffle along to adjacent Sushi Train cells the styling of its predecessor, when the setTimeout Javascript (timer) function re-executes) … that is, unless in the meantime …
  • the player, in focus (each is given 6 seconds “air time” (or until a click/touch happens)), clicks/touches (ie. selects) a “food” item, whose “price” value (hidden to the user, whereas its name is available “on hover”) contributes to that player’s score in the game

Again, you can see the HTML and CSS (combination of head style definitions and inline CSS within the HTML) at circuit.htm (changed this way) and try it out for yourself at our live run link today. We hope it gets you singing …

🎶 If you knew sushi,
Like I know sushi, 🎶
Oh, oh, 🎶 oh what a Californian rnoll


Previous relevant Circuit Webpage Primer Tutorial is shown below.

Circuit Webpage Primer Tutorial

Circuit Webpage Primer Tutorial

We’re on our way to a more fully fleshed out web application that makes use of a “circuit”, but we want to approach this project in stages.

Stage one is to create some initial HTML and CSS to show a circuit. We construct it, debatably, via underpinnings that involve …

  • HTML table element
  • Cells (td elements) involving colspan and rowspan attributes
  • Background colours strategically defined
  • Border characteristics such as …
    1. CSS border-radius
    2. Some CSS border-top and border-bottom merged into background colour with an offset …
    3. HTML hr elements replace some border-top and border-bottom “lines”

You can see the HTML and CSS (combination of head style definitions and inline CSS within the HTML) at circuit.html and try it out for yourself at our live run link today. We hope it gets you thinking.

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

Health App on iPhone Gait Checking Tutorial

Health App on iPhone Gait Checking Tutorial

Health App on iPhone Gait Checking Tutorial

We’re returning to thoughts, with more granularity, regarding an iPhone’s Health (mobile) app as we talked about at Health App on iPhone Primer Tutorial, because all this year we’ve been “having the iPhone on hand” more often, as a monitoring tool, and nothing else (ie. better is to have a health practitioner on board too), via that Health app (free, out of the iOS box).

We’ve been finding useful there, in particular …


Health app -> Health Categories -> Mobility -> Walking Asymmetry

… as per …

Walking asymmetry is an imbalance in your gait (the way you walk), where one leg or side of your body differs from the other in step length, timing, force, or movement speed.

… to see whether …

  • accident in January 2026
  • incident back in 2017

… both affecting my gait, is improving. My recent physiotherapy class sessions seem to be helping, just lately, for example.


Previous relevant Health App on iPhone Primer Tutorial is shown below.

Health App on iPhone Primer Tutorial

Health App on iPhone Primer Tutorial

There’s not much doubt that FitBits, as presented with Fitbit Activity Tracker Bluetooth Primer Tutorial below, are great for purpose, that purpose being to monitor some aspects to our health …

  • activity
  • sleep

…. at the very least. But did you know that there is an app that comes with an iPhone called “Health” that can help with the concepts above, in addition to …

  • mindfulness
  • nutrition

? For instance, in the case of “activity” it can measure the number of steps you take on an hourly, daily or averaged over a week, basis. Useful, huh? Your iPhone could be in your pocket, and have seen people strap them to arms as well, for these purposes. In the iPhone’s Settings app, check on the Privacy settings, and in the Motion and Fitness section make sure the Health subsection switch is turned on, and possibly any FitnessTracking subsection switch you see on the same screen. Can’t remember whether I needed to allow Location Services to help out, but quite obviously if asked, and you need your steps to be counted, allow Location Services to do its thingthang.

Other than that, let the Health app record activity and see the results in Column Chart results, like you can see in today’s PDF slideshow. Maybe it’s your way to getting fit?!

You can also see this play out at WordPress 4.1.1’s Health App on iPhone Primer Tutorial.


Previous relevant Fitbit Activity Tracker Bluetooth Primer Tutorial is shown below.

Fitbit Activity Tracker Bluetooth Primer Tutorial

Fitbit Activity Tracker Bluetooth Primer Tutorial

Fitbit devices, in our case an activity tracker, feels, for me at least, like one of the most integrated bits of computer, or perhaps you’d say “leisure”, equipment around. In helping set one up recently, it was really impressive to me the integration among …

  • Fitbit device
  • iPad Fitbit app
  • iOS Notifications
  • Bluetooth
  • WiFi
  • Windows laptop
  • Web reporting software

… and though we are so very fond of “ubiquitous” black and while leads around here, dealing with hardware and software not involving a lead of any sort, is quite pleasurable. Mind you, with leads, we feel that …

Nor that idea, with a lot of software, that assumes you will be available almost 24/7, and it giving the impression that this is a boon to your life. Maybe to some, but our motto is … “forget the hype, unless it really has added to your life, rather than just putting on slightly more than it inconveniences” … pretty quirky adage, eh wot … guv’. But seriously, am happy to say the Fitbit experience was so much better than we thought it would be.

And the major reason for this is Bluetooth technology, as well as the great iOS Notifications functionality, which we’ve tried to talk about before … can remember sitting in the VW Golf with a DVD Player experimenting for hours … “good times”. Let’s see a bit of what Wikipedia has to say about this technology …

Bluetooth is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz[4]) from fixed and mobile devices, and building personal area networks (PANs). Invented by telecom vendor Ericsson in 1994,[5] it was originally conceived as a wireless alternative to RS-232 data cables. It can connect several devices, overcoming problems of synchronization.

Take a look at this image courtesy of Chronology.MD – Project HealthDesign putting a Fitbit device into a health monitoring usage framework …

Once heard about the proportion of the world’s data that Fitbit applications represent, and remember being staggered, and so having a feeling you would not be alone if you acquired your own Fitbit.

We’ll leave you today with a “stream of consciousness” PDF “slideshow” view of some of the setup and early integration days of the Fitbit activity device communicating with an iPad and Windows laptop.

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

Cowsay Revisit Textarea Event Rearrangements Tutorial

Cowsay Revisit Textarea Event Rearrangements Tutorial

Cowsay Revisit Textarea Event Rearrangements Tutorial

In order to have yesterday’s Cowsay Revisit Data Type Tutorial introduce some canvas image (from text) additional functionality, it involved …


overlay

… thinking, and with this in mind, some event logics often need a rethink from the way they were before any overlay thoughts. And so, as of today, regarding the Cowsay Cartoon section textarea (maybe overlayed by canvas) …

  • textarea onmousemove and ontouchmove …

    You can mouse move (non-mobile) or touch move (mobile) on textarea Cowsay presentations to toggle between a text and image (from there right click and touch move can edit the image via canvas, and double click places textarea back on top) form of presentation, where right click (non-mobile) on textarea can offer flip and flop transformations

    … can allow overlay logic (using canvas) to proceed, where onmousemove logic is often interested in which element currently has focus …
    <?php echo ”

    var last==null;

    function afterready() {
    lasto=null;
    }

    function readycanvas(tao) {
    if (tao) {
    if (document.activeElement === tao) {
    if (lasto) {
    if (lasto == tao) return '';
    }
    lasto=tao;
    setTimeout(afterready, 5000);
    } else if (tao != lasttaid) {
    return '';
    } else {
    lasto=null;
    tao.title=' ';
    if (parent.document.getElementById('url')) {
    setTimeout(function(){ if (document.getElementById('inout')) { document.getElementById('inout').focus(); } parent.document.getElementById('url').scrollIntoView(); parent.document.getElementById('url').focus(); }, 4000);
    }
    }
    }

    var thissuffix='l';
    textareaone=tao;
    textareatwo=tao;
    if (textareaone) {
    thissuffix='l';
    if (textareaone.title.indexOf(' ') != -1) {
    textareaone.title='';
    document.getElementById('atendl').style.visibility='hidden';
    document.getElementById('myCanvasl').visibility='hidden';
    textareaone.style.color='black';
    document.getElementById('lri').value=document.getElementById('lri').value.replace('l' + document.getElementById('randl').value,'');
    extralri='&lri=' + document.getElementById('lri').value;
    return '';
    } else {
    lasttaid=tao;
    textareaone.title=' ';
    document.getElementById('lri').value=document.getElementById('lri').value.replace('l' + document.getElementById('randl').value,'') + 'l' + document.getElementById('randl').value;
    extralri='&lri=' + document.getElementById('lri').value;
    }
    }
    if (textareaone) {
    var rectone=textareaone.getBoundingClientRect();
    var recttwo=textareaone.getBoundingClientRect();
    document.getElementById('atend' + thissuffix).style.visibility='visible';
    document.getElementById('atend' + thissuffix).style.position='absolute';
    document.getElementById('atend' + thissuffix).style.left='' + tao.getBoundingClientRect().left + 'px';
    document.getElementById('atend' + thissuffix).style.top='' + eval('' + recttwo.top) + 'px';
    document.getElementById('atend' + thissuffix).style.height='' + eval(0 + eval('' + recttwo.height)) + 'px';
    document.getElementById('atend' + thissuffix).style.zIndex='99';
    var sw=0;
    sw=tao.getBoundingClientRect().width;
    document.getElementById('atend' + thissuffix).innerHTML='<canvas ontouchmove=\"wopit(this,' + sw + ',' + recttwo.height + ');\" oncontextmenu=\"wopit(this,' + sw + ',' + recttwo.height + ');\" ondblclick=\"readycanvas(lasttaid);\" style=\"border:0px solid red;\" id=myCanvas' + thissuffix + ' width=' + tao.getBoundingClientRect().width + ' height=' + eval(0 + eval('' + recttwo.height)) + '></canvas>';
    canvas=document.getElementById('myCanvas' + thissuffix);
    ctx=canvas.getContext('2d');
    drawTextToCanvas();
    if (textareaone) {
    textareaone.scrollIntoView();
    } else {
    tao.scrollIntoView();
    }
    textareaone.style.color='transparent';
    textareaone=null;
    textareatwo=null;
    }
    }

    “; ?>

  • … and then, once under “overlay” conditions …
    1. canvas right click (non-mobile) or touch move (mobile) allows for annotation style canvas content editing (in place)
    2. canvas double click returns to last textarea incarnation
  • while, back with textarea, for non-mobile, right click can offer some flipping and flopping (of textarea) functionality

… allowing for some textarea flipping and flopping as new functionality, here, in the changed Cowsay using cowsay.php new temporary file pointing web application.


Previous relevant Cowsay Revisit Data Type Tutorial is shown below.

Cowsay Revisit Data Type Tutorial

Cowsay Revisit Data Type Tutorial

After yesterday’s Cowsay Revisit Regarding Temporaries Tutorial “shoring up” of the temporary folder arrangements of today we get helped by …

… via iframe usage included new HTML …

<?php

$hstuff="<div id=atend style=visibility:hidden;overflow-X:visible;></div>
<div id=atendl style=visibility:hidden;overflow-X:visible;></div>
<div id=atendr style=visibility:hidden;overflow-X:visible;></div>
<form target=ifl id=myforml method=POST action=./cow_says_insertion.php style=display:none;>
<input type=hidden name=randl id=randl value=''></input><input type=hidden name=durll id=durll value=''></input><input type=submit style=display:none; value=Submit id=subl></input>
</form>
<iframe name=ifl id=ifl style=display:none; src=/About_Us.html></iframe>
<input type=hidden id=inpl value=''></input>
<form target=ifr id=myformr method=POST action=./cow_says_insertion.php style=display:none;>
<input type=hidden name=randr id=randr value=''></input><input type=hidden name=durlr id=durlr value=''></input><input type=submit style=display:none; value=Submit id=subr></input>
</form>
<iframe name=ifr id=ifr style=display:none; src=/About_Us.html></iframe>
<input type=hidden id=inpr value=''></input><input type=hidden id=lri name=lri value=''></input>
<input type=text id=inout style=position:absolute;left:-500px;top:0px; value=''></input>
";

?>

… and iframe usage included new Javascript …

<?php

$lts='|';
$gts='|';
if (strtoupper(PHP_OS) == 'DARWIN') {
$lts='<';
$gts='>';
}
$thirtytwo="32";
$thirtytwoplus="42";
$dresl="";
$dresr="";
$fivehundred="300"; // 500

$scstuff="
var textareaone=null, textareatwo=null, extralri='', canvas=null, ctx=null, lasttaid='', awocmd='', awol=null, awor=null, datal='', datar='';

function readycanvas(tao) {
var thissuffix='l';
textareaone=tao;
textareatwo=tao;
if (textareaone) {
thissuffix='l';
if (textareaone.title.indexOf(' ') != -1) {
textareaone.title='';
document.getElementById('atendl').style.visibility='hidden';
document.getElementById('myCanvasl').visibility='hidden';
textareaone.style.color='black';
document.getElementById('lri').value=document.getElementById('lri').value.replace('l' + document.getElementById('randl').value,'');
extralri='&lri=' + document.getElementById('lri').value;
return '';
} else {
lasttaid=tao;
textareaone.title=' ';
document.getElementById('lri').value=document.getElementById('lri').value.replace('l' + document.getElementById('randl').value,'') + 'l' + document.getElementById('randl').value;
extralri='&lri=' + document.getElementById('lri').value;
}
}
if (textareaone) {
var rectone=textareaone.getBoundingClientRect();
var recttwo=textareaone.getBoundingClientRect();
document.getElementById('atend' + thissuffix).style.visibility='visible';
document.getElementById('atend' + thissuffix).style.position='absolute';
document.getElementById('atend' + thissuffix).style.left='' + tao.getBoundingClientRect().left + 'px';
document.getElementById('atend' + thissuffix).style.top='' + eval('' + recttwo.top) + 'px';
document.getElementById('atend' + thissuffix).style.height='' + eval(0 + eval('' + recttwo.height)) + 'px';
document.getElementById('atend' + thissuffix).style.zIndex='99';
var sw=0;
sw=tao.getBoundingClientRect().width;
document.getElementById('atend' + thissuffix).innerHTML='<canvas ontouchmove=\"wopit(this,' + sw + ',' + recttwo.height + ');\" oncontextmenu=\"wopit(this,' + sw + ',' + recttwo.height + ');\" ondblclick=\"readycanvas(lasttaid);\" style=\"border:0px solid red;\" id=myCanvas' + thissuffix + ' width=' + tao.getBoundingClientRect().width + ' height=' + eval(0 + eval('' + recttwo.height)) + '></canvas>';
canvas=document.getElementById('myCanvas' + thissuffix);
ctx=canvas.getContext('2d');
drawTextToCanvas();
if (textareaone) {
textareaone.scrollIntoView();
} else {
tao.scrollIntoView();
}
textareaone.style.color='transparent';
textareaone=null;
textareatwo=null;
}
}

function checkawos() {
var newdatal='', newdatar='';
if (awol) {
if (!awol.closed) {
if (!document.getElementById('myCanvasl')) {
awol.close();
aworl=null;
} else {
awol=awol;
}
} else {
awol=null;
datal='';
}
}
if (awor) {
if (!awor.closed) {
if (!document.getElementById('myCanvasr')) {
awor.close();
awor=null;
} else {
awor=awor;
}
} else {
awor=null;
datar='';
}
}

if (awol) {
if (datal == '' && document.getElementById('myCanvasl')) {
datal=document.getElementById('myCanvasl').toDataURL('data/jpeg', 10);
}
}

if (awor) {
if (datar == '' && document.getElementById('myCanvasr')) {
datar=document.getElementById('myCanvasr').toDataURL('data/jpeg', 10);
}
}

if (awol) {
newdatal=awol.document.getElementById('topcanvas').toDataURL('data/jpeg', 10);
if (newdatal != datal && eval('' + newdatal.length) > 16526) {
var imgl = new Image();

imgl.onload = function() {
document.getElementById('myCanvasl').getContext('2d').drawImage(imgl, 0, 0);
};

imgl.src=newdatal;
if (document.getElementById('randl').value == '') {
document.getElementById('randl').value='' + Math.floor(Math.random() * 19878641);
if (document.getElementById('lri').value.indexOf('l') != -1) {
document.getElementById('lri').value=document.getElementById('lri').value.replace('l','l' + document.getElementById('randl').value);
} else {
document.getElementById('lri').value+='l' + document.getElementById('randl').value;
}
extralri='&lri=' + document.getElementById('lri').value;
}
document.getElementById('durll').value=newdatal;
datal=newdatal;
document.getElementById('subl').click();
}
}

if (awor) {
newdatar=awor.document.getElementById('topcanvas').toDataURL('data/jpeg', 10);
if (newdatar != datar && eval('' + newdatar.length) > 16526) {
var imgr = new Image();

imgr.onload = function() {
document.getElementById('myCanvasr').getContext('2d').drawImage(imgr, 0, 0);
};

imgr.src=newdatar;
if (document.getElementById('randr').value == '') {
document.getElementById('randr').value='' + Math.floor(Math.random() * 19878641);
if (document.getElementById('lri').value.indexOf('r') != -1) {
document.getElementById('lri').value=document.getElementById('lri').value.replace('r','r' + document.getElementById('randr').value);
} else {
document.getElementById('lri').value+='r' + document.getElementById('randr').value;
}
extralri='&lri=' + document.getElementById('lri').value;
}
document.getElementById('durlr').value=newdatar;
datar=newdatar;
document.getElementById('subr').click();
}
}


}

function wopit(canvo,cw,ch) {
//alert(canvo.id);
if (awocmd == '') {
setInterval(checkawos, 12000);
}
if (canvo.id.slice(-1).toLowerCase() == 'l') {
awocmd=\"awol=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=','_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
} else if (canvo.id.slice(-1).toLowerCase() == 'r') {
awocmd=\"awor=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=','_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
} else {
awocmd=\"awo=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=','_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
}
//alert(awocmd);
setTimeout(function(){ eval(awocmd); awocmd=' '; }, 5000);
}

function drawTextToCanvas() { // thanks to https://www.google.com/search?q=textarea+text+to+canvas&rlz=1C5OZZY_en&oq=textarea+text+to+canvas+&gs_lcrp=EgZjaHJvbWUyCQgAEEUYORifBTIHCAEQIRigATIHCAIQIRigATIHCAMQIRigATIHCAQQIRigATIHCAUQIRigAdIBCDkxNjRqMGo0qAIAsAIB&sourceid=chrome&source=chrome.ob&ie=UTF-8
var ii=0, jj=-1, maxchars=0, gtsfound=false, leftno='', lthingo='x';
var tao=document.getElementsByTagName('textarea')[0];
if (textareatwo.id.substring(0,1) == 'l' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') != -1) {
lthingo='l';
} else if (textareatwo.id.substring(0,1) == 'r' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') != -1) {
lthingo='R';
//alert('is R');
}
// 1. Clear the canvas before redrawing
ctx.clearRect(0, 0, canvas.width, canvas.height);

// 2. Set text styles
ctx.font = \"14px Courier New\";
ctx.fillStyle = \"#000000\"; // #333333
ctx.textBaseline = \"top\"; // Align from top-left for easier line calculations

// 3. Split the text by line breaks
var lines = ((textareaone != null ? textareaone.value + String.fromCharCode(10) : '')).split(String.fromCharCode(10)); // + (textareatwo != null ? textareatwo.value : '')).split(String.fromCharCode(10));

for (var ii=0; ii<lines.length; ii++) {
if (eval('' + lines[ii].length) > maxchars) { maxchars=eval('' + lines[ii].length); }
if (textareatwo.id.substring(0,1) == 'r' && leftno == '' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') == -1 && lines[ii].trim() != '' && lines[ii].indexOf('" . $lts . "') != -1) {
leftno=lines[ii].split('" . $lts . "')[0];
//alert(leftno);
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
leftno=' ';
}
}
}

if (textareatwo.id.substring(0,1).toUpperCase() == lthingo.toUpperCase() || 7 == 7) {
for (var ii=0; ii<lines.length; ii++) {
if (!gtsfound) {
lines[ii]=lines[ii].trim(); //.replace(/\ $/g,'');
}
while (eval('' + lines[ii].length) < maxchars) {
if (!gtsfound) {
lines[ii]=' ' + lines[ii];
} else {
lines[ii]+=' ';
}
}
if (lines[ii].indexOf('" . $gts . "') != -1) {
jj=eval(1 + ii); //gtsfound=true;
} else if (ii == jj) {
gtsfound=true;
}
}
//} else {
//alert('why');
}

//alert('prerevstr=' + prerevstr + ' and revstr=' + revstr + ' and textareaonevalue=' + textareaone.value + String.fromCharCode(10) + textareatwo.value);

// 4. Draw each line with vertical offset (line height)
var lineHeight = 16;
var startX = 0;
var startY = 10;
if (textareatwo.id.substring(0,1) == 'r' && lthingo.toUpperCase() != 'R') {
startY-=" . $thirtytwo . ";
}

if (textareatwo.id.substring(0,1) == lthingo || textareatwo.id.substring(0,1).toUpperCase() == lthingo) {
startX = canvas.width;
startY-=14;
ctx.textAlign = 'right';
//alert('Here');
}

lines.forEach((line, index) => {
//if (textareatwo.id.substring(0,1) == lthingo && 1 == 5) {
if (textareatwo.id.substring(0,1) == lthingo && 1 == 5) {
ctx.fillText(line.split('').reverse().join(''), startX, startY + (index * lineHeight));
//alert('thEre');
} else {
if (leftno != '') {
//alert('there');
ctx.fillText(line.replace(leftno,''), startX, startY + (index * lineHeight));
} else {
ctx.fillText(line, startX, startY + (index * lineHeight));
}
}
});

if (textareatwo.id.substring(0,1).toUpperCase() == lthingo.toUpperCase()) { // thanks to https://www.google.com/search?q=just+scale+part+of+an+HTML+canvas&sca_esv=ddd109fd00e45f93&rlz=1C5OZZY_en&sxsrf=AKL5yDgSuo_oLZNuX2RTf0dEj8ymY_NrUg%3A1794091464710&ei=yKnvatDyKvrl2roP5PjAkAE&biw=1440&bih=703&uact=5&oq=just+scale+part+of+an+HTML+canvas&gs_lp=Egxnd3Mtd2l6LXNlcnAiIWp1c3Qgc2NhbGUgcGFydCBvZiBhbiBIVE1MIGNhbnZhczIIECEYoAEYwwQyCBAhGKABGMMESIE3UJgUWKw1cAN4AZABAJgBzgGgAYkLqgEFMC43LjG4AQPIAQD4AQGYAgqgAoMKwgIKEAAYRxjWBBiwA8ICBxAjGLACGCfCAgUQABjvBcICChAhGAoYoAEYwwSYAwCIBgGQBgiSBwUzLjYuMaAHlCKyBwUwLjYuMbgH9QnCBwUxLjMuNsgHHYAIAQ&sclient=gws-wiz-serp
//alert('where');
var offscreen = document.createElement('canvas');
var offCtx = offscreen.getContext('2d');
var offscreentop = document.createElement('canvas');
var offCtxtop = offscreentop.getContext('2d');

var sourceX = 0, sourceY = " . $thirtytwoplus . ", sourceW = canvas.width, sourceH = eval(-" . $thirtytwoplus . " + canvas.height);
offscreen.width = sourceW;
offscreen.height = sourceH;
offscreentop.width = sourceW;
offscreentop.height = " . $thirtytwoplus . ";

// 2. Copy the specific part from the main canvas to the offscreen canvas
offCtx.drawImage(canvas, sourceX, sourceY, sourceW, sourceH, 0, 0, sourceW, sourceH);
offCtxtop.drawImage(canvas, 0,0, sourceW, " . $thirtytwoplus . ", 0, 0, sourceW, " . $thirtytwoplus . ");

// 3. Draw it back onto the main canvas at a larger or smaller scale
var xscaleFactor = 1;
var yscaleFactor = 1;
ctx.save();

// 2. Move the origin to the center (or left) of where you want the image
//alert('w,h=' + canvas.width + ',' + canvas.height);
//ctx.translate(canvas.width * 1.6, 0);
ctx.translate(canvas.width * 1.6, 0);

// 3. Flip the X axis (scales width by -1)
ctx.scale(-1, 1);

ctx.globalCompositeOperation = 'copy';
ctx.drawImage(
offscreen,
0, 0, sourceW, sourceH, // source rectangle
sourceX, sourceY, sourceW * xscaleFactor, sourceH * yscaleFactor // destination rectangle
);

ctx.globalCompositeOperation = 'source-over';
ctx.restore();
ctx.drawImage(
offscreentop,
0, 0, sourceW, " . $thirtytwoplus . ", // source rectangle
sourceX, 0, sourceW * xscaleFactor, " . $thirtytwoplus . " * yscaleFactor // destination rectangle
);

if (lthingo == 'R') {
//alert('huh');
var rectone=tao.getBoundingClientRect();
var recttwo=document.getElementById('myCanvasr').getBoundingClientRect();
if (eval('' + recttwo.right) > eval('' + rectone.right)) {
//alert('yes ' + document.getElementById('myCanvasr').style.left);
//alert('' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px');
document.getElementById('atendr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('atendr').style.left.replace('px',''))) + 'px';
document.getElementById('myCanvasr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px';
}
//} else if (textareatwo.id.substring(0,1) == 'r') {
//alert('RE huh');
}
} else if (textareatwo.id.substring(0,1) == 'r') {
//alert('RE Huh');
var rectone=tao.getBoundingClientRect();
var recttwo=document.getElementById('myCanvasr').getBoundingClientRect();
if (eval('' + recttwo.left) < eval('' + rectone.left)) {
//alert('Yes ' + document.getElementById('myCanvasr').style.left);
//alert('' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px');
document.getElementById('atendr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('atendr').style.left.replace('px',''))) + 'px';
document.getElementById('myCanvasr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px';
}
}


textareaone.style.color='transparent';
textareatwo.style.color='transparent';
document.getElementById('inout').focus();
}


function ouralert(elo) {
if (elo != null) {
if (elo != lastelo) {
if (('' + elo.outerHTML).split('>')[0].indexOf(' title=') != -1) {
lastelo=elo;
alert(elo.title);
}
}
}
}

function inpit() {
if (document.getElementById('inpl').value.trim() != '') {
var ximgl = new Image();

ximgl.onload = function() {
document.getElementById('myCanvasl').getContext('2d').clearRect(0, 0, document.getElementById('myCanvasl').width, document.getElementById('myCanvasl').height);
document.getElementById('myCanvasl').getContext('2d').drawImage(ximgl, 0, 0);
};

ximgl.src=document.getElementById('inpl').value;
document.getElementById('inpl').value=' ';
}
if (document.getElementById('inpr').value.trim() != '') {
var ximgr = new Image();

ximgr.onload = function() {
document.getElementById('myCanvasr').getContext('2d').clearRect(0, 0, document.getElementById('myCanvasr').width, document.getElementById('myCanvasr').height);
document.getElementById('myCanvasr').getContext('2d').drawImage(ximgr, 0, 0);
};

ximgr.src=document.getElementById('inpr').value;
document.getElementById('inpr').value=' ';
}
}

setInterval(inpit, 5000);

";

$bscstuff="<scr" . "ipt type=text/javascript> " . $scstuff . " </scr" . "ipt>";

?>

… in the changed Cowsay using cowsay.php new temporary file pointing web application.


Previous relevant Cowsay Revisit Regarding Temporaries Tutorial is shown below.

Cowsay Revisit Regarding Temporaries Tutorial

Cowsay Revisit Regarding Temporaries Tutorial

Like with the recent GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial, around here, we need not to forget …


/tmp/

… referencing PHP web applications on AlmaLinux for the RJM Programming have not worked, regarding restricted file permissions, for about the last two incarnations of our web server.

Instead, on some projects, like this one that, so far, never calls the PHP from the command line in CLI fashion (where if command line was used curl would be more apt for the reasoning below), we’ve been preferring the use of, in “PHP speak” …


$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR

… or https://www.rjmprogramming.com.au/tmp/ ( in “absolute URL speak” where $_SERVER[‘DOCUMENT_ROOT’] points to the Apache web server Document Root (folder) as (absolute URL) https://www.rjmprogramming.com.au ) as a better place “to doodle” with today’s rearranged PHP web application, that being the Cowsay using web application we referenced back with Live Captions Interfacing to Text to Speech Interfacing Tutorial.

When a PHP project has referenced /tmp/ as often as this one, you should not assume non-moderated global substitutions, or even three sets of non-moderated global substitutions, is the best approach. What we did was three passes of global substitution but verify each occasion, in TextWrangler, for mentions of …

Find (though second one we found none) … More than likely replace with …
'/tmp/ $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . '

"/tmp/ $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . "

 /tmp/ Sometimes …
 ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . '
… and sometimes …
 " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . "

… followed by …

  1. php -l cowsay.php
  2. address bar https://www.rjmprogramming.com.au/cowsay.php run throughs

… in the changed Cowsay using cowsay.php new temporary file pointing web application.


Previous relevant GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial is shown below.

GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial

GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial

Onto the recent GraphViz via PHP on AlmaLinux Family Tree Tutorial we’ve applied similar …

  • get rid of /tmp/ temporary folder to read and write to references … in favour of either/both …
    1. tmp folder off the Apache web server’s Document Root (we created for this, and other, purposes, one day)
    2. folder above Apache web server’s Document Root

… as a basis to have these GraphViz PHP hosting Python and/or dot based web applications a solid “interim file place” basis to “do their thiang” creating interesting graphical items amongst …

… options. Why the bother? Well, on recent AlmaLinux Apache web server versions, the reading and writing from/to …


/tmp/

… folder by the web content user (as distinct from the cPanel user) has been restricted. Perhaps this could be lifted as a restriction, but we tend to think if the WHM and cPanel Apache web server hosters tend to think this way, it is probably to do with a security concern that they would be far more wise to than we could be.


Previous relevant GraphViz via PHP on AlmaLinux Family Tree Tutorial is shown below.

GraphViz via PHP on AlmaLinux pFamily Tree Tutorial

GraphViz via PHP on AlmaLinux Family Tree Tutorial

Today we continue down our road of replacing PHP (hosts Python and uses Graphviz) code series that used to use /tmp/ to read and write interim files from, in favour of a tmp folder off the Apache web server Document Root, like with the recent GraphViz via PHP on AlmaLinux New Temporary Folder Tutorial.

Today’s “cab off the rank” creates “dot inspired” Family Trees, where a changed file_tree.php Family Tree web application is definitely worth it to try, especially if you understand hierarchical data structures …


Previous relevant Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial is shown below.

Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial

Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial

Onto yesterday’s Ffmpeg Interfacing Intranet Feeling Tutorial today’s work moving forward is to change references to temporary folder …


/tmp/

.. to …


the folder above the Apache Document Root folder

… because …

  1. it can be read and written to by the RJM Programming web server username … and yet …
  2. cannot be referenced by users surfing the net … being lower down the directory tree than the /home/rjmprogr/public_html which corresponds to our Apache Document Root folder
  3. it can be read and written to by the cPanel username … meaning …
  4. our web server’s main functioning crontab scheduling can reference it, like with yesterday’s New Temporary Folder Arrangements Tidying Tutorial

… in the downloadable a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application.


Previous relevant Ffmpeg Interfacing Intranet Feeling Tutorial is shown below.

Ffmpeg Interfacing Intranet Feeling Tutorial

Ffmpeg Interfacing Intranet Feeling Tutorial

Today, onto the recent Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial, as far as interfacing to the great ffmpeg video editing software goes …

  • we start, in the work today, calling any existant macOS installed …
    1. ffmpeg
    2. downloaded macos_ffmpeg_convert.php placed into a macOS MAMP local Apache web server port 8888 Document Root folder
  • fix /tmp/ usage as flagged in the blog posting New Temporary Folder Arrangements PHP Primer Tutorial
  • whatever else that becomes an issue or can be an improvement

… in a new makeover operation.

What did we discover today? We think, perhaps, the “named iframe element called by second parameter of window.open” may not be an approach we can take on this makeover, perhaps because HTML content gets into the mix, whereas with the Talking Select Multiple Webpage Palette Speech Bubble Tutorial threads, “the content” has no HTML, just PHP calling the operating system via the macOS “say” command … unless tomorrow reveals today’s folly … that is?!

We can still use window.open second parameter “_blank” and third parameter “positioning” scenarios, though, as how we leave today’s machinations within a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application.


Previous relevant Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial is shown below.

Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial

Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial

In yesterday’s Ffmpeg User Defined Video Editing Sharing Tutorial about sharing video data (that might have been edited by ffmpeg command line means) we warned …

even though it is only likely to work for shorter videos

… regarding the data URI hashtagged parts to SMS or email links that we were exclusively using … then. But, with this in mind, what do …

  1. data URI based URLs (hashtagged in an email or SMS link) … and …
  2. absolute URL that points to a web server soft link file, itself pointing to /tmp/ video data files ((we’re still hashtagging, but now, don’t really have to, apply) in an email or SMS link)

… share? We’d say, as far as sharing goes …

A sense of permanency.

But …

  • the second one does not “push the barrow” as much as the first regarding the amount of data … whereas …
  • the first is totally ephemeral and not asking anything more of the web server (ie. the RJM Programming associated one) regarding ongoing storage but is asking a lot of web browsers and client mail applications in the case of video data of any bulk

In terms of sharing videos of any bulk, we’re now, with our web application …

  • renaming the top button (that used to be “Display”) as “Display for a Day” and applying absolute URL (that point at web server soft links that, in turn, point at what can be sizeable video data files that might hang around in RJM Programming domain associated web server /tmp/ location) logics which call on “crontab” … (

    */53 * * * * /etc/init.d/every_hour.sh

    … now mentions …

    ksh -c 'for i in `find /tmp -name "my_video_*.*" -mmin -1440`; do rm -f $i; done'

    ) … assistance to do with the tidy up we feel we need to do on the web server so that large files do not hang around forever (and as you might surmise, at most a day, regarding the bulk of data requirements that are temporarily stored in /tmp/ locations with user associated IP addresses part of the file naming paradigm) … whereas …
  • the bottom button remains as “Display” and still uses data URI based logic

… so that these bulky videos can be successfully shared (via clicks of that “Display for a Day” button) as long as the email or SMS link is attended to by the collaboration recipient within those 24 hours, further to yesterday’s Ffmpeg User Defined Video Editing Sharing Tutorial.

As well, today, as a genericization measure, we stop seeing govetts_leap in any video file naming, replaced by my_video now that the input video control has become less rigid, and now can be controlled, to some extent, by the user in our changed fourth draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Video Editing Sharing Tutorial is shown below.

Ffmpeg User Defined Video Editing Sharing Tutorial

Ffmpeg User Defined Video Editing Sharing Tutorial

Sharing options for video based data are often more restrictive regarding email and SMS conduits, but we’ll still go ahead with a …

  • “a” link “mailto:” (for emails) or “sms:” (for SMS) methodology …
  • email subject containing ffmpeg command used for an output video mode of sharing … or …
  • input video mode of sharing before any ffmpeg involvement … based on …
  • email or SMS links where the video data URI (as necessary) is hashtagged

… set of ideas to try out, even though it is only likely to work for shorter videos. The other more obvious sharing mechanism is to download video data via right click options the web browser product you are using offers anyway. And another sharing idea, independent, and working for input videos is to browse for a video using the helper web application from yesterday, and use its Share API based button below the browsing button to share that input video using one of …

  • Mail
  • Messages
  • AirDrop
  • Notes
  • Simulator
  • Freeform

… on our macOS Safari web browser here on a MacBook Air.

Further to yesterday’s Ffmpeg User Defined Browsed Video Editing Tutorial, then, we have some new (PHP writes) Javascript functions …

<?php echo ”

function smsit() {
var smsno=prompt('Please enter SMS number.', '');
if (smsno != null) {
if (document.getElementById('cto').title.indexOf('data:') == 0) {
document.getElementById('asms').href='sms:' + smsno + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('cto').title);
} else {
document.getElementById('asms').href='sms:' + smsno + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('resultav').value);
}
document.getElementById('asms').click();
}
}


function emailit() {
var emailaddr=prompt('Please enter Email address.', '');
if (emailaddr != null) {
if (document.getElementById('cto').title.indexOf('data:') == 0) {
document.getElementById('aemail').href='mailto:' + emailaddr + '?subject=Ffmpeg%20Video' + encodeURIComponent(' ... ' + document.getElementById('mysubtwo').value.replace(/^Display$/g,'')) + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('cto').title);
} else {
document.getElementById('aemail').href='mailto:' + emailaddr + '?subject=Ffmpeg%20Video' + encodeURIComponent(' ... ' + document.getElementById('mysubtwo').value.replace(/^Display$/g,'')) + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('resultav').value);
}
document.getElementById('aemail').click();
}
}

function documentgetElementByIdmysubpclick() { // new arrangement for the programmatic click of form submit button
if (eval('' + document.getElementById('resultav').value.length) < 300) {
document.getElementById('myiftwo').src=document.URL.split('?')[0].split('#')[0] + '?becomes=' + encodeURIComponent(document.getElementById('becomes').value) + '&browsed=' + encodeURIComponent(document.getElementById('resultav').value);
} else {
document.getElementById('mysubp').click();
}
}

“; ?>

… in our changed third draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Browsed Video Editing Tutorial is shown below.

Ffmpeg User Defined Browsed Video Editing Tutorial

Ffmpeg User Defined Browsed Video Editing Tutorial

Today’s work, onto yesterday’s Ffmpeg User Defined Video Editing Tutorial, is to loosen the restrictions regarding “input video file source” we had happening in that “first draft” incarnation of our Ffmpeg User Defined Video Editing web application.

In order to achieve this, we called on a previous Ffmpeg Install and Public Face Tutorial inspired change to our inhouse macos_ffmpeg_convert.php PHP web application, which can serve as our conduit to either/or …

  • browse for a video file off the user local operating system environment … or …
  • path to a web server placed video file … or …
  • URL to a video file

… extra means by which the user can define the “input video file source” that we’re loosening the shackles regarding usage.

To do this, we look for user actions (via PHP writing out Javascript) …

<?php echo ”

var lastpathc='';
var lastopathc='';
var lastvidc='';
var lastvalue='.m4v';
var exactvalue='';
var vext='.mp4';

function lookfor() {
vext='.mp4';
var thisext='';
if (document.getElementById('opath').value != '') {
if (lastopathc != document.getElementById('opath').value && document.getElementById('opath').title != document.getElementById('opath').value) {
lastopathc=document.getElementById('opath').value;
}
}
if (document.getElementById('path').value != '') {
if (lastpathc != document.getElementById('path').value) {
lastpathc=document.getElementById('path').value;
if (lastopathc == ' ') { lastopathc=document.getElementById('opath').value; }
}
}
if (lastopathc.trim() != '') {
thisext=(lastopathc + '.').split('.')[1].split('.')[0].trim();
if (thisext != '') {
document.getElementById('opath').title=lastopathc;
document.getElementById('path').title='video/' + thisext + ';' + lastpathc + lastopathc;
document.getElementById('resultav').value=lastpathc + lastopathc;
lastopathc=' ';
}
}
if (document.getElementById('resultav').value != '') {
if (lastvidc != document.getElementById('resultav').value) {
if ((document.getElementById('path').title + document.getElementById('resultav').value).indexOf('video/') != -1) {
if (document.getElementById('ifbrowse').src.indexOf('=') != -1) {
document.getElementById('myaltin').value=decodeURIComponent(document.getElementById('ifbrowse').src.split('=')[1].split('&')[0].split('#')[0]);
}
if ((document.getElementById('path').title + document.getElementById('resultav').value).indexOf('video/') != -1) {
if (vext.indexOf((document.getElementById('path').title + document.getElementById('resultav').value).split('video/')[1].split(';')[0].split(',')[0]) == -1) {
vext='.' + document.getElementById('resultav').value.split('video/')[1].split(';')[0].split(',')[0];
document.getElementById('myaltin').value=document.getElementById('myaltin').value.split('.')[0] + vext;
document.getElementById('becomes').value=document.getElementById('becomes').value.split('.')[0] + vext;
}
}
lastvidc=document.getElementById('resultav').value;
document.getElementById('resultav').title='rework';
document.getElementById('mysubp').click();
setTimeout(function(){
if (1 == 1) {
document.getElementById('divvid').innerHTML=\"<video id=myinvideo style=width:95%; controls><source id=myinsource type='video/\" + vext.substring(1) + \"' src='\" + document.getElementById('resultav').value + \"'></source></video>\";
} else {
document.getElementById('myinsource').src=document.getElementById('resultav').value;
}
}, 2000);
//setTimeout(function(){
//document.getElementById('resultav').value='';
//}, 20000);
//alert(lastvidc);
setTimeout(lookfor, 23000);
return '';
}
setTimeout(lookfor, 3000);
return '';
}
}
setTimeout(lookfor, 3000);
return '';
}

setTimeout(lookfor, 3000);

“; ?>

… and then arrange the /tmp/ placed temporary video data via …

<?php

if (isset($_POST['browsed']) && isset($_POST['becomes'])) {
$fgccont='';
//file_put_contents('xzm.xzm', '1');
$outtmpfile=str_replace('+',' ',urldecode($_POST['becomes']));
//file_put_contents('xzm2.xzm2', $outtmpfile);
$outext=explode('.', $outtmpfile)[-1 + sizeof(explode('.', $outtmpfile))];
//file_put_contents('xzm3.xzm3', str_replace(' ','+',urldecode($_POST['browsed'])));
if (strpos(('xwq' . $_POST['browsed']), 'xwqdata') !== false) {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), base64_decode(explode(";base64,", str_replace(' ','+',urldecode($_POST['browsed'])))[1]));
} else if (strpos(('xwq' . strtolower($_POST['browsed'])), 'xwqhttps') !== false) {
$fgccont=file_get_contents('http' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),5));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower($_POST['browsed'])), 'xwqhttp') !== false) {
$fgccont=file_get_contents('http' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),4));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower(str_replace('+',' ',urldecode($_POST['browsed'])))), 'xwq//') !== false) {
$fgccont=file_get_contents('http:' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),0));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower(str_replace('+',' ',urldecode($_POST['browsed'])))), 'xwqwww.') !== false) {
$fgccont=file_get_contents('http://' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),0));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (file_exists(str_replace('+',' ',urldecode($_POST['browsed'])))) {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), file_get_contents(str_replace('+',' ',urldecode($_POST['browsed']))));
}
//file_put_contents('xzm4.xzm4', explode(";base64,", str_replace(' ','+',urldecode($_POST['browsed'])))[1]);
exit;
}

?>

… all the while being helped out by a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application helper to our changed second draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Video Editing Tutorial is shown below.

Ffmpeg User Defined Video Editing Tutorial

Ffmpeg User Defined Video Editing Tutorial

Today we’re combining video contents from …

  • yesterday’s Ffmpeg Helps iPhone Video to YouTube Tutorial … with …
  • our newly created public interface to ffmpeg with the “soon to be DNS version of rjmprogramming.com.au … but not yet” AlmaLinux Apache/PHP/MySql web server install we talked about at Ffmpeg Install and Public Face Tutorial … and …
  • IP address redirecting, as needed, ifconfig (via PHP shell_exec and $_SERVER[‘SERVER_ADDR’]) based logic …
    <?php

    $whereplace=shell_exec("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'");
    if (strpos(($whereplace . ' ' . $_SERVER['SERVER_ADDR']), '65.254.92.213') !== false) {
    $sv='/usr/bin/ffmpeg';
    header('Location: https://65.254.95.247/PHP/tmp_ffmpeg.php'); //$smallpath='https://65.254.95.247/PHP/'; //header('Location: https://65.254.95.247/PHP/tmp_ffmpeg.php');
    exit; //exit;
    }

    ?>
    … we talked about at AlmaLinux Landing Page WordPress Content Update Solution Tutorial … as well as …
  • user definable form navigation … using …
  • optional dropdown ideas incorporating ideas from Sepia Video via ffmpeg Primer Tutorial … and using …
  • temporary storage places to place output video … and making use of …
  • soft links regarding URLs we talked about at Linux Web Server Soft Link URL Tutorial (saving us having to use ‘data:video/mp4;base64,’ . base64_encode(file_get_contents(trim($endout))) style PHP interventions (which were testing friendships))

… to start down this road towards public facing ffmpeg video editing around here (which we have been hankering for for several years now).

In this first draft of Your Own Ffmpeg Video Changes (via command line ffmpeg) we’re really buttoning down (via not allowing the forward slash character in amongst the user defined ffmpeg command innards) what happens regarding …

  • output video file source location … and …
  • input video file source …

… but who knows what the future holds?!


Previous relevant Ffmpeg Helps iPhone Video to YouTube Tutorial is shown below.

Ffmpeg Helps iPhone Video to YouTube Tutorial

Ffmpeg Helps iPhone Video to YouTube Tutorial

Today we recorded a video looking out from Govetts Leap, Blackheath, here in the Blue Mountains. We captured it via the Camera app on an iPhone via its Video option.

Nineteen seconds long, to share to this MacBook Air we needed AirDrop, the size of it precluding us from using the Photo app’s Mail sharing option.

And that’s where we wanted to use the great ffmpeg in an optimal way to create a video that we could upload to YouTube. In this, we arrived at this excellent link getting us to try …


ffmpeg -i govetts_leap.MOV -c:v libx264 -preset slow -crf 18 -vf scale=out_color_matrix=bt709 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -c:a aac -ar 48000 -ac 2 -b:a 320k -profile:v high -level 4.0 -bf 2 -coder 1 -pix_fmt yuv420p -b:v 10M -threads 4 -cpu-used 0 -r 30 -g 15 -movflags +faststart govetts_leap.mp4

… with success. Checking with this other excellent link, thanks, we were comforted that they would have recommended an output mp4 file format as well, it seems …

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.


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

Cowsay Revisit Data Type Tutorial

Cowsay Revisit Data Type Tutorial

Cowsay Revisit Data Type Tutorial

After yesterday’s Cowsay Revisit Regarding Temporaries Tutorial “shoring up” of the temporary folder arrangements of today we get helped by …

… via iframe usage included new HTML …

<?php

$hstuff="<div id=atend style=visibility:hidden;overflow-X:visible;></div>
<div id=atendl style=visibility:hidden;overflow-X:visible;></div>
<div id=atendr style=visibility:hidden;overflow-X:visible;></div>
<form target=ifl id=myforml method=POST action=./cow_says_insertion.php style=display:none;>
<input type=hidden name=randl id=randl value=''></input><input type=hidden name=durll id=durll value=''></input><input type=submit style=display:none; value=Submit id=subl></input>
</form>
<iframe name=ifl id=ifl style=display:none; src=/About_Us.html></iframe>
<input type=hidden id=inpl value=''></input>
<form target=ifr id=myformr method=POST action=./cow_says_insertion.php style=display:none;>
<input type=hidden name=randr id=randr value=''></input><input type=hidden name=durlr id=durlr value=''></input><input type=submit style=display:none; value=Submit id=subr></input>
</form>
<iframe name=ifr id=ifr style=display:none; src=/About_Us.html></iframe>
<input type=hidden id=inpr value=''></input><input type=hidden id=lri name=lri value=''></input>
<input type=text id=inout style=position:absolute;left:-500px;top:0px; value=''></input>
";

?>

… and iframe usage included new Javascript …

<?php

$lts='|';
$gts='|';
if (strtoupper(PHP_OS) == 'DARWIN') {
$lts='<';
$gts='>';
}
$thirtytwo="32";
$thirtytwoplus="42";
$dresl="";
$dresr="";
$fivehundred="300"; // 500

$scstuff="
var textareaone=null, textareatwo=null, extralri='', canvas=null, ctx=null, lasttaid='', awocmd='', awol=null, awor=null, datal='', datar='';

function readycanvas(tao) {
var thissuffix='l';
textareaone=tao;
textareatwo=tao;
if (textareaone) {
thissuffix='l';
if (textareaone.title.indexOf(' ') != -1) {
textareaone.title='';
document.getElementById('atendl').style.visibility='hidden';
document.getElementById('myCanvasl').visibility='hidden';
textareaone.style.color='black';
document.getElementById('lri').value=document.getElementById('lri').value.replace('l' + document.getElementById('randl').value,'');
extralri='&lri=' + document.getElementById('lri').value;
return '';
} else {
lasttaid=tao;
textareaone.title=' ';
document.getElementById('lri').value=document.getElementById('lri').value.replace('l' + document.getElementById('randl').value,'') + 'l' + document.getElementById('randl').value;
extralri='&lri=' + document.getElementById('lri').value;
}
}
if (textareaone) {
var rectone=textareaone.getBoundingClientRect();
var recttwo=textareaone.getBoundingClientRect();
document.getElementById('atend' + thissuffix).style.visibility='visible';
document.getElementById('atend' + thissuffix).style.position='absolute';
document.getElementById('atend' + thissuffix).style.left='' + tao.getBoundingClientRect().left + 'px';
document.getElementById('atend' + thissuffix).style.top='' + eval('' + recttwo.top) + 'px';
document.getElementById('atend' + thissuffix).style.height='' + eval(0 + eval('' + recttwo.height)) + 'px';
document.getElementById('atend' + thissuffix).style.zIndex='99';
var sw=0;
sw=tao.getBoundingClientRect().width;
document.getElementById('atend' + thissuffix).innerHTML='<canvas ontouchmove=\"wopit(this,' + sw + ',' + recttwo.height + ');\" oncontextmenu=\"wopit(this,' + sw + ',' + recttwo.height + ');\" ondblclick=\"readycanvas(lasttaid);\" style=\"border:0px solid red;\" id=myCanvas' + thissuffix + ' width=' + tao.getBoundingClientRect().width + ' height=' + eval(0 + eval('' + recttwo.height)) + '></canvas>';
canvas=document.getElementById('myCanvas' + thissuffix);
ctx=canvas.getContext('2d');
drawTextToCanvas();
if (textareaone) {
textareaone.scrollIntoView();
} else {
tao.scrollIntoView();
}
textareaone.style.color='transparent';
textareaone=null;
textareatwo=null;
}
}

function checkawos() {
var newdatal='', newdatar='';
if (awol) {
if (!awol.closed) {
if (!document.getElementById('myCanvasl')) {
awol.close();
aworl=null;
} else {
awol=awol;
}
} else {
awol=null;
datal='';
}
}
if (awor) {
if (!awor.closed) {
if (!document.getElementById('myCanvasr')) {
awor.close();
awor=null;
} else {
awor=awor;
}
} else {
awor=null;
datar='';
}
}

if (awol) {
if (datal == '' && document.getElementById('myCanvasl')) {
datal=document.getElementById('myCanvasl').toDataURL('data/jpeg', 10);
}
}

if (awor) {
if (datar == '' && document.getElementById('myCanvasr')) {
datar=document.getElementById('myCanvasr').toDataURL('data/jpeg', 10);
}
}

if (awol) {
newdatal=awol.document.getElementById('topcanvas').toDataURL('data/jpeg', 10);
if (newdatal != datal && eval('' + newdatal.length) > 16526) {
var imgl = new Image();

imgl.onload = function() {
document.getElementById('myCanvasl').getContext('2d').drawImage(imgl, 0, 0);
};

imgl.src=newdatal;
if (document.getElementById('randl').value == '') {
document.getElementById('randl').value='' + Math.floor(Math.random() * 19878641);
if (document.getElementById('lri').value.indexOf('l') != -1) {
document.getElementById('lri').value=document.getElementById('lri').value.replace('l','l' + document.getElementById('randl').value);
} else {
document.getElementById('lri').value+='l' + document.getElementById('randl').value;
}
extralri='&lri=' + document.getElementById('lri').value;
}
document.getElementById('durll').value=newdatal;
datal=newdatal;
document.getElementById('subl').click();
}
}

if (awor) {
newdatar=awor.document.getElementById('topcanvas').toDataURL('data/jpeg', 10);
if (newdatar != datar && eval('' + newdatar.length) > 16526) {
var imgr = new Image();

imgr.onload = function() {
document.getElementById('myCanvasr').getContext('2d').drawImage(imgr, 0, 0);
};

imgr.src=newdatar;
if (document.getElementById('randr').value == '') {
document.getElementById('randr').value='' + Math.floor(Math.random() * 19878641);
if (document.getElementById('lri').value.indexOf('r') != -1) {
document.getElementById('lri').value=document.getElementById('lri').value.replace('r','r' + document.getElementById('randr').value);
} else {
document.getElementById('lri').value+='r' + document.getElementById('randr').value;
}
extralri='&lri=' + document.getElementById('lri').value;
}
document.getElementById('durlr').value=newdatar;
datar=newdatar;
document.getElementById('subr').click();
}
}


}

function wopit(canvo,cw,ch) {
//alert(canvo.id);
if (awocmd == '') {
setInterval(checkawos, 12000);
}
if (canvo.id.slice(-1).toLowerCase() == 'l') {
awocmd=\"awol=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=','_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
} else if (canvo.id.slice(-1).toLowerCase() == 'r') {
awocmd=\"awor=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=','_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
} else {
awocmd=\"awo=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=','_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
}
//alert(awocmd);
setTimeout(function(){ eval(awocmd); awocmd=' '; }, 5000);
}

function drawTextToCanvas() { // thanks to https://www.google.com/search?q=textarea+text+to+canvas&rlz=1C5OZZY_en&oq=textarea+text+to+canvas+&gs_lcrp=EgZjaHJvbWUyCQgAEEUYORifBTIHCAEQIRigATIHCAIQIRigATIHCAMQIRigATIHCAQQIRigATIHCAUQIRigAdIBCDkxNjRqMGo0qAIAsAIB&sourceid=chrome&source=chrome.ob&ie=UTF-8
var ii=0, jj=-1, maxchars=0, gtsfound=false, leftno='', lthingo='x';
var tao=document.getElementsByTagName('textarea')[0];
if (textareatwo.id.substring(0,1) == 'l' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') != -1) {
lthingo='l';
} else if (textareatwo.id.substring(0,1) == 'r' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') != -1) {
lthingo='R';
//alert('is R');
}
// 1. Clear the canvas before redrawing
ctx.clearRect(0, 0, canvas.width, canvas.height);

// 2. Set text styles
ctx.font = \"14px Courier New\";
ctx.fillStyle = \"#000000\"; // #333333
ctx.textBaseline = \"top\"; // Align from top-left for easier line calculations

// 3. Split the text by line breaks
var lines = ((textareaone != null ? textareaone.value + String.fromCharCode(10) : '')).split(String.fromCharCode(10)); // + (textareatwo != null ? textareatwo.value : '')).split(String.fromCharCode(10));

for (var ii=0; ii<lines.length; ii++) {
if (eval('' + lines[ii].length) > maxchars) { maxchars=eval('' + lines[ii].length); }
if (textareatwo.id.substring(0,1) == 'r' && leftno == '' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') == -1 && lines[ii].trim() != '' && lines[ii].indexOf('" . $lts . "') != -1) {
leftno=lines[ii].split('" . $lts . "')[0];
//alert(leftno);
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
leftno=' ';
}
}
}

if (textareatwo.id.substring(0,1).toUpperCase() == lthingo.toUpperCase() || 7 == 7) {
for (var ii=0; ii<lines.length; ii++) {
if (!gtsfound) {
lines[ii]=lines[ii].trim(); //.replace(/\ $/g,'');
}
while (eval('' + lines[ii].length) < maxchars) {
if (!gtsfound) {
lines[ii]=' ' + lines[ii];
} else {
lines[ii]+=' ';
}
}
if (lines[ii].indexOf('" . $gts . "') != -1) {
jj=eval(1 + ii); //gtsfound=true;
} else if (ii == jj) {
gtsfound=true;
}
}
//} else {
//alert('why');
}

//alert('prerevstr=' + prerevstr + ' and revstr=' + revstr + ' and textareaonevalue=' + textareaone.value + String.fromCharCode(10) + textareatwo.value);

// 4. Draw each line with vertical offset (line height)
var lineHeight = 16;
var startX = 0;
var startY = 10;
if (textareatwo.id.substring(0,1) == 'r' && lthingo.toUpperCase() != 'R') {
startY-=" . $thirtytwo . ";
}

if (textareatwo.id.substring(0,1) == lthingo || textareatwo.id.substring(0,1).toUpperCase() == lthingo) {
startX = canvas.width;
startY-=14;
ctx.textAlign = 'right';
//alert('Here');
}

lines.forEach((line, index) => {
//if (textareatwo.id.substring(0,1) == lthingo && 1 == 5) {
if (textareatwo.id.substring(0,1) == lthingo && 1 == 5) {
ctx.fillText(line.split('').reverse().join(''), startX, startY + (index * lineHeight));
//alert('thEre');
} else {
if (leftno != '') {
//alert('there');
ctx.fillText(line.replace(leftno,''), startX, startY + (index * lineHeight));
} else {
ctx.fillText(line, startX, startY + (index * lineHeight));
}
}
});

if (textareatwo.id.substring(0,1).toUpperCase() == lthingo.toUpperCase()) { // thanks to https://www.google.com/search?q=just+scale+part+of+an+HTML+canvas&sca_esv=ddd109fd00e45f93&rlz=1C5OZZY_en&sxsrf=AKL5yDgSuo_oLZNuX2RTf0dEj8ymY_NrUg%3A1794091464710&ei=yKnvatDyKvrl2roP5PjAkAE&biw=1440&bih=703&uact=5&oq=just+scale+part+of+an+HTML+canvas&gs_lp=Egxnd3Mtd2l6LXNlcnAiIWp1c3Qgc2NhbGUgcGFydCBvZiBhbiBIVE1MIGNhbnZhczIIECEYoAEYwwQyCBAhGKABGMMESIE3UJgUWKw1cAN4AZABAJgBzgGgAYkLqgEFMC43LjG4AQPIAQD4AQGYAgqgAoMKwgIKEAAYRxjWBBiwA8ICBxAjGLACGCfCAgUQABjvBcICChAhGAoYoAEYwwSYAwCIBgGQBgiSBwUzLjYuMaAHlCKyBwUwLjYuMbgH9QnCBwUxLjMuNsgHHYAIAQ&sclient=gws-wiz-serp
//alert('where');
var offscreen = document.createElement('canvas');
var offCtx = offscreen.getContext('2d');
var offscreentop = document.createElement('canvas');
var offCtxtop = offscreentop.getContext('2d');

var sourceX = 0, sourceY = " . $thirtytwoplus . ", sourceW = canvas.width, sourceH = eval(-" . $thirtytwoplus . " + canvas.height);
offscreen.width = sourceW;
offscreen.height = sourceH;
offscreentop.width = sourceW;
offscreentop.height = " . $thirtytwoplus . ";

// 2. Copy the specific part from the main canvas to the offscreen canvas
offCtx.drawImage(canvas, sourceX, sourceY, sourceW, sourceH, 0, 0, sourceW, sourceH);
offCtxtop.drawImage(canvas, 0,0, sourceW, " . $thirtytwoplus . ", 0, 0, sourceW, " . $thirtytwoplus . ");

// 3. Draw it back onto the main canvas at a larger or smaller scale
var xscaleFactor = 1;
var yscaleFactor = 1;
ctx.save();

// 2. Move the origin to the center (or left) of where you want the image
//alert('w,h=' + canvas.width + ',' + canvas.height);
//ctx.translate(canvas.width * 1.6, 0);
ctx.translate(canvas.width * 1.6, 0);

// 3. Flip the X axis (scales width by -1)
ctx.scale(-1, 1);

ctx.globalCompositeOperation = 'copy';
ctx.drawImage(
offscreen,
0, 0, sourceW, sourceH, // source rectangle
sourceX, sourceY, sourceW * xscaleFactor, sourceH * yscaleFactor // destination rectangle
);

ctx.globalCompositeOperation = 'source-over';
ctx.restore();
ctx.drawImage(
offscreentop,
0, 0, sourceW, " . $thirtytwoplus . ", // source rectangle
sourceX, 0, sourceW * xscaleFactor, " . $thirtytwoplus . " * yscaleFactor // destination rectangle
);

if (lthingo == 'R') {
//alert('huh');
var rectone=tao.getBoundingClientRect();
var recttwo=document.getElementById('myCanvasr').getBoundingClientRect();
if (eval('' + recttwo.right) > eval('' + rectone.right)) {
//alert('yes ' + document.getElementById('myCanvasr').style.left);
//alert('' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px');
document.getElementById('atendr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('atendr').style.left.replace('px',''))) + 'px';
document.getElementById('myCanvasr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px';
}
//} else if (textareatwo.id.substring(0,1) == 'r') {
//alert('RE huh');
}
} else if (textareatwo.id.substring(0,1) == 'r') {
//alert('RE Huh');
var rectone=tao.getBoundingClientRect();
var recttwo=document.getElementById('myCanvasr').getBoundingClientRect();
if (eval('' + recttwo.left) < eval('' + rectone.left)) {
//alert('Yes ' + document.getElementById('myCanvasr').style.left);
//alert('' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px');
document.getElementById('atendr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('atendr').style.left.replace('px',''))) + 'px';
document.getElementById('myCanvasr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px';
}
}


textareaone.style.color='transparent';
textareatwo.style.color='transparent';
document.getElementById('inout').focus();
}


function ouralert(elo) {
if (elo != null) {
if (elo != lastelo) {
if (('' + elo.outerHTML).split('>')[0].indexOf(' title=') != -1) {
lastelo=elo;
alert(elo.title);
}
}
}
}

function inpit() {
if (document.getElementById('inpl').value.trim() != '') {
var ximgl = new Image();

ximgl.onload = function() {
document.getElementById('myCanvasl').getContext('2d').clearRect(0, 0, document.getElementById('myCanvasl').width, document.getElementById('myCanvasl').height);
document.getElementById('myCanvasl').getContext('2d').drawImage(ximgl, 0, 0);
};

ximgl.src=document.getElementById('inpl').value;
document.getElementById('inpl').value=' ';
}
if (document.getElementById('inpr').value.trim() != '') {
var ximgr = new Image();

ximgr.onload = function() {
document.getElementById('myCanvasr').getContext('2d').clearRect(0, 0, document.getElementById('myCanvasr').width, document.getElementById('myCanvasr').height);
document.getElementById('myCanvasr').getContext('2d').drawImage(ximgr, 0, 0);
};

ximgr.src=document.getElementById('inpr').value;
document.getElementById('inpr').value=' ';
}
}

setInterval(inpit, 5000);

";

$bscstuff="<scr" . "ipt type=text/javascript> " . $scstuff . " </scr" . "ipt>";

?>

… in the changed Cowsay using cowsay.php new temporary file pointing web application.


Previous relevant Cowsay Revisit Regarding Temporaries Tutorial is shown below.

Cowsay Revisit Regarding Temporaries Tutorial

Cowsay Revisit Regarding Temporaries Tutorial

Like with the recent GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial, around here, we need not to forget …


/tmp/

… referencing PHP web applications on AlmaLinux for the RJM Programming have not worked, regarding restricted file permissions, for about the last two incarnations of our web server.

Instead, on some projects, like this one that, so far, never calls the PHP from the command line in CLI fashion (where if command line was used curl would be more apt for the reasoning below), we’ve been preferring the use of, in “PHP speak” …


$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR

… or https://www.rjmprogramming.com.au/tmp/ ( in “absolute URL speak” where $_SERVER[‘DOCUMENT_ROOT’] points to the Apache web server Document Root (folder) as (absolute URL) https://www.rjmprogramming.com.au ) as a better place “to doodle” with today’s rearranged PHP web application, that being the Cowsay using web application we referenced back with Live Captions Interfacing to Text to Speech Interfacing Tutorial.

When a PHP project has referenced /tmp/ as often as this one, you should not assume non-moderated global substitutions, or even three sets of non-moderated global substitutions, is the best approach. What we did was three passes of global substitution but verify each occasion, in TextWrangler, for mentions of …

Find (though second one we found none) … More than likely replace with …
'/tmp/ $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . '

"/tmp/ $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . "

 /tmp/ Sometimes …
 ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . '
… and sometimes …
 " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . "

… followed by …

  1. php -l cowsay.php
  2. address bar https://www.rjmprogramming.com.au/cowsay.php run throughs

… in the changed Cowsay using cowsay.php new temporary file pointing web application.


Previous relevant GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial is shown below.

GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial

GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial

Onto the recent GraphViz via PHP on AlmaLinux Family Tree Tutorial we’ve applied similar …

  • get rid of /tmp/ temporary folder to read and write to references … in favour of either/both …
    1. tmp folder off the Apache web server’s Document Root (we created for this, and other, purposes, one day)
    2. folder above Apache web server’s Document Root

… as a basis to have these GraphViz PHP hosting Python and/or dot based web applications a solid “interim file place” basis to “do their thiang” creating interesting graphical items amongst …

… options. Why the bother? Well, on recent AlmaLinux Apache web server versions, the reading and writing from/to …


/tmp/

… folder by the web content user (as distinct from the cPanel user) has been restricted. Perhaps this could be lifted as a restriction, but we tend to think if the WHM and cPanel Apache web server hosters tend to think this way, it is probably to do with a security concern that they would be far more wise to than we could be.


Previous relevant GraphViz via PHP on AlmaLinux Family Tree Tutorial is shown below.

GraphViz via PHP on AlmaLinux pFamily Tree Tutorial

GraphViz via PHP on AlmaLinux Family Tree Tutorial

Today we continue down our road of replacing PHP (hosts Python and uses Graphviz) code series that used to use /tmp/ to read and write interim files from, in favour of a tmp folder off the Apache web server Document Root, like with the recent GraphViz via PHP on AlmaLinux New Temporary Folder Tutorial.

Today’s “cab off the rank” creates “dot inspired” Family Trees, where a changed file_tree.php Family Tree web application is definitely worth it to try, especially if you understand hierarchical data structures …


Previous relevant Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial is shown below.

Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial

Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial

Onto yesterday’s Ffmpeg Interfacing Intranet Feeling Tutorial today’s work moving forward is to change references to temporary folder …


/tmp/

.. to …


the folder above the Apache Document Root folder

… because …

  1. it can be read and written to by the RJM Programming web server username … and yet …
  2. cannot be referenced by users surfing the net … being lower down the directory tree than the /home/rjmprogr/public_html which corresponds to our Apache Document Root folder
  3. it can be read and written to by the cPanel username … meaning …
  4. our web server’s main functioning crontab scheduling can reference it, like with yesterday’s New Temporary Folder Arrangements Tidying Tutorial

… in the downloadable a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application.


Previous relevant Ffmpeg Interfacing Intranet Feeling Tutorial is shown below.

Ffmpeg Interfacing Intranet Feeling Tutorial

Ffmpeg Interfacing Intranet Feeling Tutorial

Today, onto the recent Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial, as far as interfacing to the great ffmpeg video editing software goes …

  • we start, in the work today, calling any existant macOS installed …
    1. ffmpeg
    2. downloaded macos_ffmpeg_convert.php placed into a macOS MAMP local Apache web server port 8888 Document Root folder
  • fix /tmp/ usage as flagged in the blog posting New Temporary Folder Arrangements PHP Primer Tutorial
  • whatever else that becomes an issue or can be an improvement

… in a new makeover operation.

What did we discover today? We think, perhaps, the “named iframe element called by second parameter of window.open” may not be an approach we can take on this makeover, perhaps because HTML content gets into the mix, whereas with the Talking Select Multiple Webpage Palette Speech Bubble Tutorial threads, “the content” has no HTML, just PHP calling the operating system via the macOS “say” command … unless tomorrow reveals today’s folly … that is?!

We can still use window.open second parameter “_blank” and third parameter “positioning” scenarios, though, as how we leave today’s machinations within a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application.


Previous relevant Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial is shown below.

Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial

Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial

In yesterday’s Ffmpeg User Defined Video Editing Sharing Tutorial about sharing video data (that might have been edited by ffmpeg command line means) we warned …

even though it is only likely to work for shorter videos

… regarding the data URI hashtagged parts to SMS or email links that we were exclusively using … then. But, with this in mind, what do …

  1. data URI based URLs (hashtagged in an email or SMS link) … and …
  2. absolute URL that points to a web server soft link file, itself pointing to /tmp/ video data files ((we’re still hashtagging, but now, don’t really have to, apply) in an email or SMS link)

… share? We’d say, as far as sharing goes …

A sense of permanency.

But …

  • the second one does not “push the barrow” as much as the first regarding the amount of data … whereas …
  • the first is totally ephemeral and not asking anything more of the web server (ie. the RJM Programming associated one) regarding ongoing storage but is asking a lot of web browsers and client mail applications in the case of video data of any bulk

In terms of sharing videos of any bulk, we’re now, with our web application …

  • renaming the top button (that used to be “Display”) as “Display for a Day” and applying absolute URL (that point at web server soft links that, in turn, point at what can be sizeable video data files that might hang around in RJM Programming domain associated web server /tmp/ location) logics which call on “crontab” … (

    */53 * * * * /etc/init.d/every_hour.sh

    … now mentions …

    ksh -c 'for i in `find /tmp -name "my_video_*.*" -mmin -1440`; do rm -f $i; done'

    ) … assistance to do with the tidy up we feel we need to do on the web server so that large files do not hang around forever (and as you might surmise, at most a day, regarding the bulk of data requirements that are temporarily stored in /tmp/ locations with user associated IP addresses part of the file naming paradigm) … whereas …
  • the bottom button remains as “Display” and still uses data URI based logic

… so that these bulky videos can be successfully shared (via clicks of that “Display for a Day” button) as long as the email or SMS link is attended to by the collaboration recipient within those 24 hours, further to yesterday’s Ffmpeg User Defined Video Editing Sharing Tutorial.

As well, today, as a genericization measure, we stop seeing govetts_leap in any video file naming, replaced by my_video now that the input video control has become less rigid, and now can be controlled, to some extent, by the user in our changed fourth draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Video Editing Sharing Tutorial is shown below.

Ffmpeg User Defined Video Editing Sharing Tutorial

Ffmpeg User Defined Video Editing Sharing Tutorial

Sharing options for video based data are often more restrictive regarding email and SMS conduits, but we’ll still go ahead with a …

  • “a” link “mailto:” (for emails) or “sms:” (for SMS) methodology …
  • email subject containing ffmpeg command used for an output video mode of sharing … or …
  • input video mode of sharing before any ffmpeg involvement … based on …
  • email or SMS links where the video data URI (as necessary) is hashtagged

… set of ideas to try out, even though it is only likely to work for shorter videos. The other more obvious sharing mechanism is to download video data via right click options the web browser product you are using offers anyway. And another sharing idea, independent, and working for input videos is to browse for a video using the helper web application from yesterday, and use its Share API based button below the browsing button to share that input video using one of …

  • Mail
  • Messages
  • AirDrop
  • Notes
  • Simulator
  • Freeform

… on our macOS Safari web browser here on a MacBook Air.

Further to yesterday’s Ffmpeg User Defined Browsed Video Editing Tutorial, then, we have some new (PHP writes) Javascript functions …

<?php echo ”

function smsit() {
var smsno=prompt('Please enter SMS number.', '');
if (smsno != null) {
if (document.getElementById('cto').title.indexOf('data:') == 0) {
document.getElementById('asms').href='sms:' + smsno + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('cto').title);
} else {
document.getElementById('asms').href='sms:' + smsno + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('resultav').value);
}
document.getElementById('asms').click();
}
}


function emailit() {
var emailaddr=prompt('Please enter Email address.', '');
if (emailaddr != null) {
if (document.getElementById('cto').title.indexOf('data:') == 0) {
document.getElementById('aemail').href='mailto:' + emailaddr + '?subject=Ffmpeg%20Video' + encodeURIComponent(' ... ' + document.getElementById('mysubtwo').value.replace(/^Display$/g,'')) + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('cto').title);
} else {
document.getElementById('aemail').href='mailto:' + emailaddr + '?subject=Ffmpeg%20Video' + encodeURIComponent(' ... ' + document.getElementById('mysubtwo').value.replace(/^Display$/g,'')) + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('resultav').value);
}
document.getElementById('aemail').click();
}
}

function documentgetElementByIdmysubpclick() { // new arrangement for the programmatic click of form submit button
if (eval('' + document.getElementById('resultav').value.length) < 300) {
document.getElementById('myiftwo').src=document.URL.split('?')[0].split('#')[0] + '?becomes=' + encodeURIComponent(document.getElementById('becomes').value) + '&browsed=' + encodeURIComponent(document.getElementById('resultav').value);
} else {
document.getElementById('mysubp').click();
}
}

“; ?>

… in our changed third draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Browsed Video Editing Tutorial is shown below.

Ffmpeg User Defined Browsed Video Editing Tutorial

Ffmpeg User Defined Browsed Video Editing Tutorial

Today’s work, onto yesterday’s Ffmpeg User Defined Video Editing Tutorial, is to loosen the restrictions regarding “input video file source” we had happening in that “first draft” incarnation of our Ffmpeg User Defined Video Editing web application.

In order to achieve this, we called on a previous Ffmpeg Install and Public Face Tutorial inspired change to our inhouse macos_ffmpeg_convert.php PHP web application, which can serve as our conduit to either/or …

  • browse for a video file off the user local operating system environment … or …
  • path to a web server placed video file … or …
  • URL to a video file

… extra means by which the user can define the “input video file source” that we’re loosening the shackles regarding usage.

To do this, we look for user actions (via PHP writing out Javascript) …

<?php echo ”

var lastpathc='';
var lastopathc='';
var lastvidc='';
var lastvalue='.m4v';
var exactvalue='';
var vext='.mp4';

function lookfor() {
vext='.mp4';
var thisext='';
if (document.getElementById('opath').value != '') {
if (lastopathc != document.getElementById('opath').value && document.getElementById('opath').title != document.getElementById('opath').value) {
lastopathc=document.getElementById('opath').value;
}
}
if (document.getElementById('path').value != '') {
if (lastpathc != document.getElementById('path').value) {
lastpathc=document.getElementById('path').value;
if (lastopathc == ' ') { lastopathc=document.getElementById('opath').value; }
}
}
if (lastopathc.trim() != '') {
thisext=(lastopathc + '.').split('.')[1].split('.')[0].trim();
if (thisext != '') {
document.getElementById('opath').title=lastopathc;
document.getElementById('path').title='video/' + thisext + ';' + lastpathc + lastopathc;
document.getElementById('resultav').value=lastpathc + lastopathc;
lastopathc=' ';
}
}
if (document.getElementById('resultav').value != '') {
if (lastvidc != document.getElementById('resultav').value) {
if ((document.getElementById('path').title + document.getElementById('resultav').value).indexOf('video/') != -1) {
if (document.getElementById('ifbrowse').src.indexOf('=') != -1) {
document.getElementById('myaltin').value=decodeURIComponent(document.getElementById('ifbrowse').src.split('=')[1].split('&')[0].split('#')[0]);
}
if ((document.getElementById('path').title + document.getElementById('resultav').value).indexOf('video/') != -1) {
if (vext.indexOf((document.getElementById('path').title + document.getElementById('resultav').value).split('video/')[1].split(';')[0].split(',')[0]) == -1) {
vext='.' + document.getElementById('resultav').value.split('video/')[1].split(';')[0].split(',')[0];
document.getElementById('myaltin').value=document.getElementById('myaltin').value.split('.')[0] + vext;
document.getElementById('becomes').value=document.getElementById('becomes').value.split('.')[0] + vext;
}
}
lastvidc=document.getElementById('resultav').value;
document.getElementById('resultav').title='rework';
document.getElementById('mysubp').click();
setTimeout(function(){
if (1 == 1) {
document.getElementById('divvid').innerHTML=\"<video id=myinvideo style=width:95%; controls><source id=myinsource type='video/\" + vext.substring(1) + \"' src='\" + document.getElementById('resultav').value + \"'></source></video>\";
} else {
document.getElementById('myinsource').src=document.getElementById('resultav').value;
}
}, 2000);
//setTimeout(function(){
//document.getElementById('resultav').value='';
//}, 20000);
//alert(lastvidc);
setTimeout(lookfor, 23000);
return '';
}
setTimeout(lookfor, 3000);
return '';
}
}
setTimeout(lookfor, 3000);
return '';
}

setTimeout(lookfor, 3000);

“; ?>

… and then arrange the /tmp/ placed temporary video data via …

<?php

if (isset($_POST['browsed']) && isset($_POST['becomes'])) {
$fgccont='';
//file_put_contents('xzm.xzm', '1');
$outtmpfile=str_replace('+',' ',urldecode($_POST['becomes']));
//file_put_contents('xzm2.xzm2', $outtmpfile);
$outext=explode('.', $outtmpfile)[-1 + sizeof(explode('.', $outtmpfile))];
//file_put_contents('xzm3.xzm3', str_replace(' ','+',urldecode($_POST['browsed'])));
if (strpos(('xwq' . $_POST['browsed']), 'xwqdata') !== false) {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), base64_decode(explode(";base64,", str_replace(' ','+',urldecode($_POST['browsed'])))[1]));
} else if (strpos(('xwq' . strtolower($_POST['browsed'])), 'xwqhttps') !== false) {
$fgccont=file_get_contents('http' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),5));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower($_POST['browsed'])), 'xwqhttp') !== false) {
$fgccont=file_get_contents('http' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),4));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower(str_replace('+',' ',urldecode($_POST['browsed'])))), 'xwq//') !== false) {
$fgccont=file_get_contents('http:' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),0));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower(str_replace('+',' ',urldecode($_POST['browsed'])))), 'xwqwww.') !== false) {
$fgccont=file_get_contents('http://' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),0));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (file_exists(str_replace('+',' ',urldecode($_POST['browsed'])))) {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), file_get_contents(str_replace('+',' ',urldecode($_POST['browsed']))));
}
//file_put_contents('xzm4.xzm4', explode(";base64,", str_replace(' ','+',urldecode($_POST['browsed'])))[1]);
exit;
}

?>

… all the while being helped out by a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application helper to our changed second draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Video Editing Tutorial is shown below.

Ffmpeg User Defined Video Editing Tutorial

Ffmpeg User Defined Video Editing Tutorial

Today we’re combining video contents from …

  • yesterday’s Ffmpeg Helps iPhone Video to YouTube Tutorial … with …
  • our newly created public interface to ffmpeg with the “soon to be DNS version of rjmprogramming.com.au … but not yet” AlmaLinux Apache/PHP/MySql web server install we talked about at Ffmpeg Install and Public Face Tutorial … and …
  • IP address redirecting, as needed, ifconfig (via PHP shell_exec and $_SERVER[‘SERVER_ADDR’]) based logic …
    <?php

    $whereplace=shell_exec("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'");
    if (strpos(($whereplace . ' ' . $_SERVER['SERVER_ADDR']), '65.254.92.213') !== false) {
    $sv='/usr/bin/ffmpeg';
    header('Location: https://65.254.95.247/PHP/tmp_ffmpeg.php'); //$smallpath='https://65.254.95.247/PHP/'; //header('Location: https://65.254.95.247/PHP/tmp_ffmpeg.php');
    exit; //exit;
    }

    ?>
    … we talked about at AlmaLinux Landing Page WordPress Content Update Solution Tutorial … as well as …
  • user definable form navigation … using …
  • optional dropdown ideas incorporating ideas from Sepia Video via ffmpeg Primer Tutorial … and using …
  • temporary storage places to place output video … and making use of …
  • soft links regarding URLs we talked about at Linux Web Server Soft Link URL Tutorial (saving us having to use ‘data:video/mp4;base64,’ . base64_encode(file_get_contents(trim($endout))) style PHP interventions (which were testing friendships))

… to start down this road towards public facing ffmpeg video editing around here (which we have been hankering for for several years now).

In this first draft of Your Own Ffmpeg Video Changes (via command line ffmpeg) we’re really buttoning down (via not allowing the forward slash character in amongst the user defined ffmpeg command innards) what happens regarding …

  • output video file source location … and …
  • input video file source …

… but who knows what the future holds?!


Previous relevant Ffmpeg Helps iPhone Video to YouTube Tutorial is shown below.

Ffmpeg Helps iPhone Video to YouTube Tutorial

Ffmpeg Helps iPhone Video to YouTube Tutorial

Today we recorded a video looking out from Govetts Leap, Blackheath, here in the Blue Mountains. We captured it via the Camera app on an iPhone via its Video option.

Nineteen seconds long, to share to this MacBook Air we needed AirDrop, the size of it precluding us from using the Photo app’s Mail sharing option.

And that’s where we wanted to use the great ffmpeg in an optimal way to create a video that we could upload to YouTube. In this, we arrived at this excellent link getting us to try …


ffmpeg -i govetts_leap.MOV -c:v libx264 -preset slow -crf 18 -vf scale=out_color_matrix=bt709 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -c:a aac -ar 48000 -ac 2 -b:a 320k -profile:v high -level 4.0 -bf 2 -coder 1 -pix_fmt yuv420p -b:v 10M -threads 4 -cpu-used 0 -r 30 -g 15 -movflags +faststart govetts_leap.mp4

… with success. Checking with this other excellent link, thanks, we were comforted that they would have recommended an output mp4 file format as well, it seems …

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.


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

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

Cowsay Revisit Regarding Temporaries Tutorial

Cowsay Revisit Regarding Temporaries Tutorial

Cowsay Revisit Regarding Temporaries Tutorial

Like with the recent GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial, around here, we need not to forget …


/tmp/

… referencing PHP web applications on AlmaLinux for the RJM Programming have not worked, regarding restricted file permissions, for about the last two incarnations of our web server.

Instead, on some projects, like this one that, so far, never calls the PHP from the command line in CLI fashion (where if command line was used curl would be more apt for the reasoning below), we’ve been preferring the use of, in “PHP speak” …


$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR

… or https://www.rjmprogramming.com.au/tmp/ ( in “absolute URL speak” where $_SERVER[‘DOCUMENT_ROOT’] points to the Apache web server Document Root (folder) as (absolute URL) https://www.rjmprogramming.com.au ) as a better place “to doodle” with today’s rearranged PHP web application, that being the Cowsay using web application we referenced back with Live Captions Interfacing to Text to Speech Interfacing Tutorial.

When a PHP project has referenced /tmp/ as often as this one, you should not assume non-moderated global substitutions, or even three sets of non-moderated global substitutions, is the best approach. What we did was three passes of global substitution but verify each occasion, in TextWrangler, for mentions of …

Find (though second one we found none) … More than likely replace with …
'/tmp/ $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . '

"/tmp/ $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . "

 /tmp/ Sometimes …
 ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . '
… and sometimes …
 " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . "

… followed by …

  1. php -l cowsay.php
  2. address bar https://www.rjmprogramming.com.au/cowsay.php run throughs

… in the changed Cowsay using cowsay.php new temporary file pointing web application.


Previous relevant GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial is shown below.

GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial

GraphViz via PHP on AlmaLinux Suite Temporaries Tutorial

Onto the recent GraphViz via PHP on AlmaLinux Family Tree Tutorial we’ve applied similar …

  • get rid of /tmp/ temporary folder to read and write to references … in favour of either/both …
    1. tmp folder off the Apache web server’s Document Root (we created for this, and other, purposes, one day)
    2. folder above Apache web server’s Document Root

… as a basis to have these GraphViz PHP hosting Python and/or dot based web applications a solid “interim file place” basis to “do their thiang” creating interesting graphical items amongst …

… options. Why the bother? Well, on recent AlmaLinux Apache web server versions, the reading and writing from/to …


/tmp/

… folder by the web content user (as distinct from the cPanel user) has been restricted. Perhaps this could be lifted as a restriction, but we tend to think if the WHM and cPanel Apache web server hosters tend to think this way, it is probably to do with a security concern that they would be far more wise to than we could be.


Previous relevant GraphViz via PHP on AlmaLinux Family Tree Tutorial is shown below.

GraphViz via PHP on AlmaLinux pFamily Tree Tutorial

GraphViz via PHP on AlmaLinux Family Tree Tutorial

Today we continue down our road of replacing PHP (hosts Python and uses Graphviz) code series that used to use /tmp/ to read and write interim files from, in favour of a tmp folder off the Apache web server Document Root, like with the recent GraphViz via PHP on AlmaLinux New Temporary Folder Tutorial.

Today’s “cab off the rank” creates “dot inspired” Family Trees, where a changed file_tree.php Family Tree web application is definitely worth it to try, especially if you understand hierarchical data structures …


Previous relevant Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial is shown below.

Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial

Ffmpeg Interfacing Intranet Feeling New Temporary Folder Tutorial

Onto yesterday’s Ffmpeg Interfacing Intranet Feeling Tutorial today’s work moving forward is to change references to temporary folder …


/tmp/

.. to …


the folder above the Apache Document Root folder

… because …

  1. it can be read and written to by the RJM Programming web server username … and yet …
  2. cannot be referenced by users surfing the net … being lower down the directory tree than the /home/rjmprogr/public_html which corresponds to our Apache Document Root folder
  3. it can be read and written to by the cPanel username … meaning …
  4. our web server’s main functioning crontab scheduling can reference it, like with yesterday’s New Temporary Folder Arrangements Tidying Tutorial

… in the downloadable a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application.


Previous relevant Ffmpeg Interfacing Intranet Feeling Tutorial is shown below.

Ffmpeg Interfacing Intranet Feeling Tutorial

Ffmpeg Interfacing Intranet Feeling Tutorial

Today, onto the recent Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial, as far as interfacing to the great ffmpeg video editing software goes …

  • we start, in the work today, calling any existant macOS installed …
    1. ffmpeg
    2. downloaded macos_ffmpeg_convert.php placed into a macOS MAMP local Apache web server port 8888 Document Root folder
  • fix /tmp/ usage as flagged in the blog posting New Temporary Folder Arrangements PHP Primer Tutorial
  • whatever else that becomes an issue or can be an improvement

… in a new makeover operation.

What did we discover today? We think, perhaps, the “named iframe element called by second parameter of window.open” may not be an approach we can take on this makeover, perhaps because HTML content gets into the mix, whereas with the Talking Select Multiple Webpage Palette Speech Bubble Tutorial threads, “the content” has no HTML, just PHP calling the operating system via the macOS “say” command … unless tomorrow reveals today’s folly … that is?!

We can still use window.open second parameter “_blank” and third parameter “positioning” scenarios, though, as how we leave today’s machinations within a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application.


Previous relevant Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial is shown below.

Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial

Ffmpeg User Defined Video Editing Crontab Assisted Sharing Tutorial

In yesterday’s Ffmpeg User Defined Video Editing Sharing Tutorial about sharing video data (that might have been edited by ffmpeg command line means) we warned …

even though it is only likely to work for shorter videos

… regarding the data URI hashtagged parts to SMS or email links that we were exclusively using … then. But, with this in mind, what do …

  1. data URI based URLs (hashtagged in an email or SMS link) … and …
  2. absolute URL that points to a web server soft link file, itself pointing to /tmp/ video data files ((we’re still hashtagging, but now, don’t really have to, apply) in an email or SMS link)

… share? We’d say, as far as sharing goes …

A sense of permanency.

But …

  • the second one does not “push the barrow” as much as the first regarding the amount of data … whereas …
  • the first is totally ephemeral and not asking anything more of the web server (ie. the RJM Programming associated one) regarding ongoing storage but is asking a lot of web browsers and client mail applications in the case of video data of any bulk

In terms of sharing videos of any bulk, we’re now, with our web application …

  • renaming the top button (that used to be “Display”) as “Display for a Day” and applying absolute URL (that point at web server soft links that, in turn, point at what can be sizeable video data files that might hang around in RJM Programming domain associated web server /tmp/ location) logics which call on “crontab” … (

    */53 * * * * /etc/init.d/every_hour.sh

    … now mentions …

    ksh -c 'for i in `find /tmp -name "my_video_*.*" -mmin -1440`; do rm -f $i; done'

    ) … assistance to do with the tidy up we feel we need to do on the web server so that large files do not hang around forever (and as you might surmise, at most a day, regarding the bulk of data requirements that are temporarily stored in /tmp/ locations with user associated IP addresses part of the file naming paradigm) … whereas …
  • the bottom button remains as “Display” and still uses data URI based logic

… so that these bulky videos can be successfully shared (via clicks of that “Display for a Day” button) as long as the email or SMS link is attended to by the collaboration recipient within those 24 hours, further to yesterday’s Ffmpeg User Defined Video Editing Sharing Tutorial.

As well, today, as a genericization measure, we stop seeing govetts_leap in any video file naming, replaced by my_video now that the input video control has become less rigid, and now can be controlled, to some extent, by the user in our changed fourth draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Video Editing Sharing Tutorial is shown below.

Ffmpeg User Defined Video Editing Sharing Tutorial

Ffmpeg User Defined Video Editing Sharing Tutorial

Sharing options for video based data are often more restrictive regarding email and SMS conduits, but we’ll still go ahead with a …

  • “a” link “mailto:” (for emails) or “sms:” (for SMS) methodology …
  • email subject containing ffmpeg command used for an output video mode of sharing … or …
  • input video mode of sharing before any ffmpeg involvement … based on …
  • email or SMS links where the video data URI (as necessary) is hashtagged

… set of ideas to try out, even though it is only likely to work for shorter videos. The other more obvious sharing mechanism is to download video data via right click options the web browser product you are using offers anyway. And another sharing idea, independent, and working for input videos is to browse for a video using the helper web application from yesterday, and use its Share API based button below the browsing button to share that input video using one of …

  • Mail
  • Messages
  • AirDrop
  • Notes
  • Simulator
  • Freeform

… on our macOS Safari web browser here on a MacBook Air.

Further to yesterday’s Ffmpeg User Defined Browsed Video Editing Tutorial, then, we have some new (PHP writes) Javascript functions …

<?php echo ”

function smsit() {
var smsno=prompt('Please enter SMS number.', '');
if (smsno != null) {
if (document.getElementById('cto').title.indexOf('data:') == 0) {
document.getElementById('asms').href='sms:' + smsno + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('cto').title);
} else {
document.getElementById('asms').href='sms:' + smsno + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('resultav').value);
}
document.getElementById('asms').click();
}
}


function emailit() {
var emailaddr=prompt('Please enter Email address.', '');
if (emailaddr != null) {
if (document.getElementById('cto').title.indexOf('data:') == 0) {
document.getElementById('aemail').href='mailto:' + emailaddr + '?subject=Ffmpeg%20Video' + encodeURIComponent(' ... ' + document.getElementById('mysubtwo').value.replace(/^Display$/g,'')) + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('cto').title);
} else {
document.getElementById('aemail').href='mailto:' + emailaddr + '?subject=Ffmpeg%20Video' + encodeURIComponent(' ... ' + document.getElementById('mysubtwo').value.replace(/^Display$/g,'')) + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#vcont=' + document.getElementById('resultav').value);
}
document.getElementById('aemail').click();
}
}

function documentgetElementByIdmysubpclick() { // new arrangement for the programmatic click of form submit button
if (eval('' + document.getElementById('resultav').value.length) < 300) {
document.getElementById('myiftwo').src=document.URL.split('?')[0].split('#')[0] + '?becomes=' + encodeURIComponent(document.getElementById('becomes').value) + '&browsed=' + encodeURIComponent(document.getElementById('resultav').value);
} else {
document.getElementById('mysubp').click();
}
}

“; ?>

… in our changed third draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Browsed Video Editing Tutorial is shown below.

Ffmpeg User Defined Browsed Video Editing Tutorial

Ffmpeg User Defined Browsed Video Editing Tutorial

Today’s work, onto yesterday’s Ffmpeg User Defined Video Editing Tutorial, is to loosen the restrictions regarding “input video file source” we had happening in that “first draft” incarnation of our Ffmpeg User Defined Video Editing web application.

In order to achieve this, we called on a previous Ffmpeg Install and Public Face Tutorial inspired change to our inhouse macos_ffmpeg_convert.php PHP web application, which can serve as our conduit to either/or …

  • browse for a video file off the user local operating system environment … or …
  • path to a web server placed video file … or …
  • URL to a video file

… extra means by which the user can define the “input video file source” that we’re loosening the shackles regarding usage.

To do this, we look for user actions (via PHP writing out Javascript) …

<?php echo ”

var lastpathc='';
var lastopathc='';
var lastvidc='';
var lastvalue='.m4v';
var exactvalue='';
var vext='.mp4';

function lookfor() {
vext='.mp4';
var thisext='';
if (document.getElementById('opath').value != '') {
if (lastopathc != document.getElementById('opath').value && document.getElementById('opath').title != document.getElementById('opath').value) {
lastopathc=document.getElementById('opath').value;
}
}
if (document.getElementById('path').value != '') {
if (lastpathc != document.getElementById('path').value) {
lastpathc=document.getElementById('path').value;
if (lastopathc == ' ') { lastopathc=document.getElementById('opath').value; }
}
}
if (lastopathc.trim() != '') {
thisext=(lastopathc + '.').split('.')[1].split('.')[0].trim();
if (thisext != '') {
document.getElementById('opath').title=lastopathc;
document.getElementById('path').title='video/' + thisext + ';' + lastpathc + lastopathc;
document.getElementById('resultav').value=lastpathc + lastopathc;
lastopathc=' ';
}
}
if (document.getElementById('resultav').value != '') {
if (lastvidc != document.getElementById('resultav').value) {
if ((document.getElementById('path').title + document.getElementById('resultav').value).indexOf('video/') != -1) {
if (document.getElementById('ifbrowse').src.indexOf('=') != -1) {
document.getElementById('myaltin').value=decodeURIComponent(document.getElementById('ifbrowse').src.split('=')[1].split('&')[0].split('#')[0]);
}
if ((document.getElementById('path').title + document.getElementById('resultav').value).indexOf('video/') != -1) {
if (vext.indexOf((document.getElementById('path').title + document.getElementById('resultav').value).split('video/')[1].split(';')[0].split(',')[0]) == -1) {
vext='.' + document.getElementById('resultav').value.split('video/')[1].split(';')[0].split(',')[0];
document.getElementById('myaltin').value=document.getElementById('myaltin').value.split('.')[0] + vext;
document.getElementById('becomes').value=document.getElementById('becomes').value.split('.')[0] + vext;
}
}
lastvidc=document.getElementById('resultav').value;
document.getElementById('resultav').title='rework';
document.getElementById('mysubp').click();
setTimeout(function(){
if (1 == 1) {
document.getElementById('divvid').innerHTML=\"<video id=myinvideo style=width:95%; controls><source id=myinsource type='video/\" + vext.substring(1) + \"' src='\" + document.getElementById('resultav').value + \"'></source></video>\";
} else {
document.getElementById('myinsource').src=document.getElementById('resultav').value;
}
}, 2000);
//setTimeout(function(){
//document.getElementById('resultav').value='';
//}, 20000);
//alert(lastvidc);
setTimeout(lookfor, 23000);
return '';
}
setTimeout(lookfor, 3000);
return '';
}
}
setTimeout(lookfor, 3000);
return '';
}

setTimeout(lookfor, 3000);

“; ?>

… and then arrange the /tmp/ placed temporary video data via …

<?php

if (isset($_POST['browsed']) && isset($_POST['becomes'])) {
$fgccont='';
//file_put_contents('xzm.xzm', '1');
$outtmpfile=str_replace('+',' ',urldecode($_POST['becomes']));
//file_put_contents('xzm2.xzm2', $outtmpfile);
$outext=explode('.', $outtmpfile)[-1 + sizeof(explode('.', $outtmpfile))];
//file_put_contents('xzm3.xzm3', str_replace(' ','+',urldecode($_POST['browsed'])));
if (strpos(('xwq' . $_POST['browsed']), 'xwqdata') !== false) {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), base64_decode(explode(";base64,", str_replace(' ','+',urldecode($_POST['browsed'])))[1]));
} else if (strpos(('xwq' . strtolower($_POST['browsed'])), 'xwqhttps') !== false) {
$fgccont=file_get_contents('http' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),5));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower($_POST['browsed'])), 'xwqhttp') !== false) {
$fgccont=file_get_contents('http' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),4));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower(str_replace('+',' ',urldecode($_POST['browsed'])))), 'xwq//') !== false) {
$fgccont=file_get_contents('http:' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),0));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (strpos(('xwq' . strtolower(str_replace('+',' ',urldecode($_POST['browsed'])))), 'xwqwww.') !== false) {
$fgccont=file_get_contents('http://' . substr(str_replace('+',' ',urldecode($_POST['browsed'])),0));
if (trim($fgccont) != '') {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), $fgccont);
}
} else if (file_exists(str_replace('+',' ',urldecode($_POST['browsed'])))) {
file_put_contents(str_replace('+',' ',urldecode($_POST['becomes'])), file_get_contents(str_replace('+',' ',urldecode($_POST['browsed']))));
}
//file_put_contents('xzm4.xzm4', explode(";base64,", str_replace(' ','+',urldecode($_POST['browsed'])))[1]);
exit;
}

?>

… all the while being helped out by a tweaked macos_ffmpeg_convert.php works Ffmpeg Converter Tool PHP web application helper to our changed second draft of Your Own Ffmpeg Video Changes, which can be that much more useful in a new way in the AlmaLinux web server environment.


Previous relevant Ffmpeg User Defined Video Editing Tutorial is shown below.

Ffmpeg User Defined Video Editing Tutorial

Ffmpeg User Defined Video Editing Tutorial

Today we’re combining video contents from …

  • yesterday’s Ffmpeg Helps iPhone Video to YouTube Tutorial … with …
  • our newly created public interface to ffmpeg with the “soon to be DNS version of rjmprogramming.com.au … but not yet” AlmaLinux Apache/PHP/MySql web server install we talked about at Ffmpeg Install and Public Face Tutorial … and …
  • IP address redirecting, as needed, ifconfig (via PHP shell_exec and $_SERVER[‘SERVER_ADDR’]) based logic …
    <?php

    $whereplace=shell_exec("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'");
    if (strpos(($whereplace . ' ' . $_SERVER['SERVER_ADDR']), '65.254.92.213') !== false) {
    $sv='/usr/bin/ffmpeg';
    header('Location: https://65.254.95.247/PHP/tmp_ffmpeg.php'); //$smallpath='https://65.254.95.247/PHP/'; //header('Location: https://65.254.95.247/PHP/tmp_ffmpeg.php');
    exit; //exit;
    }

    ?>
    … we talked about at AlmaLinux Landing Page WordPress Content Update Solution Tutorial … as well as …
  • user definable form navigation … using …
  • optional dropdown ideas incorporating ideas from Sepia Video via ffmpeg Primer Tutorial … and using …
  • temporary storage places to place output video … and making use of …
  • soft links regarding URLs we talked about at Linux Web Server Soft Link URL Tutorial (saving us having to use ‘data:video/mp4;base64,’ . base64_encode(file_get_contents(trim($endout))) style PHP interventions (which were testing friendships))

… to start down this road towards public facing ffmpeg video editing around here (which we have been hankering for for several years now).

In this first draft of Your Own Ffmpeg Video Changes (via command line ffmpeg) we’re really buttoning down (via not allowing the forward slash character in amongst the user defined ffmpeg command innards) what happens regarding …

  • output video file source location … and …
  • input video file source …

… but who knows what the future holds?!


Previous relevant Ffmpeg Helps iPhone Video to YouTube Tutorial is shown below.

Ffmpeg Helps iPhone Video to YouTube Tutorial

Ffmpeg Helps iPhone Video to YouTube Tutorial

Today we recorded a video looking out from Govetts Leap, Blackheath, here in the Blue Mountains. We captured it via the Camera app on an iPhone via its Video option.

Nineteen seconds long, to share to this MacBook Air we needed AirDrop, the size of it precluding us from using the Photo app’s Mail sharing option.

And that’s where we wanted to use the great ffmpeg in an optimal way to create a video that we could upload to YouTube. In this, we arrived at this excellent link getting us to try …


ffmpeg -i govetts_leap.MOV -c:v libx264 -preset slow -crf 18 -vf scale=out_color_matrix=bt709 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -c:a aac -ar 48000 -ac 2 -b:a 320k -profile:v high -level 4.0 -bf 2 -coder 1 -pix_fmt yuv420p -b:v 10M -threads 4 -cpu-used 0 -r 30 -g 15 -movflags +faststart govetts_leap.mp4

… with success. Checking with this other excellent link, thanks, we were comforted that they would have recommended an output mp4 file format as well, it seems …

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

Cowsay Cartoon Cell Edit Image Tutorial

Cowsay Cartoon Cell Edit Image Tutorial

Cowsay Cartoon Cell Edit Image Tutorial

The images (of text) introduced with yesterday’s Cowsay Cartoon Cell Data Type Tutorial …

  • cloned a Cowsay text form into an image form via textarea double click event logics … and today we allow that HTML5 canvas element conduit also be a conduit to …
  • allow that image be editable in a popup window opened canvas allowing for annotations (starting with a scribble mode of use) that the user can personalize that image with

… via a canvas element right click (non-mobile) or touch move (mobile) …

<?php echo ”

function checkawos() {
var newdatal='', newdatar='';
if (awol) {
if (!awol.closed) {
if (!document.getElementById('myCanvasl')) {
awol.close();
aworl=null;
} else {
awol=awol;
}
} else {
awol=null;
datal='';
}
}
if (awor) {
if (!awor.closed) {
if (!document.getElementById('myCanvasr')) {
awor.close();
awor=null;
} else {
awor=awor;
}
} else {
awor=null;
datar='';
}
}

if (awol) {
if (datal == '' && document.getElementById('myCanvasl')) {
datal=document.getElementById('myCanvasl').toDataURL('data/jpeg', 10);
}
}

if (awor) {
if (datar == '' && document.getElementById('myCanvasr')) {
datar=document.getElementById('myCanvasr').toDataURL('data/jpeg', 10);
}
}

if (awol) {
newdatal=awol.document.getElementById('topcanvas').toDataURL('data/jpeg', 10);
if (newdatal != datal && eval('' + newdatal.length) > 16526) {
var imgl = new Image();

imgl.onload = function() {
document.getElementById('myCanvasl').getContext('2d').drawImage(imgl, 0, 0);
};

imgl.src=newdatal;
if (document.getElementById('randl').value == '') {
document.getElementById('randl').value='' + Math.floor(Math.random() * 19878641);
if (document.getElementById('lri').value.indexOf('l') != -1) {
document.getElementById('lri').value=document.getElementById('lri').value.replace('l','l' + document.getElementById('randl').value);
} else {
document.getElementById('lri').value+='l' + document.getElementById('randl').value;
}
extralri='&lri=' + document.getElementById('lri').value;
}
document.getElementById('durll').value=newdatal;
datal=newdatal;
document.getElementById('subl').click();
}
}

if (awor) {
newdatar=awor.document.getElementById('topcanvas').toDataURL('data/jpeg', 10);
if (newdatar != datar && eval('' + newdatar.length) > 16526) {
var imgr = new Image();

imgr.onload = function() {
document.getElementById('myCanvasr').getContext('2d').drawImage(imgr, 0, 0);
};

imgr.src=newdatar;
if (document.getElementById('randr').value == '') {
document.getElementById('randr').value='' + Math.floor(Math.random() * 19878641);
if (document.getElementById('lri').value.indexOf('r') != -1) {
document.getElementById('lri').value=document.getElementById('lri').value.replace('r','r' + document.getElementById('randr').value);
} else {
document.getElementById('lri').value+='r' + document.getElementById('randr').value;
}
extralri='&lri=' + document.getElementById('lri').value;
}
document.getElementById('durlr').value=newdatar;
datar=newdatar;
document.getElementById('subr').click();
}
}


}

function wopit(canvo,cw,ch) {
//alert(canvo.id);
if (awocmd == '') {
setInterval(checkawos, 12000);
}
if (canvo.id.slice(-1).toLowerCase() == 'l') {
awocmd=\"awol=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=','_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
} else if (canvo.id.slice(-1).toLowerCase() == 'r') {
awocmd=\"awor=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=','_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
} else {
awocmd=\"awo=window.open('/HTMLCSS/user_of_signature_signature.htm?zoom=1.0&cancontw=\" + cw + \"&canconth=\" + ch + \"#imagemap=',_blank','top=' + eval(-450 + screen.height) + ',left=30,width=' + eval(-60 + screen.width) + ',height=450')\";
}
//alert(awocmd);
setTimeout(function(){ eval(awocmd); awocmd=' '; }, 5000);
}

“; ?>

… but please note that the sharing of such edited images have a time limit to use which users should think of as amounting to a couple of hours.

Again, this can apply all the way through to the next Draw and/or email or SMS sharing in the changed cow_says_insertion.php PHP based web application you can also try below.


Previous relevant Cowsay Cartoon Cell Data Type Tutorial is shown below.

Cowsay Cartoon Cell Data Type Tutorial

Cowsay Cartoon Cell Data Type Tutorial

You may have noticed in yesterday’s Cowsay Cartoon Ordered Recursion Tutorial code changes that preparations were being made to make use of (as of HTML5) …


canvas

… element means by which a user can double click on a textarea element with …

  • text … Cowsay inspired drawing, and be able to receive an approximation of that text means of Cowsay presentation in an overlayed …
  • image … form (via that canvas)

<?php echo ”

function readycanvas(tao) {
var thissuffix='';
if (tao.id.substring(0,1) == 'r') {
thissuffix='r';
textareaone=document.getElementById('rhxta');
textareatwo=document.getElementById('rhta');
if (textareatwo.title.indexOf(' ') != -1) {
textareaone.title='';
textareatwo.title='';
document.getElementById('atendr').style.visibility='hidden';
document.getElementById('myCanvasr').visibility='hidden';
textareaone.style.color='black';
textareatwo.style.color='black';
document.getElementById('lri').value=document.getElementById('lri').value.replace('r','');
extralri='&lri=' + document.getElementById('lri').value;
return '';
} else {
textareaone.title=' ';
textareatwo.title=' ';
document.getElementById('lri').value=document.getElementById('lri').value.replace('r','') + 'r';
extralri='&lri=' + document.getElementById('lri').value;
}
} else if (tao.id.substring(0,1) == 'l') {
thissuffix='l';
textareaone=document.getElementById('lhxta');
textareatwo=document.getElementById('lhta');
if (textareatwo.title.indexOf(' ') != -1) {
textareaone.title='';
textareatwo.title='';
document.getElementById('atendl').style.visibility='hidden';
document.getElementById('myCanvasl').visibility='hidden';
textareaone.style.color='black';
textareatwo.style.color='black';
document.getElementById('lri').value=document.getElementById('lri').value.replace('l','');
extralri='&lri=' + document.getElementById('lri').value;
return '';
} else {
textareaone.title=' ';
textareatwo.title=' ';
document.getElementById('lri').value=document.getElementById('lri').value.replace('l','') + 'l';
extralri='&lri=' + document.getElementById('lri').value;
}
}
if (textareaone && textareatwo) {
var rectone=textareaone.getBoundingClientRect();
var recttwo=textareatwo.getBoundingClientRect();
document.getElementById('atend' + thissuffix).style.visibility='visible';
document.getElementById('atend' + thissuffix).style.position='absolute';
if (textareatwo.id.substring(0,1) == 'r' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') != -1) {
document.getElementById('atend' + thissuffix).style.left='' + document.getElementById('tdright').getBoundingClientRect().left + 'px';
document.getElementById('atend' + thissuffix).style.width='' + document.getElementById('tdright').getBoundingClientRect().width + 'px';
//alert(recttwo.top);
} else {
//alert(1);
if (textareatwo.id.substring(0,1) == 'r') {
document.getElementById('atend' + thissuffix).style.left='' + document.getElementById('tdright').getBoundingClientRect().left + 'px';
} else {
document.getElementById('atend' + thissuffix).style.left='' + recttwo.left + 'px';
}
document.getElementById('atend' + thissuffix).style.width='' + document.getElementById('tdleft').getBoundingClientRect().width + 'px';
}
if (eval('' + recttwo.top) >= eval('" . $thirtytwo . "')) {
//alert(11);
document.getElementById('atend' + thissuffix).style.top='' + eval(-" . $thirtytwo . " + recttwo.top) + 'px';
document.getElementById('atend' + thissuffix).style.height='' + eval(eval('" . $thirtytwo . "') + eval('' + recttwo.height)) + 'px';
} else {
//alert(111);
document.getElementById('atend' + thissuffix).style.top='' + eval('' + recttwo.top) + 'px';
document.getElementById('atend' + thissuffix).style.height='' + eval(0 + eval('' + recttwo.height)) + 'px';
}
//alert(recttwo.left);
document.getElementById('atend' + thissuffix).style.zIndex='99';
if (eval('' + recttwo.top) >= eval('" . $thirtytwo . "')) {
//document.getElementById('atend' + thissuffix).innerHTML='<canvas style=\"border:1px solid red;\" id=myCanvas' + thissuffix + ' width=' + recttwo.width + ' height=' + eval(eval('" . $thirtytwo . "') + eval('' + recttwo.height)) + '></canvas>';
document.getElementById('atend' + thissuffix).innerHTML='<canvas ondblclick=\"readycanvas(document.getElementById(this.id.slice(-1) + myhta));\" style=\"border:0px solid red;\" id=myCanvas' + thissuffix + ' width=' + document.getElementById('tdleft').getBoundingClientRect().width + ' height=' + eval(eval('" . $thirtytwo . "') + eval('' + recttwo.height)) + '></canvas>';
} else if (textareatwo.id.substring(0,1) == 'r' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') != -1) {
document.getElementById('atend' + thissuffix).innerHTML='<canvas ondblclick=\"readycanvas(document.getElementById(this.id.slice(-1) + myhta));\" style=\"position:absolute;top:' + eval('' + recttwo.top) + 'px;left:' + document.getElementById('tdright').getBoundingClientRect().left + 'px;border:0px solid red;\" id=myCanvas' + thissuffix + ' width=' + document.getElementById('tdright').getBoundingClientRect().width + ' height=' + eval(0 + eval('' + recttwo.height)) + '></canvas>';
} else {
//document.getElementById('atend' + thissuffix).innerHTML='<canvas style=\"border:1px solid red;\" id=myCanvas' + thissuffix + ' width=' + recttwo.width + ' height=' + eval(0 + eval('' + recttwo.height)) + '></canvas>';
document.getElementById('atend' + thissuffix).innerHTML='<canvas ondblclick=\"readycanvas(document.getElementById(this.id.slice(-1) + myhta));\" style=\"border:0px solid red;\" id=myCanvas' + thissuffix + ' width=' + document.getElementById('tdleft').getBoundingClientRect().width + ' height=' + eval(0 + eval('' + recttwo.height)) + '></canvas>';
}
canvas=document.getElementById('myCanvas' + thissuffix);
ctx=canvas.getContext('2d');
drawTextToCanvas();
textareaone.style.color='transparent';
textareatwo.style.color='transparent';
textareaone=null;
textareatwo=null;
}
}

function drawTextToCanvas() { // thanks to https://www.google.com/search?q=textarea+text+to+canvas&rlz=1C5OZZY_en&oq=textarea+text+to+canvas+&gs_lcrp=EgZjaHJvbWUyCQgAEEUYORifBTIHCAEQIRigATIHCAIQIRigATIHCAMQIRigATIHCAQQIRigATIHCAUQIRigAdIBCDkxNjRqMGo0qAIAsAIB&sourceid=chrome&source=chrome.ob&ie=UTF-8
var ii=0, jj=-1, maxchars=0, gtsfound=false, leftno='', lthingo='x';
if (textareatwo.id.substring(0,1) == 'l' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') != -1) {
lthingo='l';
} else if (textareatwo.id.substring(0,1) == 'r' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') != -1) {
lthingo='R';
//alert('is R');
}
// 1. Clear the canvas before redrawing
ctx.clearRect(0, 0, canvas.width, canvas.height);

// 2. Set text styles
ctx.font = \"14px Courier New\";
ctx.fillStyle = \"#333333\";
ctx.textBaseline = \"top\"; // Align from top-left for easier line calculations

// 3. Split the text by line breaks
var lines = ((textareaone != null ? textareaone.value + String.fromCharCode(10) : '') + (textareatwo != null ? textareatwo.value : '')).split(String.fromCharCode(10));


for (var ii=0; ii<lines.length; ii++) {
if (eval('' + lines[ii].length) > maxchars) { maxchars=eval('' + lines[ii].length); }
if (textareatwo.id.substring(0,1) == 'r' && leftno == '' && ('' + textareatwo.outerHTML).replace('scaleX(1)','').indexOf('scale') == -1 && lines[ii].trim() != '' && lines[ii].indexOf('" . $lts . "') != -1) {
leftno=lines[ii].split('" . $lts . "')[0];
//alert(leftno);
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
leftno=' ';
}
}
}


if (textareatwo.id.substring(0,1).toUpperCase() == lthingo.toUpperCase() || 7 == 7) {
for (var ii=0; ii<lines.length; ii++) {
if (!gtsfound) {
lines[ii]=lines[ii].trim(); //.replace(/\ $/g,'');
}
while (eval('' + lines[ii].length) < maxchars) {
if (!gtsfound) {
lines[ii]=' ' + lines[ii];
} else {
lines[ii]+=' ';
}
}
if (lines[ii].indexOf('" . $gts . "') != -1) {
jj=eval(1 + ii); //gtsfound=true;
} else if (ii == jj) {
gtsfound=true;
}
}
//} else {
//alert('why');
}

//alert('prerevstr=' + prerevstr + ' and revstr=' + revstr + ' and textareaonevalue=' + textareaone.value + String.fromCharCode(10) + textareatwo.value);

// 4. Draw each line with vertical offset (line height)
var lineHeight = 16;
var startX = 0;
var startY = 10;
if (textareatwo.id.substring(0,1) == 'r' && lthingo.toUpperCase() != 'R') {
startY-=" . $thirtytwo . ";
}

if (textareatwo.id.substring(0,1) == lthingo || textareatwo.id.substring(0,1).toUpperCase() == lthingo) {
startX = canvas.width;
startY-=14;
ctx.textAlign = 'right';
//alert('Here');
}

lines.forEach((line, index) => {
//if (textareatwo.id.substring(0,1) == lthingo && 1 == 5) {
if (textareatwo.id.substring(0,1) == lthingo && 1 == 5) {
ctx.fillText(line.split('').reverse().join(''), startX, startY + (index * lineHeight));
//alert('thEre');
} else {
if (leftno != '') {
//alert('there');
ctx.fillText(line.replace(leftno,''), startX, startY + (index * lineHeight));
} else {
ctx.fillText(line, startX, startY + (index * lineHeight));
}
}
});


if (textareatwo.id.substring(0,1).toUpperCase() == lthingo.toUpperCase()) { // thanks to https://www.google.com/search?q=just+scale+part+of+an+HTML+canvas&sca_esv=ddd109fd00e45f93&rlz=1C5OZZY_en&sxsrf=AKL5yDgSuo_oLZNuX2RTf0dEj8ymY_NrUg%3A1794091464710&ei=yKnvatDyKvrl2roP5PjAkAE&biw=1440&bih=703&uact=5&oq=just+scale+part+of+an+HTML+canvas&gs_lp=Egxnd3Mtd2l6LXNlcnAiIWp1c3Qgc2NhbGUgcGFydCBvZiBhbiBIVE1MIGNhbnZhczIIECEYoAEYwwQyCBAhGKABGMMESIE3UJgUWKw1cAN4AZABAJgBzgGgAYkLqgEFMC43LjG4AQPIAQD4AQGYAgqgAoMKwgIKEAAYRxjWBBiwA8ICBxAjGLACGCfCAgUQABjvBcICChAhGAoYoAEYwwSYAwCIBgGQBgiSBwUzLjYuMaAHlCKyBwUwLjYuMbgH9QnCBwUxLjMuNsgHHYAIAQ&sclient=gws-wiz-serp
//alert('where');
var offscreen = document.createElement('canvas');
var offCtx = offscreen.getContext('2d');
var offscreentop = document.createElement('canvas');
var offCtxtop = offscreentop.getContext('2d');

var sourceX = 0, sourceY = " . $thirtytwoplus . ", sourceW = canvas.width, sourceH = eval(-" . $thirtytwoplus . " + canvas.height);
offscreen.width = sourceW;
offscreen.height = sourceH;
offscreentop.width = sourceW;
offscreentop.height = " . $thirtytwoplus . ";

// 2. Copy the specific part from the main canvas to the offscreen canvas
offCtx.drawImage(canvas, sourceX, sourceY, sourceW, sourceH, 0, 0, sourceW, sourceH);
offCtxtop.drawImage(canvas, 0,0, sourceW, " . $thirtytwoplus . ", 0, 0, sourceW, " . $thirtytwoplus . ");

// 3. Draw it back onto the main canvas at a larger or smaller scale
var xscaleFactor = 1;
var yscaleFactor = 1;
ctx.save();

// 2. Move the origin to the center (or left) of where you want the image
//alert('w,h=' + canvas.width + ',' + canvas.height);
//ctx.translate(canvas.width * 1.6, 0);
ctx.translate(canvas.width * 1.6, 0);

// 3. Flip the X axis (scales width by -1)
ctx.scale(-1, 1);

ctx.globalCompositeOperation = 'copy';
ctx.drawImage(
offscreen,
0, 0, sourceW, sourceH, // source rectangle
sourceX, sourceY, sourceW * xscaleFactor, sourceH * yscaleFactor // destination rectangle
);

ctx.globalCompositeOperation = 'source-over';
ctx.restore();
ctx.drawImage(
offscreentop,
0, 0, sourceW, " . $thirtytwoplus . ", // source rectangle
sourceX, 0, sourceW * xscaleFactor, " . $thirtytwoplus . " * yscaleFactor // destination rectangle
);

if (lthingo == 'R') {
//alert('huh');
var rectone=document.getElementById('tdright').getBoundingClientRect();
var recttwo=document.getElementById('myCanvasr').getBoundingClientRect();
if (eval('' + recttwo.right) > eval('' + rectone.right)) {
//alert('yes ' + document.getElementById('myCanvasr').style.left);
//alert('' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px');
document.getElementById('atendr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('atendr').style.left.replace('px',''))) + 'px';
document.getElementById('myCanvasr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px';
}
//} else if (textareatwo.id.substring(0,1) == 'r') {
//alert('RE huh');
}
} else if (textareatwo.id.substring(0,1) == 'r') {
//alert('RE Huh');
var rectone=document.getElementById('tdright').getBoundingClientRect();
var recttwo=document.getElementById('myCanvasr').getBoundingClientRect();
if (eval('' + recttwo.left) < eval('' + rectone.left)) {
//alert('Yes ' + document.getElementById('myCanvasr').style.left);
//alert('' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px');
document.getElementById('atendr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('atendr').style.left.replace('px',''))) + 'px';
document.getElementById('myCanvasr').style.left='' + eval(eval(rectone.right - recttwo.right) + eval(document.getElementById('myCanvasr').style.left.replace('px',''))) + 'px';
}
}


textareaone.style.color='transparent';
textareatwo.style.color='transparent';
document.getElementById('inout').focus();
}

“; ?>

… opening the door to the web browser offering many more right click (on non-mobile, and hold finger down on mobile) means by which these images can be copied or shared etcetera etcetera etcetera.

Another double click can revert back to text, and this is remembered, as the last toggle state, all the way through to the next Draw and/or email or SMS sharing in the changed cow_says_insertion.php PHP based web application you can also try below.


Previous relevant Cowsay Cartoon Ordered Recursion Tutorial is shown below.

Cowsay Cartoon Ordered Recursion Tutorial

Cowsay Cartoon Ordered Recursion Tutorial

The recent Cowsay Cartoon Recursion Tutorial started allowing for “greater than 2 multiple of 2” numbered action cell Cowsay based cartoons but it was blasĆ© about order, while we cannot think of too many concepts where “jokes will fall flat” as much as with a cartoon presented “out of order”!

There’s probably some way within the hierarchical logic to work this out, but we’d rather apply the more blunt instrument of user URL get arguments (we often categorize hashtag modifications into) to help a webpage incarnation of our Cow Says Cartoon know where it sits within the order of the left to right running cartoon.

We happen to have a habit of analyzing URL get arguments by logic such as, if it’s string data and named “lhdiag”, codelines like …


var lhdiagvar=location.search.split('lhdiag=')[1] ? decodeURIComponent(location.search.split('lhdiag=')[1].split('&')[0]) : "";

This ternary statement habit, and ternary incarnations like it, has played nicely into how our solution to “introducing order” into the logic, via the simply adjusted …

<?php echo ”

function getget() {
return '?' + (document.URL.indexOf('prefix=') != -1 ? document.URL.split('prefix=')[1].split('&')[0].split('#')[0] : '') + 'lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar + gtr + gtl + syl + syr;
}

“; ?>

… adding an order three digit left zero justified “additional cartoon set” identifier count into the URL hashtag mix (also reaching email and SMS links) identified at document.body onload event logic now featuring …

<?php echo ”

if (('' + location.hash).indexOf('lhdiag=') != -1) {
if (('' + document.referrer).indexOf('/cow_says_insertion.php') != -1) {
ises=false;
} else { // probably email or SMS with more than 2 cells
ises=true;
setTimeout(function(){ window.scrollTo(0,0); }, 8000);
}
var newcalldatas=('' + location.hash).split('lhdiag=');
for (var ibn=1; ibn<newcalldatas.length; ibn++) {
newget='?lhdiag=' + newcalldatas[ibn].split('#')[0].replace(/\#$/g,'') + '&prefix=' + ('000' + ibn).slice(-3) + (ises == true ? '&noopen=y' : '');
addone();
newget='';
}

if (ises) {
document.getElementById('mydet').open=false; //setAttribute('open', false);
}
}

“; ?>

We also start showing exact cell cartoon positioning information into the ++ “button” title (and onto use for mobile users via good ol’ ontouchmove=’alert(this.title);’) onto the existant title total cell count existant information via …

<?php echo ”

var retval='Add two more cartoon cells to right ... ' + eval(2 * eval(1 + numtoshow)) + ' cartoon cells in total' + (document.URL.indexOf('prefix=') == -1 ? ' .... showing action cells 1 to 2' : ' .... showing action cells ' + eval(1 + eval(2 * eval(document.URL.split('prefix=')[1].split('&')[0].split('#')[0].replace(/^0/g,'').replace(/^0/g,'')) )) + ' to ' + eval(2 + eval(2 * eval(document.URL.split('prefix=')[1].split('&')[0].split('#')[0].replace(/^0/g,'').replace(/^0/g,''))) ));

“; ?>

… ahead of, back at the originating webpage sorting this so that “cartoons can be the intended cartoons” …

<?php echo ”

function hhsort(hh) {
var hhs=[], hhsnew=[], jhhs=0, newhh='';
newhh=hh;
if (hh != hh.replace(/[0-9]lhdiag/g,'lhdiag')) {
hhs=hh.split('#');
hhsnew=hhs.sort();
newhh='';
for (jhhs=0; jhhs<hhsnew.length; jhhs++) {
if (hhsnew[jhhs].trim() != '') {
newhh+='#' + hhsnew[jhhs];
}
}
}
return newhh;
}

function hashit(hh) {
var hhs=[], hhsnew=[], jhhs=0;
homehash+=hh.replace(/^\?/g,'#');
if (homehash != homehash.replace(/[0-9]lhdiag/g,'lhdiag')) {
hhs=homehash.split('#');
hhsnew=hhs.sort();
homehash='';
for (jhhs=0; jhhs<hhsnew.length; jhhs++) {
if (hhsnew[jhhs].trim() != '') {
homehash+='#' + hhsnew[jhhs];
}
}
}
return true;
}


function homehashit() {
if (window.top != window.self && ('' + top.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return top.hashit(getget());
} else if (window.parent != window.self && ('' + parent.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return parent.hashit(getget());
}
if (homehash != '') {
top.location.href='./cow_says_insertion.php' + '?lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar + gtr + gtl + syl + syr + hhsort(homehash);
return false;
}
return true;
}

“; ?>

… in the changed cow_says_insertion.php PHP based web application you can also try below.

Did You Know?

Doing this project has brought closer to fruition, our wonder for some time now …

Can a PHP’s HTML form action=[itself] method=POST have it’s action attribute be dynamically given a hashtag data string ( ie. hhsort(homehash) ) and still do all the functionality a PHP’s HTML form’s onsubmit event calling Javascript statement like …

top.location.href='./cow_says_insertion.php' + '?lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar + gtr + gtl + syl + syr + hhsort(homehash);
return false;

… is achieving ( ie. returning true and letting the method=POST go through to the keeper )?

This seemed like the opportunity to find out. And yes, clicking the https://www.rjmprogramming.com.au/cow_says_insertion.php?posthash=y link and following through creating a “more than 2 action cell cartoon” creates this effect. This may seem arcane, and unimportant, but there may be a reason to “just hide the originator form data from the address bar” for some reason (or perhaps the amount of originator webpage form data is huge, much larger than the hashtag related data, yet the hashtag data is vital to the cause), and perhaps this combination could swing that?!


Previous relevant Cowsay Cartoon Recursion Tutorial is shown below.

Cowsay Cartoon Recursion Tutorial

Cowsay Cartoon Recursion Tutorial

The “up to yesterday’s Cowsay Cartoon Text to Speech Tutorial appraisal” could go something like …

Cartoons via Cowsay could be interesting, but cartoons limited to 2 “action cells”, that’s a tad limiting.

… and that all sounds a legitimate concern to me too … especially as I came up with my own complaint?!

We’ve waited for today to pounce on a way to allow for cartoon sharing via email or SMS of cartoons consisting of a larger multiple of two “action cells”. That is because we wanted to get the “just two” scenario well bedded down, before, what pans out to be “a full of recursion“, solution. We think there should be “recursion shoes” especially designed for “treading carefully” because should a recursion issue go wrong, it can be capable of at least making the web application of your webpage become inoperable, in an infinite loop. Of course, if you debug your work, it can be stopped when wrong like this, but we think extra testing applies to recursion work, for this reason.

You might wonder, if we told you the main webpage just adds td cells to the one tr row and embeds in that new td (colspan=2) an iframe element …

Can’t you just reference window.top and top.document.URL here rather than needing recursion?

We started that way, and yes, for most scenarios that works but what about our this blog hosted call of it? There, top.document.URL has nothing to do with /cow_says_insertion.php Cow Says Cartoon web application, and the simplistic reasoning (along with any parent.parent contemplations) will fall apart, but introducing recursion into the new (and recursion modified) Javascript functions below …

<?php echo ”

var numtoshow=1, gofroms=['tdleft','tdright'];
var wpxs=[], totwidth=0;
var homehash='', newget='';
var ises=false, ifrecth=0;

function getget() {
return '?lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar + gtr + gtl + syl + syr;
}

function hashit(hh) {
homehash+=hh.replace(/^\?/g,'#');
return true;
}

function homehashit() {
if (window.top != window.self && ('' + top.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return top.hashit(getget());
} else if (window.parent != window.self && ('' + parent.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return parent.hashit(getget());
}

if (homehash != '') {
top.location.href='./cow_says_insertion.php' + '?lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar + gtr + gtl + syl + syr + homehash;
return false;
}
return true;
}

function emailit() {
if (window.top != window.self && ('' + top.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return top.emailit();
} else if (window.parent != window.self && ('' + parent.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return parent.emailit();
}

document.getElementById('es').href='mailto:?subject=Cow%20Says%20Cartoon&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '?lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar + gtr + gtl + syl + syr + homehash);
document.getElementById('es').click();
document.getElementById('mysub').click();
return true;
}

function smsit() {
if (window.top != window.self && ('' + top.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return top.smsit();
} else if (window.parent != window.self && ('' + parent.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return parent.smsit();
}

document.getElementById('es').href='sms:&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '?lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar + gtr + gtl + syl + syr + homehash);
document.getElementById('es').click();
document.getElementById('mysub').click();
return true;
}

function addone() {
var rect=null, igo=0;
if (window.top != window.self && ('' + top.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return top.addone();
} else if (window.parent != window.self && ('' + parent.document.URL).indexOf('/cow_says_insertion.php') != -1) {
return parent.addone();
}

var retval='Add two more cartoon cells to right ... ' + eval(2 * eval(1 + numtoshow)) + ' cartoon cells in total';
if (numtoshow == 1) {
rect=document.body.getBoundingClientRect();
if (gofroms.length > wpxs.length && ifrecth == 0) {
ifrecth=eval('' + rect.height);
}
for (igo=0; igo<gofroms.length; igo++) {
rect=document.getElementById(gofroms[igo]).getBoundingClientRect();
if (gofroms.length > wpxs.length) {
wpxs.push(rect.width);
document.getElementById(gofroms[igo]).style.width='' + rect.width + 'px';
totwidth+=eval('' + rect.width);
//alert('' + rect.width);
}
}
document.getElementById('toptable').style.width='' + eval(eval(1 + numtoshow) * " . $origwper . ") + '%';
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || eval('' + navigator.maxTouchPoints) > 0) {
document.getElementById('toprow').innerHTML+='<td id=td' + numtoshow + ' colspan=' + gofroms.length + ' style=width:' + totwidth + 'px;overflow-y:visible;><iframe style=\"width:100%;height:' + ifrecth + 'px;overflow-y:visibile;margin:0 0 0 0;padding:0 0 0 0;\" src=./cow_says_insertion.php' + newget + '></iframe></td>';
} else {
document.getElementById('toprow').innerHTML+='<td id=td' + numtoshow + ' colspan=' + gofroms.length + ' style=width:' + totwidth + 'px;overflow-y:visible;><iframe style=\"width:100%;height:' + ifrecth + 'px;overflow-y:visibile;margin:0 0 0 0;padding:0 0 0 0;\" src=./cow_says_insertion.php' + newget + '></iframe></td>';
}
newget='';
document.getElementById('td' + numtoshow).scrollIntoView();
numtoshow++;
} else {
document.getElementById('toptable').style.width='' + eval(eval(1 + numtoshow) * " . $origwper . ") + '%';
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || eval('' + navigator.maxTouchPoints) > 0) {
document.getElementById('toprow').innerHTML+='<td id=td' + numtoshow + ' colspan=' + gofroms.length + ' style=width:' + totwidth + 'px;overflow-y:visible;><iframe style=\"width:100%;height:' + ifrecth + 'px;overflow-y:visibile;margin:0 0 0 0;padding:0 0 0 0;\" src=./cow_says_insertion.php' + newget + '></iframe></td>';
} else {
document.getElementById('toprow').innerHTML+='<td id=td' + numtoshow + ' colspan=' + gofroms.length + ' style=width:' + totwidth + 'px;overflow-y:visible;><iframe style=\"width:100%;height:' + ifrecth + 'px;overflow-y:visibile;margin:0 0 0 0;padding:0 0 0 0;\" src=./cow_says_insertion.php' + newget + '></iframe></td>';
}
newget='';
document.getElementById('td' + numtoshow).scrollIntoView();
numtoshow++;
}
document.getElementById('supadd').title=retval;
return retval; //'Add two more cartoon cells to right ... ' + eval(2 * numtoshow) + ' cartoon cells in total';
}

function supit() {
var rect=null, igo=0;
if (window.top != window.self && ('' + top.document.URL).indexOf('/cow_says_insertion.php') != -1) {
if (top.document.getElementById('supadd').title != document.getElementById('supadd').title) {
document.getElementById('supadd').title=top.document.getElementById('supadd').title;
}
setTimeout(supit, 5000);
} else if (window.parent != window.self && ('' + parent.document.URL).indexOf('/cow_says_insertion.php') != -1) {
if (parent.document.getElementById('supadd').title != document.getElementById('supadd').title) {
document.getElementById('supadd').title=parent.document.getElementById('supadd').title;
}
setTimeout(supit, 5000);
}

}

setTimeout(supit, 5000);

“; ?>

… hierarchically organizes the code not depending on what top.document.URL points at, allowing the whole Cow Says Cartoon web application be hosted by some other overseeing web application in the changed cow_says_insertion.php PHP based web application you can also try below.

And the conduit for sharing these “more than two” Cowsay Cartoons with more than two scenes are via URLs containing good ol’ hashtag data with associated document.body onload event timed Javascript logic …

<?php echo ”

function initit() {
if (('' + document.getElementById('lmcss').title).indexOf('text-shadow:') != -1) {
document.getElementById('lmcss').value=document.getElementById('lmcss').title;
document.getElementById('lmcss').style.display='inline-block';
document.getElementById('lmcss').name='lmcss';
document.getElementById('lmcss').title=document.getElementById('lmcss').placeholder;
}
if (('' + document.getElementById('rmcss').title).indexOf('text-shadow:') != -1) {
document.getElementById('rmcss').value=document.getElementById('rmcss').title;
document.getElementById('rmcss').name='rmcss';
document.getElementById('rmcss').style.display='inline-block';
document.getElementById('rmcss').title=document.getElementById('rmcss').placeholder;
}
initl=document.getElementById('lbc').value;
initr=document.getElementById('rbc').value;
if (window.self != window.parent) {
if (document.getElementById('lhdiag').value.indexOf('\"stegosaurus\"') != -1 && '" . $posted . "' == '') {
document.getElementById('lhdiag').value=document.getElementById('lhdiag').value.replace('stegosaurus','tux');
}
if (document.getElementById('rhdiag').value.indexOf('\"stegosaurus\"') != -1 && '" . $posted . "' == '') {
document.getElementById('rhdiag').value=document.getElementById('rhdiag').value.replace('stegosaurus','tux');
}
}
document.getElementById('languagel').value='" . $langl . "';
document.getElementById('languager').value='" . $langr . "';

if (document.getElementById('languagel').value != '') {
window.open('//translate.google.com/#view=home&op=translate&sl=auto&tl=' + document.getElementById('languagel').value + '&text=' + encodeURIComponent( document.getElementById('lhdiag').value.split('\"')[eval(-2 + document.getElementById('lhdiag').value.split('\"').length)] ), '_blank','left=0,top=0,width=600,height=600');
}

if (document.getElementById('languager').value != '') {
window.open('//translate.google.com/#view=home&op=translate&sl=auto&tl=' + document.getElementById('languager').value + '&text=' + encodeURIComponent( document.getElementById('rhdiag').value.split('\"')[eval(-2 + document.getElementById('rhdiag').value.split('\"').length)] ), '_blank','left=600,top=0,width=600,height=600');
}

if ('' != '" . $visl . "') {
var lvis='" . trim(str_replace('-v','',$visl)) . "';
if (document.getElementById('svoicecodel').innerHTML.indexOf(' ' + lvis + String.fromCharCode(34)) != -1) {
document.getElementById('svoicecodel').value=document.getElementById('svoicecodel').innerHTML.split(' ' + lvis + String.fromCharCode(34))[0].split(String.fromCharCode(34))[eval(-1 + document.getElementById('svoicecodel').innerHTML.split(' ' + lvis + String.fromCharCode(34))[0].split(String.fromCharCode(34)).length)] + ' ' + lvis;
}
}

if ('' != '" . $visr . "') {
var rvis='" . trim(str_replace('-v','',$visr)) . "';
if (document.getElementById('svoicecoder').innerHTML.indexOf(' ' + rvis + String.fromCharCode(34)) != -1) {
document.getElementById('svoicecoder').value=document.getElementById('svoicecoder').innerHTML.split(' ' + rvis + String.fromCharCode(34))[0].split(String.fromCharCode(34))[eval(-1 + document.getElementById('svoicecoder').innerHTML.split(' ' + rvis + String.fromCharCode(34))[0].split(String.fromCharCode(34)).length)] + ' ' + rvis;
}
}

if (('' + location.hash).indexOf('lhdiag=') != -1) {
if (('' + document.referrer).indexOf('/cow_says_insertion.php') != -1) {
ises=false;
} else { // probably email or SMS with more than 2 cells
ises=true;
setTimeout(function(){ window.scrollTo(0,0); }, 8000);
}
var newcalldatas=('' + location.hash).split('lhdiag=');
for (var ibn=1; ibn<newcalldatas.length; ibn++) {
newget='?lhdiag=' + newcalldatas[ibn].replace(/\#$/g,'') + (ises == true ? '&noopen=y' : '');
addone();
newget='';
}

if (ises) {
document.getElementById('mydet').open=false; //setAttribute('open', false);
}
}

if (document.URL.indexOf('noopen=') != -1) {
document.getElementById('mydet').open=false; //.setAttribute('open', false);
}



}

“; ?>


Previous relevant Cowsay Cartoon Text to Speech Tutorial is shown below.

Cowsay Cartoon Text to Speech Tutorial

Cowsay Cartoon Text to Speech Tutorial

Onto yesterday’s Cowsay Cartoon History Assistance Tutorial today’s two major improvements are …

  1. allow for some Text to Speech smarts courtesy of …
    • Google Translate … optional translation and optional Text to Speech … and, perhaps …
    • say … macOS command line Text to Speech functionality …
      <?php

      if (isset($_POST['lhdiag']) && isset($_POST['rhdiag']) && (isset($_GET['dosay']) || isset($_POST['dosay']))) {
      if (strtolower(substr($_POST['lhdiag'],0,6)) == 'cowsay' && strtolower(substr($_POST['rhdiag'],0,6)) == 'cowsay') {
      $visl="";
      $visr="";
      if (isset($_POST['dosay'])) {
      if (strpos(str_replace('+',' ',urldecode($_POST['dosay'])), ',') !== false) {
      $visl=" -v " . explode(',', str_replace('+',' ',urldecode($_POST['dosay'])))[0] . " ";
      $visr=" -v " . explode(',', str_replace('+',' ',urldecode($_POST['dosay'])))[1] . " ";
      } else if (trim(str_replace('+',' ',urldecode($_POST['dosay']))) != '') {
      $visl=" -v " . explode(',', str_replace('+',' ',urldecode($_POST['dosay'])))[0] . " ";
      }
      }
      if (isset($_GET['dosay'])) {
      if (strpos(str_replace('+',' ',urldecode($_GET['dosay'])), ',') !== false) {
      $visl=" -v " . explode(',', str_replace('+',' ',urldecode($_GET['dosay'])))[0] . " ";
      $visr=" -v " . explode(',', str_replace('+',' ',urldecode($_GET['dosay'])))[1] . " ";
      } else if (trim(str_replace('+',' ',urldecode($_GET['dosay']))) != '') {
      $visl=" -v " . explode(',', str_replace('+',' ',urldecode($_GET['dosay'])))[0] . " ";
      }
      }
      if ($visr == '') {
      $saycmd=" exec('say" . $visl . " \"" . explode('"', str_replace('+',' ',urldecode($_POST['lhdiag'])))[-2 + sizeof(explode('"', str_replace('+',' ',urldecode($_POST['lhdiag']))))] . "\" [[ slnc 8000 ]] " . explode('"', str_replace('+',' ',urldecode($_POST['rhdiag'])))[-2 + sizeof(explode('"', str_replace('+',' ',urldecode($_POST['rhdiag']))))] . "\"'); ";
      } else {
      $saycmd=" exec('say" . $visl . " \"" . explode('"', str_replace('+',' ',urldecode($_POST['lhdiag'])))[-2 + sizeof(explode('"', str_replace('+',' ',urldecode($_POST['lhdiag']))))] . "\" ; " . "say" . $visr . " \" [[ slnc 8000 ]] " . explode('"', str_replace('+',' ',urldecode($_POST['rhdiag'])))[-2 + sizeof(explode('"', str_replace('+',' ',urldecode($_POST['rhdiag']))))] . "\"'); ";
      }
      }
      }

      ?>
      … as relevant
  2. allow for cartoon cell reverse of default justifications (left defaults to right justification and right defaults to left justification)

… passing through to cartoon creation and sharing via email or SMS, in the changed cow_says_insertion.php PHP based web application.


Previous relevant Cowsay Cartoon History Assistance Tutorial is shown below.

Cowsay Cartoon History Assistance Tutorial

Cowsay Cartoon History Assistance Tutorial

Thinking about today’s Remembering History extension of functionality onto yesterday’s Cowsay Cartoon User Styling Tutorial, we, at first, contemplated …

  • a window.localStorage or HTTP Cookies web browser storage idea based around a user specific cowsay command content dropdown element construction … or perhaps …
  • a PHP setcookie based web browser storage idea … but, as we were using PHP, what seemed better, and we’re glad we opted for was …
  • a PHP flat file arrangement idea for user specific cowsay command content dropdown element construction

… based on the PHP function call where the user IP address incarnation is determined, as per …

<?php

function justdoit($bigsofar, $maybeyes) {
global $sb, $sbtwo, $bigsofarl, $bigsofarr, $smallsofarl, $smallsofarr, $oursbtwo, $ipaddr;
$sofar=$bigsofar;
if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('maybe','',$maybeyes))) {
$sofar=file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('maybe','',$maybeyes));
}
$rma = $_SERVER['REMOTE_ADDR'];
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
// you can add different browsers with the same way ..
if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua))
$rma = '000000'.$rma;
elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua))
$rma = '00000'.$rma;
elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua))
$rma = '0000'.$rma;
elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua))
$rma = '000'.$rma;
elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua))
$rma = '00'.$rma;
elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua))
$rma = '0'.$rma;
$ipaddr=str_replace(":", "_", $rma);
if ($bigsofar == '') {
$sofar=$oursbtwo; //trim($sb) . ' ' . trim($sbtwo);
file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('maybe','',$maybeyes), '' . $sofar);
if (strpos($maybeyes, "left") !== false) {
$bigsofarl="<select title='History of selections you can access ...' id=mysell style=width:24px; onchange=\"if (this.value.length > 0) { document.getElementById('lhdiag').value=this.value; }\">\n<option value=''>?</option>\n<option value='cowsay " . $sofar . "' data-ip='" . $ipaddr . "'>cowsay " . $sofar . "</option>\n</select>";
file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('.txt','big.txt',str_replace('maybe','',$maybeyes)), $bigsofarl);
} else if (strpos($maybeyes, "right") !== false) {
$bigsofarr="<select title='History of selections you can access ...' id=myselr style=width:24px; onchange=\"if (this.value.length > 0) { document.getElementById('rhdiag').value=this.value; }\">\n<option value=''>?</option>\n<option value='cowsay " . $sofar . "' data-ip='" . $ipaddr . "'>cowsay " . $sofar . "</option>\n</select>";
file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('.txt','big.txt',str_replace('maybe','',$maybeyes)), $bigsofarr);
}
} else if (strpos($bigsofar, 'cowsay ' . $oursbtwo) === false) {
$sofar.="\n" . $oursbtwo; //trim($sb) . ' ' . trim($sbtwo);
file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('maybe','',$maybeyes), '' . $sofar);
$bigsofar=explode('</select>',$bigsofar)[0] . "\n" . "<option value='cowsay " . $oursbtwo . "' data-ip='" . $ipaddr . "'>cowsay " . $oursbtwo . "</option></select>";
file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('.txt','big.txt',str_replace('maybe','',$maybeyes)), $bigsofar);
if (strpos($maybeyes, "left") !== false) {
$bigsofarl=$bigsofar;
$recs=explode("\n", $bigsofarl);
if (sizeof($recs) > 3) {
$smallsofarl=$recs[0] . "\n" . $recs[1] . "\n";
for ($ii=2; $ii<sizeof($recs); $ii++) {
if ($recs[$ii] == '</select>') {
$smallsofarl.='</select>';
} else if (strpos(strtolower($recs[$ii]), '"left hand comment"') !== false) {
$smallsofarl.=$recs[$ii] . "\n";
} else if (strpos($recs[$ii], " data-ip='" . $ipaddr . "'") !== false) {
$smallsofarl.=$recs[$ii] . "\n";
} else if (strpos($recs[$ii], '"') !== false) {
$lhcis=explode('"', $recs[$ii])[-2 + sizeof($recs)];
if (trim($lhcis) != '') {
if (sizeof(explode($lhcis, explode('>',$recs[$ii])[0])) == 3) {
if (strpos($smallsofarl, explode('>',explode(' data-ip=', str_replace($lhcis, '?', $recs[$ii]))[0])[0]) === false) {
$smallsofarl.=str_replace($lhcis, '?', $recs[$ii]) . "\n";
}
}
}
}
}
}
} else if (strpos($maybeyes, "right") !== false) {
$bigsofarr=$bigsofar;
$recs=explode("\n", $bigsofarrr);
if (sizeof($recs) > 3) {
$smallsofarr=$recs[0] . "\n" . $recs[1] . "\n";
for ($ii=2; $ii<sizeof($recs); $ii++) {
if ($recs[$ii] == '</select>') {
$smallsofarr.='</select>';
} else if (strpos(strtolower($recs[$ii]), '"right hand comment"') !== false) {
$smallsofarr.=$recs[$ii] . "\n";
} else if (strpos($recs[$ii], " data-ip='" . $ipaddr . "'") !== false) {
$smallsofarr.=$recs[$ii] . "\n";
} else if (strpos($recs[$ii], '"') !== false) {
$lhcis=explode('"', $recs[$ii])[-2 + sizeof($recs)];
if (trim($lhcis) != '') {
if (sizeof(explode($lhcis, explode('>',$recs[$ii])[0])) == 3) {
if (strpos($smallsofarr, explode('>',explode(' data-ip=', str_replace($lhcis, '?', $recs[$ii]))[0])[0]) === false) {
$smallsofarr.=str_replace($lhcis, '?', $recs[$ii]) . "\n";
}
}
}
}
}
}
}
} else {
if (strpos($maybeyes, "left") !== false) {
$bigsofarl=$bigsofar;
$recs=explode("\n", $bigsofarl);
if (sizeof($recs) > 3) {
$smallsofarl=$recs[0] . "\n" . $recs[1] . "\n";
for ($ii=2; $ii<sizeof($recs); $ii++) {
if ($recs[$ii] == '</select>') {
$smallsofarl.='</select>';
} else if (strpos(strtolower($recs[$ii]), '"left hand comment"') !== false) {
$smallsofarl.=$recs[$ii] . "\n";
} else if (strpos($recs[$ii], " data-ip='" . $ipaddr . "'") !== false) {
$smallsofarl.=$recs[$ii] . "\n";
} else if (strpos($recs[$ii], '"') !== false) {
$lhcis=explode('"', $recs[$ii])[-2 + sizeof($recs)];
if (trim($lhcis) != '') {
if (sizeof(explode($lhcis, explode('>',$recs[$ii])[0])) == 3) {
if (strpos($smallsofarl, explode('>',explode(' data-ip=', str_replace($lhcis, '?', $recs[$ii]))[0])[0]) === false) {
$smallsofarl.=str_replace($lhcis, '?', $recs[$ii]) . "\n";
}
}
}
}
}
}
} else if (strpos($maybeyes, "right") !== false) {
$bigsofarr=$bigsofar;
$recs=explode("\n", $bigsofarrr);
if (sizeof($recs) > 3) {
$smallsofarr=$recs[0] . "\n" . $recs[1] . "\n";
for ($ii=2; $ii<sizeof($recs); $ii++) {
if ($recs[$ii] == '</select>') {
$smallsofarr.='</select>';
} else if (strpos(strtolower($recs[$ii]), '"right hand comment"') !== false) {
$smallsofarr.=$recs[$ii] . "\n";
} else if (strpos($recs[$ii], " data-ip='" . $ipaddr . "'") !== false) {
$smallsofarr.=$recs[$ii] . "\n";
} else if (strpos($recs[$ii], '"') !== false) {
$lhcis=explode('"', $recs[$ii])[-2 + sizeof($recs)];
if (trim($lhcis) != '') {
if (sizeof(explode($lhcis, explode('>',$recs[$ii])[0])) == 3) {
if (strpos($smallsofarr, explode('>',explode(' data-ip=', str_replace($lhcis, '?', $recs[$ii]))[0])[0]) === false) {
$smallsofarr.=str_replace($lhcis, '?', $recs[$ii]) . "\n";
}
}
}
}
}
}
}
}

return $sofar;
}

?>

… where you may glean that if IP addresses do not match, because we are not moderating here, if the cowsay “animal” text is not our default vanilla one we map it to the question mark character, on it’s way to a dropdown option element value mapped to the corresponding input type=text textbox one should the user select this option.

And as this involves the combination of …

  • a cowsay command text … needing to reside within …
  • an option element value

… a new input type=text onblur event function …

<?php echo ”

function nonos(texto) {
var within='', done=false;
var textv=texto.value;
if (textv.indexOf(\" '\") != -1 && textv.indexOf(' \"') == -1) {
while (!done && textv.indexOf(\" '\") != -1 && textv.indexOf(' \"') == -1) {
within=textv.split(\" '\")[1].split(\"'\")[0];
if (within.indexOf('\"') != -1) {
textv=textv.replace(\" '\" + within + \"'\", '#@!\"' + within.replace(/\\\"/g, '`') + '\"');
texto.value=textv;
if (textv.indexOf(\" '\") != -1 && textv.indexOf(' \"') == -1) {
done=false;
} else {
done=true;
}
} else {
textv=textv.replace(\" '\" + within + \"'\", '#@!\"' + within + '\"');
texto.value=textv;
if (textv.indexOf(\" '\") != -1 && textv.indexOf(' \"') == -1) {
done=false;
} else {
done=true;
}
}
}
} else if (textv.indexOf(\" '\") == -1 && textv.indexOf(' \"') != -1) {
while (!done && textv.indexOf(\" '\") == -1 && textv.indexOf(' \"') != -1) {
within=textv.split(' \"')[1].split('\"')[0];
if (within.indexOf(\"'\") != -1) {
textv=textv.replace(' \"' + within + '\"', '#@!\"' + within.replace(/\\'/g, '`') + '\"');
texto.value=textv;
if (textv.indexOf(\" '\") == -1 && textv.indexOf(' \"') != -1) {
done=false;
} else {
done=true;
}
} else {
textv=textv.replace(' \"' + within + '\"', '#@!\"' + within + '\"');
texto.value=textv;
if (textv.indexOf(\" '\") == -1 && textv.indexOf(' \"') != -1) {
done=false;
} else {
done=true;
}
}
}
} else if (textv.indexOf(\" '\") != -1) {
while (!done && textv.indexOf(\" '\") != -1) {
within=textv.split(\" '\")[1].split(\"'\")[0];
if (within.indexOf('\"') != -1) {
textv=textv.replace(\" '\" + within + \"'\", '#@!\"' + within.replace(/\\\"/g, '`') + '\"');
texto.value=textv;
if (textv.indexOf(\" '\") != -1) {
done=false;
} else {
done=true;
}
} else {
textv=textv.replace(\" '\" + within + \"'\", '#@!\"' + within + '\"');
texto.value=textv;
if (textv.indexOf(\" '\") != -1) {
done=false;
} else {
done=true;
}
}
}
}

if (textv.indexOf(';') != -1) { textv=textv.replace(/\;/g,':'); done=true; }
if (done) { texto.value=textv.replace(/\#\@\!/g, ' '); }
}

“; ?>

… amends quote delimiter usage within the proposed cowsay command, as required in the changed cow_says_insertion.php PHP based web application.


Previous relevant Cowsay Cartoon User Styling Tutorial is shown below.

Cowsay Cartoon User Styling Tutorial

Cowsay Cartoon User Styling Tutorial

Today’s work hones in on our interpretation of some user styling we could offer users of the Cowsay Cartoon web application we introduced in yesterday’s Cowsay Reacquaintance and CodeCows Xcode Extension Tutorial, in the following ways, after a bit of a try out on an iPhone (ouch!) …

  • CSS …

    <style>

    input { color: blue; }
    input[type=text] { background-color: #ffecf2; }

    input[type=button] { border-radius: 100px; padding: 15 15 15 15; }
    input[type=submit] { border-radius: 100px; padding: 15 15 15 15; }

    textarea { background-color: #f9f9f9; font-weight: bold; }

    /* Thanks to https://www.google.com/search?q=hide+vertical+scroller&sca_esv=28ba29a10f60894c&rlz=1C5OZZY_en&sxsrf=AKL5yDhDhuXcCcipvfxuwIlsw7XRFis8cA%3A1793564144145&ei=8J3nauS6CMP91e8PqN_9oAw&biw=1427&bih=698&uact=5&oq=hide+vertical+scroller&gs_lp=Egxnd3Mtd2l6LXNlcnAiFmhpZGUgdmVydGljYWwgc2Nyb2xsZXIyBxAAGIAEGA0yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIIEAAYBRgeGA0yCBAAGAUYHhgNMggQABgFGB4YDTIIEAAYBRgeGA0yCBAAGAUYHhgNSMxBUJYFWLs3cAF4AZABAJgB5AGgAf4SqgEFMC44LjS4AQPIAQD4AQGYAgigAtgMwgIKEAAYRxjWBBiwA8ICBRAAGO8FwgIIEAAYiQUYogTCAggQABgIGB4YDcICCxAAGIAEGIoFGIYDmAMA4gMFEgExIECIBgGQBgiSBwUxLjAuN6AH7UeyBwMyLTe4B70MwgcDMy04yAdJgAgB&sclient=gws-wiz-serp */
    /* Chrome, Safari, and Opera */
    #lhxta::-webkit-scrollbar {
    display: none;
    }

    /* Firefox */
    #lhxta {
    scrollbar-width: none;
    }

    /* Internet Explorer and Edge */
    #lhxta {
    -ms-overflow-style: none;
    }
    </style>

    …
  • colour picker controls of left hand cartoon part regarding font colour and background colour
  • colour picker controls of right hand cartoon part regarding font colour and background colour

… in the changed cow_says_insertion.php PHP based web application.

Stop Press

For the first time we can remember, with a colour picker, we track “double valuing”. To us, “double valuing” is to select and deploy a colour value for the picker, and then do that at least a second time with a new colour value. Why code for this? Well, to allow for an HTML textarea’s …

  • font colour … be user adjustable via a user defined …
  • text shadow colour can be a game changer (as far as clarity can go, on occasions)

… sounds like a great idea to allow for, but not to overcomplicate by adding a third colour picker for left or right cartoon cells.

Very debatable we know, but there you go, we’re trying this out.


Previous relevant Cowsay Reacquaintance and CodeCows Xcode Extension Tutorial is shown below.

Cowsay Reacquaintance and CodeCows Xcode Extension Tutorial

Cowsay Reacquaintance and CodeCows Xcode Extension Tutorial

We stumbled upon an interesting extension for Xcode on macOS here, called CodeCows. It makes it possible to paste into Xcode code, via an …


Xcode -> Editor -> CodeCows -> Menu with many options

… set of functionalities, cartoonish text similar to what the Cowsay functionality talked about in Google Chart Geo Chart Integration Speech Bubbles Popup Div Hashtag Tutorial did. Gasp! Since the new web server we haven’t yet thought to type into our WHM cPanel’s Terminal window …


sudo dnf install cowsay -y

… to reinstall cowsay … what a moooooooooooooooooooooooute point!

Anyway, that’s done now. Also done today was that that got us to considering our favourite text editor, TextWrangler (now known as BBEdit … but should have been TextPowerRangerWrangler), on it’s scripting smarts. Surely cowsay could be a tailored text paster extraordinaire here as well?! And yes, the advice of can cowsays integration work in BBEdit …

Yes, cowsay integration works beautifully in BBEdit. Because BBEdit natively supports running Unix scripts and filters directly on your open text, you can pass any selected text out to cowsay and replace it with a talking ASCII cow instantly.
You can set this up as a Text Filter so that it appears directly inside BBEdit’s Text menu.

… got us …

  1. in macOS Terminal session …

    cd /Applications/MAMP/htdocs
    vi cowsay.sh
    cat cowsay.sh

    cd ~/Library
    cd "Application Support"
    cd BBEdit
    cd "Text Filters"
    cp /Applications/MAMP/htdocs/cowsay.sh ./cowsay.sh
    chmod +x ./cowsay.sh

    … and then, from then on, using BBEdit (or TextWrangler aka TextPowerRangerWrangler) …
  2. if text is highlighted, optionally …

    Text -> Apply Text Filter -> cowsay

    … can prompt the user for using highlighted text as the last argument to a command line command like …

    cowsay "last argument"

    … but usually more elaborate (as you see fit at the prompting window presented), to paste a cowsay drawing into the text you are editing (and if the relevance is not apparent, within PHP, for instance, if this was to be pasted between the two quotes in a PHP statement such as …
    <?php

    $mycowsays="";

    ?>
    … the end result would have encapsulated the gist of a cowsay drawing into your PHP variable $mycowsays and be syntactically valid (in our experience, so far)

… and then onto a new PHP web application …

… we constructed via this inspiration whereby a two picture cowsay drawn cartoon can be created and shared via email or SMS based on two textboxes a user fills out using.

Did you know?

On macOS not knowing what a command does?

First try, in the Terminal desktop app, for say, cowsay …


man cowsay

… then perhaps …


help cowsay

… then perhaps …


info cowsay


Previous relevant Google Chart Geo Chart Integration Speech Bubbles Popup Div Hashtag Tutorial is shown below.

Google Chart Geo Chart Integration Speech Bubbles Popup Div Hashtag Tutorial

Google Chart Geo Chart Integration Speech Bubbles Popup Div Hashtag Tutorial

Back to the main workflow of Google Chart Geo Chart Integration Speech Bubbles Textarea Relative Media Tutorial the day before yesterday’s Window Opener and Parent Conduit Tutorial it becomes apparent working those relative URLs in amongst absolute URLs or data URI references within your Speech Bubble content, today we simulate …

  • what we’ve done in the past overlaying the textarea element with a div one … but there is too little room in this project’s scenarios, so …
  • we open a new popup with just the div linking content as above via a textarea onclick event modus operandi

… the content “mediarized” as user controlled, via a hashtag system that expands media within that popup div element via more Journal project thinking …

… where hashtags #qrcode and #play and #display and #listen and #embed and #show and #background are hashtag media effect options …

… using …


Previous relevant Window Opener and Parent Conduit Tutorial is shown below.

Window Opener and Parent Conduit Tutorial

Window Opener and Parent Conduit Tutorial

After yesterday’s Google Chart Geo Chart Integration Speech Bubbles Textarea Relative Media Tutorial we come to another “generic detour” we want to attend to.

Yesterday’s relative URL, like …


/responsive_more.jpg

… set us to thinking how such a relative URL cannot work in the scenario …


var woo=window.open('','_blank','top=0,left=0,width=600,height=800');
woo.document.write([content]);

… but if we wrote some HTML to pass on content from the originator …


var woo=window.open('//www.rjmprogramming.com.au/window_opener_pal.html?hcontent=[content]','_blank','top=0,left=0,width=600,height=800');

… should [content] contain one of those such relative URLs we think that could be a different story. So window_opener_pal.html idea …


<html>
<head>
<title>Help RJM Programming Window Open Callers - RJM Programming - March, 2026</title>
<script type=text/javascript>

var hcontent=(location.search + ('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'')).split('hcontent=')[1] ? decodeURIComponent((location.search + ('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'')).split('hcontent=')[1].split('&')[0]) : '';
var functocall=(location.search + ('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'')).split('functocall=')[1] ? decodeURIComponent((location.search + ('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'')).split('functocall=')[1].split('&')[0]) : '';
var vartoref=(location.search + ('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'')).split('vartoref=')[1] ? decodeURIComponent((location.search + ('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'')).split('vartoref=')[1].split('&')[0]) : '';
var elid=(location.search + ('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'')).split('elid=')[1] ? decodeURIComponent((location.search + ('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'')).split('elid=')[1].split('&')[0]) : '';

function checkwop() {
if (window.opener) {
if (hcontent != '') {
document.body.innerHTML=hcontent;
} else if (functocall != '') {
console.warn('hcontent=("" + window.opener.' + functocall + '()).replace(/^undefined/g,"").replace(/^null/g,"")');
eval('hcontent=("" + window.opener.' + functocall + '()).replace(/^undefined/g,"").replace(/^null/g,"")');
if (hcontent == '' && elid != '') {
eval('document.body.innerHTML=("" + window.opener.document.getElementById("' + elid + '").outerHTML.replace(/none\;/g,"block;").replace("parent.getCursor","window.opener.getCursor")).replace(/^undefined/g,"").replace(/^null/g,"")');
}
} else if (vartoref != '') {
eval('hcontent=("" + window.opener.' + vartoref + ').replace(/^undefined/g,"").replace(/^null/g,"")');
if (hcontent == '' && elid != '') {
eval('document.body.innerHTML=("" + window.opener.document.getElementById("' + elid + '").outerHTML.replace(/none\;/g,"block;").replace("parent.getCursor","window.opener.getCursor")).replace(/^undefined/g,"").replace(/^null/g,"")');
}
} else if (elid != '') {
eval('document.body.innerHTML=("" + window.opener.document.getElementById("' + elid + '").outerHTML.replace(/none\;/g,"block;").replace("parent.getCursor","window.opener.getCursor")).replace(/^undefined/g,"").replace(/^null/g,"")');
}
} else if (window.parent != window.self) {
if (hcontent != '') {
document.body.innerHTML=hcontent;
} else if (functocall != '') {
eval('hcontent=("" + window.parent.' + functocall + '()).replace(/^undefined/g,"").replace(/^null/g,"")');
if (hcontent == '' && elid != '') {
eval('document.body.innerHTML=("" + window.parent.document.getElementById("' + elid + '").outerHTML.replace(/none\;/g,"block;").replace("parent.getCursor","window.opener.getCursor")).replace(/^undefined/g,"").replace(/^null/g,"")');
}
} else if (vartoref != '') {
eval('hcontent=("" + window.parent.' + vartoref + ').replace(/^undefined/g,"").replace(/^null/g,"")');
if (hcontent == '' && elid != '') {
eval('document.body.innerHTML=("" + window.parent.document.getElementById("' + elid + '").outerHTML.replace(/none\;/g,"block;").replace("parent.getCursor","window.opener.getCursor")).replace(/^undefined/g,"").replace(/^null/g,"")');
}
} else if (elid != '') {
eval('document.body.innerHTML=("" + window.parent.document.getElementById("' + elid + '").outerHTML.replace(/none\;/g,"block;").replace("parent.getCursor","window.opener.getCursor")).replace(/^undefined/g,"").replace(/^null/g,"")');
}
} else if (hcontent != '') {
document.body.innerHTML=hcontent;
}
}

</script>
</head>
<body onload=checkwop(); id=xxbody>
</body>
</html>

… is like our new see-through “conduit” friend.


Previous relevant Google Chart Geo Chart Integration Speech Bubbles Textarea Relative Media Tutorial is shown below.

Google Chart Geo Chart Integration Speech Bubbles Textarea Relative Media Tutorial

Google Chart Geo Chart Integration Speech Bubbles Textarea Relative Media Tutorial

Back to the main workflow of Google Chart Geo Chart Integration Speech Bubbles Textarea Onblur Tutorial as the day before yesterday’s Google Chart Geo Chart AppleScript Functionality Integration Bug Tutorial we touch on two steps, moving forward …

  1. appended …

    #say

    … means by which …

    • textarea ondblclick event controlled
    • Intranet feeling
    • window.open popup
    • PHP localhost URL http://localhost:8888/macos_say_record.php
    • using exec to point to
    • underlying macOS and MAMP local Apache/PHP/MySql web server environment command say
    • means to turn Text to Speech

    … users can be offered a continuous Text to Speech execution modus operandi …

  2. allow for image, video, audio media (just, so far) relative URL, such as …

    /responsive_more.jpg

    … hence the “Relative Media” words in the blog posting title … that, if exist, add to the “hardcoding to textarea onclick to left savvy” link logic covering now …

    • YouTube 11 character … link to a YouTube video …
    • YouTube 34 character … link to a YouTube playlist …
    • Spotify 22 character … link to a Spotify playlist …
    • Strings with . and @ … link to a mailto: “a” link means of communication …
    • Strings mainly numerical … link to an SMS: “a” link means of communication
    • Strings starting with “http” or “//” … link to a URL, suiting ones like Wikipedia uses (at this stage)
    • Strings starting with a single “/” … link to a media (so far) relative URL that exists on the RJM Programming domain web server

… featuring in (with thanks to this link) …


var xtypes = ['image/tif', 'audio/x-m4r','audio/wav','audio/x-wav','audio/x-pn-realaudio','audio/x-mpegurl','audio/x-aiff','audio/mpeg','audio/mid',
'audio/basic','audio/ogg','video/x-sgi-movie','video/x-msvideo','video/quicktime','audio/mp3','video/mp4','video/mpeg',
'video/x-la-asf','video/ogg','video/webm','audio/mp4', 'image/jpeg', 'image/jpeg', 'image/png', 'image/gif', 'image/bmp',
'text/html', 'text/html', 'text/html', 'text/javascript', 'text/css', 'text/plain', 'text/xml', 'text/csv',
'application/vnd.ms-word', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/x-php', 'application/pdf', 'IMAGE/pdf',
'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.ms-powerpoint',
'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'video/mp4'];
var xexts = ['.tif','.m4r','.wav','.wav','.ram','.m3u','.aiff','.mp3','.rmi',
'.snd','.ogg','.movie','.avi','.mov','.mp3','.m4v','.mpeg',
'.lsx','.ogv','.webm','.m4a', '.jpg', '.jpeg', '.png', '.gif', '.bmp',
'.htm', '.html', '.htmls', '.js', '.css', '.txt', '.xml', '.csv',
'.doc', '.docx', '.php', '.pdf', '.pdf',
'.pptx', '.ppt',
'.xls', '.xlsx', '.mp4'];
var reluadd='', relulist=[];
var relunlist=[];
var pwind=0, pwinda=[];


async function checkUrlExists(url) { // thanks to https://www.google.com/search?q=can+a+window.open+second+parameter+pointing+to+iframe+name+be+used+to+check+for+existence+of+a+relative+URL+file+on+a+web+server&sca_esv=6b7c40959298e02e&rlz=1C5OZZY_en&sxsrf=ANbL-n5LheO67tq8kUgMIT0WDvjv3n25Rw%3A1774317391889&ei=T-_Baf36Namkvr0P55LamQQ&biw=1440&bih=732&ved=0ahUKEwi93vKut7eTAxUpkq8BHWeJNkMQ4dUDCBE&uact=5&oq=can+a+window.open+second+parameter+pointing+to+iframe+name+be+used+to+check+for+existence+of+a+relative+URL+file+on+a+web+server&gs_lp=Egxnd3Mtd2l6LXNlcnAigAFjYW4gYSB3aW5kb3cub3BlbiBzZWNvbmQgcGFyYW1ldGVyIHBvaW50aW5nIHRvIGlmcmFtZSBuYW1lIGJlIHVzZWQgdG8gY2hlY2sgZm9yIGV4aXN0ZW5jZSBvZiBhIHJlbGF0aXZlIFVSTCBmaWxlIG9uIGEgd2ViIHNlcnZlckgAUABYAHAAeAGQAQCYAQCgAQCqAQC4AQPIAQD4AQGYAgCgAgCYAwCSBwCgBwCyBwC4BwDCBwDIBwCACAA&sclient=gws-wiz-serp
try {
const response = await fetch(url, { method: 'HEAD' }); // Use HEAD to avoid downloading the file
// response.ok is true for status codes 200-299
if (reluadd != '') { relulist.push(reluadd); sofarothers.push(reluadd); sofarurls.push(reluadd); }
reluadd='';
pwind++;
return response.ok;
} catch (error) {
// This catch block handles network errors, not necessarily 404s
if (reluadd != '') { relunlist.push(reluadd); }
reluadd='';
pwind++;
return false;
}
}


function inline_linking(aname) {
var delayis=1000;
pwind=0;
pwinda=[];

// code here from previous work ...
if (relulist.indexOf(pword) == -1 && relunlist.indexOf(pword) == -1 && (pword + ' ').substring(0,1) == '/' && (pword + ' ').indexOf('//') == -1) {
if (pword.indexOf('.') != -1) {
if (xexts.indexOf('.' + pword.split('.')[eval(-1 + pword.split('.').length)].split('#')[0].toLowerCase()) != -1) {
if (xtypes[xexts.indexOf('.' + pword.split('.')[eval(-1 + pword.split('.').length)].split('#')[0].toLowerCase())].indexOf('image/') == 0) {
pwinda.push(pword);
setTimeout(function(){
// Example Usage (for a relative URL file on the same server)
reluadd=pwinda[pwind];
checkUrlExists(reluadd.split('#')[0]).then(exists => { //
console.log(exists ? "File exists!" : "File does not exist.");
});
}, delayis);
delayis+=3000;
} else if (xtypes[xexts.indexOf('.' + pword.split('.')[eval(-1 + pword.split('.').length)].split('#')[0].toLowerCase())].indexOf('video/') == 0) {
pwinda.push(pword);
setTimeout(function(){
// Example Usage (for a relative URL file on the same server)
reluadd=pwinda[pwind];
checkUrlExists(reluadd.split('#')[0]).then(exists => { //
console.log(exists ? "File exists!" : "File does not exist.");
});
}, delayis);
delayis+=3000;
} else if (xtypes[xexts.indexOf('.' + pword.split('.')[eval(-1 + pword.split('.').length)].split('#')[0].toLowerCase())].indexOf('audio/') == 0) {
pwinda.push(pword);
setTimeout(function(){
// Example Usage (for a relative URL file on the same server)
reluadd=pwinda[pwind];
checkUrlExists(reluadd.split('#')[0]).then(exists => { //
console.log(exists ? "File exists!" : "File does not exist.");
});
}, delayis);
delayis+=3000;
}
}
}
} else if (relulist.indexOf(pword) == -1 && relunlist.indexOf(pword) == -1 && (pword + ' ').substring(0,1) == '/' && (pword + ' ').indexOf('//') == 0) {
relulist.push(pword);
}

// code here from previous work ...
}

… incorporated in …

… you can try out for yourself below if you like.


Previous relevant Google Chart Geo Chart AppleScript Functionality Integration Bug Tutorial is shown below.

Google Chart Geo Chart AppleScript Functionality Integration Bug Tutorial

Google Chart Geo Chart AppleScript Functionality Integration Bug Tutorial

After yesterday’s Google Chart Geo Chart Integration Speech Bubbles Textarea Intranet Feeling Tutorial we come to a “generic detour” we need to attend to.

Symptom …
The onhover smarts of the Google Chart Geo Chart suffer when the AppleScript integrations are loaded
Culprit …
We tracked it down to what we used to have …

function ggmuchlater() { // thanks to https://dev-answers.com/solutions/3287e028/how-do-i-include-a-javascript-file-in-another-javascript-file
if (!document.getElementById('apscr') && !document.getElementById('asue')) {
var scriptz = document.createElement("script"); // create a script DOM node
scriptz.src = '/apple_script_url.js?left=calc(100% - 60px)&top=2px&emojXi=128220&css=font-size:30px;opacity:0.8;&mustcontain=&'; // set its src to the provided URL
document.head.appendChild(scriptz); // add it to the end of the head section of the page (could change 'head' to 'body' to add it to the end of the body section instead)
}
}

… working with …


<script id=apXscr type=text/javascript src="/apple_script_url.js?left=calc(100% - 60px)&top=2px&emojXi=128220&css=font-size:30px;opacity:0.8;&mustcontain=&"></script>

Solution …

function gggmuchlater(evt) { // thanks to https://dev-answers.com/solutions/3287e028/how-do-i-include-a-javascript-file-in-another-javascript-file
var scriptz = document.createElement("script"); // create a script DOM node
scriptz.src = '/apple_script_url.js?left=calc(100% - 60px)&top=2px&emojXi=128220&css=font-size:30px;opacity:0.8;&mustcontain=&'; // set its src to the provided URL
document.getElementById('bitsatend').appendChild(scriptz); // add it to the end of the head section of the page (could change 'head' to 'body' to add it to the end of the body section instead)
globevt=evt;
setTimeout(function(){ justplayme(globevt); setTimeout(function(){ if (('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'') != '') { window.location.reload(true); } else { location.href=document.URL; } }, 15000); }, 5000);
}

… working with, just …


<a style="position:fixed;left:calc(100% - 60px);top:2px;cursor: pointer; text-decoration: none;font-size:30px; display: inline-block; background-color: green; border-bottom-right-radius: 85px; opacity: 1;" onclick="gggmuchlater(event);" title="Apple Script snapshot re-execution via macOS Desktop with double click emailing at left and top and double click SMS at bottom right corner only" id="asue">&#x1F4DD;</a>

… and the avoidance of use of document.head.appendChild(scriptz); (at least with a delayed window reload) did the trick to make the Geo Chart onhover functionality start working again, more consistently with …

… you can try out for yourself below if you like.


Previous relevant Google Chart Geo Chart Integration Speech Bubbles Textarea Intranet Feeling Tutorial is shown below.

Google Chart Geo Chart Integration Speech Bubbles Textarea Intranet Feeling Tutorial

Google Chart Geo Chart Integration Speech Bubbles Textarea Intranet Feeling Tutorial

Further to yesterday’s Google Chart Geo Chart Integration Speech Bubbles Textarea Onblur Tutorial today’s extension to textarea smarts, potentially, involves …

  • textarea ondblclick event controlled
  • Intranet feeling
  • window.open popup
  • PHP localhost URL http://localhost:8888/macos_say_record.php
  • using exec to point to
  • underlying macOS and MAMP local Apache/PHP/MySql web server environment command say
  • means to turn Text to Speech

… allowing users to “cowsay say say” via the changed latest draft Cartoon creation and email sharing capable PHP web application teaming with the changed gchartgen.js external Javascript helper onkeydown keyboard event Javascript code which non-mobile you can try out for yourself below if you like.


Previous relevant Google Chart Geo Chart Integration Speech Bubbles Textarea Onblur Tutorial is shown below.

Google Chart Geo Chart Integration Speech Bubbles Textarea Onblur Tutorial

Google Chart Geo Chart Integration Speech Bubbles Textarea Onblur Tutorial

Adding onto yesterday’s Google Chart Geo Chart Integration Speech Bubbles Textarea Onclick Tutorial we’re creeping forward on functionality today, adding to …

  1. address bar URL hashtag
  2. blind typing … with, today …
  3. textarea typing via it’s onblur or onpaste events

… allowing users to “cowsay say” via the changed “third draft” Cartoon creation and email sharing capable PHP web application teaming with the changed gchartgen.js external Javascript helper onkeydown keyboard event Javascript code which non-mobile you can try out for yourself below if you like.


Previous relevant Google Chart Geo Chart Integration Speech Bubbles Textarea Onclick Tutorial is shown below.

Google Chart Geo Chart Integration Speech Bubbles Textarea Onclick Tutorial

Google Chart Geo Chart Integration Speech Bubbles Textarea Onclick Tutorial

Onto yesterday’s Google Chart Geo Chart Integration Speech Bubbles Modus Operandi Tutorial within the Speech Bubble text we’ve added textarea onclick logic to detect clicks to the left of words which might describe such link interests such as YouTube video ID 11 character code words.

More detail on this to come via the changed gchartgen.js external Javascript helper onkeydown keyboard event Javascript code which non-mobile you can try out for yourself below if you like.


Previous relevant Google Chart Geo Chart Integration Speech Bubbles Modus Operandi Tutorial is shown below.

Google Chart Geo Chart Integration Speech Bubbles Modus Operandi Tutorial

Google Chart Geo Chart Integration Speech Bubbles Modus Operandi Tutorial

Onto yesterday’s Google Chart Geo Chart Integration Speech Bubbles Tutorial …

  • web browser address bar “hashtag add” modus operandi for potential Google Chart Geo Chart Integration Speech Bubbles via our integration with the cowsay Python API / Command-line tool … today we add the less kludgy …
  • non-mobile, ? and & argumented URL, hidden typing option to create Google Chart Geo Chart Integration Speech Bubbles

… via the changed gchartgen.js external Javascript helper onkeydown keyboard event Javascript code …


function gcokd(evt) {
var char = 0;
var kcs=[";".charCodeAt(0),"186","=".charCodeAt(0),"187",",".charCodeAt(0),"188","-".charCodeAt(0),"189",".".charCodeAt(0),"190","/".charCodeAt(0),"191","`".charCodeAt(0),"192","[".charCodeAt(0),"219","\\".charCodeAt(0),"220","]".charCodeAt(0),"221","'".charCodeAt(0),"222"];
var belows=["`","1","2","3","4","5","6","7","8","9","0","-","=","[","]",";","'",",",".","/","\\"];
var aboves=['~','!','@','#','$','%','^','&','*','(',')','_','+','{','}',':','"','<','>','?', '|']
if (nomoreokd) {
//document.title='no';
return true;
}
if (evt.altKey && lastkeymodifier != 'a') {
lastkeymodifier='a';
return true;
} else if (evt.ctrlKey && lastkeymodifier != 'c') {
lastkeymodifier='c';
return true;
} else if (evt.shiftKey && lastkeymodifier != 's') {
lastkeymodifier='s';
char = evt.which || evt.keyCode;
if (kcs.indexOf('' + (evt.which || evt.keyCode)) != -1) {
char=(kcs[eval(-1 + kcs.indexOf('' + (evt.which || evt.keyCode)))]); //.charCodeAt(0);
}
if (char == 46 || char == 8) {
if (okdcommentary != '') {
okdcommentary.substring(0,eval(-1 + okdcommentary.length));
if (('' + location.hash).indexOf('commentary=') != -1) {
if (okdcommentary != '') {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
} else {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
}
} else if (('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'') == '') {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
}
}
} else if (char >= 10) {
console.warn('char=' + char + ' evt.keyCode=' + evt.keyCode + ' evt.which=' + evt.which);
if (belows.indexOf(String.fromCharCode(char)) != -1) {
//alert(56);
char=aboves[belows.indexOf(String.fromCharCode(char))].charCodeAt(0);
//alert(char);
okdcommentary+=String.fromCharCode(char);
//document.title=okdcommentary;
if (('' + location.hash).indexOf('commentary=') != -1) {
location.hash+=encodeURIComponent(String.fromCharCode(char));
} else if (('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'') == '') {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
}
lastkeymodifier='';
} else if (String.fromCharCode(char) >= 'A' && String.fromCharCode(char) <= 'Z') {
char+=('a'.charCodeAt(0) - 'A'.charCodeAt(0));
okdcommentary+=String.fromCharCode(char);
//document.title=okdcommentary;
if (('' + location.hash).indexOf('commentary=') != -1) {
location.hash+=encodeURIComponent(String.fromCharCode(char));
} else if (('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'') == '') {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
}
lastkeymodifier='';
}
}
return true;
}
char = evt.which || evt.keyCode;
//document.title='' + char + ' ... ';
if (kcs.indexOf('' + (evt.which || evt.keyCode)) != -1) {
char=(kcs[eval(-1 + kcs.indexOf('' + (evt.which || evt.keyCode)))]); //.charCodeAt(0);
//document.title+='' + char + ' .=. ';
}
if (char == 46 || char == 8) {
if (okdcommentary != '') {
okdcommentary.substring(0,eval(-1 + okdcommentary.length));
if (('' + location.hash).indexOf('commentary=') != -1) {
if (okdcommentary != '') {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
} else {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
}
} else if (('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'') == '') {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
}
}
} else if (char >= 10) {
//document.getElementById('myh3').innerHTML='' + char + ' ' + evt.type;
//var chrCode = char - 48 * Math.floor(char / 48); // thanks to https://stackoverflow.com/questions/1772179/get-character-value-from-keycode-in-javascript-then-trim
//var chr = String.fromCharCode((96 <= char) ? chrCode: char);
//char=chr;
if (lastkeymodifier == 's' && String.fromCharCode(char) >= 'A' && String.fromCharCode(char) <= 'Z') {
char+=('a'.charCodeAt(0) - 'A'.charCodeAt(0));
} else if (String.fromCharCode(char) >= 'A' && String.fromCharCode(char) <= 'Z') {
char+=('A'.charCodeAt(0) - 'A'.charCodeAt(0));
}
if (lastkeymodifier == 's') {
if (belows.indexOf(String.fromCharCode(char)) != -1) {
//alert(56);
char=aboves[belows.indexOf(String.fromCharCode(char))].charCodeAt(0);
//alert(char);
}
}
okdcommentary+=String.fromCharCode(char);
//document.title=okdcommentary;
if (('' + location.hash).indexOf('commentary=') != -1) {
location.hash+=encodeURIComponent(String.fromCharCode(char));
} else if (('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'') == '') {
location.hash='#commentary=' + encodeURIComponent(okdcommentary);
}
}
lastkeymodifier='';
return true;
}

if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
setTimeout(function(){ if (!nomoreokd) { document.body.onkeydown=function(event){ gcokd(event); } } }, 3000);
}

… which non-mobile you can try out for yourself below if you like.


Previous relevant Google Chart Geo Chart Integration Speech Bubbles Tutorial is shown below.

Google Chart Geo Chart Integration Speech Bubbles Tutorial

Google Chart Geo Chart Integration Speech Bubbles Tutorial

Yesterday’s HTML Canvas Memories Frog Game Speech Bubbles Tutorial kickstarted us into imagining other ways …

  • our inhouse integrated cowsay Python API / Command-line tool interfacing … could …
  • be used as hashtag based commentary or Speech Bubbles for our inhouse integrations with Google Charts, our “first cab off the rank” trying this idea being the Geo Chart

We honed in on the external Javascript called by many Google Chart integrators with the changed gchartgen.js external Javascript helper’s …


var washerelhis=(('' + document.URL + '#').split('#')[1]) + ' ';
if (decodeURIComponent(washerelhis).indexOf('commentary=') == 0) {
if (decodeURIComponent(washerelhis).indexOf(',') != -1) {
location.hash=location.hash.replace(/\,/g,' ').replace(/\%44/g,'%20');
washerelhis=washerelhis.replace(/\,/g,' ').replace(/\%44/g,'%20');
}
}

setInterval(postlhway, 3000);

… timer function as per …


function postlhway() {
var foundu='';
var rectcg=null;
var prefoundu='';
var herelhis=(('' + document.URL + '#').split('#')[1]);
if (herelhis == washerelhis && washerelhis != '') {
herelhis=(('#' + location.hash + '#').replace('##','#').split('#')[1]);
}
if (herelhis != washerelhis) {
if (decodeURIComponent(herelhis).indexOf('commentary=') == 0) {
if (document.getElementById('ifcom')) {
document.getElementById('ifcom').src='/cowsay.php?viagc=transXparent&inwords=' + (herelhis.substring(('commentary=').length).split('&')[0].replace(/\+/g,'%20'));
} else if (document.getElementById('dpostform') && document.getElementById('myh')) {
rectcg=document.getElementById('myh').getBoundingClientRect();
document.getElementById('dpostform').innerHTML+='<iframe allowTransparency=true id=ifcom src="/cowsay.php?viagc=transXparent&inwords=' + (herelhis.substring(('commentary=').length).split('&')[0].replace(/\+/g,'%20')) + '" frameborder=0 scrolling=no style="background-color:transparent;position:absolute;top:' + eval(-10 + rectcg.bottom) + 'px;left:' + rectcg.left + 'px;width:300px;height:72px;z-index:564;"></iframe>';
} else if (document.getElementById('dpostform') && document.getElementById('chart_div')) {
rectcg=document.getElementById('chart_div').getBoundingClientRect();
document.getElementById('dpostform').innerHTML+='<iframe allowTransparency=true id=ifcom src="/cowsay.php?viagc=transXparent&inwords=' + (herelhis.substring(('commentary=').length).split('&')[0].replace(/\+/g,'%20')) + '" frameborder=0 scrolling=no style="background-color:transparent;position:absolute;top:' + rectcg.top + 'px;left:' + rectcg.left + 'px;width:300px;height:72px;z-index:564;"></iframe>';
}
}
washerelhis=herelhis;
}

if (bimode == -1) {
if (document.getElementById('bkcol')) {
if (('' + document.getElementById('bkcol').style.backgroundImage).toLowerCase().indexOf('url(') != -1) {
foundu='' + ('' + document.getElementById('bkcol').style.backgroundImage).split('(')[eval(-1 + ('' + document.getElementById('bkcol').style.backgroundImage).split('(').length)].split(')')[0].replace(/^\"/g,'').replace(/\"$/g,'').replace(/^\'/g,'').replace(/\'$/g,'');
bimode=2;
prefoundu='+';
}
}
if (bimode == -1) {
if (('' + document.body.style.backgroundImage).toLowerCase().indexOf('url(') != -1) {
foundu='' + ('' + document.body.style.backgroundImage).split('(')[eval(-1 + ('' + document.body.style.backgroundImage).split('(').length)].split(')')[0].replace(/^\"/g,'').replace(/\"$/g,'').replace(/^\'/g,'').replace(/\'$/g,'');
bimode=1;
if (document.getElementById('iagc')) {
document.getElementById('iagc').style.width='1px';
document.getElementById('iagc').style.height='1px';
} else {
setInterval(function(){
if (document.getElementById('iagc')) {
document.getElementById('iagc').style.width='1px';
document.getElementById('iagc').style.height='1px';
}
}, 2000);
}
} else if (('' + document.body.innerHTML).indexOf('<style> body { background-image:') != -1) {
foundu='' + ('' + document.body.innerHTML.split('<style> body { background-image:')[1].split('}')[0]).split('(')[eval(-1 + ('' + document.body.innerHTML.split('<style> body { background-image:')[1].split('}')[0]).split('(').length)].split(')')[0].replace(/^\"/g,'').replace(/\"$/g,'').replace(/^\'/g,'').replace(/\'$/g,'');
bimode=1;
if (document.getElementById('iagc')) {
document.getElementById('iagc').style.width='1px';
document.getElementById('iagc').style.height='1px';
} else {
setInterval(function(){
if (document.getElementById('iagc')) {
document.getElementById('iagc').style.width='1px';
document.getElementById('iagc').style.height='1px';
}
}, 2000);
}
} else if (document.getElementById('bitsatend') && ('' + document.getElementById('bitsatend').innerHTML).indexOf('<style> body { background-image:') != -1) {
foundu='' + ('' + document.getElementById('bitsatend').innerHTML.split('<style> body { background-image:')[1].split('}')[0]).split('(')[eval(-1 + ('' + document.getElementById('bitsatend').innerHTML.split('<style> body { background-image:')[1].split('}')[0]).split('(').length)].split(')')[0].replace(/^\"/g,'').replace(/\"$/g,'').replace(/^\'/g,'').replace(/\'$/g,'');
bimode=1;
if (document.getElementById('iagc')) {
document.getElementById('iagc').style.width='1px';
document.getElementById('iagc').style.height='1px';
} else {
setInterval(function(){
if (document.getElementById('iagc')) {
document.getElementById('iagc').style.width='1px';
document.getElementById('iagc').style.height='1px';
}
}, 2000);
}
} else if (document.getElementById('bitsatend') && ('' + document.getElementById('bitsatend').innerHTML).indexOf('<style> #bkcol { background-image:') != -1) {
foundu='' + ('' + document.getElementById('bitsatend').innerHTML.split('<style> #bkcol { background-image:')[1].split('}')[0]).split('(')[eval(-1 + ('' + document.getElementById('bitsatend').innerHTML.split('<style> #bkcol { background-image:')[1].split('}')[0]).split('(').length)].split(')')[0].replace(/^\"/g,'').replace(/\"$/g,'').replace(/^\'/g,'').replace(/\'$/g,'');
bimode=2;
prefoundu='+';
if (document.getElementById('iagc')) {
document.getElementById('iagc').style.width='1px';
document.getElementById('iagc').style.height='1px';
} else {
setInterval(function(){
if (document.getElementById('iagc')) {
document.getElementById('iagc').style.width='1px';
document.getElementById('iagc').style.height='1px';
}
}, 2000);
}
}
}
}
if (foundu != '') {
if (document.getElementById('remail')) {
if (document.getElementById('remail').href.indexOf(encodeURIComponent('bi=')) == -1) {
if (document.getElementById('remail').href.indexOf(encodeURIComponent('#')) != -1 && document.getElementById('remail').href.indexOf(encodeURIComponent('&')) != -1) {
if (3 == 3) {
document.getElementById('remail').href+='' + encodeURIComponent('&#bi=') + prefoundu + encodeURIComponent(foundu.replace('?',encodeURIComponent('?')).replace('?',encodeURIComponent('&')));
if (document.getElementById('remail').href.indexOf('&body=') != -1) {
document.getElementById('rsms').href='sms:&body=' + (document.getElementById('remail').href.split('&body=')[1]);
} else {
document.getElementById('rsms').href+='' + encodeURIComponent('&#bi=') + prefoundu + encodeURIComponent(foundu);
}
} else {
document.getElementById('remail').href=document.getElementById('remail').href.replace(encodeURIComponent('&'), encodeURIComponent('&bi=') + prefoundu + encodeURIComponent(foundu.replace('?',encodeURIComponent('?')).replace('?',encodeURIComponent('&')) + '&'));
if (document.getElementById('remail').href.indexOf('&body=') != -1) {
document.getElementById('rsms').href='sms:&body=' + (document.getElementById('remail').href.split('&body=')[1]);
} else {
document.getElementById('rsms').href=document.getElementById('rsms').href.replace(encodeURIComponent('&'), encodeURIComponent('&bi=') + prefoundu + encodeURIComponent(foundu.replace('?',encodeURIComponent('?')).replace('?',encodeURIComponent('&')) + '&'));
}
}
} else if (document.getElementById('remail').href.indexOf(encodeURIComponent('#')) != -1) {
document.getElementById('remail').href=document.getElementById('remail').href.replace(encodeURIComponent('#'), encodeURIComponent('#bi=') + prefoundu + encodeURIComponent(foundu.replace('?',encodeURIComponent('?')).replace('?',encodeURIComponent('&')) + '&'));
if (document.getElementById('remail').href.indexOf('&body=') != -1) {
document.getElementById('rsms').href='sms:&body=' + (document.getElementById('remail').href.split('&body=')[1]);
} else {
document.getElementById('rsms').href=document.getElementById('rsms').href.replace(encodeURIComponent('#'), encodeURIComponent('#bi=') + prefoundu + encodeURIComponent(foundu.replace('?',encodeURIComponent('?')).replace('?',encodeURIComponent('&')) + '&'));
}
} else {
document.getElementById('remail').href+='' + encodeURIComponent('#bi=') + prefoundu + encodeURIComponent(foundu.replace('?',encodeURIComponent('?')).replace('?',encodeURIComponent('&')));
if (document.getElementById('remail').href.indexOf('&body=') != -1) {
document.getElementById('rsms').href='sms:&body=' + (document.getElementById('remail').href.split('&body=')[1]);
} else {
document.getElementById('rsms').href+='' + encodeURIComponent('#bi=') + prefoundu + encodeURIComponent(foundu.replace('?',encodeURIComponent('?')).replace('?',encodeURIComponent('&')));
}
}
}
}
}
}

… combined with the changed “third draft” Cartoon creation and email sharing capable PHP web application, where it’s hosting is such that a great degree of transparency is applied …


Previous relevant HTML Canvas Memories Frog Game Speech Bubbles Tutorial is shown below.

HTML Canvas Memories Frog Game Speech Bubbles Tutorial

HTML Canvas Memories Frog Game Speech Bubbles Tutorial

Yesterday’s HTML Canvas Memories Frog Game Drag and Drop Tutorial‘s new Frog mode of use adds to the degree of difficulty, no doubt.

And so, today, we’ve decided maybe some Speech Bubbles unique to each frog can be an additional memory aid. This was the opportunity to involve the great cowsay Python API / Command-line tool which we have written some PHP to integrate with here at RJM Programming. Add to that some Kermit sayings …


var rectc=null;

var cfttoggle=0;
var kermitisms=["It's not easy " + String.fromCharCode(10) + " being green.","Hi-ho, " + String.fromCharCode(10) + " Kermit the Frog here!","Life's like a movie, write your own ending. Keep believing, keep pretending.","Someday we'll find it, the rainbow connection. The lovers, the dreamers, and me.","Just because you haven't found your talent yet, doesn't mean you don't have one.","If you have to eat two frogs, eat the ugliest one first.","Here's one other thing that I think every person or frog needs to be creative: friends.","I promised " + String.fromCharCode(10) + " me.","Time's fun when you're having " + String.fromCharCode(10) + " flies!","May success and a smile always be yours … even when you're knee-deep in the sticky muck of life.",
"It's not easy " + String.fromCharCode(10) + " being green","Hi-ho, " + String.fromCharCode(10) + " Kermit the Frog here","Life's like a movie, write your own ending. Keep believing, keep pretending","Someday we'll find it, the rainbow connection. The lovers, the dreamers, and me","Just because you haven't found your talent yet, doesn't mean you don't have one","If you have to eat two frogs, eat the ugliest one first","Here's one other thing that I think every person or frog needs to be creative: friends","I promised " + String.fromCharCode(10) + " me","Time's fun when you're having " + String.fromCharCode(10) + " flies","May success and a smile always be yours … even when you're knee-deep in the sticky muck of life",
"it's not easy " + String.fromCharCode(10) + " being green","hi-ho, " + String.fromCharCode(10) + " Kermit the Frog here","life's like a movie, write your own ending. Keep believing, keep pretending","someday we'll find it, the rainbow connection. The lovers, the dreamers, and me","just because you haven't found your talent yet, doesn't mean you don't have one","if you have to eat two frogs, eat the ugliest one first","here's one other thing that I think every person or frog needs to be creative: friends","i promised " + String.fromCharCode(10) + " me","time's fun when you're having " + String.fromCharCode(10) + " flies","may success and a smile always be yours … even when you're knee-deep in the sticky muck of life",
"it's not easy " + String.fromCharCode(10) + " being green.","hi-ho, " + String.fromCharCode(10) + " Kermit the Frog here!","life's like a movie, write your own ending. Keep believing, keep pretending.","someday we'll find it, the rainbow connection. The lovers, the dreamers, and me.","just because you haven't found your talent yet, doesn't mean you don't have one.","if you have to eat two frogs, eat the ugliest one first.","here's one other thing that I think every person or frog needs to be creative: friends.","i promised " + String.fromCharCode(10) + " me.","time's fun when you're having " + String.fromCharCode(10) + " flies!","may success and a smile always be yours … even when you're knee-deep in the sticky muck of life.",
"- It's not easy " + String.fromCharCode(10) + " being green.","- Hi-ho, " + String.fromCharCode(10) + " Kermit the Frog here!","- Life's like a movie, write your own ending. Keep believing, keep pretending.","- Someday we'll find it, the rainbow connection. The lovers, the dreamers, and me.","- Just because you haven't found your talent yet, doesn't mean you don't have one.","- If you have to eat two frogs, eat the ugliest one first.","- Here's one other thing that I think every person or frog needs to be creative: friends.","- I promised " + String.fromCharCode(10) + " me.","- Time's fun when you're having " + String.fromCharCode(10) + " flies!","- May success and a smile always be yours … even when you're knee-deep in the sticky muck of life.",
"- It's not easy " + String.fromCharCode(10) + " being green. -","- Hi-ho, " + String.fromCharCode(10) + " Kermit the Frog here! -"
];
var kermitismowners=[];
var kermitismidxs=[];

function cft(inw,xz,yz) {
var ihuh=-1, jhuh=-1;
// cfttoggle=0 onediv =1 twodiv
// https://www.rjmprogramming.com.au/cowsay.php?inwords=well%20yes
// kermitisms[] via kermitismowners[]
if (!rectc) {
rectc=document.getElementById('canvaselement').getBoundingClientRect();
}
//alert('xz=' + xz + ' and yz=' + yz + ' ' + eval(rectc.left + xz) + ',' + eval(rectc.top + yz));
yz=eval(rectc.top + yz);
xz=eval(rectc.left + xz);
if (eval('' + kermitismowners.length) == 0) {
while (eval('' + kermitismidxs.length) < eval('' + kermitisms.length)) {
ihuh=Math.floor(Math.random() * 52);
while (kermitismidxs.indexOf(ihuh) != -1) {
ihuh=Math.floor(Math.random() * 52);
}
kermitismidxs.push(ihuh);
}
}
jhuh=kermitismowners.indexOf(inw);
if (jhuh == -1) {
kermitismowners.push(inw);
}
jhuh=kermitismowners.indexOf(inw);
if (cfttoggle == 0) {
document.getElementById('twodiv').innerHTML='';
document.getElementById('onediv').style.position='absolute';
document.getElementById('onediv').style.top='' + Math.max(0,eval(-80 + yz)) + 'px';
document.getElementById('onediv').style.left='' + Math.max(0,eval(-240 + xz)) + 'px';
document.getElementById('onediv').style.width='300px';
document.getElementById('onediv').style.height='100px';
//document.getElementById('onediv').style.overflowX='hidden';
//document.getElementById('onediv').innerHTML='<iframe src="//www.rjmprogramming.com.au/cowsay.php?viamemories=y&inwords=' + encodeURIComponent(kermitisms[kermitismidxs[jhuh]]) + '" frameborder=0 style="position:absolute;top=' + eval(-30 + yz) + 'px;left=' + xz + 'px;width=100px;height:60px;"></iframe>';
document.getElementById('onediv').innerHTML='<iframe src="/cowsay.php?viamemories=y&inwords=' + encodeURIComponent(kermitisms[kermitismidxs[jhuh]]) + '" frameborder=0 scrolling=no style="position:absolute;top:' + Math.max(0,eval(-80 + yz)) + 'px;left:' + Math.max(0,eval(-240 + xz)) + 'px;width:300px;height:100px;"></iframe>';
cfttoggle=1;
} else {
//document.getElementById('onediv').innerHTML='';
document.getElementById('twodiv').style.position='absolute';
document.getElementById('twodiv').style.top='' + Math.max(0,eval(-80 + yz)) + 'px';
document.getElementById('twodiv').style.left='' + Math.max(0,eval(-240 + xz)) + 'px';
document.getElementById('twodiv').style.width='300px';
document.getElementById('twodiv').style.height='100px';
//document.getElementById('twodiv').style.overflowX='hidden';
//document.getElementById('twodiv').innerHTML='<iframe src="//www.rjmprogramming.com.au/cowsay.php?viamemories=y&inwords=' + encodeURIComponent(kermitisms[kermitismidxs[jhuh]]) + '" frameborder=0 style="position:absolute;top=' + eval(-30 + yz) + 'px;left=' + xz + 'px;width=100px;height:60px;"></iframe>';
document.getElementById('twodiv').innerHTML='<iframe src="/cowsay.php?viamemories=y&inwords=' + encodeURIComponent(kermitisms[kermitismidxs[jhuh]]) + '" frameborder=0 scrolling=no style="position:absolute;top:' + Math.max(0,eval(-80 + yz)) + 'px;left:' + Math.max(0,eval(-240 + xz)) + 'px;width:300px;height:100px;"></iframe>';
cfttoggle=0;
}
//window.open('//www.rjmprogramming.com.au/cowsay.php?inwords=' + encodeURIComponent(kermitisms[kermitismidxs[jhuh]]),'_blank','top=40,left=40,width=100,height=100');

}

… and you have the means to add in that addition Speech Bubble uniquifying functionality in the changed memories.html Memories Game.


Previous relevant HTML Canvas Memories Frog Game Drag and Drop Tutorial is shown below.

HTML Canvas Memories Frog Game Drag and Drop Tutorial

HTML Canvas Memories Frog Game Drag and Drop Tutorial

We’re revisiting the HTML Canvas Memories Game Drag and Drop Tutorial‘s …

  • Memories card game … allowing …
  • frogs (or toad) images to substitute for the playing card images, as user selected

… the idea arising, again, from my sister’s great frog photographic selection.

This change involved two phases …

  1. a phase creating 52 *.jpeg frog images to cover for each of the 52 *.gif playing card images …
  2. a software change phase

… in the changed memories.html Memories Game.


Previous relevant HTML Canvas Memories Game Drag and Drop Tutorial is shown below.

HTML Canvas Memories Game Drag and Drop Tutorial

HTML Canvas Memories Game Drag and Drop Tutorial

The Canvas HTML element tag combines with some drag and drop event Javascript logic today with our revised Memories Card Game we first developed some time back with HTML/Javascript Canvas Memories Card Game Primer Tutorial as shown below. In the same line of thinking was yesterday’s HTML Colour Coded Tic Tac Toe Drag and Drop Tutorial.

An HTML5 canvas element can be used as the container to draw graphics on the fly usually via the use of Javascript functions for rendering and event management.

Today, with this topic, we’ve focussed on non-mobile platforms with the new drag and drop possibilities, but the old methods, with touch/click, will still work for mobile platforms, and at a later date we may find room for “drag and drop” improvement with the mobile platforms as well … in the fullness of time … given the constraints of economic belt tightening … over the course of the current forward estimates.

So what events, applied directly to the canvas element this time (incidentally, yesterday, this was not the case), were additionally of interest for non-mobile drag and drop functionality (in decreasing order of importance (where the already existant canvas “onclick” event remains the most important))?

  • ondragstart=”drag(event)” … where we can differentiate a drag and drop (of the first card chosen) from a click/touch
  • onmouseup=”omu(event)” … where we can get the (x,y) of the second card chosen
  • onmousemove=”omo(event)” … not really important, but we can show it is a drag and drop up in the HTML h1 wording
  • ondragover=”allowDrop(event)” … not called upon for non-mobile
  • ondrop=”drop(event)” … not used for non-mobile

And what additional property?

The end result on a non-mobile platform is that two cards separately clicked act very much like a drag and drop. Our drag and drop does not draw the card flopping onto the other, but shows a change in the HTML h1 wording.

Here is a link to some downloadable HTML programming code … rename to memories.html and how it changed for the tutorial below is described at this link.

And you may want to try a memories.htmllive run of this card game that tests your memory, and perseverance, at the very least.


Previous relevant HTML/Javascript Canvas Memories Card Game Primer Tutorial is shown below.

HTML/Javascript Canvas Memories Card Game Primer Tutorial

HTML/Javascript Canvas Memories Card Game Primer Tutorial

The Canvas HTML element tag can be used as the container to draw graphics on the fly usually via the use of Javascript functions for rendering and event management.

In today’s tutorial we mainly use the drawImage function to create a webpage where you can play the card game called Memories.

You may want to read more at HTML Canvas Reference as a generic reference, or here, at the tutorial javascript – How do I add a simple onClick event handler to a canvas element? – Stack Overflow.

As you can imagine, this HTML canvas element, new to HTML5, can be very useful for some practical client-side web functionality.

Link to some downloadable HTML programming code … rename to memories.html

You’ll notice heavy use of the Javascript Math.random() function.

We hope you enjoy this Memories Card Game tutorial live run.

Yes … you’ve reached the end … have a top supportive day full of happy memories!

Stop Press

As of the 5th June 2015 you may notice this game changed to add functionality, and that the live run above might support some drag and drop functionality on non-mobile platforms so you may want to compare this to an old live run for how it worked before this date.

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.


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 Coding, eLearning, Event-Driven Programming, Installers, Operating System, Software, Tutorials, Xcode | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment