You might have noticed with yesterdayโs Details Summary Button Onclick Primer Tutorialโs โฆ.
- details or summary element onclick logic that it relied on an assumption that โฆ
- the onclick event occurs after a details element attribute โopenโ is finalized โฆ and though โฆ
- we โfeelโ that this might be true โฆ yet, we would rather โฆ
- not chance it, and make it that the onclick event occurs โdelayedโ after any details element attribute โopenโ is finalized โฆ using โฆ
- that ever useful setTimeout timer function
โฆ but with more nuance than our usual Javascript โฆ
function calledBySetTimeout_nothingPassed() {
console.log('called by setTimeout');
}
setTimeout(calledBySetTimeout_nothingPassed, 3000); // delayed by 3 seconds
โฆ way of doing things, that we seem to use in every second project. Today, with great advice from this very useful link we jump quite a few nuances to more complexity than we had in mind for some future โinfillingโ blog postings, but the ideas being so cute, we want to drop you users unfamiliar with the joys of the โsetTimeoutโ timer into some quite deeeeeeeeeeep water โฆ with โฆ called โฆ
function makeDelayedHandler(f, time){ // Delay execution of event handler function "f" by "time" ms, thanks to https://stackoverflow.com/questions/3048005/document-onclick-settimeout-function-javascript-help
return function(e){
var ev = e || window.event;
setTimeout(function(){
f(ev);
}, time);
};
}
function checkds(e) {
var ois = (e && e.target) || (event && event.srcElement);
var dpp='';
var dld='';
var oga='';
try {
dpp=ois.getAttribute('data-preid').replace(/^null$/g, '').replace(/^undefined$/g, '');
dld=ois.getAttribute('data-lastid').replace(/^null$/g, '').replace(/^undefined$/g, '');
} catch(ewq) {
}
if (ois.parentElement && ois.outerHTML.toLowerCase().indexOf('<summary') == 0) {
oga=('' + ois.getAttribute('data-pardet')).replace(/^null$/g, '').replace(/^undefined$/g, '').replace(/^false$/g, '');
if (oga != '') {
ois=document.getElementById(oga);
oga=ois.open; //('' + ois.getAttribute('open')).replace(/^null$/g, '').replace(/^undefined$/g, '').replace(/^false$/g, '');
try {
if (dpp.trim() == '' && dld.trim() == '') {
dpp=ois.getAttribute('data-preid').replace(/^null$/g, '').replace(/^undefined$/g, '');
dld=ois.getAttribute('data-lastid').replace(/^null$/g, '').replace(/^undefined$/g, '');
}
} catch(ewqtwo) {
}
} else {
oga=ois.parentElement.open; //('' + ois.parentElement.getAttribute('open')).replace(/^null$/g, '').replace(/^undefined$/g, '').replace(/^false$/g, '');
ois=ois.parentElement;
}
if (dpp.trim() == '' && dld.trim() == '') {
dpp=ois.getAttribute('data-preid').replace(/^null$/g, '').replace(/^undefined$/g, '');
dld=ois.getAttribute('data-lastid').replace(/^null$/g, '').replace(/^undefined$/g, '');
}
} else {
oga=ois.open; //('' + ois.getAttribute('open')).replace(/^null$/g, '').replace(/^undefined$/g, '').replace(/^false$/g, '');
}
if (oga) {
location.href='#' + dpp; //ois.getAttribute('data-preid');
location.href='#' + dld; //ois.getAttribute('data-lastid');
}
}
โฆ via changed calling logic as per โฆ
var initiallynone=false;
function lookfordsa() {
var lastdet1='', lastdet2='', lastdetid='';
var ebefore='', fbefore='';
var nodetails=true;
var lasteis=null, lastid='';
var indselems=document.getElementsByTagName('details');
var hashtop='top';
var bihis='';
if (eval('' + indselems.length) > 0) {
var inelems=document.getElementsByTagName('*');
nodetails=false;
if (initiallynone) { initiallynone=false; setTimeout(lookfordsa, 3000); return; }
bihis=document.body.innerHTML;
for (var iplj=0; iplj<inelems.length; iplj++) {
if (('' + inelems[iplj].outerHTML).toLowerCase().replace(/^null$/g, '').replace(/^undefined$/g, '').indexOf('<br') == 0) {
lastid=lastid;
} else if (('' + inelems[iplj].outerHTML).toLowerCase().replace(/^null$/g, '').replace(/^undefined$/g, '').indexOf('<summary') == 0) {
nodetails=false;
if (lastdetid != '') {
inelems[iplj].setAttribute('data-pardet', lastdetid);
lastdetid='';
}
if (lasteis && lastid != '') {
if (('' + inelems[iplj].onclick).replace(/^null$/g, '').replace(/^undefined$/g, '') == '') {
inelems[iplj].setAttribute('data-preid', '' + hashtop.replace('#',''));
inelems[iplj].setAttribute('data-lastid', '' + lastid);
if (1 == 1) {
inelems[iplj].onclick = makeDelayedHandler(checkds, 1000);
} else {
inelems[iplj].onclick = function(evt) { location.href='#' + evt.target.getAttribute('data-preid'); location.href='#' + evt.target.getAttribute('data-lastid'); }
}
console.log('summary:' + lastid);
}
}
lasteis=null;
lastid='';
} else if (('' + inelems[iplj].outerHTML).toLowerCase().replace(/^null$/g, '').replace(/^undefined$/g, '').indexOf('<details') == 0) {
nodetails=false;
if (lasteis && lastid != '') {
if (('' + inelems[iplj].onclick).replace(/^null$/g, '').replace(/^undefined$/g, '') == '') {
lastdet1=hashtop.replace('#','');
inelems[iplj].setAttribute('data-preid', '' + hashtop.replace('#',''));
lastdet2=lastid;
inelems[iplj].setAttribute('data-lastid', '' + lastid);
//document.getElementById('myh1').innerHTML+=('details:' + lastid);
if (1 == 1) {
inelems[iplj].onclick = makeDelayedHandler(checkds, 1000);
} else {
inelems[iplj].onclick = function(evt) { if (('' + evt.target.getAttribute('open')).replace(/^null$/g, '').replace(/^undefined$/g, '').replace(/^false$/g, '') != '') { location.href='#' + evt.target.getAttribute('data-preid'); location.href='#' + evt.target.getAttribute('data-lastid'); } }
}
//inelems[iplj].onclick = function(evt) { location.href='#' + evt.target.getAttribute('data-preid'); location.href='#' + evt.target.getAttribute('data-lastid'); }
lastdetid=('' + inelems[iplj].id);
lasteis=null;
lastid='';
}
} else {
if (bihis.indexOf(('' + inelems[iplj].outerHTML).replace(/^null$/g, '').replace(/^undefined$/g, '')) != -1) {
ebefore=bihis.split(('' + inelems[iplj].outerHTML).replace(/^null$/g, '').replace(/^undefined$/g, ''))[0].replace(/\ \;/g,'');
if ((ebefore.trim() + '~').indexOf('</a>~') != -1) {
fbefore='<a ' + ebefore.split('<a ')[eval(-1 + ebefore.split('<a ').length)];
if (fbefore.indexOf(' id="') != -1) {
lastid=fbefore.split(' id="')[1].split('"')[0];
lasteis=document.getElementById(lastid);
console.log(lastid);
console.log(lasteis.outerHTML);
console.log(lasteis.href);
if (('' + lasteis.href).indexOf('#') >= 0) {
hashtop='#' + lasteis.href.split('#')[1];
//alert('4:' + hashtop);
}
if (('' + inelems[iplj].onclick).replace(/^null$/g, '').replace(/^undefined$/g, '') == '') {
lastdet1=hashtop.replace('#','');
inelems[iplj].setAttribute('data-preid', '' + hashtop.replace('#',''));
lastdet2=lastid;
inelems[iplj].setAttribute('data-lastid', '' + lastid);
//document.getElementById('myh1').innerHTML+=('details:' + lastid);
if (1 == 1) {
inelems[iplj].onclick = makeDelayedHandler(checkds, 1000);
} else {
inelems[iplj].onclick = function(evt) { if (('' + evt.target.getAttribute('open')).replace(/^null$/g, '').replace(/^undefined$/g, '').replace(/^false$/g, '') != '') { location.href='#' + evt.target.getAttribute('data-preid'); location.href='#' + evt.target.getAttribute('data-lastid'); } }
}
lastdetid=('' + inelems[iplj].id);
lasteis=null;
lastid='';
}
}
//alert('Not Here ');
}
}
}
} else {
if (('' + inelems[iplj].type).toLowerCase() == 'a') {
if (('' + inelems[iplj].id) != '') {
if (('' + inelems[iplj].href).indexOf('#') >= 0) {
hashtop='#' + inelems[iplj].href.split('#')[1];
//alert('7:' + hashtop);
lasteis=inelems[iplj];
lastid=inelems[iplj].id;
} else {
lasteis=null;
lastid='';
}
}
} else if (('' + inelems[iplj].outerHTML).replace(/^null$/g, '').replace(/^undefined$/g, '').replace(/\ \;/g, '').trim() != '') {
//if (lasteis) { alert('lastid=' + lastid + ' and this.outerHTML=' + inelems[iplj].outerHTML); }
lasteis=null;
lastid='';
}
}
}
}
if (nodetails) { initiallynone=true; setTimeout(lookfordsa, 3000); } else if (initiallynone) { initiallynone=false; setTimeout(lookfordsa, 3000); }
}
setTimeout(lookfordsa, 3000);
โฆ involved in thechanged external Javascript details_hashjs that you can test with our
inhouse chat web application.
Previous relevant Details Summary Button Onclick Primer Tutorial is shown below.
Weโve written an external Javascript details_hashjs that โฆ
- adds button like qualities (ie. onclick logic) to details/summary element combinations that are โฆ
- preceeded by an โaโ tag with # hashtag navigation โhrefโ attribute โฆ and a โฆ
- real โidโ attribute (that, in turn, can be hashtag navigated to) โฆ in which case โฆ
- dynamic โonclickโ logic is added (to details or summary), if none defined already, to hashtag navigate to a good view of this details/summary content (to top of screen, but allowing for โBack to Chatโ hashtag navigation, already there, as well)
โฆ uses logic we had yesterdayโs Chat No Sockets Chrome Hear It Tutorial web architecture to work from, with testing and which you can try yourself via todayโschanged php_listenerphpโs chat
web application.
Youโll see in that changed code above, the biggest changes being the call of this external Javascript, as per (within document.head) โฆ
<?php echo โ
<style>
b:hover { border: 1px solid red; }
a[href=\"#myh1\"] { font-size: 32px; }
summary { background-color:#f0f0f0; border: 1px solid olive; }
</style>
<script type='text/javascript' src='HTTP://www.rjmprogramming.com.au/PHP/details_hash.js?x=" . rand(0,23456) . "' defer></script>
โ; ?>
Previous relevant Chat No Sockets Chrome Hear It Tutorial is shown below.
Back at the inhouse Chat web application today we combine โฆ
- the progress up to Chat No Sockets Chrome Hands Free Tutorial โฆ
- augmented by the recent Voiceover Ideas Google Translate Tutorial
โฆ to get helped out by the excellent Google Translateโs translation and Text to Speech capabilities, to add a โhear itโ layer of functionality to this Chat web application.
As well, we establish โฆ
- bold text styling of the latest chat line from a chat collaborator โฆ that has โฆ
- HTML โฆ
<b onclick="gtit(this);" onmouseover="gtit(this);">Chat Line</b>
โฆ combining with โฆ - Javascript โฆ
var gtw=null, gtwurl='';
function windowopen(gtu, gtb, gtx) {
if (gtu == gtwurl) {
if (gtw) {
if (gtw.closed) {
return window.open(gtu, gtb, gtx);
}
} else {
return window.open(gtu, gtb, gtx);
}
} else {
gtwurl=gtu;
if (gtw) {
if (!gtw.closed) {
gtw.close();
}
}
return window.open(gtu, gtb, gtx);
}
return gtw;
}
function gtit(ihis) {
var instuff=(ihis.innerHTML.split('<')[0]);
gtw=windowopen('https://translate.google.com/#view=home&op=translate&sl=' + top.document.getElementById('ootw').value.substring(0,2).replace(top.document.getElementById('ootw').value.substring(2),'auto') + '&tl=' + top.document.getElementById('ootw').value.substring(2) + '&text=' + encodeURIComponent(instuff.split('<br>')[0]), '_blank', 'left=100,top=100,width=500,height=500');
} - for the non-Microsoft web browsers we establish our favourite โrevealโ stylers, the details/summary element combination that can programmatically โscrunch upโ and allow user interactive flexibility via โฆ
<?php echo โ
function detsum(viaoid, thisoid, ems) {
var eparts=ems.split('.'), ipre=0;
var eprefix=\"<p title='Animated Emoji' style='opacity: 0.4; font-size: 32px;'>&#\" + eparts[0] + \";</p>\";
eprefix=\"&#\" + eparts[0] + \";\";
var esuffix='';
if (navigator.appName == 'Microsoft Internet Explorer' || (navigator.appName == 'Netscape' && navigator.appVersion.indexOf('Edge') > -1)) {
return '';
}
var noif=thisoid.replace('if','');
if (viaoid.indexOf(noif) != -1) {
if (eparts.length > 1) {
eprefix=\"<span title='Animated Emoji' style='opacity: 0.4; font-size: 32px;'>&#\" + eparts[0] + \";</span>\";
for (ipre=1; ipre<eparts.length; ipre++) {
esuffix+=\"<span title='Animated Emoji' style='opacity: 0.4; font-size: 32px;'>&#\" + eparts[ipre] + \";</span>\";
}
}
eprefix=eprefix.replace('</p>','</span>').replace('<p','<span');
return ' <details id=det' + noif + ' style=display:inline-block;width:95%; open><summary style=display:inline;font-size:32px;>' + eprefix + esuffix + '</summary>';
} else {
if (eparts.length > 1) {
eprefix=\"<span title='Animated Emoji' style='opacity: 0.4; font-size: 32px;'>&#\" + eparts[0] + \";</span>\";
for (ipre=1; ipre<eparts.length; ipre++) {
esuffix+=\"<span title='Animated Emoji' style='opacity: 0.4; font-size: 32px;'>&#\" + eparts[ipre] + \";</span>\";
}
}
eprefix=eprefix.replace('</p>','</span>').replace('<p','<span');
return ' <details id=det' + noif + ' style=display:inline-block;width:95%;><summary style=display:inline;font-size:32px;>' + eprefix + esuffix + '</summary>';
}
}
function sumdet(viaoid, thisoid) {
if (navigator.appName == 'Microsoft Internet Explorer' || (navigator.appName == 'Netscape' && navigator.appVersion.indexOf('Edge') > -1)) {
return '';
}
return '</details>';
}
function ddivfbit(ioi) {
var detlist=document.getElementsByTagName('details'), idetlist=1;
if (document.getElementById('dfeedback').innerHTML == '') {
document.getElementById('dfeedback').innerHTML=\"<a id=ifdict href=#myh1 style=vertical-align:top; title=Top>^</a>\" + detsum(ioi.id,'ifdict','128483') + \"<br><iframe id=idict style='width:100%;height:800px;' src='https://www.rjmprogramming.com.au/PHP/speech_supervisor.php?topchat=" . $enduring . "'></iframe>\" + sumdet(ioi.id,'ifdict') + \"<br><a id=ifimg href=#myh1 style=vertical-align:top; title=Top>^</a>\" + detsum(ioi.id,'ifimg','128444.127912') + \"<br><iframe id=iimg style='width:100%;height:800px;' src='../HTMLCSS/feedback.htm?sid=" . $enduring . "'></iframe>\" + sumdet(ioi.id,'ifimg') + \"<br><a id=ifav href=#myh1 style=vertical-align:top; title=Top>^</a>\" + detsum(ioi.id,'ifav','128452.128250') + \"<br><iframe id=iav style='width:100%;height:800px;' src='../macos_say_record.php?topchat=" . $enduring . "'></iframe>\" + sumdet(ioi.id,'ifav') + \"\";
} else if (ioi.id.indexOf('dict') != -1 && document.getElementById('idict').src.indexOf('topchat=') == -1) {
if (document.getElementById('detdict')) { document.getElementById('detdict').setAttribute('open',true); for (idetlist=1; idetlist<detlist.length; idetlist++) { detlist[idetlist].removeAttribute('open'); } }
document.getElementById('idict').src=document.getElementById('idict').src.split('?')[0].split('#')[0] + '?topchat=" . $enduring . "';
} else if (detlist.length > 0) {
for (idetlist=0; idetlist<detlist.length; idetlist++) {
if (detlist[idetlist].id.indexOf(ioi.id.replace('if','').replace('aa','')) != -1) {
detlist[idetlist].setAttribute('open',true);
} else {
detlist[idetlist].removeAttribute('open');
}
}
}
}
function divfbit(ioi) {
var detlist=document.getElementsByTagName('details'), idetlist=1;
if (document.getElementById('dfeedback').innerHTML == '') {
document.getElementById('dfeedback').innerHTML=\"<a id=ifdict href=#myh1 style=vertical-align:top; title=Top>^</a>\" + detsum(ioi.id,'ifdict','128483') + \"<br><iframe id=idict style='width:100%;height:800px;' src='https://www.rjmprogramming.com.au/PHP/speech_supervisor.php'></iframe>\" + sumdet(ioi.id,'ifdict') + \"<br><a id=ifimg href=#myh1 style=vertical-align:top; title=Top>^</a>\" + detsum(ioi.id,'ifimg','128444.127912') + \"<br><iframe id=iimg style='width:100%;height:800px;' src='../HTMLCSS/feedback.htm?sid=" . $enduring . "'></iframe>\" + sumdet(ioi.id,'ifimg') + \"<br><a id=ifav href=#myh1 style=vertical-align:top; title=Top>^</a>\" + detsum(ioi.id,'ifav','128452.128250') + \"<br><iframe id=iav style='width:100%;height:800px;' src='../macos_say_record.php?topchat=" . $enduring . "'></iframe>\" + sumdet(ioi.id,'ifav') + \"\";
} else if (ioi.id.indexOf('dict') != -1 && document.getElementById('idict').src.indexOf('topchat=') != -1) {
if (document.getElementById('detdict')) { document.getElementById('detdict').setAttribute('open',true); for (idetlist=1; idetlist<detlist.length; idetlist++) { detlist[idetlist].removeAttribute('open'); } }
document.getElementById('idict').src=document.getElementById('idict').src.split('?')[0].split('#')[0];
} else if (detlist.length > 0) {
for (idetlist=0; idetlist<detlist.length; idetlist++) {
if (detlist[idetlist].id.indexOf(ioi.id.replace('if','').replace('aa','')) != -1) {
detlist[idetlist].setAttribute('open',true);
} else {
detlist[idetlist].removeAttribute('open');
}
}
}
}
โ; ?>
Todayโschanged php_listenerphpโs chat
web application is worth your while (re)trying, we reckon.
Previous relevant Chat No Sockets Chrome Hands Free Tutorial is shown below.
Continuing on with yesterdayโs Chat No Sockets Dictation Tutorial start to our โฆ
Google Chrome โHands Freeโ Chat dream
โฆ weโve progressed a little via โฆ
- localStorage recall of last email or SMS into respective textbox โplaceholderโ attributes (ie. not all the way to โvalueโ attribute yet) โฆ ready for โฆ
- new โemailโ or โsmsโ Dictation word logic to try to focus to respective (Email โiemailโ or SMS โismsโ) textbox โฆ triggering ..,.
- respective (Email โiemailโ or SMS โismsโ) textbox โplaceholderโ attribute sets โvalueโ attribute to that localStorage derived setting โฆ
- dictated โemail inviteโ will send an email invitation via PHP mail rather than the extra interactions of using an โaโ โmailto:โ email client application link (as you can see with todayโs tutorial picture)
Of course thereโs more โhands freeโ (logic) to go, but consider โHey Siriโ or other ways to get to the webpageโs web application, and the dream is gradually becoming a reality.
Todayโschanged php_listenerphpโs chat
web application now also interfaces to achanged speech_supervisor
php PHP code for โDictationโ functionalities.
Previous relevant Chat No Sockets Dictation Tutorial is shown below.
Weโve got a couple of concepts onto yesterdayโs Chat No Sockets Media Tutorial progress, those being โฆ
- allow, at least for Google Chrome web browsing, โDictationโ Speech to Text functionality thanks to Google Speech to Text functionality we last would have referenced with Looks Nice Nearby Speech to Text Game Video Tutorial โฆ and associated with an overall aim for โhands freeโ (as well) โฆ
- on some browsers weโve succeeded playing a B
eeoop sound when your Chat collaborator โchat lineโ has arrived, and weโd like to thank this excellent link for the methodology used โฆ Javascript โฆ
var a=null;
if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
a=new AudioContext(); // browsers limit the number of concurrent audio contexts, so you better re-use'em
}
function beep(vol, freq, duration) { // thanks to https://odino.org/emit-a-beeping-sound-with-javascript/
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
navigator.vibrate(200);
} else if (a) {
v=a.createOscillator();
u=a.createGain();
v.connect(u);
v.frequency.value=freq;
v.type="square";
u.connect(a.destination);
u.gain.value=vol*0.01;
v.start(a.currentTime);
v.stop(a.currentTime+duration*0.001);
}
}
function mosay(instuff) {
document.getElementById('bboop').click(); //beep(999, 220, 300);
return instuff;
}
โฆ to work with HTML โฆ
<button style='display:none;' id=bboop onclick='beep(999, 220, 300);'>Boop</button>
Todayโschanged php_listenerphpโs chat
web application now also interfaces to achanged speech_supervisor
php PHP code for โDictationโ functionalities.
Previous relevant Chat No Sockets Media Tutorial is shown below.
Adding to yesterdayโs Chat No Sockets Imagery Tutorial โฆ
- image functionality โฆ thereโs more to โmediaโ in the online wooooorrrrrlllllldddd than just images, and so today โฆ we add the possibility for โฆ
- audio
- video
โฆ sharing capabilities with our inhouse Chat web application. We need to turn to a โhelperโ that uses the HTML5 File API, and the recent one we almost immediately thought of (after some small room ruminations) that recent โVoiceoverโ ideas web application (which became a helper, in turn, to the โHaikuโ creator web application (connected to the knee bone)).
An awkward single โaโ link seemed a bit forlorn in view of these Chat data functionality extensions, and so we constructed two Animated Emoji Button โaโ/โspanโ sets utilizing the Javascript โthrobbingspans()โ function as per โฆ
var tgsps=[], tgspsop=[], newres='', preurl='', tgspsopwhat=[];
// Eg. of html <a style='text-decoration:underline;cursor:pointer;' onclick=\"divfbit(); location.href='#ifimg'; \" title='Image Canvas'><span title='Animated Emoji' style='opacity: 0.4; font-size: 32px;'>🖼</span><span style='margin-left: -32px; opacity: 0.4; font-size: 32px;'>🎨</span></a>
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];
} 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];
} 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];
} 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];
} 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];
} 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];
}
}
setTimeout(throbbingspans, 900);
}
}
Todayโschanged php_listenerphpโs chat
web application now also interfaces to achanged macos_say_record
php PHP code for โVoiceoverโ audio and video creation functionalities.
Previous relevant Chat No Sockets Imagery Tutorial is shown below.
SMS moved on many years ago from a text based content system onto one that these days allows media sharing, as well, so we should allow for this too, adding onto the functionality of yesterdayโs Chat No Sockets SMS Invitation Tutorial.
We wanted to do this by interfacing to an inhouse web application that allows for canvas graphical data creation, and then onto the Chat invitee as imagery (via the [canvas].toDataURL method). For this we decided to interface to the inhouse โFeedbackโ web application.
At regular intervals we call the โFeedbackโ web application, flagging it to regularly check for changed canvas data conditions, in which case our parent โChatโ web application table cell like โฆ
<td id=thi style='background-size:contain;background-repeat:no-repeat;background-color:white;'></td>
โฆ is given a background image (later passed onto your Chat collaborator) via Javascript DOM (that is the onload event logic of a child iframe to the parent Chat (PHP) web application) such as โฆ
function zcheckitagain(iois) {
if (iois != null) {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
if (aconto.body.innerHTML != '') {
if (aconto.body.innerHTML.indexOf('"da' + 'ta:') != -1) {
parent.otherimgdatauri='data:' + aconto.body.innerHTML.split('"da' + 'ta:')[1].split('"')[0];
parent.document.getElementById('thi').style.backgroundImage='URL(' + parent.otherimgdatauri + ')';
} else if (aconto.body.innerHTML.indexOf("'da" + 'ta:') != -1) {
parent.otherimgdatauri='data:' + aconto.body.innerHTML.split("'da" + 'ta:')[1].split("'")[0];
parent.document.getElementById('thi').style.backgroundImage='URL(' + parent.otherimgdatauri + ')';
}
}
}
}
}
}
Thechanged php_listenerphpโs chat
web application โfourth draftโ interfacing to the canvas functionality of the โFeedbackโ web application, and helped out by thechanged external Javascript world
js code.
Previous relevant Chat No Sockets SMS Invitation Tutorial is shown below.
Yesterdayโs Chat No Sockets Session Tutorial gives us an opportunity to become more โgranularโ with our examination of nuances to โฆ
- the web applicationโs โsurfing the webโ look and aesthetics (first look) and usage practicalities (involving button disabling/enabling at appropriate places in the PHP code (writing Javascript logic)) โฆ and โฆ a bit gobsmacking to us โฆ
- the need to place a two step logic โtidy upโ of obsolete files when dealing with SMS Invitations (to Chat)
โฆ the latter being that we discovered that โฆ
- between the point an inviter opens their SMS Messaging app with a populated message that is the URL our Chat web application wants the inviter to send โฆ and โฆ
- that inviter typing the carriage return character that โrendersโ that SMS that is sent to the invitee โฆ but โฆ
- before the invitee even sees the SMS
โฆ that URL โrenderโ causes an (unexpected to us) real visit of our web server code, and we need to just let the โlook ofโ the โresultant SMS webpageโ through at this point, but leave โthe implicationsโ for the next time this โSMS webpageโ is asked for when the invitee clicks/taps the SMS link they receive from the inviter. The timing of all this is controlled in the logic by the existence of a (what used to be exclusively) โchat_*.lineโ file, but we now need (to allow for โchat_*.lin2โ then โchat_*.lineโ) as per โฆ
On clicking the โInviteโ button, having filled out the โSMS numberโ field (rather than the Email one) |
---|
function butlogic() { if (document.getElementById(โismsโ).value.trim() != โ) { document.getElementById(โjchildโ).src=document.URL.split(โ#โ)[0].split(โ?โ)[0] + โ?sid=โ . $enduring . โ&address=โ + encodeURIComponent(document.getElementById(โismsโ).value + โ#โ) + โ&ipaddress=โ + encodeURIComponent(โโ . $sra . โโ) + โ&ichat=โ + encodeURIComponent(document.getElementById(โichatโ).value); var wasasms=document.getElementById(โasmsโ).href; if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { document.getElementById(โasmsโ).href=(document.getElementById(โasmsโ).href.replace(โ:&โ,โ:โ + document.getElementById(โismsโ).value + โ&โ) + encodeURIComponent(document.URL.split(โ#โ)[0].split(โ?โ)[0]) + encodeURIComponent(โ?address=โ + dummyencodeURIComponent(encodeURIComponent(document.getElementById(โismsโ).value)) + โ#โ)); } else { document.getElementById(โasmsโ).href=(document.getElementById(โasmsโ).href.replace(โ:&โ,โ:โ + document.getElementById(โismsโ).value + โ&โ) + encodeURIComponent(document.URL.split(โ#โ)[0].split(โ?โ)[0]) + encodeURIComponent(โ?address=โ + encodeURIComponent(encodeURIComponent(document.getElementById(โismsโ).value)) + โ#โ)); } document.getElementById(โasmsโ).click(); document.getElementById(โasmsโ).href=wasasms; } else if (document.getElementById(โiemailโ).value.indexOf(โ@โ) != -1) { document.getElementById(โjchildโ).src=document.URL.split(โ#โ)[0].split(โ?โ)[0] + โ?sid=โ . $enduring . โ&address=โ + encodeURIComponent(document.getElementById(โiemailโ).value) + โ&ipaddress=โ + encodeURIComponent(โโ . $sra . โโ) + โ&ichat=โ + encodeURIComponent(document.getElementById(โichatโ).value); document.getElementById(โaemailโ).href=(document.getElementById(โaemailโ).href.replace(โ:?โ,โ:โ + document.getElementById(โiemailโ).value + โ?โ) + encodeURIComponent(document.URL.split(โ#โ)[0].split(โ?โ)[0]) + encodeURIComponent(โ?address=โ + encodeURIComponent(document.getElementById(โiemailโ).value))); document.getElementById(โaemailโ).click(); document.getElementById(โaemailโ).href=wasaemail; } } |
Where the child iframe call above lobs onto in order to create an interim file |
} else if (isset($_GET[โaddressโ]) && isset($_GET[โipaddressโ])) { if (strpos(str_replace(โ@โ,โโ,str_replace(โ+โ,โ โ,urldecode($_GET[โaddressโ]))), โ#โ) !== false) { file_put_contents(โchat_โ . explode(โ#โ, str_replace(โ@โ,โโ,str_replace(โ+โ,โ โ,urldecode($_GET[โaddressโ]))))[0] . โ__โ . str_replace(โ+โ,โ โ,urldecode($_GET[โipaddressโ])) . โ.RLSโ, str_replace(โ+โ,โ โ,urldecode($_GET[โichatโ]))); } else { file_put_contents(โchat_โ . explode(โ#โ, str_replace(โ@โ,โโ,str_replace(โ+โ,โ โ,urldecode($_GET[โaddressโ]))))[0] . โ__โ . str_replace(โ+โ,โ โ,urldecode($_GET[โipaddressโ])) . โ.rlsโ, str_replace(โ+โ,โ โ,urldecode($_GET[โichatโ]))); } exit; |
Where the โcommand lineโ usage part does its bit to appropriately rename those interim files |
if ($argv) { // command line โฆ $cfindings=โโ; $goes=0; $howmanygoes=โ-1โณ; $par=getenv(โTERMโ); // thanks to https://stackoverflow.com/questions/3214935/can-a-bash-script-tell-if-its-being-run-via-cron if (โ$parโ == โโ || โ$parโ == โdummyโ) { // via cron $cfindings1=exec(โcrontab -l | grep โphp_listenerโ | grep -v โgrepโ | cut -d โ โ -f 1โ); $cfindings2=exec(โcrontab -l | grep โphp_listenerโ | grep -v โgrepโ | cut -d โ โ -f 2โ); $cfindings3=exec(โcrontab -l | grep โphp_listenerโ | grep -v โgrepโ | cut -d โ โ -f 3โ); $cfindings4=exec(โcrontab -l | grep โphp_listenerโ | grep -v โgrepโ | cut -d โ โ -f 4โ); $cfindings5=exec(โcrontab -l | grep โphp_listenerโ | grep -v โgrepโ | cut -d โ โ -f 5โ); if (strpos($cfindings1, โ*/โ) !== false) { $howmanygoes=12 * explode(โ*/โ, $cfindings1)[1]; } else if (strpos($cfindings2, โ*/โ) !== false) { $howmanygoes=720 * explode(โ*/โ, $cfindings2)[1]; } else if (strpos($cfindings3, โ*/โ) !== false) { $howmanygoes=17280 * explode(โ*/โ, $cfindings3)[1]; } } while (1) { foreach (glob(dirname(__FILE__) . โ/chat_*.rlsโ) as $ourfilename) { rename($ourfilename, explode(โ.rlsโ, $ourfilename)[0] . โ.lineโ); } foreach (glob(dirname(__FILE__) . โ/chat_*.RLSโ) as $ourfilename) { rename($ourfilename, explode(โ.RLSโ, $ourfilename)[0] . โ.lin2โ); } if ($howmanygoes >= 0) { $goes++; if ($goes >= $howmanygoes) { exit; } } sleep(5); } exit; } |
Where the โcommand lineโ usage partโs renamed file is found by the web application and the two step deletion is needed |
} else { // here from email or SMS link $sra=โโ; $cont=โโ; foreach (glob(โchat_โ . str_replace(โ@โ,โโ,str_replace(โ+โ,โ โ,urldecode($_GET[โaddressโ]))) . โ__*.lin*โ) as $ourfilename) { $sra=explode(โ.โ,explode(โchat_โ . str_replace(โ@โ,โโ,str_replace(โ+โ,โ โ,urldecode($_GET[โaddressโ]))) . โ__โ, $ourfilename)[1])[0]; $scont=file_get_contents($ourfilename); $cont=$scont . โ<br>โ; if (trim($scont) != โโ) { $scont=โ โฆ starting with โโ . file_get_contents($ourfilename) . โโโ; } if (strpos($ourfilename, โ.lin2โ) !== false) { rename($ourfilename, explode(โ.lin2โ, $ourfilename)[0] . โ.lineโ); $datait=โ data-โ; } else { unlink($ourfilename); } } echo โ<!doctype html> // etcetera etcetera etcetera <body โ . $datait . โonload=โonlis();โ> // etcetera etcetera etcetera โ; |
So yet again, feel free to try thechanged (including โsessionโ logic) php_listenerphpโs chat
web application โthird draftโ.
Previous relevant Chat No Sockets Session Tutorial is shown below.
Back from the โcommand lineโ PHP usage of yesterdayโs Chat No Sockets Cron Tutorial that dayโs thinking about how to improve the โsurfing the netโ parts of the Chat web application weโre developing got us starting to involve PHP โฆ
โฆ and canโt they just be really useful as the identifying methodology to hone in on a webpage session of interest, and exclude all irrelevant others โฆ
<?php
session_start();
$enduring='' . session_id();
if (isset($_GET['sid'])) {
$enduring=str_replace("+"," ",urldecode($_GET['sid']));
} else if (isset($_POST['sid'])) {
$enduring=str_replace("+"," ",urldecode($_POST['sid']));
}
$dbit=' data-oe="" ';
function server_remote_addr() {
global $enduring;
$rma = $_SERVER['REMOTE_ADDR'];
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
// you can add different browsers with the same way ..
if(preg_match('/(opr)[ \/]([\w.]+)/', $ua))
$rma = '000'.$rma;
elseif(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;
return str_replace(".", "x", str_replace(":", "x", $rma . $enduring));
}
?>
โฆ the only nuance being that iframe children get their session IDs mapped to that of the parent via that โsidโ argument above.
And so todayโs work represents a โshoring upโ day for the basis for a Chat, and a relief that this โbetter honingโ also meant that we no longer needed to tweak those pesky $_SERVER[โHTTP_USER_AGENTโ] combinations (a dark art indeed).
So again, feel free to try thechanged php_listenerphpโs chat
web application โthird draftโ.
Previous relevant Chat No Sockets Cron Tutorial is shown below.
Yesterdayโs Chat No Sockets Primer Tutorial had a โcommand lineโ PHP usage component, we wonder whether you noticed? We intend to keep this arrangement for our โno socketsโ Chat web application. It will not function as that โChatโ without the command line part of the โequationโ being activated. You might think of it as the โtraffic copโ of the web application.
As far as that โcommand lineโ PHP usage goes โฆ
- Isnโt it great to have the one code source for all this?
- How are we going to manage this command line usage, out of โฆ
- interactive in an interactive command line session
- set off a background process run of it via the โ&โ suffix
- crontab it (on our Linux web server)
?
Suggestion 1 is kludgy, over the top and awkward to arrange for any long period of time, though useful if non-continuous โprocess coverageโ is the go.
Suggestion 2 and 3 are great for โcontinuous process coverageโ (we privately think of as โjigsaw coverageโ), but in our books (and the pamphlettes have scarpered it to Pamphlette Island โฆ which they must intend on โfoundingโ?!) crontab is a better option to take for at least two reasons โฆ
- crontab resurrects itself on a system reboot
- crontab is self documenting (an important advantage regarding command line processing usage)
โฆ but if we are to use crontab โjigsaw coverageโ, to avoid โjigsaw overlapโ weโre going to have to change โฆ regarding โฆ
โโโโโโโโโโโ minute (0 โ 59)
โ โโโโโโโโโ hour (0 โ 23)
โ โ โโโโโโโ day of month (1 โ 31)
โ โ โ โโโโโ month (1 โ 12)
โ โ โ โ โโโ day of week (0 โ 6 => Sunday โ Saturday, or
โ โ โ โ โ 1 โ 7 => Monday โ Sunday)
โ โ โ โ โ
* * * * * command to be executed
โฆ thanks to https://stackoverflow.com/questions/18919151/crontab-day-of-the-week-syntax for above crontab syntax โฆ as per ( our assumption being that the user will use one of the โevery ? unitsโ syntax such as
*/6 * * * * php this_php_happens_every_six_minutes.php
) โฆ
To <โ | <โ From |
---|---|
|
|
Again, feel free to try thechanged php_listenerphpโs chat
web application โsecond draftโ.
Previous relevant Chat No Sockets Primer Tutorial is shown below.
Weโre starting on a new PHP web application project. Weโve got a โfirst draftโ of a chat web application that does not use sockets, but rather โฆ
- invites somebody else (via โInviteโ button) via email or SMS
- that โsomebody elseโ opens the web application via email or SMS links
- from then on keep the chat going via โSendโ buttons in the two chat incarnations
It needs more work, that is for sure, but perhaps you want to see php_listenerphpโs chat
web application โfirst draftโ.
As with good learning between two parties, each listens, takes it in, and replies, as required.
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.