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

Clairvoyance Game Chat Tutorial

Clairvoyance Game Chat Tutorial

Clairvoyance Game Chat Tutorial

Stepping back from the Clairvoyance++ Game project, of recent times, further to the recent Clairvoyance Game IP Address Links Tutorial it occurred to us just this morning how similar …

  • User Questions mode … is to …
  • a Chat web application

… and so we may as well build on the “connection work” already there, and bedded down, to also offer a two user Chat conversation set of functionalities, as a new dropdown option the user can choose.

New ideas are all fine and good, as long as it is not a pain in the neck to organize, fitting in with other dropdown option functionalities, and with this in mind, invented a new argument “itype” value of zero, it not having been used yet, and not interfering with window.localStorage “starting itype value” considerations.

You can try “Chat” as a new option in …


Previous relevant Clairvoyance Game IP Address Links Tutorial is shown below.

Clairvoyance Game IP Address Links Tutorial

Clairvoyance Game IP Address Links Tutorial

We’re not here, today, to in any way criticize the Javascript prompt window, and it’s (harkening back to the desktop application wooooorrrrrllldd in it’s feel) interactive talents, that wee bit removed and independent from webpage goings on. In fact, it is modal (ie. is capable of freezing the Javascript) and this talent needs to be used in the apt place, but is the easiest “modal means” when that is required.

Where it is not as useful, in it’s operating system origins, is it’s lack of colour coding possibilities, and it happens, today, that our work to improve on yesterday’s Clairvoyance Game Textarea Onblur Tutorial regarding creating IP Address Other Player links, can be all the more useful with some colour coding. We have these “colour modes of operation” going, today, as per …

  • IP Address Other Player comma separated links list alternates among …
    1. flash of yellow background on first showing, else white background
    2. blue font … for IP Address of current player … else …
    3. black font … alternating with …
    4. white fonts … shortly after window.prompt answer made … except for …
  • orange background is given to users “just arrived on the scene since last black/blue font incarnation” … and can persist through white fonts and pushed to start of links list

… perhaps helping users “hook up” with other users they are in contact with, and can invite, via these “just logged in” identifications.

Feel free to retry …


Previous relevant Clairvoyance Game Textarea Onblur Tutorial is shown below.

Clairvoyance Game Textarea Onblur Tutorial

Clairvoyance Game Textarea Onblur Tutorial

Further to the day before yesterday’s Clairvoyance Game Element Type Tutorial it’s in that form allowing users to design their own Clairvoyance Game style of game we harness …

the powers of the onblur event

… that great event to intervene with when processing the content of …

  • many input type elements
  • textarea
  • myriad of innerHTML friendly elements involving global attribute contenteditable=true

via


<textarea onblur=maybeif(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='House'; document.getElementById('two').value='Thing'; " rows=2 style=width:90%; type=text placeholder='Image Map HTML URL eg. https://www.rjmprogramming.com.au/HTMLCSS/livingroom.htm' value='' name=three id=three></textarea><br><span> ... or ...</span><br>
<textarea onblur=numdotsonly(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='Counting Number'; document.getElementById('two').value='Number'; " rows=3 style=width:90%; type=text placeholder='Comma separated list of 5 Emoji Decimal HTML Entity Values eg. for Game Name Words value of Counting Number (where . can facilitate complex emojis and the #span creates span elements) could be 49.65039.8419,50.65039.8419,51.65039.8419,52.65039.8419,53.65039.8419#span' value='' name=four id=four></textarea><br><span> ... or ...</span><br>
<textarea onblur=perhapsiframes(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='Fish'; document.getElementById('two').value='Fish'; " rows=3 style=width:90%; type=text placeholder='Comma separated list of 5 Image URLs eg. for Game Name Words value of Fish could be //fishesofaustralia.net.au/images/thumbnailimage/NarcetesErimelasAlcock.jpg,//fishesofaustralia.net.au/images/thumbnailimage/LutjansuBengalensisuwkwaj.jpg,//fishesofaustralia.net.au/images/thumbnailimage/GobiodonSpadix2Holotype.jpg,//fishesofaustralia.net.au/images/thumbnailimage/SebastapistesMonospinaRandallHolotype.jpg,//fishesofaustralia.net.au/images/thumbnailimage/AmblyeleotrisBellicaudaRandall.jpg' value='' name=five id=five></textarea><br><br>

… to allow for many more scenarios a user might apply entering in various URLs or text data or hashtagging “switches”, as per …


function perhapsiframes(tao) {
var badcnt=0, compext='', jj=0, potnew='', othercnt=0, otherthing='';
if (tao.value != '') {
var ims=tao.value.split('#');
if (eval('' + ims.length) < 2) {
potnew=tao.value + '#iframe';
var intrms=ims[0].replace(/\;base64\,/g,';base64c').replace(/\;utf8\,/g,';utf8c').split(',');
for (jj=0; jj<intrms.length; jj++) {
intrms[jj]=intrms[jj].replace(';base64c',';base64,').replace(';utf8c',';utf8,')
if (intrms[jj].indexOf('data:') == 0) {
if (intrms[jj].indexOf('data:image/') == -1) {
badcnt++;
if (jj == 0) {
otherthing=intrms[jj].split('data:')[1].split('/')[0];
othercnt++;
} else if (otherthing == intrms[jj].split('data:')[1].split('/')[0]) {
othercnt++;
}
}
} else if (intrms[jj].indexOf('/') != -1) {
if (intrms[jj].indexOf('.') == -1) {
badcnt++;
} else {
compext='.' + intrms[jj].split('.')[eval(-1 + intrms[jj].split('.').length)].split('?')[0].split('&')[0].split('#')[0].toLowerCase();
if (xexts.indexOf(compext) != -1) {
if (xtypes[eval('' + xexts.indexOf(compext))].indexOf('image/') != 0) {
badcnt++;
if (jj == 0) {
otherthing=xtypes[eval('' + xexts.indexOf(compext))].split('/')[0];
othercnt++;
} else if (otherthing == xtypes[eval('' + xexts.indexOf(compext))].split('/')[0]) {
othercnt++;
}
}
} else {
badcnt++;
}
}
}
}
}
//alert(badcnt);
var comma=',';
if (othercnt == eval('' + intrms.length)) {
potnew=potnew.replace('#iframe', '#' + otherthing.replace('text','embed'));
tao.value=potnew;
} else if (badcnt == eval('' + intrms.length)) {
for (jj=eval(-1 + intrms.length); jj>=0; jj--) {
if (jj == 0) { comma=''; }
if (intrms[jj].toLowerCase().indexOf('http') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(intrms[jj]));
} else if (intrms[jj].indexOf('//') != -1) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + intrms[jj].split('//')[1]));
} else if (intrms[jj].indexOf('/') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj]));
} else if (intrms[jj].indexOf('./') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj].substring(1)));
} else if (intrms[jj].indexOf('../') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj].substring(2)));
} else {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + '/' + intrms[jj]));
}
}
tao.value=potnew.replace(/\/\/www\.rjmprogramming\.com\.au\/recording\_ideas\.php\?/g, document.URL.split(':')[0] + '://www.rjmprogramming.com.au/recording_ideas.php?');
}
}
}

function numdotsonly(ttxao) {
if (ttxao.value != '') {
var hsta=ttxao.value.split('#');
if (hsta[0] != '') {
if (hsta[0].replace(/\./g,'').replace(/\,/g,'').replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
return ttxao;
} else {
var newhtz=hsta[0].toHtmlEntities();
var inimter=newhtz.replace(/\&\#44\;/g,',').replace(/\&\#46\;/g,'.');
var insmtr=inimter.split('&#');
for (var jj=1; jj<insmtr.length; jj++) {
if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) >= '0' && String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) <= '9') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('0:' + inimter);
} else if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) == '.') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('1:' + inimter);
} else if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) == ',') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('2:' + inimter);
} else {
inimter=(inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', '.' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + '.')).replace(/\.\./g,'.').replace(/^\./g,'').replace(/\.$/g,'').replace(/\.\,\./g,',').replace(/\.\,/g,',').replace(/\,\./g,',');
//alert('3:' + inimter);
}
}
//ttxao.value=newhtz.replace(/\&\#44\;/g,',').replace(/\&\#46\;/g,'.').replace(/\&\#/g,'').replace(/\;/g,'') + (eval('' + hsta.length) > 1 ? '#' + hsta[1] : '');
ttxao.value=inimter.replace(/\&\#/g,'').replace(/\;/g,'') + (eval('' + hsta.length) > 1 ? '#' + hsta[1] : '');
//alert(newhtz + ' ' + ttxao.value);
}
}
}
return ttxao;
}

function maybeif(tao) {
if (tao.value.trim() != '' && tao.value.trim().indexOf('//') != -1) {
justvalidity=true;
document.getElementById('ifimc').src='//' + tao.value.trim().split('//')[1];
setTimeout(function(){ justvalidity=false; }, 8000);
}
}

… sometimes resorting to QR Codes as a representation of a URL should we not be able to extract any data from that URL, in a changed latest draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Element Type Tutorial is shown below.

Clairvoyance Game Element Type Tutorial

Clairvoyance Game Element Type Tutorial

Today’s blog posting work …

… to make those User Bonus Score questions and answer default suggestions have lots more variety.

Also, today, we use the oninput event means by which we can stop the user entering particular delimiter characters we hope they do not use defining Game Names and Game Nouns …


<input oninput='this.value=this.value.replace(/[+|"#]/g, " ");' style=width:90%; type=text placeholder='Game Name Words' onblur="if (this.value.trim() != '' && document.getElementById('two').value.trim() == '') { document.getElementById('two').value=this.value; }" value='' name=one id=one></input><br>
<input oninput='this.value=this.value.replace(/[+|"#]/g, " ");' style=width:90%; type=text placeholder='Game Noun(s)' value='' name=two id=two></input><br><hr></hr>

And, today, we allow the user to hashtag enter an HTML element type as the output element type output within the five table cells of the game, exemplified by


function fireup() {
var thisiw=theiw;
var zrect=document.getElementById('td1').getBoundingClientRect();
if (thisiw >= eval('' + thewords.length)) { thisiw=0; }
for (var ii=1; ii<=5; ii++) {
if (document.getElementById('td' + ii).outerHTML.indexOf('background') == -1 && window.parent == window.self) {
//alert(theelems[thisiw] + ' ... ' + zener_cards[eval(-1 + ii)]);
if (theelems[thisiw].indexOf('<img ') == 0) {
//document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + ' id=img' + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + ' id=img' + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
} else if (usereletype != '') {
document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + " id=img" + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
//alert('1:' + document.getElementById('td' + ii).innerHTML);
if (document.getElementById('img' + ii).title != '' && ('' + document.getElementById('img' + ii).innerHTML).replace(/^null/g,'').replace(/^undefined/g,'') == '') {
if ((document.getElementById('img' + ii).title + zener_cards[0]).indexOf('&#') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
if (dataeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
//alert(0);
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
//alert(10);
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (valueeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (srceltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else {
document.getElementById('img' + ii).innerHTML=document.getElementById('img' + ii).title.split('|')[1];
}
//alert('2:' + document.getElementById('td' + ii).innerHTML);
} else {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url(' + document.getElementById('img' + ii).title.split('|')[1] + ')';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
//alert('3:' + document.getElementById('td' + ii).outerHTML);
}
}

} else {
if (dataeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
//alert(0);
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
//alert(10);
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (valueeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (srceltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else {

document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + " id=img" + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
}
}
//document.getElementById('td' + ii).style.background="url('" + zener_cards[eval(-1 + ii)] + "')";
//document.getElementById('td' + ii).style.backgroundSize='contain';
//document.getElementById('td' + ii).style.backgroundRepeat='no-repeat';
//alert(ii);
}
}
}

… in …


Previous relevant Clairvoyance Game Scoring Bonus Tutorial is shown below.

Clairvoyance Game Scoring Bonus Tutorial

Clairvoyance Game Scoring Bonus Tutorial

When a game scores and it’s got a non-aspirational feel about it, it can turn off some potential players. And so, with this in mind, onto yesterday’s Clairvoyance Game User Definitions Tutorial we now offer some optional bonus scoring functionality to also involve either …

  • Maths questions
  • User created questions

Either player can ask for this additional challenge involving …


Previous relevant Clairvoyance Game User Definitions Tutorial is shown below.

Clairvoyance Game User Definitions Tutorial

Clairvoyance Game User Definitions Tutorial

The day before yesterday’s Clairvoyance Game Image Map Tutorial work gets incorporated into today’s work allowing a three type way, as per …

  1. Image Map HTML URL
  2. Emoji list of 5
  3. Image URL list of 5

… means by which a user might design their own game to add to the dropdown list, and store in …


window.localStorage

… within the realms of the web browser being used. Then that newly created user defined game can be shared when invoking email or SMS invitations, and can get added to in that Game type dropdown, where another “Your Own …” suboption brings up the HTML form (and there, some textarea element double click logics might help with the filling out, and/or “modelling the filling out” for you) where the user can create and control these definitions.

Feel free to try this all out within a changed seventh draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Image Map Tutorial is shown below.

Clairvoyance Game Image Map Tutorial

Clairvoyance Game Image Map Tutorial

With our Clairvoyance++ Game project of recent times, before yesterday’s Clairvoyance Game Waiting Tutorial there was the day before yesterday’s Clairvoyance Game Sharing Scores Tutorial, where we “objectified” the project. Today’s job is to add into that “objectify mix” …


Image Map

… integration, where the …

  • HTML containing the …
  • Image img element’s …
  • Map map element guillotining … via …
    1. area element shape=”rect” … or …
    2. area element shape=”poly”

    subelements

… can be referenced to fill in new Clairvoyance++ Game looking incarnations as well as a means, via background image of a newly “top part of webpage” HTML div element, clicking means by which the original image map action item can be reopened, as well.

We think, at this stage, that we want to offer the user some “own incarnation” functionality eventually, and we’d like to add this image map idea into the mix. We’ll see about that later, but for now we have the modelled new dropdown options below …


var zener_cards=['/circle_yellow.jpg#circle_yellow','/cross_red.jpg#cross_red','/waves_blue.jpg#waves_blue','/square_black.jpg#square_black','/star_green.jpg#star_green'];

var theword='Clairvoyance';
var thenoun='Zener Card';
var theelem="<img style='object-fit:contain;' src=";
var thewords=['Clairvoyance', 'Fruit', 'Food', 'Animal', 'Bird', 'Carpentry', 'London', 'India', 'Australian Indigenous Language', 'Cell'];
var theelems=["<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src="];
var theihs=[">", ">", ">", ">", ">", ">", ">", ">", ">", ">"];
var thenouns=['Zener Card', 'Fruit', 'Meal', 'Creature', 'Bird', 'Framework Feature', 'Day', 'State', 'Language Area', 'Cell Part'];
var theiw=(document.URL.indexOf('itype=') != -1 ? eval(-1 + eval('' + document.URL.split('itype=')[1].split('&')[0].split('#'))) : 0);

if (theiw > 0) {
zcblurb='';
document.title=document.title.replace('Clairvoyance ', thewords[theiw] + ' ');
if (thewords[theiw] == 'Food') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#x1f35b;';
zener_cards[1]+='|&#x1f371;';
zener_cards[2]+='|&#x1f358;';
zener_cards[3]+='|&#x1f359;';
zener_cards[4]+='|&#x1f363;';
} else if (thewords[theiw] == 'Fruit') { // '127825', '127825', '127818', '127827', '127821'
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#127817;';
zener_cards[1]+='|&#127825;';
zener_cards[2]+='|&#127818;';
zener_cards[3]+='|&#127827;';
zener_cards[4]+='|&#127821;';
} else if (thewords[theiw] == 'Animal') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#128018;';
zener_cards[1]+='|&#129421;';
zener_cards[2]+='|&#129447;';
zener_cards[3]+='|&#128054;';
zener_cards[4]+='|&#128021;';
} else if (thewords[theiw] == 'Bird') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/bird_quiz.htm" style="object-fit:contain;" src="';
} else {
theelems[theiw]='<img data-url="/bird_quiz.htm" style="object-fit:contain;" src="';
}
theihs[theiw]='>';
zener_cards[0]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#8,5,374,370';
zener_cards[1]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#374,5,930,370';
zener_cards[2]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#930,5,1164,370';
zener_cards[3]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#1164,5,1500,370';
zener_cards[4]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#5,680,374,1120';
} else if (thewords[theiw] == 'Carpentry') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/floor_wall_roof_framing_members.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/floor_wall_roof_framing_members.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'London') {
delay=8000;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/london_trip_via_map_element.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/london_trip_via_map_element.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'India') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/india_map.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/india_map.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'Australian Indigenous Language') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/ImageMap/Languages/aboriginal_language_regions.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/ImageMap/Languages/aboriginal_language_regions.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'Cell') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/the_cell.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/the_cell.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';

}
}

var sideas=['Awaiting Other Player Choosing a ' + thenouns[theiw] + ' to Guess','Select the ' + thenouns[theiw] + ' Your Player Partner Selected','Select a ' + thenouns[theiw] + ' You Are Asking Your Player Partner to Guess','Awaiting Guess from Your Player Partner','Awaiting a ' + thenouns[theiw] + ' Selection from Your Playing Partner'];

… working with the cropping and resizing smarts the HTML canvas element is capable of …


function imc(iois) {

var aconto=null, prefixing='', ipr=0, minx=0, miny=0, maxx=0, maxy=0, donesofar=',';
if (iois.src.indexOf('/About_Us.htm') == -1) {
aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
//alert('' + aconto.body.innerHTML.indexOf('<area ') + '!' + aconto.body.innerHTML.split(' shape="rect"').length + '?' + iois.src + ';' + aconto.body.innerHTML.split('<map ')[0].split('<img ')[eval(-1 + aconto.body.innerHTML.split('<map ')[0].split('<img ').length)] + ':' + aconto.body.innerHTML);
if (eval('' + aconto.body.innerHTML.indexOf('<map ')) > eval('' + aconto.body.innerHTML.indexOf('<img ')) && aconto.body.innerHTML.indexOf('<map ') != -1 && aconto.body.innerHTML.indexOf('<img ') != -1 && aconto.body.innerHTML.indexOf('<area ') != -1 && aconto.body.innerHTML.replace(/shape\=\"poly\"/g,'shape="rect"').indexOf('shape="rect"') != -1) {
//alert('000:' + '');
if (aconto.body.innerHTML.indexOf('shape="rect"') == -1) {
prefixing=' ';
//if (document.URL.indexOf('&debug=') != -1) { alert('yes'); }
}
wourl=iois.src;
coordsarr=aconto.body.innerHTML.replace(/shape\=\"poly\"/g,'shape="rect"').split('shape="rect"');
//alert('0000:' + coordsarr.length);
if (eval('' + coordsarr.length) > 5) {
//alert('00:' + '');
imname=aconto.body.innerHTML.split('<map ')[0].split('<img ')[eval(-1 + aconto.body.innerHTML.split('<map ')[0].split('<img ').length)];
//alert('0:' + imname);
imname=imname.split('src="')[1];
//alert('1:' + imname);
imname=imname.split('"')[0];
//alert('2:' + imname);
if ((imname + 'x').indexOf('//') != -1 || (imname + 'x').indexOf('data:') == 0) { // || (imname + 'x').substring(0,1) == '/') {
if ((imname + 'x').indexOf('data:') == 0) {
imname=imname;
} else {
imname='//' + imname.split('//')[1];
}
} else if ((imname + 'x').substring(0,1) == '/') {
if (iois.src.indexOf('//') != -1) {
imname='//' + iois.src.split('//')[1].split('/')[0] + '/' + imname.substring(1);
} else {
imname='//www.rjmprogramming.com.au/' + imname.substring(1);
}
} else if ((imname + 'xxxxxxxxx').substring(0,12) == '../../../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-5 + iois.src.split('/').length)], imname.substring(12) + '#');
} else if ((imname + 'xxxxxxxxx').substring(0,9) == '../../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-4 + iois.src.split('/').length)], imname.substring(9) + '#');
} else if ((imname + 'xxxxxx').substring(0,6) == '../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-3 + iois.src.split('/').length)], imname.substring(6) + '#');
} else if ((imname + 'xxx').substring(0,3) == '../') {
imname=iois.src.replace(iois.src.split('/')[eval(-2 + iois.src.split('/').length)], imname.substring(3) + '#');
} else if ((imname + 'xx').substring(0,1) == './') {
imname=iois.src.replace(iois.src.split('/')[eval(-1 + iois.src.split('/').length)], imname.substring(2));
} else {
imname=iois.src.replace(iois.src.split('/')[eval(-1 + iois.src.split('/').length)], imname.substring(0));
}
}

//alert(imname.split(' ')[0] + ' ' + coordsarr[1]);
imlist=document.getElementsByTagName('img');
tds=document.getElementsByTagName('td');
squaredim=eval('' + tds[0].getBoundingClientRect().width);
document.getElementById('dtop').style.background='linear-gradient(rgba(255,255,255,0.1),rgba(255,255,255,0.1)),url(' + imname.split(' ')[0] + ')';
document.getElementById('dtop').style.backgroundRepeat='no-repeat';
document.getElementById('dtop').style.backgroundSize='contain';
document.getElementById('dtop').style.backgroundPosition='right top';
document.getElementById('dtop').onclick=function(event){ event.stopPropagation(); window.open(wourl,'_blank','top=50,left=50,width=600,height=600'); };

var imgis=new Image();
imgis.onload = function(){
var ict=1, jct=1;
var zcanvas = document.createElement('canvas');
zcanvas.width = squaredim; //imgis.width;
zcanvas.height = squaredim; //imgis.height;
var zctx = zcanvas.getContext('2d');
if (!randomize) {
while (coordsarr[ict].indexOf(' coords="') == -1) {
ict++;
}
}
if (randomize) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
//alert('first ict=' + ict + ' ... ' + donesofar);
while (ict == 0 || (donesofar + ',').indexOf(',' + ict + ',') != -1) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
if (coordsarr[ict].indexOf(' coords="') == -1) {
if (donesofar != ',') {
ict=eval('' + donesofar.substring(1).split(',')[0]);
} else {
ict++;
}
}
}
donesofar+='' + ict + ',';
}
//for (ict=1; ict<=5; ict++) {
while (jct <= 5) {
//if (document.URL.indexOf('&debug=') != -1) { alert(coordsarr[ict]); }
coordsarr[ict]=coordsarr[ict].split(' coords="')[1].split('"')[0];
if (randomize || prefixing != '' || (eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])) > 10 && eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])) > 10)) {
//alert('zctx.drawImage("' + imname.split(' ')[0] + '",' + eval(coordsarr[ict].split(',')[0].split('"')[0]) + ',' + eval(coordsarr[ict].split(',')[1].split('"')[0]) + ',' + eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])) + ',' + eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])) + ',0,0' + ',' + tds[eval(-1 + ict)].getBoundingClientRect().width + ',' + tds[eval(-1 + ict)].getBoundingClientRect().width + ')');
if (prefixing != '') {
//if (document.URL.indexOf('&debug=') != -1) { alert('YES'); }
minx=0;
miny=0;
maxx=0;
maxy=0;
for (ipr=0; ipr<coordsarr[ict].split(',').length; ipr+=2) {
if (ipr == 0) {
minx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]);
maxx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]);
miny=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]);
maxy=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]);
} else {
if (eval(coordsarr[ict].split(',')[ipr].split('"')[0]) < minx) { minx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[ipr].split('"')[0]) > maxx) { maxx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]) < miny) { miny=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]) > maxy) { maxy=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]); }
}
}
prefixing='' + minx + ',' + miny + ',' + maxx + ',' + maxy;
//if (document.URL.indexOf('&debug=') != -1) { alert('prefixing=' + prefixing); }
coordsarr[ict]=prefixing.trim(); // + ',' + coordsarr[ict];
}
if (theelems[theiw].indexOf('object-fit:none') != -1 || theelems[theiw].indexOf('object-fit:Cover') != -1) {
//if (document.URL.indexOf('&debug=') != -1) { alert('Yes'); }
zcanvas.width = eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])); //imgis.width;
//if (document.URL.indexOf('&debug=') != -1) { alert('YeS'); }
zcanvas.height = eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])); //imgis.height;
//if (document.URL.indexOf('&debug=') != -1) { alert('YEs'); }
zctx.drawImage(imgis, eval(coordsarr[ict].split(',')[0].split('"')[0]), eval(coordsarr[ict].split(',')[1].split('"')[0]), eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])),0,0,eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])));
//if (document.URL.indexOf('&debug=') != -1) { alert('yeS'); }
} else {
zctx.drawImage(imgis, eval(coordsarr[ict].split(',')[0].split('"')[0]), eval(coordsarr[ict].split(',')[1].split('"')[0]), eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])),0,0,squaredim,squaredim);
}
xaltdu=zcanvas.toDataURL("image/jpeg", 0.1);
//alert(xaltdu);
//alert(imlist[eval(-1 + ict)].outerHTML);
//if (document.URL.indexOf('&debug=') != -1) { alert(xaltdu); }
imlist[eval(-1 + jct)].src=xaltdu;
//zener_cards[eval(-1 + jct)]+='' + xaltdu;
if (jct < 5) {
zcanvas.width = squaredim; //imgis.width;
zcanvas.height = squaredim; //imgis.height;
if (prefixing != '') { prefixing=' '; } else { prefixing=''; }
}
jct++;
//} else {
//alert(coordsarr[ict]);
}
if (!randomize) {
ict++;
if (document.URL.indexOf('&debug=') != -1) { alert('ict=' + ict + ' and jct=' + jct); }
} else {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
//alert('first ict=' + ict + ' ... ' + donesofar);
while (ict == 0 || (donesofar + ',').indexOf(',' + ict + ',') != -1) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
if (coordsarr[ict].indexOf(' coords="') == -1) {
if (donesofar != ',') {
ict=eval('' + donesofar.substring(1).split(',')[0]);
} else {
ict++;
}
}
}
donesofar+='' + ict + ',';
}
}
};

imgis.src=imname.split(' ')[0];

}
}
}
}
}

function imagemapcheck() {
if (theelems[theiw].indexOf(' data-url="') != -1 && theelems[theiw].indexOf(' data-url=""') == -1 && zener_cards[0].replace('#circle_yellow','').indexOf('#') == -1) {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].indexOf('#') == -1) {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].slice(-5).indexOf('.') == -1 && theelems[theiw].split(' data-url="')[1].split('"')[0].slice(-1) != '/') {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0] + '/#';
} else {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0] + '#';
}
} else {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].split('#')[0].slice(-5).indexOf('.') == -1 && theelems[theiw].split(' data-url="')[1].split('"')[0].split('#')[0].slice(-1) != '/') {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0].replace('#','/#');
} else {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0];
}
}
}
}

… in a changed sixth draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Waiting Tutorial is shown below.

Clairvoyance Game Waiting Tutorial

Clairvoyance Game Waiting Tutorial

The recent Clairvoyance Game Objectify Tutorial work is revisited today, with the news that we’ve introduced …

implied invitations

… when the user enters a “player name” (looking a lot like an IP address) from that list of “potential players online” that is not any form of their own IP address player name. It will be apparent to regular readers that this methodology was intended to be the “usual methodology” at the beginning of our project, and so “we’ll allow a leave pass” for you to ask …

How come this took so long?

And then we’d say …

Huh?!

And there you go! Just “keep those cards and letters” flowing in!

So what do we mean by “implied invitations”? Well, in between a user “Wait” answer and the next, any other user can ask to play that waiting user, and the next time out of the prompt window they may find they’re in the midst of a game of some sort, invited by another player. We hope this does not offend?!

The concept of a “formal invitation” still exists for the email or SMS collaboration conduits, we hasten to add.

And so “day ?whatevvvvvvvvvvveeeeerrrrrrrr” got us to …


Previous relevant Clairvoyance Game Objectify Tutorial is shown below.

Clairvoyance Game Objectify Tutorial

Clairvoyance Game Objectify Tutorial

Extending yesterday’s Clairvoyance Game Sharing Scores Tutorial, it’s not exactly OOP (Object Oriented Programming) we are doing, but what we’d describe as “objectify” the proceedings we’re attending to today. Take a look at the following Javascript initialization code (now versus before) …


var zener_cards=['/circle_yellow.jpg#circle_yellow','/cross_red.jpg#cross_red','/waves_blue.jpg#waves_blue','/square_black.jpg#square_black','/star_green.jpg#star_green'];

var theword='Clairvoyance';
var thenoun='Zener Card';
var theelem="<img style='object-fit:contain;' src=";
var thewords=['Clairvoyance', 'Fruit', 'Food'];
var theelems=["<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src="];
var theihs=[">", ">", ">"];
var thenouns=['Zener Card', 'Fruit', 'Food'];
var theiw=(document.URL.indexOf('itype=') != -1 ? eval(-1 + eval('' + document.URL.split('itype=')[1].split('&')[0].split('#'))) : 0);

var ppsuff='';
var youare='';
var otheris='';
var score=0, goes=0;
var woois=null;
var pick=-1, awaiting=false, holdon=false;
var bihnull=true;
var anchor=null;
var initval='';
var lastafterscore='';
var wherewrong=false;
var sharemyscore=false, allowsdone=false;
var zcblurb=' You can enter ? to find out more about the history of Zener Cards. ';

if (theiw > 0) {
zcblurb='';
document.title=document.title.replace('Clairvoyance ', thewords[theiw] + ' ');
if (thenouns[theiw] == 'Food') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#x1f35b;';
zener_cards[1]+='|&#x1f371;';
zener_cards[2]+='|&#x1f358;';
zener_cards[3]+='|&#x1f359;';
zener_cards[4]+='|&#x1f363;';
} else if (thenouns[theiw] == 'Fruit') { // '127825', '127825', '127818', '127827', '127821'
theelems[theiw]='&lt;button style=font-size:100px; title=';
theihs[theiw]='&gt;';
zener_cards[0]+='|&#127817;';
zener_cards[1]+='|&#127825;';
zener_cards[2]+='|&#127818;';
zener_cards[3]+='|&#127827;';
zener_cards[4]+='|&#127821;';
}
}


var sideas=['Awaiting Other Player Choosing a ' + thenouns[theiw] + ' to Guess','Select the ' + thenouns[theiw] + ' Your Player Partner Selected','Select a ' + thenouns[theiw] + ' You Are Asking Your Player Partner to Guess','Awaiting Guess from Your Player Partner','Awaiting a ' + thenouns[theiw] + ' Selection from Your Playing Partner'];

… helping build up HTML for a new dropdown (versus what was there before) …


function multimaybe() {
var selbit='', jsel=0;
if (eval('' + thenouns.length) > 1) {
selbit="<sup><select style=width:30px; onchange=\"if (eval('' + this.value) != eval(1 + eval('' + theiw))) { location.href=document.URL.split('?')[0].split('#')[0] + '?itype=' + this.value; }\"><option value=" + eval(1 + theiw) + ">?</option></select> </sup> ";
for (jsel=0; jsel<thenouns.length; jsel++) {
selbit=selbit.replace('</select>', '<option value=' + eval(1 + jsel) + '>' + thewords[jsel] + ' Game</option></select>');
}
}
return selbit;
}

… and then later within the HTML <body> section …


<script type=text/javascript>
document.write("<h1 id=muh1>" + thewords[theiw] + " Game " + multimaybe() + "<input type=checkbox id=allows style=display:none; onchange=chscal(this);><font size=1 id=fshare style=display:none;>Share Score</font></input> <input type=checkbox id=allowstwo style=display:none; onchange=chscaltwo(this);><font size=1 id=fsharetwo style=display:none;>Be Told Where You Went Wrong</font></input></h1>");
</script>

… and am sure you can see where an initial “Clairvoyance” noun “hardcoding” feel of logic gets expanded to an “array of nouns” (where lots of programmers will immediately shout “objects”), as an alternative way of thinking to the ways our Javascript functions are like “verbs”. If you “abstract” the “what was a hardcoding” into “a dynamically selectable list of nouns” this objectifying process can be quite useful.

And so “day six” got us to …


Previous relevant Clairvoyance Game Sharing Scores Tutorial is shown below.

Clairvoyance Game Sharing Scores Tutorial

Clairvoyance Game Sharing Scores Tutorial

Onto the day before yesterday’s (yes, another two dayer!) Clairvoyance Game Invitations Tutorial primarily we have a checkbox part regarding …

  • Be Told Where You Went Wrong … guessing within our two player Clairvoyance Game … easy peasy … but …
  • Share Your Score … was really difficult … go figure …

… though the latter did ask a lot regarding timing and the sleep patterns of the PHP interlocutor … ?

Let’s just “move on” … shall we?!

Also on the agenda was some colour coding … and who doesn’t like a bit of colour coding! We purloined CSS into play, with “the kind of kludgy / kind of cute (well, you had to be there)” introduction of a title attribute to the status wording element and then apply that CSS …


<style>
#tdstatus[title^='Awaiting Other '] {
border: 3px solid red;
}

#tdstatus[title^='Awaiting a '] {
border: 3px solid rgb(127,0,0);
}


#tdstatus[title^='Awaiting Guess '] {
border: 3px solid orange;
}

#tdstatus[title^='Select the '] {
border: 6px solid lightgreen;
}

#tdstatus[title^='Select a '] {
border: 6px solid green;
}

$tdstatus { padding: 5 5 5 5; }
</style>

We often find it the way, when it comes to colour coding, we borrow from “the traffic light creed” regarding the colours used, where a reddish colour means “hang on” and a greenish colour is an invitation to the user. One could also think of “beeps” or “notifications” here, but not with us here, as of yet.

And so “day four” and “day five” saw …


Previous relevant Clairvoyance Game Invitations Tutorial is shown below.

Clairvoyance Game Invitations Tutorial

Clairvoyance Game Invitations Tutorial

In yesterday’s Clairvoyance Game Tutorial, with our Clairvoyance Game, really a game for two, downplayed invitations to the end of the blog posting blurb. But really, invitations are the “be all and end all” for a two player game shared over the Internet and just using a “PHP and HTML/Javascript” level of sophistication.

And, of course, two days later (when we think it should have only been “one day later”), it might be me, but making this work for email or SMS invitations was not trivial, partly because …

  • we launched into this “phase two public invitational sharing” on a false premise … our “phase one window.open and window.opener” Javascript logics were flawed (further into the logic than the first foray, shall we say) … bad news … we reckon one out of two days “getting there” would have to be put down to the lack of testing on day one … whereas …
  • our thought that “phase two” is just phase one window.open and window.opener transfers to PHP writes Javascript equivalents was “more or less” true, but we all know “programming life” throws up unexpected roadblocks

… and that is the excuse today, which we are sticking to … so there, ngaaahhhh!

This calls into play the importance, often, of “project planning”, and the compartmentalizing of testing, including really tight unit testing, especially if your software plan has so much dependency in “day two” on the “day one” quality. As far as that goes, in our defence, regarding a networking web application, that this Clairvoyance Game “more or less is” (though yesterday’s work simplistically pared that down so that we never needed more than our local MAMP Apache/PHP web server involved) sometimes you find it is hard to recognize “units” within the big picture.

And so “day two” and “day three” were all about “online invitation” logic for email or SMS invitations in …


Previous relevant Clairvoyance Game Tutorial is shown below.

Clairvoyance Game Tutorial

Clairvoyance Game Tutorial

Are you sixth sensical? Can you read tea leaves? If it’s one out of two, that will do.

We’re starting down the road to a new …

Clairvoyance Game

… today, that on today’s first draft, as a design for two players …

  • starts you playing yourself, or a nearby other player willing to share windows on your one common web browser incarnation …
  • kind of ludicrous on this day one but the building blocks are there, they being …
    1. HTML and Javascript parent … talking to …
    2. PHP interlocutor

    … which we’re going to extend, on day two, simulating what a window.open and window.opener (just on client) can do, just with a few more calls, and sleeping

Two players take it in turns …

  1. selecting a Zener Card the other player is asked to guess
  2. other player trying to guess that Zener Card selected

… to score, or not, in this first draft Clairvoyance Game helped out by PHP first draft interlocutor.

In days to come, we think we’ll also be coding for email or SMS invitations to play, as well. This will be old news to some of you telepathic genii.

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

Canvas Methods ToDataURL Method Tutorial

Canvas Methods ToDataURL Method Tutorial

Canvas Methods ToDataURL Method Tutorial

The recent Canvas Methods DrawImage Method Tutorial‘s …

  • [canvasContext].drawImage method user forms … is joined today by the very useful
  • [canvas].toDataURL method user forms …

… as a means by which those “platform independent” (but sizeable) data URI representations of graphical data can be created.

We often use the image/jpeg option with a quality second argument less than one to reduce data sizes here.

Also, today, we allow users to browse for or specify URLs pointing to video data, as well as the image data means by which drawImage‘s first argument can be designated with the changed svg_to_canvas.html “what we’ll call” Canvas Showcase web application you can also try below.


Previous relevant Canvas Methods DrawImage Method Tutorial is shown below.

Canvas Methods DrawImage Method Tutorial

Canvas Methods DrawImage Method Tutorial

Today we’re completing our HTML5 canvas [canvasContext].drawImage method started recently with Canvas Methods Revisit Tutorial where we had a start using …

  1. Positioning … via 3 arguments …

    [canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate]);

    … today we add …
  2. Positioning and Scaling … via 5 arguments …

    [canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate], [Width], [Height]);
  3. Slicing and Scaling and Cropping … via 9 arguments …

    [canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate], [ClippedWidth], [ClippedHeight], [Final X co-ordinate], [Final Y co-ordinate], [FinalWidth], [FinalHeight]);

So feel free to have a go yourself with the changed svg_to_canvas.html “what we’ll call” Canvas Showcase web application you can also try below.


Previous relevant Canvas Methods Revisit Tutorial is shown below.

Canvas Methods Revisit Tutorial

Canvas Methods Revisit Tutorial

When we started being “blown away” by the potential of the HTML5 canvas element coming into play quite some time ago now, it was a bit like …

Wow!! But where to start?

… and due to our naivety we were not in a position back then to break down what was “cut through” (or not that practical, perhaps) about the canvas element “methods” with any authority. Over the years, though, we are more equipped, so what we are setting out to do is …

  • start with, though written a while ago, still to this day, feels like an advanced canvas application (as explained at Canvas DrawImage First Parameter Primer Tutorial) involving video elements (ie. we got a lot of help, thanks all) … and use this template …
  • to work it the other way (via new dropdown elements), building on “what you might aspire to if you are a beginner with the canvas element” and display new options to emphasise the huuuuuuuuuuuuugely valuable canvas methods out there (yes, OOP methods, not functions, as such)

The first cab off the rank here is the …


[canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate]);

… simplest usage of that drawImage method (in “OOP land” this 3 argument call can be thought of as “not the same logic” as (what we are going to get to later, for example) a 9 argument call). A form is presented here, and you, the user, can see the effects of controlling the 3 arguments (and you’ll notice “no truck” is given to any 5 minute? arguments here).

Feel free to have a go yourself with the changed svg_to_canvas.html “what we’ll call” Canvas Showcase web application you can also try below …


Previous relevant Canvas DrawImage First Parameter Primer Tutorial is shown below.

Canvas DrawImage First Parameter Primer Tutorial

Canvas DrawImage First Parameter Primer Tutorial

Some time ago we presented a short tutorial about a great online product addressing a big area of interest to online users … online meetings. We showcased the great GoToMeeting, with GoToMeeting Primer Tutorial, and we remember using it to good effect among …

  • installing software remotely
  • diagnosing software and hardware issues remotely
  • discussing issues remotely
  • client liaison remotely

… at a job involving EDI solutions with SAP Business One and Accpac. But that is just the subject matter basis here. Today we really want to use some media from that subject matter basis and use it’s video media as the first argument to the wonderful, the stupendous Canvas drawImage() Method, specifically its fascinating first parameter

Syntax
Position the image on the canvas:

context.drawImage(img, x, y)
Position the image on the canvas, and specify width and height of the image:

context.drawImage(img, x, y, width, height)
Clip the image and position the clipped part on the canvas:

context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height)

Don’t be fooled! It is a method offering, thanks, so much more that just an

el interface intrinsicHeight(el) intrinsicWidth(el)
HTMLImageElement el.naturalWidth el.naturalHeight
SVGImageElement el.[… special case] el.[… special case]
HTMLVideoElement el.videoWidth el.videoHeight
HTMLCanvasElement el.width el.height
ImageBitmap el.width el.height
OffscreenCanvas el.width el.height

… but whaaaaatttttt?! What happens here assigning a video object as a first parameter to the canvas (context)’s drawImage method? It takes a snapshot image of the slide of the playing (and if not, the first image of that) video! That means, couch that in a codeline like …


setInterval(function(){ ctx.drawImage(ovid, 800, 0); }, 100);

… at the right time, and you can be playing a video into the canvas! Yay!!! Actually, we’ve done this before, and, call us innocents if you like, but this gave us the same thrill then, thanks to all the online contributors regarding heads up ideas here.

But we are “value adding” today. It hadn’t occurred to us that we could do this video to the right of the canvas and dedicate the left side to captions, and that over there, there was enough room to show the “whole blurb” … and nothing but the blurb, and that if we use …

  • HTML video element attribute … autostart=true
  • HTML video element attribute … autoplay=true
  • HTML video element attribute … loop=true

… even if they do not work right from the document.body onload event time, once the video play button is clicked, we could do without the actual video from then on, perhaps (we’ve allowed you to resurrect the video display, and have more work into the future, maybe, regarding the repercussions of this … we’ll see?!).

What form of caption source did we use? We happened to have a “.srt” format WebVTT file pertinent to the GoToMeeting video hanging about, and so we shoved it into the innards of an HTML textarea element, and coded it from there …


<html>
<head>
<title>SVG to Canvas - RJM Programming - May, 2024 ... thanks to https://jsfiddle.net/Na6X5/</title>
<style>
canvas {
border: 1px solid gray;
}
</style>
<script type='text/javascript'>
var divstrc='';
var timings=[];
var times=[];
var tstimes=[];
var blurbs=[];
var cf = "12px Verdana";
var thisy=20, thisi=0, thisc=0;
var can=null, ctx=null;
var collist=['black','blue','purple','magenta','darkred','darkgreen'];
var lenc=eval('' + collist.length);
var oppmode='none';

function tanal(intr) {
var pts=intr.split(':');
console.log(intr);
tstimes.push(eval(eval(pts[0] * 60 * 60 * 1000) + eval(pts[1] * 60 * 1000) + eval(pts[2] * 1000)));
return intr;
}

function onl() {
can = document.getElementById('canvas1');
ctx = can.getContext('2d');

var svg = document.getElementById('simage');
var oimg = document.getElementById('simg');
var ovid = document.getElementById('myvd');

divstrc=document.getElementById('divsrt').value;
timings=divstrc.split(' --> ');
//alert(timings.length);
times.push(tanal(timings[0].slice(-13).trim()));
for (var ii=1; ii<timings.length; ii++) {
if (1 == 2) { times.push(tanal(timings[ii].substring(0,13).trim())); }
if (eval(1 + ii) != eval('' + timings.length)) {
times.push(tanal(timings[ii].slice(-13).trim()));
} else {
times.push(tanal(timings[ii].substring(0,13).trim()));
}
blurbs.push(timings[ii].split(String.fromCharCode(10))[1]);
}

console.log(blurbs);
console.log(tstimes);

var img = new Image();
img.onload = function() {
//ctx.drawImage(svg, 0, 0);
//ctx.drawImage(img, 200, 0);
//ctx.drawImage(oimg, 400, 0);
//ovid.play();
setInterval(function(){ ctx.drawImage(ovid, 800, 0); }, 100);
}
//img.src = "http://upload.wikimedia.org/wikipedia/commons/d/d2/Svg_example_square.svg";
//img.src = "/hexagon.svg";
//img.src = "/homecircle.svg";
img.src=oimg.src;
}

function dotext() {
if (eval(1 + thisi) >= eval('' + tstimes.length)) {
thisc++;
if (thisc >= eval('' + collist.length)) {
collist.push(collist[eval(thisc % lenc)]);
}
return loadsrt('');
}
setTimeout(dotext, eval(tstimes[eval(1 + thisi)] - tstimes[eval(0 + thisi)]));
ctx.font = cf;
ctx.strokeStyle=collist[thisc];
ctx.strokeText(blurbs[thisi],20,thisy);
thisy+=15;
thisi++;
}

function loadsrt(dsp) {
thisi=0;
thisy=20;
setTimeout(dotext, tstimes[0]);
if (dsp != '') {
document.getElementById('mysummary').innerHTML='Please click to toggle video display ...';
}
return dsp;
}
</script>
</head>
<body onload="onl();">
<canvas style='background-color:yellow;' id="canvas1" width="1400" height="400"></canvas>

<div id=previd style="display:none;">
<svg id="mySVG" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect width="150" height="150" fill="rgb(0, 255, 0)" stroke-width="1" stroke="rgb(0, 0, 0)"/>
</svg>

<svg id="mySVGimage" width="300" height="300" viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" version="1.1">
<image id=simage href="/hexagon.svg" height="300" width="300" />
</svg>

<img id=simg src='data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve" height="100px" width="100px">
<g>
<path d="M28.1,36.6c4.6,1.9,12.2,1.6,20.9,1.1c8.9-0.4,19-0.9,28.9,0.9c6.3,1.2,11.9,3.1,16.8,6c-1.5-12.2-7.9-23.7-18.6-31.3 c-4.9-0.2-9.9,0.3-14.8,1.4C47.8,17.9,36.2,25.6,28.1,36.6z"/>
<path d="M70.3,9.8C57.5,3.4,42.8,3.6,30.5,9.5c-3,6-8.4,19.6-5.3,24.9c8.6-11.7,20.9-19.8,35.2-23.1C63.7,10.5,67,10,70.3,9.8z"/>
<path d="M16.5,51.3c0.6-1.7,1.2-3.4,2-5.1c-3.8-3.4-7.5-7-11-10.8c-2.1,6.1-2.8,12.5-2.3,18.7C9.6,51.1,13.4,50.2,16.5,51.3z"/>
<path d="M9,31.6c3.5,3.9,7.2,7.6,11.1,11.1c0.8-1.6,1.7-3.1,2.6-4.6c0.1-0.2,0.3-0.4,0.4-0.6c-2.9-3.3-3.1-9.2-0.6-17.6 c0.8-2.7,1.8-5.3,2.7-7.4c-5.2,3.4-9.8,8-13.3,13.7C10.8,27.9,9.8,29.7,9,31.6z"/>
<path d="M15.4,54.7c-2.6-1-6.1,0.7-9.7,3.4c1.2,6.6,3.9,13,8,18.5C13,69.3,13.5,61.8,15.4,54.7z"/>
<path d="M39.8,57.6C54.3,66.7,70,73,86.5,76.4c0.6-0.8,1.1-1.6,1.7-2.5c4.8-7.7,7-16.3,6.8-24.8c-13.8-9.3-31.3-8.4-45.8-7.7 c-9.5,0.5-17.8,0.9-23.2-1.7c-0.1,0.1-0.2,0.3-0.3,0.4c-1,1.7-2,3.4-2.9,5.1C28.2,49.7,33.8,53.9,39.8,57.6z"/>
<path d="M26.2,88.2c3.3,2,6.7,3.6,10.2,4.7c-3.5-6.2-6.3-12.6-8.8-18.5c-3.1-7.2-5.8-13.5-9-17.2c-1.9,8-2,16.4-0.3,24.7 C20.6,84.2,23.2,86.3,26.2,88.2z"/>
<path d="M30.9,73c2.9,6.8,6.1,14.4,10.5,21.2c15.6,3,32-2.3,42.6-14.6C67.7,76,52.2,69.6,37.9,60.7C32,57,26.5,53,21.3,48.6 c-0.6,1.5-1.2,3-1.7,4.6C24.1,57.1,27.3,64.5,30.9,73z"/>
</g>
</svg>'></img>
</div>

<details onclick=" document.getElementById('myvd').style.display=oppmode; if (oppmode == 'block') { oppmode='none'; } else { oppmode='block'; }" open><summary id=mysummary>Please click play button below ...</summary>
<video onplay="this.style.display=loadsrt('none');" id=myvd autoplay=true autostart=true loop=true controls><source src='/Mac/GoToMeeting/GoToMeeting.m4v' type='video/mp4'></source></video>
<div id=divhs style=display:inline-block;vertical-align:top;>
<h1>Video and Captions to Canvas</h1>
<h3>RJM Programming - May, 2024</h3>
<h4>Thanks to https://jsfiddle.net/Na6X5/</h4>
</div>
</details>

<textarea id=divsrt style="display:none;">
WEBVTT FILE

1
00:00:00.100 --> 00:00:01.000 D:vertical A:start
Welcome to our GoTo Meeting tutorial ...
{
"title": "GoTo Meeting tutorial image 1 of 5",
"description": "Welcome to our GoTo Meeting tutorial",
"src": "gm1.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

2
00:00:01.000 --> 00:00:04.000
... we've installed GoTo Meeting and started it up. We have done the invite so we will be the "Presenter" ...

3
00:00:04.000 --> 00:00:06.000
... we click "Show My Screen" ...
{
"title": "GoTo Meeting tutorial image 2 of 5",
"description": "Show My Screen",
"src": "gm2.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

4
00:00:06.000 --> 00:00:16.000
... which is enabled because we are the "Presenter". Now lets ready other things ready to make a connection ...

5
00:00:16.000 --> 00:00:22.000
... we click "Show My Webcam" and start Connecting ...
{
"title": "GoTo Meeting tutorial image 3 of 5",
"description": "Show My Webcam",
"src": "gm3.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

6
00:00:22.000 --> 00:00:24.000
... the GoTo Viewer appears showing you a view of the person you are meeting ...

7
00:00:24.000 --> 00:00:26.000
... we have "lift off" ...
{
"title": "GoTo Meeting tutorial image 4 of 5",
"description": "Lift Off",
"src": "gm4.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

8
00:00:26.000 --> 00:00:28.000
... lo and behold, we've called ourself ...

9
00:00:28.000 --> 00:00:32.000
... have a look at us looking at us ...

10
00:00:32.000 --> 00:00:52.000
... but don't let it blow your mind?!
{
"title": "GoTo Meeting tutorial image 5 of 5",
"description": "Don't blow your mind",
"src": "gm5.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

11
00:00:52.000 --> 00:01:34.000
Leaving the GoTo Meeting now. See you again soon.

</textarea>

</body>
</html>

Yes, we started the day with a different idea, and end up where we are at with our first draft proof of concept Video to Canvas web application incarnation … again.


Previous relevant GoToMeeting Primer Tutorial is shown below.

GoToMeeting Primer Tutorial

GoToMeeting Primer Tutorial

Here is a tutorial that introduces you to GoToMeeting. GoToMeeting is a great user-friendly video conferencing software by Citrix.

For simple scenarios I’ve always felt comfortable with GoToMeeting for that video conferencing functionality, or for how I usually used it, remotely testing, troubleshooting and/or installing software on remote client sites. Other choices for all Windows scenarios, here are Remote Desktop, and for mixed scenarios, VNC.

GoToMeeting can work with a phone connection or by using the Microphone and Speakers at both ends of the connection. You can host the meeting or join the meeting, share your keyboard or mouse, share your display via a shared webcam, as necessary, meet straight away, or schedule it, or email an invitation … all in all there is a lot of great functionality. Like with Skype, audio and visual can be considered separate … from our tutorial session here is some audio, and here is some visual (ie. video).

Other such meeting ideas can be accessed via Skype, or WebEx Web Conferencing. All these are great ideas that can save companies lots of money on overseas trips!

Link to GoToMeeting “spiritual home” at GoToMeeting, which is owned by Citrix.

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


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


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


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


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

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

WordPress Previous Relevant Published Date Tutorial

WordPress Previous Relevant Published Date Tutorial

WordPress Previous Relevant Published Date Tutorial

Meanwhile, back at “this blog posting’s WordPress Blog Twenty Ten theme header.php land”, like with the recent WordPress Same Action Item Tutorial we wanted to add some intelligence to those …

<p id=wpimbyrmt>Previous relevant <a href=’//www.rjmprogramming.com.au/ITblog/wordpress-is-mentioned-by-less-recently-modified-tutorial’ target=”_blank” rel=”noopener”>WordPress Is Mentioned By Less Recently Modified Tutorial</a> is shown below.</p>

… style of links we have going “stringing along” components of our more complex “blog posting threads”. We wanted to add into the title attribute …


WordPress Is Mentioned By Less Recently Modified Tutorial published on May 12, 2026

… to add some more context into these “blog posting thread” stories, via …

<php

if (isset($post->post_content)) { // publication date
$monam=['January','February','March','April','May','June','July','August','September','October','November','December','January','February','March','April','May','June','July','August','September'];
$mnin=['01','02','03','04','05','06','07','08','09','10','11','12','1','2','3','4','5','6','7','8','9'];
$pras=explode('>Previous relevant <a ', $post->post_content);
if (sizeof($pras) > 1) {
$selxbitsare=file_get_contents("../tutorial_options.html");
for ($inbc=1; $inbc<sizeof($pras); $inbc++) {
$titsofar=explode('>', explode('</a>', $pras[$inbc])[0])[-1 + sizeof(explode('>', explode('</a>', $pras[$inbc])[0]))];
if (strpos($selxbitsare, '>' . $titsofar . ' (') !== false && strpos(explode('</a>', $pras[$inbc])[0], ' title="' . $titsofar . '"') !== false) {
$eightis=explode(')',explode('>' . $titsofar . ' (',$selxbitsare)[1])[0];
if (strlen($eightis) == 8) {
$post->post_content=str_replace(' title="' . $titsofar . '"', ' title="' . $titsofar . ' published on ' . $monam[array_search(substr($eightis,-4,2),$mnin)] . ' ' . substr($eightis,-2,2) . ', ' . substr($eightis,0,4) . '"', $post->post_content);
} else {
$post->post_content=str_replace(' title="' . $titsofar . '"', ' title="' . $titsofar . ' published on ' . $eightis . '"', $post->post_content);
}
} else if (strpos($selxbitsare, '>' . $titsofar . ' (') !== false && strpos(explode('</a>', $pras[$inbc])[0], " title='" . $titsofar . "'") !== false) {
$eightis=explode(')',explode('>' . $titsofar . ' (',$selxbitsare)[1])[0];
if (strlen($eightis) == 8) {
$post->post_content=str_replace(" title='" . $titsofar . "'", " title='" . $titsofar . " published on " . $monam[array_search(substr($eightis,-4,2),$mnin)] . ' ' . substr($eightis,-2,2) . ', ' . substr($eightis,0,4) . "'", $post->post_content);
} else {
$post->post_content=str_replace(" title='" . $titsofar . "'", " title='" . $titsofar . " published on " . $eightis . "'", $post->post_content);
}
}
}
}
}

?>

… new to good ol’ header.php of the TwentyTen Theme of this WordPress blog, and using our crontab/curl based overnight processing help here.


Previous relevant WordPress Same Action Item Tutorial is shown below.

WordPress Same Action Item Tutorial

WordPress Same Action Item Tutorial

Today, we’re extending our WordPress TwentyTen themed blog posting inhouse feature …

… PHP changed logic within is_mentioned_by.php controlled via emoji ☞ button.


Previous relevant WordPress Is Mentioned By Less Recently Modified Tutorial is shown below.

WordPress Is Mentioned By Less Recently Modified Tutorial

WordPress Is Mentioned By Less Recently Modified Tutorial

Supposing you came in here paying scant attention to the Blog Posting Title and its Animated GIF Tutorial picture I’d like to set you the challenge to look at the build up to organizing the use of the theme for today’s tutorial, and you try to anticipate what that may be? Up to the challenge? We hope so, because, with respect to the recent WordPress Is Mentioned By Recently Modified Tutorial‘s …

  • MySql SQL …
    <?php

    $res = mysql_query("SELECT " . $tname . ".post_title, " . $tname . ".guid, " . $tname . ".post_content, LOCATE('" . $ourtitle . "'," . $tname . ".post_content) as tfind, LOCATE('" . $ourother . "'," . $tname . ".post_title) as tother, " . $tname . ".post_date as post_date FROM " . $tname . "
    WHERE " . $tname . ".post_status = 'publish' " . "
    AND (1 = 1 OR LOWER(" . $tname . ".post_title) != LOWER('" . $ourtitle . "')) " . "
    AND (" . $tname . ".post_content like CONCAT(CONCAT('%?p='," . $tname . ".guid), '%') " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',permalinkit($ourtitle)) . "%' " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourother) . "%' " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourtitle) . "%') " . " UNION SELECT " . $tname . ".post_title, " . $tname . ".post_content as guid, ' ' as post_content, -1 as tfind, -1 as tother, " . $tname . ".post_modified as post_date FROM " . $tname . " WHERE " . $tname . ".post_status = 'publish' AND " . $tname . ".post_modified > NOW() - INTERVAL 1 WEEK " . " UNION SELECT 'Code Download Table' as post_title, " . $tname . ".post_content as guid, '' as post_content, 1 as tfind, 0 as tother, CURTIME() as post_date FROM " . $tname . "
    WHERE " . $tname . ".post_status = 'publish' " . "
    AND LOWER(" . $tname . ".post_title) = LOWER('" . $ourtitle . "') " . "
    AND " . $tname . ".post_content like '%GETME%' ORDER BY post_date ");

    ?>
    … we changed it to be
    <?php

    $res = mysql_query("SELECT " . $tname . ".post_title, " . $tname . ".guid, " . $tname . ".post_content, LOCATE('" . $ourtitle . "'," . $tname . ".post_content) as tfind, LOCATE('" . $ourother . "'," . $tname . ".post_title) as tother, " . $tname . ".post_date as post_date FROM " . $tname . "
    WHERE " . $tname . ".post_status = 'publish' " . "
    AND (1 = 1 OR LOWER(" . $tname . ".post_title) != LOWER('" . $ourtitle . "')) " . "
    AND (" . $tname . ".post_content like CONCAT(CONCAT('%?p='," . $tname . ".guid), '%') " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',permalinkit($ourtitle)) . "%' " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourother) . "%' " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourtitle) . "%') " . " UNION SELECT " . $tname . ".post_title, " . $tname . ".post_content as guid, ' ' as post_content, -1 as tfind, (-480 + TIMESTAMPDIFF(MINUTE,NOW()," . $tname . ".post_modified)) as tother, " . $tname . ".post_modified as post_date FROM " . $tname . " WHERE " . $tname . ".post_status = 'publish' AND " . $tname . ".post_modified > NOW() - INTERVAL 1 MONTH " . " UNION SELECT 'Code Download Table' as post_title, " . $tname . ".post_content as guid, '' as post_content, 1 as tfind, 0 as tother, CURTIME() as post_date FROM " . $tname . "
    WHERE " . $tname . ".post_status = 'publish' " . "
    AND LOWER(" . $tname . ".post_title) = LOWER('" . $ourtitle . "') " . "
    AND " . $tname . ".post_content like '%GETME%' ORDER BY post_date ");

    ?>
    … to fit in with …
  • we changed the modified is_mentioned_by.php‘s SQL result set logic “if logic framework” … from
    <?php

    while (($r_array = mysql_fetch_row($res))) {
    if ($r_array[3] == "-1" && strtolower($r_array[3]) == strtolower($r_array[4])) {
    // this is a member of the modified list (via middle UNION SELECT) of the MySQL SQL query result set
    } else if (strtolower($r_array[0]) == strtolower($ourtitle)) {
    // matches current post logic goes here
    } else {
    // does not match current post logic goes here
    }
    }

    ?>
    to
    <?php

    while (($r_array = mysql_fetch_row($res))) {
    if ($r_array[3] == "-1" && strpos(("" . $r_array[4]), "-") !== false) {
    // this is a member of the modified (and less recently modified) list (via middle UNION SELECT) of the MySQL SQL query result set
    } else if (strtolower($r_array[0]) == strtolower($ourtitle)) {
    // matches current post logic goes here
    } else {
    // does not match current post logic goes here
    }
    }

    ?>
    … turning a “binary” piece of logic into a “ternary” (and above) one … as well as, for good ol’ header.php we add some global Javascript variables

    var coption='option';
    var cdisabled='disabled';
    var chidden='hidden';
    var cblank='_blank';

Is it apparent to you now what we are using to achieve some new “Less Recently Modified Tutorial” list data onto the “Recently Modified Tutorial” list data of below? But how do we go about doing that, that has been an enthusiasm around here, of recent times? What if we could say …

  • we changed the modified is_mentioned_by.php‘s SQL result set logic “within that top if logic” … from
    <?php

    if ($secresult == "") {
    $secresult=" <span id=xdrpl><select style=\"background-color:orange;display:inline-block;width:80px;\" id=mr" . permalinkit($ourtitle) . " onchange=window.open(this.value,\"_blank\"); title=\"Modified recently (over last week)\"><option value=\"\">Modified</option></select></span> ";
    }
    $secresult=str_replace('>Modified</option>','>Modified</option><option value=https://www.rjmprogramming.com.au/ITblog/' . permalinkit($r_array[0]) . '>' . $r_array[0] . '</option>', $secresult);

    ?>
    to
    <?php

    if ($secresult == "") {
    $secresult=" <span id=xdrpl><select style=\"background-color:orange;display:inline-block;width:80px;\" id=mr" . permalinkit($ourtitle) . " onchange=\"if (this.value.trim().length == 0) { var optslst=document.getElementsByTagName(coption); for (var ioptslst=0; ioptslst<optslst.length; ioptslst++) { if (optslst[ioptslst].outerHTML.indexOf(this.value) != -1) { if (optslst[ioptslst].outerHTML.indexOf(cdisabled) != -1) { optslst[ioptslst].removeAttribute(cdisabled); } if (optslst[ioptslst].outerHTML.indexOf(chidden) != -1) { optslst[ioptslst].removeAttribute(chidden); } } } } else { window.open(this.value,cblank); }\" title=\"Modified recently (over last week)\"><option value=\"\">Modified</option></select></span> ";
    }
    if ($r_array[4] <= -11520) {
    $blks=(40 - floor((0 - $r_array[4]) / (24 * 60)));
    $optv='<option value="">Enable and show through to ' . (40 - $blks) . ' days';
    $altv=' title=""';
    for ($iblks=0; $iblks<$blks; $iblks++) {
    $altv=str_replace(' title="', ' title=" ', $altv);
    $optv=str_replace(' value="', ' value=" ', $optv);
    }
    if (strpos($secresult, $optv) !== false) { $secresult=str_replace($optv . " ... ",$optv . " ... " . $r_array[0] . " and ",$secresult); $optv=""; } else { $optv .= " ... " . $r_array[0] . "</option>"; }
    $secresult=str_replace('>Modified</option>','>Modified</option>' . $optv . '<option' . $altv . ' value=https://www.rjmprogramming.com.au/ITblog/' . permalinkit($r_array[0]) . ' disabled hidden>' . $r_array[0] . '</option>', $secresult);
    } else {

    $secresult=str_replace('>Modified</option>','>Modified</option><option value=https://www.rjmprogramming.com.au/ITblog/' . permalinkit($r_array[0]) . '>' . $r_array[0] . '</option>', $secresult);
    }

    ?>
  • and does the disabled hidden above tell you more?

Yes, back with the recent Emoji Circuit Quiz Animated Emoji Tutorial you might recall …

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 we’ve found a new (probably you’d say, “more apt”) use of this idea. We differentiate the …

  • arguably more potent “week’s worth” of modified postings list (as per WordPress Is Mentioned By Recently Modified Tutorial‘s situation) … still as is, and “singly selectable” … with …
  • new less potent (you could argue) “older than one week and up to one month” of modified postings list that can be made “singly selectable” by the user (but don’t start that way, because they initially have “hidden” and “disabled” option element attributes set) … and …
  • in order to save space and honour those platforms that really render the “hidden” option tags we add “older than one week and up to one month” blog posting titles onto the “selectable day age” ones (all causing a select (dropdown) element value property of blank (if trimmed … ie. their length matches (40 – number of days age)) so that that new Javascript onchange logic can just look for a select element value existing in an option (list) member outerHTML property in order to decide whether to remove the “disabled” and “hidden” properties initially populated into those option “older than one week and up to one month” elements

Now can we recommend turning off the “scant attention” and having a look at today’s animated GIF tutorial picture showing a bit of how this new functionality works in practice here at the WordPress TwentyTen themed blog you are reading up with the emoji button (you click) above.

For biassed moi, just another reason to keep on admiring and using the ever useful HTML select (dropdown) element in our web applications.


Previous relevant WordPress Is Mentioned By Recently Modified Tutorial is shown below.

WordPress Is Mentioned By Recently Modified Tutorial

WordPress Is Mentioned By Recently Modified Tutorial

Administering this blog there are two major criteria that would cause a blog posting’s modified date to change, that being …

  1. at this blog we schedule one new blog post per day … and …
  2. as we see things, on an ad hoc basis, we’ll make changes

… but that “Recent Posts” widget you see at this blog only reflects blog post criteria 1 above. Supposing you are following a thread of blog posts or an old blog post, try out the code and see that there is something amiss. How could this possibly be so! Yes, humanity rainsreigns, and we are scouring the postings you might visit to see what you might see, as a basis for revisits to code of the past.

And pretty naturally, if we find an issue, and can do something about it, with that category 2 blog posting type above, we may change one or other or both of …

  • the underlying code of said category 2 blog posting … and/or, as applicable …
  • the blog posting content of said category 2 blog posting

… the latter of which will cause that blog posting’s modified date to change, and as of today, adding onto yesterday’s WordPress Is Mentioned By Posting Order Tutorial, your clicking of “Is Mentioned By” “emoji button” above to change the “Recent Posts” widget title to “Recent Posts”, that (select element) dropdown populated in chronological order by a week’s worth of modified date changes at this blog. Using this, you may get an update to something you cannot figure, else drop us a line.

What needed to change for this? Well, first off, we’d like to thank the inspiration of 27 Handy SQL Query Hacks for WordPress for the means by which we changed is_mentioned_by.php‘s central SQL SELECT (DML) statement should receive a new UNION clause as per

<?php

$res = mysql_query("SELECT " . $tname . ".post_title, " . $tname . ".guid, " . $tname . ".post_content, LOCATE('" . $ourtitle . "'," . $tname . ".post_content) as tfind, LOCATE('" . $ourother . "'," . $tname . ".post_title) as tother, " . $tname . ".post_date as post_date FROM " . $tname . "
WHERE " . $tname . ".post_status = 'publish' " . "
AND (1 = 1 OR LOWER(" . $tname . ".post_title) != LOWER('" . $ourtitle . "')) " . "
AND (" . $tname . ".post_content like CONCAT(CONCAT('%?p='," . $tname . ".guid), '%') " . "
OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',permalinkit($ourtitle)) . "%' " . "
OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourother) . "%' " . "
OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourtitle) . "%') " . " UNION SELECT " . $tname . ".post_title, " . $tname . ".post_content as guid, ' ' as post_content, -1 as tfind, -1 as tother, " . $tname . ".post_modified as post_date FROM " . $tname . " WHERE " . $tname . ".post_status = 'publish' AND " . $tname . ".post_modified > NOW() - INTERVAL 1 WEEK " . " UNION SELECT 'Code Download Table' as post_title, " . $tname . ".post_content as guid, '' as post_content, 1 as tfind, 0 as tother, CURTIME() as post_date FROM " . $tname . "
WHERE " . $tname . ".post_status = 'publish' " . "
AND LOWER(" . $tname . ".post_title) = LOWER('" . $ourtitle . "') " . "
AND " . $tname . ".post_content like '%GETME%' ORDER BY post_date ");

?>

… that -1 as tfind, -1 as tother an intentional ploy to fit in with a new “if” clause in the PHP (that loops through database record reads of the MySql SQL query above) as per

<?php

$secresult="";
if ($res == 0) {
if (1 == 2) echo("<b>Error " . mysql_errno() . ": " . mysql_error() . "</b>");
} else if (mysql_num_rows($res) == 0) {
if (1 == 2) echo("<b>Query executed successfully</b>");
$retval=$delim;
$retval = str_replace(" }", " parent.document.getElementById('d" . permalinkit($ourtitle) . "').innerHTML='<select style=background-color:yellow; id=" . permalinkit($ourtitle) . " onchange=window.open(this.value,\"_blank\"); title=\"Is mentioned by\"><option value=\"\">Sadly, this tutorial is not mentioned by any others, yet</option></select>'; }", $retval);
} else {
while (($r_array = mysql_fetch_row($res))) {
if ($r_array[3] == "-1" && strtolower($r_array[3]) == strtolower($r_array[4])) {
if ($secresult == "") {
$secresult=" <span id=xdrpl><select style=\"background-color:orange;display:inline-block;width:80px;\" id=mr" . permalinkit($ourtitle) . " onchange=window.open(this.value,\"_blank\"); title=\"Modified recently (over last week)\"><option value=\"\">Modified</option></select></span> ";
}
$secresult=str_replace('>Modified</option>','>Modified</option><option value=https://www.rjmprogramming.com.au/ITblog/' . permalinkit($r_array[0]) . '>' . $r_array[0] . '</option>', $secresult);
}
else if (strtolower($r_array[0]) == strtolower($ourtitle)) {
$isize++;
$retval = str_replace(" }", " isize++; theseopts=theseopts.replace(' size=' + eval(-1 + isize) + ' ', ' size=' + isize + ' ').replace('>','><option value=https://www.rjmprogramming.com.au/ITblog/" . permalinkit($r_array[0]) . " selected>" . $r_array[0] . pluckfirstreal($r_array[2]) . "</option>'); }", $retval);
} else {
$pdate = $r_array[1];
if ($retval == "") {
$retval=$delim;
$retval = str_replace(" }", " var theseoptions='<select style=background-color:yellow; id=" . permalinkit($ourtitle) . " onchange=window.open(this.value,\"_blank\"); title=\"Is mentioned by\"><option value=\"\">This tutorial is mentioned by ...</option></select>'; }", $retval);
$retval = str_replace(" }", " var theseopts='<select si' + 'ze=0 style=width:100%;background-color:#f0f0f0; class=select_ms id=z" . permalinkit($ourtitle) . " onchange=changed(this.value,ocb); title=\"Is part of a blog posting thread ... and you can select multiple tutorials to show\"></selec' + 't>'; }", $retval);
}
if ($r_array[3] != "0") $retval = str_replace(" }", " theseoptions=theseoptions.replace('</select>','<option value=https://www.rjmprogramming.com.au/ITblog/" . permalinkit($r_array[0]) . ">" . $r_array[0] . "</option></select>'); }", $retval);
if ($criteria != "") {
if (str_replace($criteria, "", $r_array[0]) != $r_array[0] && $r_array[4] != "0") {
$found = true;
$isize++;
$retval = str_replace(" }", " isize++; theseopts=theseopts.replace(' size=' + eval(-1 + isize) + ' ', ' size=' + isize + ' ').replace('>','><option value=https://www.rjmprogramming.com.au/ITblog/" . permalinkit($r_array[0]) . ">" . $r_array[0] . pluckfirstreal($r_array[2]) . "</option>'); }", $retval);
}
}
}
}
if ($retval != "") {
if (!$found) {
$retval = str_replace(" }", " theseopts=''; }", $retval);
} else {
$retval = str_replace(" }", " theseoptions+=(' ' + theseopts); }", $retval);
}
$retval = str_replace(" }", " parent.document.getElementById('d" . permalinkit($ourtitle) . "').innerHTML=theseoptions; parent.checkclass(\"\"); }", $retval);
}
}
mysql_close($link); // close the MySql database connection
if ($retval != "") {
if ($secresult != "") {
$retval=str_replace("></selec' + 't>';", "></selec' + 't>' + '" . $secresult . "'; ", $retval);
}

echo $retval; // this get communicated back to TwentyTen theme's header.php changes as explained below ...
}

?>

… teaming up with this blog’s TwentyTen theme’s (good ol’) header.php changes (to suit above) that go

<?php

var rppspana=null;

function rpcheck() {
if (rppspana == null) {
var h3sare=document.getElementsByTagName('h3');
for (var ih3sare=0; ih3sare<h3sare.length; ih3sare++) {
if (('' + h3sare[ih3sare].innerHTML).indexOf('cent Post') != -1) { rppspana=h3sare[ih3sare]; }
}
}
if (rppspana != null && document.getElementById('xdrpl')) {
if (rppspana.innerHTML.indexOf('cent Post') != -1 && document.getElementById('xdrpl').innerHTML != '') {
var dx=document.getElementById('xdrpl').innerHTML;
document.getElementById('xdrpl').innerHTML='';
rppspana.innerHTML=rppspana.innerHTML.replace('cent Post', 'cent ' + dx + ' Post');
} else {
setTimeout(rpcheck, 4000);
}
} else if (document.getElementById('xdrpl')) {
setTimeout(rpcheck, 4000);
} else if (rppspana != null) {
setTimeout(rpcheck, 4000);
}
}


function preresize_font(aois) {
setTimeout(rpcheck, 3000);
zzzspare=aois.id.replace('t','d');
resize_font();
}

function is_mentioned_by() {
var zspare,xspare,xxspare,ximb,xpspana=docgetclass("entry-title", "h2"); // search URL returns
for (ximb=0; ximb<xpspana.length; ximb++) {
xxspare=xpspana[ximb].innerHTML.replace('</a>','').split('>');
xspare=xxspare[eval(-1 + xxspare.length)];
zspare=xspare.toLowerCase().replace(String.fromCharCode(35), "").replace(".", "").replace(".", "").replace(".", "").replace("+", "").replace("+", "").replace("'", "").replace('%27','').replace(/\//g, "").replace(/,/g, "").replace("---","-").replace("---","-").replace(/--/g,"-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-");
if (document.body.innerHTML.indexOf('d' + zspare) == -1) {
xpspana[ximb].innerHTML+=' <div style="display:inline-block;border:3px solid rgba(255,165,0,0.4); background-color:rgba(255,255,0,0.3); " id=cc' + zspare + '><a target=_blank style="cursor:pointer;display:inline-block;text-decoration:none; font-size:12px;" href=//www.rjmprogramming.com.au/slideshow.html?title=' + encodeURIComponent(xspare) + ' " title="Cut to the Chase to (the gist of) ' + (xspare) + '" id=tcc' + zspare + '>✂</a><a target=_blank style="background: rgba(0,255,0,0.3); background: -webkit-linear-gradient(left top, rgba(0,255,0,0.3), rgba(255,255,0,0.3)); background: -o-linear-gradient(bottom right, rgba(0,255,0,0.3), rgba(255,255,0,0.3)); background: -moz-linear-gradient(bottom right, rgba(0,255,0,0.3), rgba(255,255,0,0.3)); background: linear-gradient(to bottom right, rgba(0,255,0,0.3), rgba(255,255,0,0.3)); cursor:pointer;display:inline-block;text-decoration:none;transform: scale(-1, 1); -o-transform: scale(-1, 1); -moz-transform: scale(-1, 1); -ms-transform: scale(-1, 1); -webkit-transform: scale(-1, 1); font-size:12px;" href=//www.rjmprogramming.com.au/slideshow.html?title=' + encodeURIComponent(xspare) + ' " title="Cut to the Chase to (the gist of) ' + (xspare) + '" id=ttcc' + zspare + '>🏃🏾‍♀️🏃🏼‍♂️</a><iframe style=display:none; id=icc' + zspare + ' src=></iframe></div>';
xpspana[ximb].innerHTML+=' <div style="display:inline; background-color:rgba(255,255,0,0.3);" id=d' + zspare + '><a style="cursor:pointer;display:inline;text-decoration:none; border:2px solid yellow;" onclick=" preresize_font(this); document.getElementById(this.id.replace(String.fromCharCode(116),String.fromCharCode(105))).src=' + "'" + '//www.rjmprogramming.com.au/PHP/is_mentioned_by.php?title=' + encodeURIComponent(xspare) + "'" + '; setTimeout(precheckclass,3000); " title="' + (xspare) + ' is mentioned by ..." id=t' + zspare + '>☞</a><iframe style=display:none; id=i' + zspare + ' src=></iframe></div>';
}
}
xpspana=docgetclass("entry-title", "h1"); // real blog postings
for (ximb=0; ximb<xpspana.length; ximb++) {
xxspare=xpspana[ximb].innerHTML.replace('</a>','').split('>');
xspare=xxspare[eval(-1 + xxspare.length)];
zspare=xspare.toLowerCase().replace(String.fromCharCode(35), "").replace(".", "").replace(".", "").replace(".", "").replace("+", "").replace("+", "").replace("'", "").replace('%27','').replace(/\//g, "").replace(/,/g, "").replace("---","-").replace("---","-").replace(/--/g,"-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-");
if (document.body.innerHTML.indexOf('d' + zspare) == -1) {
xpspana[ximb].innerHTML+=' <div style="display:inline-block;border:3px solid rgba(255,165,0,0.4); background-color:rgba(255,255,0,0.3); " id=cc' + zspare + '><a target=_blank style="cursor:pointer;display:inline-block;text-decoration:none; font-size:12px;" href=//www.rjmprogramming.com.au/slideshow.html?title=' + encodeURIComponent(xspare) + ' " title="Cut to the Chase to (the gist of) ' + (xspare) + '" id=tcc' + zspare + '>✂</a><a target=_blank style="background: rgba(0,255,0,0.3); background: -webkit-linear-gradient(left top, rgba(0,255,0,0.3), rgba(255,255,0,0.3)); background: -o-linear-gradient(bottom right, rgba(0,255,0,0.3), rgba(255,255,0,0.3)); background: -moz-linear-gradient(bottom right, rgba(0,255,0,0.3), rgba(255,255,0,0.3)); background: linear-gradient(to bottom right, rgba(0,255,0,0.3), rgba(255,255,0,0.3)); cursor:pointer;display:inline-block;text-decoration:none;transform: scale(-1, 1); -o-transform: scale(-1, 1); -moz-transform: scale(-1, 1); -ms-transform: scale(-1, 1); -webkit-transform: scale(-1, 1); font-size:12px;" href=//www.rjmprogramming.com.au/slideshow.html?title=' + encodeURIComponent(xspare) + ' " title="Cut to the Chase to (the gist of) ' + (xspare) + '" id=ttcc' + zspare + '>🏃🏾‍♀️🏃🏼‍♂️</a><iframe style=display:none; id=icc' + zspare + ' src=></iframe></div>';
xpspana[ximb].innerHTML+=' <div style="display:inline; background-color:rgba(255,255,0,0.3);" id=d' + zspare + '><a style="cursor:pointer;display:inline;text-decoration:none; border:2px solid yellow;" onclick=" preresize_font(this); document.getElementById(this.id.replace(String.fromCharCode(164),String.fromCharCode(151))).src=' + "'" + '//www.rjmprogramming.com.au/PHP/is_mentioned_by.php?title=' + encodeURIComponent(xspare) + "'" + '; " setTimeout(precheckclass,3000); title="' + (xspare) + ' is mentioned by ..." id=t' + zspare + '>☞</a><iframe style=display:none; id=i' + zspare + ' src=></iframe></div>';
}
}
}

?>

… to move this newly created “Modified” (select element) dropdown from the Blog Posting content area over to the title of the Recent Posts widget to become that “Recent Posts” dropdown populated with a week’s worth of modified date changed blog posting titles that if selected navigate the user onto that blog posting.


Previous relevant WordPress Is Mentioned By Posting Order Tutorial is shown below.

WordPress Is Mentioned By Posting Order Tutorial

WordPress Is Mentioned By Posting Order Tutorial

We are revisiting the WordPress Blog “Is Mentioned By” functionality talked about at WordPress Is Mentioned By Posting Thread Tutorial for a few reasons …

  1. the order of blog postings that could end up on dropdowns as a result of this PHP code was not always chronological … and …
  2. the … “glimpse into” wording on the dropdown options told us (the users) nothing … and …
  3. the navigation off a user selected dropdown option was flaky and sporadic

… so let’s talk about these in more depth below …

  1. the order of blog postings that could end up on dropdowns as a result of this PHP code was not always chronological … so … we changed is_mentioned_by.php‘s central bit of SELECT (DML) SQL as per
    <?php

    $res = mysql_query("SELECT " . $tname . ".post_title, " . $tname . ".guid, " . $tname . ".post_content, LOCATE('" . $ourtitle . "'," . $tname . ".post_content) as tfind, LOCATE('" . $ourother . "'," . $tname . ".post_title) as tother, " . $tname . ".post_date as post_date FROM " . $tname . "
    WHERE " . $tname . ".post_status = 'publish' " . "
    AND (1 = 1 OR LOWER(" . $tname . ".post_title) != LOWER('" . $ourtitle . "')) " . "
    AND (" . $tname . ".post_content like CONCAT(CONCAT('%?p='," . $tname . ".guid), '%') " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',permalinkit($ourtitle)) . "%' " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourother) . "%' " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourtitle) . "%') UNION SELECT 'Code Download Table' as post_title, " . $tname . ".post_content as guid, '' as post_content, 1 as tfind, 0 as tother, CURTIME() as post_date FROM " . $tname . "
    WHERE " . $tname . ".post_status = 'publish' " . "
    AND LOWER(" . $tname . ".post_title) = LOWER('" . $ourtitle . "') " . "
    AND " . $tname . ".post_content like '%GETME%' ORDER BY post_date ");

    ?>
    … noting that ORDER BY clause fields should appear in the (SELECT) column list, and we chose to put it at the end (of that list) to avoid any array indexing code changes
  2. the … “glimpse into” wording on the dropdown options told us (the users) nothing … so … we changed is_mentioned_by.php‘s “function pluckfirstreal” as per
    <?php

    function pluckfirstreal($pcont) {
    $xpcont=$pcont;
    if (strpos($xpcont, "[/caption]</p>") !== false) {
    $xpcont=explode("[/caption]</p>", $pcont)[1];
    } else if (strpos($xpcont, "[/caption]") !== false) {
    $xpcont=explode("[/caption]", $pcont)[1];
    }

    $paras = explode("</p", str_replace("<p", "</p", $xpcont));
    if (sizeof($paras) > 2) {
    $oth = explode("<", $paras[1]);
    $retval = " ... ";
    for ($i=0; $i<sizeof($oth); $i++) {
    $huh = explode(">", $oth[$i]);
    $retval .= str_replace("'", "`", str_replace("}", " ", str_replace("{", " ", $huh[-1 + sizeof($huh)])));
    }
    return substr($retval,0,200);
    }
    return "";
    }

    ?>
  3. the navigation off a user selected dropdown option was flaky and sporadic … so … in (good ol’) header.php of the WordPress Blog TwentyTen theme folder we changed
    <?php

    function changed(inval,intxt) {
    if (1 == 1 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
    if (callwhat.length == 0) {
    parentwino(inval,intxt.toLowerCase(),'');
    }
    }

    if (callwhat.length > 1) {
    if (prevxcmd != "") {
    eval(prevxcmd);
    } else if (prevcmd != "") {
    eval(prevcmd.replace("''","'top=50,left=50,width=600,height=600'"));
    }
    prevxcmd="parentwino('" + inval + "','" + intxt.toLowerCase() + "','top=50,left=50,width=600,height=600')";
    prevcmd="";
    } else if (callwhat.length == 1) {
    if (sitlist.indexOf(',') != -1) {
    prevcmd="";
    prevxcmd="";
    var invala=sitlist.split(',');
    for (var ip=0; ip<invala.length; ip++) {
    if (prevxcmd != "") {
    eval(prevxcmd);
    } else if (prevcmd != "") {
    eval(prevcmd.replace("''","'top=50,left=50,width=600,height=600'"));
    }
    prevxcmd="parentwino('" + invala[ip] + "','" + intxt.toLowerCase() + "','top=50,left=50,width=600,height=600')";
    prevcmd="";
    }
    } else if (1 == 1) {
    parentwino(inval,intxt.toLowerCase(),'');
    } else {
    if (prevcmd != "") {
    eval(prevcmd);
    } else if (prevxcmd != "") {
    eval(prevxcmd.replace("'top=50,left=50,width=600,height=600'", "''"));
    }
    prevcmd="parentwino('" + inval + "','" + intxt.toLowerCase() + "','')";
    prevxcmd="";
    }
    }
    }

    function antiaway() {
    if (document.getElementById('hfloater') && document.getElementById('aaway')) {
    document.getElementById('hfloater').innerHTML=document.getElementById('hfloater').innerHTML.replace(' ' + document.getElementById('aaway').outerHTML, '');
    }
    }


    function parentwino(a, b, c) {
    var woisp=null, eqas=null;
    if (c == "") {
    try {
    if (woisp == null && document.getElementById('hfloater')) { // && !navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
    document.getElementById('hfloater').innerHTML+=' <a id="aaway" target="_blank" href="' + a + '" style="display:none;">WOpen</a>';
    document.getElementById('aaway').click();
    setTimeout(antiaway, 4300);
    } else {
    woisp=window.open(a,b);
    }
    } catch(eqas) {
    woisp=null;
    }

    return woisp; //window.open(a,b);

    } else {
    try {
    if (woisp == null && document.getElementById('hfloater')) { // && !navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
    document.getElementById('hfloater').innerHTML+=' <a id="aaway" target="_blank" href="' + a + '" style="display:none;">WOpen</a>';
    document.getElementById('aaway').click();
    setTimeout(antiaway, 4300);
    } else {
    woisp=window.open(a,b,c);
    }
    } catch(eqas) {
    woisp=null;
    }
    }

    return woisp; //window.open(a,b,c);
    }

    ?>
    … helping reduce the amount of Javascript window.open we call (and use)
  4. To try this, try the “emoji button” above.


    Previous relevant WordPress Is Mentioned By Posting Thread Tutorial is shown below.

    WordPress Is Mentioned By Posting Thread Tutorial

    WordPress Is Mentioned By Posting Thread Tutorial

    At this blog we are keen for users to learn one off ideas and on occasions linked “threaded” (or blog postings of a theme) ones.

    The last WordPress Blog (TwentyTen theme) “Is Mentioned by” functionality is good for certain scenarios, but what if you arrive at a blog posting that is part of a “threaded” series of blog postings? We normally show you older ones and that’s fine. But I’m not so much talking about the avid reader here who follows it “hot off the press” but more the users finding things off search engines, coming to this blog, and the posting they get to may not be the last in the “thread”. Below the blog posting they log in at, the reader can read all the information of the past to do with the thread, but what of getting it into context, relative to the entire “thread” up to that point, or out more recently “beyond” it? Well, that is the purpose of today’s extension of functionality to the WordPress Blog “Is Mentioned by” functionality we last finished up discussing with WordPress Is Mentioned By Code Download Progress Tutorial as shown below.

    Surprisingly the WordPress Blog TwentyTen theme’s header.php does not need to change to make this happen. The PHP that queries the WordPress MySql database can handle all the change today, and ended up looking like is_mentioned_by.php changing this way.

    The method is to …

    • query the MySql database with a more complex query that results in data for …
    • “is mentioned by” and “is part of a blog posting thread” are represented by two separate dropdowns … and …
    • in order to show you the context of the current blog posting in a blog posting “thread” we have an HTML select size property set to the number of dropdown records … alas, mobile platforms do not honour the size property regarding their display of dropdowns … display and set the selected property to the current blog posting’s entry, with this entry consisting of …
    • a blog posting title and the first paragraph of content are put into the “is part of a blog posting thread” dropdown option text to enhance the context for the user, shown this list with the most recent posting first down in reverse chronological order to the older blog posting of the “thread” down the bottom

    Below in bold is how the MySql query got more complex …


    $res = mysql_query("SELECT " . $tname . ".post_title, " . $tname . ".guid, " . $tname . ".post_content, LOCATE('" . $ourtitle . "'," . $tname . ".post_content) as tfind, LOCATE('" . $ourother . "'," . $tname . ".post_title) as tother FROM " . $tname . "
    WHERE " . $tname . ".post_status = 'publish' " . "
    AND (1 = 1 OR LOWER(" . $tname . ".post_title) != LOWER('" . $ourtitle . "')) " . "
    AND (" . $tname . ".post_content like CONCAT(CONCAT('%?p='," . $tname . ".guid), '%') " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',permalinkit($ourtitle)) . "%' " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourother) . "%' " . "
    OR " . $tname . ".post_content like '%" . str_replace('youllneverfindthis','%',$ourtitle) . "%') UNION SELECT 'Code Download Table' as post_title, " . $tname . ".post_content as guid, '' as post_content, 1 as tfind, 0 as tother FROM " . $tname . "
    WHERE " . $tname . ".post_status = 'publish' " . "
    AND LOWER(" . $tname . ".post_title) = LOWER('" . $ourtitle . "') " . "
    AND " . $tname . ".post_content like '%GETME%'");

    where the (new) variable $ourother is set to being the first few words of the blog posting title.

    In order to “pluck out” one paragraph from the content (of variable $pcont) we use …


    function pluckfirstreal($pcont) {
    $paras = explode("</p", str_replace("<p", "</p", $pcont));
    if (sizeof($paras) > 2) {
    $oth = explode("<", $paras[1]);
    $retval = " ... ";
    for ($i=0; $i<sizeof($oth); $i++) {
    $huh = explode(">", $oth[$i]);
    $retval .= str_replace("'", "`", str_replace("}", " ", str_replace("{", " ", $huh[-1 + sizeof($huh)])));
    }
    return substr($retval,0,200);
    }
    return "";
    }

    … to append to the blog posting title as the user’s dropdown text for contextual purposes.

    Stop Press

    Was this a Bad Day at Black Rock? We revisit this work with WordPress Is Mentioned By Posting Order Tutorial.


    Previous relevant WordPress Is Mentioned By Code Download Progress Tutorial is shown below.

    WordPress Is Mentioned By Code Download Progress Tutorial

    WordPress Is Mentioned By Code Download Progress Tutorial

    There are various approaches with user experience (UX) considerations regarding putting a web application user at their ease as they wait for a response. I’m talking about where the response is coming from a separate serverside script doing something that may take a while, such as querying a database for instance, and that responder will do the work back at its parent to say it has finished its job. Given all this, you may be asking “What is there left to worry about, with the user, if the responder is doing this?”. Well, there is that amount of time between …

    • clicking the action item of HTML at the parent … all the way through to …
    • the responder “child”, often serverside code (for us, PHP), finishing its work and fixing the parent webpage to indicate that it has finished its work

    Now, we all hope this time period is short, and, hopefully, most of the time, it is short, and perhaps it is “overkill” to worry about doing anything here. However there are some things to consider …

    • if you are writing commercial software code there could well be an UX expectation that you would code for this, to keep the user informed at all times … and …
    • it could be the case that the database crashes at that very “clicking” moment, and though your responder may not get back to the parent with information, at least if you’ve coded for the scenario back at the client, at least the user will know something is being attempted, even if it doesn’t appear to be succeeding, which is less frustrating than getting no information at all, which could be mistaken for software code “hanging” … definitely not a great UX feel, or look

    Now there are a variety of client code approaches for showing “progress”, such as …

    • additional progress bar … like
    • additional meter … like
    • something you just clicked, changing appearance cyclically over time

    That last one appeals to us for a recent bit of functionality we added to this WordPress Blog you are reading, as well as for the fact that what we show “progress” on is difficult to numerically quantify as far as completion time is concerned, and so the first two above are not as suitable. We actually change the HTML div element font size to make an emoji “button” pressed “throb” while the user waits for the PHP and MySql query to respond back. Do you remember our thread of blog posting that used to end with WordPress Is Mentioned By Code Download CSS Tutorial? That’s the functionality we’re talking about today, as we do at WordPress 4.1.1’s WordPress Is Mentioned By Code Download Progress Tutorial.

    Now reading that previous link’s content below, you may see that we have considered the scenario of the child responder not finding any mentions and responding with …

    Sadly, this tutorial is not mentioned by any others, yet

    … which is good, but it may either take a long time for the responder to work this out, or, as we’ve indicated above, the responder’s mechanism for finding out may fail, and we’re dealing with that, from the perspective of the user looking at the client webpage, and waiting for information after clicking that emoji link we introduced when we did that work in that tutorial.

    We decided to prove our method with a “proof of concept” local MAMP web server HTML and Javascript and CSS parent taking …

    1. one blog posting bit of HTML body HTML …
    2. the is_mentioned_by function renamed to was_is_mentioned_by and a new is_mentioned_by worked until it works, tested via the Safari web browser’s Develop menu’s Web Inspector (similar to the Firefox Firebug web inspector we tend to go on and on and on and on and on and on about at this blog)

    … that took the form of this imb_poc.html … supervising the reworked PHP serverside code is_mentioned_by.php on MAMP that is, deliberately, made to …

    • wreck the connection to MySql … and then intervene to …
    • change the die message to instead sleep(18) before showing “Sadly, this tutorial is not mentioned by any others, yet” … at which time our changes should look good UX wise for the user

    We must stress this about “proof of concept”. Don’t waste time on “proof of concept” with too much fine grain simulation of the original scenario, if it is not involved in what you are proving, that is different, and is what is being tested here. See how it can even be that it suits the purposes of some “proof of concept” scenarios, like today’s, that you wreck the MySql connection in a progress “proof of concept” scenario, for example?

    We made these WordPress Blog changes in good ol’ TwentyTen themed header.php, as we so often do, and show changed code bold below …


    <script>
    var ourfs=21, zzzspare='';
    // ...
    // lots of other Javascript code
    // ...
    // down to ...

    function preresize_font(aois) {
    zzzspare=aois.id.replace('t','d');
    resize_font();
    }

    function resize_font() {
    ourfs=eval((ourfs + 5) % 45);
    if (document.getElementById(zzzspare).innerHTML.indexOf('<select ') != -1) {
    ourfs=21;
    } else {
    setTimeout(resize_font, 500);
    }
    document.getElementById(zzzspare).style.fontSize='' + ourfs + 'px';
    }

    function is_mentioned_by() {
    var zspare,xspare,xxspare,ximb,xpspana=docgetclass("entry-title", "h2");
    for (ximb=0; ximb<xpspana.length; ximb++) {
    xxspare=xpspana[ximb].innerHTML.replace('</a>','').split('>');
    xspare=xxspare[eval(-1 + xxspare.length)];
    zspare=xspare.toLowerCase().replace(String.fromCharCode(35), "").replace(".", "").replace(".", "").replace(".", "").replace("+", "").replace("+", "").replace("'", "").replace('%27','').replace(/\//g, "").replace(/,/g, "").replace("---","-").replace("---","-").replace(/--/g,"-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-");
    if (document.body.innerHTML.indexOf('d' + zspare) == -1) xpspana[ximb].innerHTML+=' <div style="display:inline;" id=d' + zspare + '><a style="cursor:pointer;display:inline;text-decoration:none; border:2px solid yellow;" onclick=" preresize_font(this); document.getElementById(this.id.replace(String.fromCharCode(116),String.fromCharCode(105))).src=' + "'" + 'http://www.rjmprogramming.com.au/PHP/is_mentioned_by.php?title=' + encodeURIComponent(xspare) + "'" + '; " title="' + (xspare) + ' is mentioned by ..." id=t' + zspare + '>☞</a><iframe style=display:none; id=i' + zspare + ' src=></iframe></div>';
    }
    xpspana=docgetclass("entry-title", "h1");
    for (ximb=0; ximb<xpspana.length; ximb++) {
    xxspare=xpspana[ximb].innerHTML.replace('</a>','').split('>');
    xspare=xxspare[eval(-1 + xxspare.length)];
    zspare=xspare.toLowerCase().replace(String.fromCharCode(35), "").replace(".", "").replace(".", "").replace(".", "").replace("+", "").replace("+", "").replace("'", "").replace('%27','').replace(/\//g, "").replace(/,/g, "").replace("---","-").replace("---","-").replace(/--/g,"-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-");
    if (document.body.innerHTML.indexOf('d' + zspare) == -1) xpspana[ximb].innerHTML+=' <div style="display:inline;" id=d' + zspare + '><a style="cursor:pointer;display:inline;text-decoration:none; border:2px solid yellow;" onclick=" preresize_font(this); document.getElementById(this.id.replace(String.fromCharCode(164),String.fromCharCode(151))).src=' + "'" + 'http://www.rjmprogramming.com.au/PHP/is_mentioned_by.php?title=' + encodeURIComponent(xspare) + "'" + '; " title="' + (xspare) + ' is mentioned by ..." id=t' + zspare + '>☞</a><iframe style=display:none; id=i' + zspare + ' src=></iframe></div>';
    }
    }

    … where is_mentioned_by function is called by the document.body onload event, to trigger all this. You can see some of all this with today’s tutorial picture, and by trying to click some of the right pointing emoji “is mentioned by” functionality “buttons” you see next to Blog Posting Titles around you here at this WordPress TwentyTen themed blog, but here’s hoping you don’t see too many throbbing emojis … heaven forbid?!

    Stop Press

    More regarding this CSS cursor property tomorrow.


    Previous relevant WordPress Is Mentioned By Code Download CSS Tutorial is shown below.

    WordPress Is Mentioned By Code Download CSS Tutorial

    WordPress Is Mentioned By Code Download CSS Tutorial

    A few things come together for today’s user experience (UX) inspired tutorial whereby …

    … to make what we are doing stand out more for the user, who may “swim” in a large table devoid of any styling to focus their attention.

    We’ll leave you with modified PHP, that writes out the HTML Code Download Table manipulator, you could call getmelist.php and which changed in this way to make the Code Download Table be more usercentric with its presentation of hashtagged calls linking a WordPress Blog Posting at this blog with a particular piece of software code of interest in our Code Download Table.

    Hope you try this functionality out for yourself.


    Previous relevant WordPress Is Mentioned By Code Download Navigation Tutorial is shown below.

    WordPress Is Mentioned By Code Download Navigation Tutorial

    WordPress Is Mentioned By Code Download Navigation Tutorial

    We’re following up on some recent WordPress navigation logic today, that we started with WordPress Is Mentioned By Navigation Primer Tutorial as shown below, for blog posting relationships between …

    • A blog posting being referred to … back, optionally, as a link, to …
    • A blog posting that mentioned that blog posting currently being viewed

    … and looking at this premise, it stands to reason that as helpful as this concept looks on paper, if a regular reader expects a recent posting be referred to by others “hot off the press” they’d be expecting quite a lot, and though what they get in this scenario …

    Sadly, this tutorial is not mentioned by any others, yet

    … probably does a good job tweaking them to the dilemma of “hot off the press” being “too recent to be referred to” it still remains a disappointment, perhaps. So, thinking a tad laterally on this, what is going to help out here will be to particularize the scenario for what we do around here … and am sorry if this annoys, but we are showing a line of thinking here … and allow for Blog Posts that contain the word “GETME” … our favourite code download mechanism around here … to add a “Code Download Table” dropdown option, that if selected will lob the user directly onto the RJM Programming Code Download Table entry for the first “GETME” file link found in that blog posting. This additional scouring of the MySql database, that utilizes the SQL UNION operator (the “adding an extra clause or paragraph” SQL operator, we like to think of it as) with its query, will not be relevant to all unmentioned blog postings, but it will help those that talk about software coding, which is quite a few.

    That functionality had us looking back at how the Code Download Table was constructed in terms of its hashtagging when we discussed PHP Blog Summary Follow Up Tutorial. In this way, we had a first try at …

    • … using the hashtagging for a date … as you see with these changes to is_mentioned_by.php at the left hand column of the Code Download Table … did a couple of unit tests seeing the first one work, the second one work if you take it a day back, and the third one not work at all, at which point it tweaked with us that the date in the Code Download Table is a date reflected by the software code file’s modified date, not the WordPress Blog Posting publication date, that we can derive off our amended query … so that being less friendly than we envisaged we end up …
    • … using the very interesting hashtagging that particularizes the filename, where the read file extension (minus all the “GETME” and “-“‘s and “_”‘s that is) is taken out of the prefix to the hashtag, and made into a suffix … like “analogue_clock.-GETMEhtml” for Analogue Clock Timezone Tutorial that is exemplified in today’s tutorial picture and as you can see the changes for at this is_mentioned_by.php link

    So it panned out to make this happen the original Code Download Table code did not need any tweaking, not good ol’ WordPress TwentyTen theme header.php … just is_mentioned_by.php … but we hope you try out clicking some “White Right Pointing Index” emoji …

    … at this WordPress blog sometime soon.

    Did you know?

    What gives with the &tsp=[someBigNumber] GET parameter … like is yellow highlighted in today’s tutorial picture … in the “Code Download Table” lookup URLs? This is so that we end up with different URLs each time a user accesses this functionality. This is because web browsers often try to help you out with speeding up your browsing, and use the web browser cache to “regurgitate” a previously visited URL should that have happened since the last clearing of any web browser cache, to “slap” the cache version quickly on the screen. But we don’t want any “slapping” to go on around our functionality today, and a way to force the web browser to reconsider the real lookup, and go back to the real web server again for data, is to make your URL be unique. A curiosity here you can try is to use something like a local MAMP (for Mac or EasyPHP for Windows) local web server to, for an image file called image.jpg that is put into the Apache web server’s Document Root

    1. see the image in your favoured web browser with the URL http://localhost:8888/image.jpg … then …
    2. change that image somehow with an image editor … and …
    3. refresh, or revisit the image with the URL http://localhost:8888/image.jpg … and you’ll probably see the cached web server version … unless you haven’t got web browser caching going … so amend this to …
    4. revisit the image with the URL http://localhost:8888/image.jpg?random=7456536 … and this time we think you’ll see the amended image that happened with your image editing … and yes, you can add GET parameters to your URLs even for image URLs (often, most helpfully with image URLs, actually)

    Previous relevant WordPress Is Mentioned By Navigation Primer Tutorial is shown below.

    WordPress Is Mentioned By Navigation Primer Tutorial

    WordPress Is Mentioned By Navigation Primer Tutorial

    We’ve written some new WordPress navigation logic today, for blog posting relationships between …

    • A blog posting being referred to … back, optionally, as a link, to …
    • A blog posting that mentioned that blog posting currently being viewed

    … done, because we see that it is not only the “vertical” type linking of blog postings into a “thread” that helps understanding … we hope … but also to jump around among commonalities between concepts (like “horizontal” “degrees of separation”), perhaps. This functionality involves MySql database queries, and is best suited to a user clicks something (rather than pre-emptive content loading) to reach the functionality so that our database query has a post title to work with, and also so that every blog post does not overload the web server with a query ahead of time whose work may not be accessed anyway. The something that is clicked is an HTML a tag whose “look” is an Emoji.

    We also wrote a proof of concept, before applying that proof of concept live. To us, a “proof of concept” is not much use if it is as involved as what it is trying to prove, and in today’s scenario we did a proof of concept for two scenarios, that being …

    • a blog posting that was referred to by others … and …
    • a blog posting that wasn’t … doh! … but if you don’t change something about the “look of things” you’ll confuse the user as to whether the web application just took notice of their click (via the onclick event) … so this is of mild importance, but we grant you that it is not as important as the first scenario’s workings

    We quite often adopt a proof of concept scenario which tests the workings of a child (often in an HTML iframe element), in this case, PHP server side, piece of code, by introducing a simplified and pared down parent, in this case HTML piece of code. At the end of successful testing you are left with a good, and close to totally suitable child piece of code, to slot into the functionality of the real and live parent code.

    That proof of concept was definitely a good “unit testing” thing to do, but nevertheless, don’t feel overconfident as you go live … living with other real “goings on” on the live website are things to consider, and test … it took us half an hour to iron out these types of issues.

    The other good thing to have on your side is a Web Inspector like on Safari, similar to the Firefox Firebug web inspector we tend to go on and on and on and on and on and on about at this blog. We’re giving you a Safari rest on that today, and we want to show you an “early days” view …

    … in the proof of concept help that the Safari Web Inspector gave us, delving in under the called (by HTML parent) PHP’s actions. This type of information makes server side programming, like you do with PHP, that much easier … much easier than ideas where you write out web server files, with information, for your own benefit, or the other one we often like, during testing, is to write information out to top.document.title or perhaps to an alert box or to use console.log (on the debugging window, down the bottom).

    You’ll never guess where we made this change to our WordPress TwentyTen themed blog? Give up … yes, good ol’ header.php changed in the bold Javascript new function way below …



    function is_mentioned_by() {
    var zspare,xspare,xxspare,ximb,xpspana=docgetclass("entry-title", "h2");
    for (ximb=0; ximb<xpspana.length; ximb++) {
    xxspare=xpspana[ximb].innerHTML.replace('</a>','').split('>');
    xspare=xxspare[eval(-1 + xxspare.length)];
    zspare=xspare.toLowerCase().replace(String.fromCharCode(35), "").replace(".", "").replace(".", "").replace(".", "").replace("+", "").replace("+", "").replace("'", "").replace('%27','').replace(/\//g, "").replace(/,/g, "").replace("---","-").replace("---","-").replace(/--/g,"-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-");
    if (document.body.innerHTML.indexOf('d' + zspare) == -1) xpspana[ximb].innerHTML+=' <div style="display:inline;" id=d' + zspare + '><a style="display:inline;text-decoration:none; border:2px solid yellow;" onclick=" document.getElementById(this.id.replace(String.fromCharCode(116),String.fromCharCode(105))).src=' + "'" + 'http://www.rjmprogramming.com.au/PHP/is_mentioned_by.php?title=' + encodeURIComponent(xspare) + "'" + '; " title="' + (xspare) + ' is mentioned by ..." id=t' + zspare + '>&#9758;</a><iframe style=display:none; id=i' + zspare + ' src=></iframe></div>';
    }
    xpspana=docgetclass("entry-title", "h1");
    for (ximb=0; ximb<xpspana.length; ximb++) {
    xxspare=xpspana[ximb].innerHTML.replace('</a>','').split('>');
    xspare=xxspare[eval(-1 + xxspare.length)];
    zspare=xspare.toLowerCase().replace(String.fromCharCode(35), "").replace(".", "").replace(".", "").replace(".", "").replace("+", "").replace("+", "").replace("'", "").replace('%27','').replace(/\//g, "").replace(/,/g, "").replace("---","-").replace("---","-").replace(/--/g,"-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-");
    if (document.body.innerHTML.indexOf('d' + zspare) == -1) xpspana[ximb].innerHTML+=' <div style="display:inline;" id=d' + zspare + '><a style="display:inline;text-decoration:none; border:2px solid yellow;" onclick=" document.getElementById(this.id.replace(String.fromCharCode(164),String.fromCharCode(151))).src=' + "'" + 'http://www.rjmprogramming.com.au/PHP/is_mentioned_by.php?title=' + encodeURIComponent(xspare) + "'" + '; " title="' + (xspare) + ' is mentioned by ..." id=t' + zspare + '>&#9758;</a><iframe style=display:none; id=i' + zspare + ' src=></iframe></div>';
    }
    }

    … called by …


    <body onload=" checkonl(); setTimeout(initpostedoncc, 3000); widgetcon(); precc(); courseCookies(); cookie_fonts(); is_mentioned_by(); " <?php body_class(); ?>>

    Team that with some new PHP source code you could call is_mentioned_by.php and you have today’s new WordPress blog TwentyTen theme “Is Mentioned By” functionality.

    The proof of concept parent HTML was is_mentioned_by.html for your perusal.

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

Canvas Methods DrawImage Method Tutorial

Canvas Methods DrawImage Method Tutorial

Canvas Methods DrawImage Method Tutorial

Today we’re completing our HTML5 canvas [canvasContext].drawImage method started recently with Canvas Methods Revisit Tutorial where we had a start using …

  1. Positioning … via 3 arguments …

    [canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate]);

    … today we add …
  2. Positioning and Scaling … via 5 arguments …

    [canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate], [Width], [Height]);
  3. Slicing and Scaling and Cropping … via 9 arguments …

    [canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate], [ClippedWidth], [ClippedHeight], [Final X co-ordinate], [Final Y co-ordinate], [FinalWidth], [FinalHeight]);

So feel free to have a go yourself with the changed svg_to_canvas.html “what we’ll call” Canvas Showcase web application you can also try below.


Previous relevant Canvas Methods Revisit Tutorial is shown below.

Canvas Methods Revisit Tutorial

Canvas Methods Revisit Tutorial

When we started being “blown away” by the potential of the HTML5 canvas element coming into play quite some time ago now, it was a bit like …

Wow!! But where to start?

… and due to our naivety we were not in a position back then to break down what was “cut through” (or not that practical, perhaps) about the canvas element “methods” with any authority. Over the years, though, we are more equipped, so what we are setting out to do is …

  • start with, though written a while ago, still to this day, feels like an advanced canvas application (as explained at Canvas DrawImage First Parameter Primer Tutorial) involving video elements (ie. we got a lot of help, thanks all) … and use this template …
  • to work it the other way (via new dropdown elements), building on “what you might aspire to if you are a beginner with the canvas element” and display new options to emphasise the huuuuuuuuuuuuugely valuable canvas methods out there (yes, OOP methods, not functions, as such)

The first cab off the rank here is the …


[canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate]);

… simplest usage of that drawImage method (in “OOP land” this 3 argument call can be thought of as “not the same logic” as (what we are going to get to later, for example) a 9 argument call). A form is presented here, and you, the user, can see the effects of controlling the 3 arguments (and you’ll notice “no truck” is given to any 5 minute? arguments here).

Feel free to have a go yourself with the changed svg_to_canvas.html “what we’ll call” Canvas Showcase web application you can also try below …


Previous relevant Canvas DrawImage First Parameter Primer Tutorial is shown below.

Canvas DrawImage First Parameter Primer Tutorial

Canvas DrawImage First Parameter Primer Tutorial

Some time ago we presented a short tutorial about a great online product addressing a big area of interest to online users … online meetings. We showcased the great GoToMeeting, with GoToMeeting Primer Tutorial, and we remember using it to good effect among …

  • installing software remotely
  • diagnosing software and hardware issues remotely
  • discussing issues remotely
  • client liaison remotely

… at a job involving EDI solutions with SAP Business One and Accpac. But that is just the subject matter basis here. Today we really want to use some media from that subject matter basis and use it’s video media as the first argument to the wonderful, the stupendous Canvas drawImage() Method, specifically its fascinating first parameter

Syntax
Position the image on the canvas:

context.drawImage(img, x, y)
Position the image on the canvas, and specify width and height of the image:

context.drawImage(img, x, y, width, height)
Clip the image and position the clipped part on the canvas:

context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height)

Don’t be fooled! It is a method offering, thanks, so much more that just an

el interface intrinsicHeight(el) intrinsicWidth(el)
HTMLImageElement el.naturalWidth el.naturalHeight
SVGImageElement el.[… special case] el.[… special case]
HTMLVideoElement el.videoWidth el.videoHeight
HTMLCanvasElement el.width el.height
ImageBitmap el.width el.height
OffscreenCanvas el.width el.height

… but whaaaaatttttt?! What happens here assigning a video object as a first parameter to the canvas (context)’s drawImage method? It takes a snapshot image of the slide of the playing (and if not, the first image of that) video! That means, couch that in a codeline like …


setInterval(function(){ ctx.drawImage(ovid, 800, 0); }, 100);

… at the right time, and you can be playing a video into the canvas! Yay!!! Actually, we’ve done this before, and, call us innocents if you like, but this gave us the same thrill then, thanks to all the online contributors regarding heads up ideas here.

But we are “value adding” today. It hadn’t occurred to us that we could do this video to the right of the canvas and dedicate the left side to captions, and that over there, there was enough room to show the “whole blurb” … and nothing but the blurb, and that if we use …

  • HTML video element attribute … autostart=true
  • HTML video element attribute … autoplay=true
  • HTML video element attribute … loop=true

… even if they do not work right from the document.body onload event time, once the video play button is clicked, we could do without the actual video from then on, perhaps (we’ve allowed you to resurrect the video display, and have more work into the future, maybe, regarding the repercussions of this … we’ll see?!).

What form of caption source did we use? We happened to have a “.srt” format WebVTT file pertinent to the GoToMeeting video hanging about, and so we shoved it into the innards of an HTML textarea element, and coded it from there …


<html>
<head>
<title>SVG to Canvas - RJM Programming - May, 2024 ... thanks to https://jsfiddle.net/Na6X5/</title>
<style>
canvas {
border: 1px solid gray;
}
</style>
<script type='text/javascript'>
var divstrc='';
var timings=[];
var times=[];
var tstimes=[];
var blurbs=[];
var cf = "12px Verdana";
var thisy=20, thisi=0, thisc=0;
var can=null, ctx=null;
var collist=['black','blue','purple','magenta','darkred','darkgreen'];
var lenc=eval('' + collist.length);
var oppmode='none';

function tanal(intr) {
var pts=intr.split(':');
console.log(intr);
tstimes.push(eval(eval(pts[0] * 60 * 60 * 1000) + eval(pts[1] * 60 * 1000) + eval(pts[2] * 1000)));
return intr;
}

function onl() {
can = document.getElementById('canvas1');
ctx = can.getContext('2d');

var svg = document.getElementById('simage');
var oimg = document.getElementById('simg');
var ovid = document.getElementById('myvd');

divstrc=document.getElementById('divsrt').value;
timings=divstrc.split(' --> ');
//alert(timings.length);
times.push(tanal(timings[0].slice(-13).trim()));
for (var ii=1; ii<timings.length; ii++) {
if (1 == 2) { times.push(tanal(timings[ii].substring(0,13).trim())); }
if (eval(1 + ii) != eval('' + timings.length)) {
times.push(tanal(timings[ii].slice(-13).trim()));
} else {
times.push(tanal(timings[ii].substring(0,13).trim()));
}
blurbs.push(timings[ii].split(String.fromCharCode(10))[1]);
}

console.log(blurbs);
console.log(tstimes);

var img = new Image();
img.onload = function() {
//ctx.drawImage(svg, 0, 0);
//ctx.drawImage(img, 200, 0);
//ctx.drawImage(oimg, 400, 0);
//ovid.play();
setInterval(function(){ ctx.drawImage(ovid, 800, 0); }, 100);
}
//img.src = "http://upload.wikimedia.org/wikipedia/commons/d/d2/Svg_example_square.svg";
//img.src = "/hexagon.svg";
//img.src = "/homecircle.svg";
img.src=oimg.src;
}

function dotext() {
if (eval(1 + thisi) >= eval('' + tstimes.length)) {
thisc++;
if (thisc >= eval('' + collist.length)) {
collist.push(collist[eval(thisc % lenc)]);
}
return loadsrt('');
}
setTimeout(dotext, eval(tstimes[eval(1 + thisi)] - tstimes[eval(0 + thisi)]));
ctx.font = cf;
ctx.strokeStyle=collist[thisc];
ctx.strokeText(blurbs[thisi],20,thisy);
thisy+=15;
thisi++;
}

function loadsrt(dsp) {
thisi=0;
thisy=20;
setTimeout(dotext, tstimes[0]);
if (dsp != '') {
document.getElementById('mysummary').innerHTML='Please click to toggle video display ...';
}
return dsp;
}
</script>
</head>
<body onload="onl();">
<canvas style='background-color:yellow;' id="canvas1" width="1400" height="400"></canvas>

<div id=previd style="display:none;">
<svg id="mySVG" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect width="150" height="150" fill="rgb(0, 255, 0)" stroke-width="1" stroke="rgb(0, 0, 0)"/>
</svg>

<svg id="mySVGimage" width="300" height="300" viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" version="1.1">
<image id=simage href="/hexagon.svg" height="300" width="300" />
</svg>

<img id=simg src='data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve" height="100px" width="100px">
<g>
<path d="M28.1,36.6c4.6,1.9,12.2,1.6,20.9,1.1c8.9-0.4,19-0.9,28.9,0.9c6.3,1.2,11.9,3.1,16.8,6c-1.5-12.2-7.9-23.7-18.6-31.3 c-4.9-0.2-9.9,0.3-14.8,1.4C47.8,17.9,36.2,25.6,28.1,36.6z"/>
<path d="M70.3,9.8C57.5,3.4,42.8,3.6,30.5,9.5c-3,6-8.4,19.6-5.3,24.9c8.6-11.7,20.9-19.8,35.2-23.1C63.7,10.5,67,10,70.3,9.8z"/>
<path d="M16.5,51.3c0.6-1.7,1.2-3.4,2-5.1c-3.8-3.4-7.5-7-11-10.8c-2.1,6.1-2.8,12.5-2.3,18.7C9.6,51.1,13.4,50.2,16.5,51.3z"/>
<path d="M9,31.6c3.5,3.9,7.2,7.6,11.1,11.1c0.8-1.6,1.7-3.1,2.6-4.6c0.1-0.2,0.3-0.4,0.4-0.6c-2.9-3.3-3.1-9.2-0.6-17.6 c0.8-2.7,1.8-5.3,2.7-7.4c-5.2,3.4-9.8,8-13.3,13.7C10.8,27.9,9.8,29.7,9,31.6z"/>
<path d="M15.4,54.7c-2.6-1-6.1,0.7-9.7,3.4c1.2,6.6,3.9,13,8,18.5C13,69.3,13.5,61.8,15.4,54.7z"/>
<path d="M39.8,57.6C54.3,66.7,70,73,86.5,76.4c0.6-0.8,1.1-1.6,1.7-2.5c4.8-7.7,7-16.3,6.8-24.8c-13.8-9.3-31.3-8.4-45.8-7.7 c-9.5,0.5-17.8,0.9-23.2-1.7c-0.1,0.1-0.2,0.3-0.3,0.4c-1,1.7-2,3.4-2.9,5.1C28.2,49.7,33.8,53.9,39.8,57.6z"/>
<path d="M26.2,88.2c3.3,2,6.7,3.6,10.2,4.7c-3.5-6.2-6.3-12.6-8.8-18.5c-3.1-7.2-5.8-13.5-9-17.2c-1.9,8-2,16.4-0.3,24.7 C20.6,84.2,23.2,86.3,26.2,88.2z"/>
<path d="M30.9,73c2.9,6.8,6.1,14.4,10.5,21.2c15.6,3,32-2.3,42.6-14.6C67.7,76,52.2,69.6,37.9,60.7C32,57,26.5,53,21.3,48.6 c-0.6,1.5-1.2,3-1.7,4.6C24.1,57.1,27.3,64.5,30.9,73z"/>
</g>
</svg>'></img>
</div>

<details onclick=" document.getElementById('myvd').style.display=oppmode; if (oppmode == 'block') { oppmode='none'; } else { oppmode='block'; }" open><summary id=mysummary>Please click play button below ...</summary>
<video onplay="this.style.display=loadsrt('none');" id=myvd autoplay=true autostart=true loop=true controls><source src='/Mac/GoToMeeting/GoToMeeting.m4v' type='video/mp4'></source></video>
<div id=divhs style=display:inline-block;vertical-align:top;>
<h1>Video and Captions to Canvas</h1>
<h3>RJM Programming - May, 2024</h3>
<h4>Thanks to https://jsfiddle.net/Na6X5/</h4>
</div>
</details>

<textarea id=divsrt style="display:none;">
WEBVTT FILE

1
00:00:00.100 --> 00:00:01.000 D:vertical A:start
Welcome to our GoTo Meeting tutorial ...
{
"title": "GoTo Meeting tutorial image 1 of 5",
"description": "Welcome to our GoTo Meeting tutorial",
"src": "gm1.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

2
00:00:01.000 --> 00:00:04.000
... we've installed GoTo Meeting and started it up. We have done the invite so we will be the "Presenter" ...

3
00:00:04.000 --> 00:00:06.000
... we click "Show My Screen" ...
{
"title": "GoTo Meeting tutorial image 2 of 5",
"description": "Show My Screen",
"src": "gm2.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

4
00:00:06.000 --> 00:00:16.000
... which is enabled because we are the "Presenter". Now lets ready other things ready to make a connection ...

5
00:00:16.000 --> 00:00:22.000
... we click "Show My Webcam" and start Connecting ...
{
"title": "GoTo Meeting tutorial image 3 of 5",
"description": "Show My Webcam",
"src": "gm3.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

6
00:00:22.000 --> 00:00:24.000
... the GoTo Viewer appears showing you a view of the person you are meeting ...

7
00:00:24.000 --> 00:00:26.000
... we have "lift off" ...
{
"title": "GoTo Meeting tutorial image 4 of 5",
"description": "Lift Off",
"src": "gm4.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

8
00:00:26.000 --> 00:00:28.000
... lo and behold, we've called ourself ...

9
00:00:28.000 --> 00:00:32.000
... have a look at us looking at us ...

10
00:00:32.000 --> 00:00:52.000
... but don't let it blow your mind?!
{
"title": "GoTo Meeting tutorial image 5 of 5",
"description": "Don't blow your mind",
"src": "gm5.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

11
00:00:52.000 --> 00:01:34.000
Leaving the GoTo Meeting now. See you again soon.

</textarea>

</body>
</html>

Yes, we started the day with a different idea, and end up where we are at with our first draft proof of concept Video to Canvas web application incarnation … again.


Previous relevant GoToMeeting Primer Tutorial is shown below.

GoToMeeting Primer Tutorial

GoToMeeting Primer Tutorial

Here is a tutorial that introduces you to GoToMeeting. GoToMeeting is a great user-friendly video conferencing software by Citrix.

For simple scenarios I’ve always felt comfortable with GoToMeeting for that video conferencing functionality, or for how I usually used it, remotely testing, troubleshooting and/or installing software on remote client sites. Other choices for all Windows scenarios, here are Remote Desktop, and for mixed scenarios, VNC.

GoToMeeting can work with a phone connection or by using the Microphone and Speakers at both ends of the connection. You can host the meeting or join the meeting, share your keyboard or mouse, share your display via a shared webcam, as necessary, meet straight away, or schedule it, or email an invitation … all in all there is a lot of great functionality. Like with Skype, audio and visual can be considered separate … from our tutorial session here is some audio, and here is some visual (ie. video).

Other such meeting ideas can be accessed via Skype, or WebEx Web Conferencing. All these are great ideas that can save companies lots of money on overseas trips!

Link to GoToMeeting “spiritual home” at GoToMeeting, which is owned by Citrix.

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


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


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


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

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

Clairvoyance Game IP Address Links Tutorial

Clairvoyance Game IP Address Links Tutorial

Clairvoyance Game IP Address Links Tutorial

We’re not here, today, to in any way criticize the Javascript prompt window, and it’s (harkening back to the desktop application wooooorrrrrllldd in it’s feel) interactive talents, that wee bit removed and independent from webpage goings on. In fact, it is modal (ie. is capable of freezing the Javascript) and this talent needs to be used in the apt place, but is the easiest “modal means” when that is required.

Where it is not as useful, in it’s operating system origins, is it’s lack of colour coding possibilities, and it happens, today, that our work to improve on yesterday’s Clairvoyance Game Textarea Onblur Tutorial regarding creating IP Address Other Player links, can be all the more useful with some colour coding. We have these “colour modes of operation” going, today, as per …

  • IP Address Other Player comma separated links list alternates among …
    1. flash of yellow background on first showing, else white background
    2. blue font … for IP Address of current player … else …
    3. black font … alternating with …
    4. white fonts … shortly after window.prompt answer made … except for …
  • orange background is given to users “just arrived on the scene since last black/blue font incarnation” … and can persist through white fonts and pushed to start of links list

… perhaps helping users “hook up” with other users they are in contact with, and can invite, via these “just logged in” identifications.

Feel free to retry …


Previous relevant Clairvoyance Game Textarea Onblur Tutorial is shown below.

Clairvoyance Game Textarea Onblur Tutorial

Clairvoyance Game Textarea Onblur Tutorial

Further to the day before yesterday’s Clairvoyance Game Element Type Tutorial it’s in that form allowing users to design their own Clairvoyance Game style of game we harness …

the powers of the onblur event

… that great event to intervene with when processing the content of …

  • many input type elements
  • textarea
  • myriad of innerHTML friendly elements involving global attribute contenteditable=true

via


<textarea onblur=maybeif(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='House'; document.getElementById('two').value='Thing'; " rows=2 style=width:90%; type=text placeholder='Image Map HTML URL eg. https://www.rjmprogramming.com.au/HTMLCSS/livingroom.htm' value='' name=three id=three></textarea><br><span> ... or ...</span><br>
<textarea onblur=numdotsonly(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='Counting Number'; document.getElementById('two').value='Number'; " rows=3 style=width:90%; type=text placeholder='Comma separated list of 5 Emoji Decimal HTML Entity Values eg. for Game Name Words value of Counting Number (where . can facilitate complex emojis and the #span creates span elements) could be 49.65039.8419,50.65039.8419,51.65039.8419,52.65039.8419,53.65039.8419#span' value='' name=four id=four></textarea><br><span> ... or ...</span><br>
<textarea onblur=perhapsiframes(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='Fish'; document.getElementById('two').value='Fish'; " rows=3 style=width:90%; type=text placeholder='Comma separated list of 5 Image URLs eg. for Game Name Words value of Fish could be //fishesofaustralia.net.au/images/thumbnailimage/NarcetesErimelasAlcock.jpg,//fishesofaustralia.net.au/images/thumbnailimage/LutjansuBengalensisuwkwaj.jpg,//fishesofaustralia.net.au/images/thumbnailimage/GobiodonSpadix2Holotype.jpg,//fishesofaustralia.net.au/images/thumbnailimage/SebastapistesMonospinaRandallHolotype.jpg,//fishesofaustralia.net.au/images/thumbnailimage/AmblyeleotrisBellicaudaRandall.jpg' value='' name=five id=five></textarea><br><br>

… to allow for many more scenarios a user might apply entering in various URLs or text data or hashtagging “switches”, as per …


function perhapsiframes(tao) {
var badcnt=0, compext='', jj=0, potnew='', othercnt=0, otherthing='';
if (tao.value != '') {
var ims=tao.value.split('#');
if (eval('' + ims.length) < 2) {
potnew=tao.value + '#iframe';
var intrms=ims[0].replace(/\;base64\,/g,';base64c').replace(/\;utf8\,/g,';utf8c').split(',');
for (jj=0; jj<intrms.length; jj++) {
intrms[jj]=intrms[jj].replace(';base64c',';base64,').replace(';utf8c',';utf8,')
if (intrms[jj].indexOf('data:') == 0) {
if (intrms[jj].indexOf('data:image/') == -1) {
badcnt++;
if (jj == 0) {
otherthing=intrms[jj].split('data:')[1].split('/')[0];
othercnt++;
} else if (otherthing == intrms[jj].split('data:')[1].split('/')[0]) {
othercnt++;
}
}
} else if (intrms[jj].indexOf('/') != -1) {
if (intrms[jj].indexOf('.') == -1) {
badcnt++;
} else {
compext='.' + intrms[jj].split('.')[eval(-1 + intrms[jj].split('.').length)].split('?')[0].split('&')[0].split('#')[0].toLowerCase();
if (xexts.indexOf(compext) != -1) {
if (xtypes[eval('' + xexts.indexOf(compext))].indexOf('image/') != 0) {
badcnt++;
if (jj == 0) {
otherthing=xtypes[eval('' + xexts.indexOf(compext))].split('/')[0];
othercnt++;
} else if (otherthing == xtypes[eval('' + xexts.indexOf(compext))].split('/')[0]) {
othercnt++;
}
}
} else {
badcnt++;
}
}
}
}
}
//alert(badcnt);
var comma=',';
if (othercnt == eval('' + intrms.length)) {
potnew=potnew.replace('#iframe', '#' + otherthing.replace('text','embed'));
tao.value=potnew;
} else if (badcnt == eval('' + intrms.length)) {
for (jj=eval(-1 + intrms.length); jj>=0; jj--) {
if (jj == 0) { comma=''; }
if (intrms[jj].toLowerCase().indexOf('http') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(intrms[jj]));
} else if (intrms[jj].indexOf('//') != -1) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + intrms[jj].split('//')[1]));
} else if (intrms[jj].indexOf('/') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj]));
} else if (intrms[jj].indexOf('./') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj].substring(1)));
} else if (intrms[jj].indexOf('../') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj].substring(2)));
} else {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + '/' + intrms[jj]));
}
}
tao.value=potnew.replace(/\/\/www\.rjmprogramming\.com\.au\/recording\_ideas\.php\?/g, document.URL.split(':')[0] + '://www.rjmprogramming.com.au/recording_ideas.php?');
}
}
}

function numdotsonly(ttxao) {
if (ttxao.value != '') {
var hsta=ttxao.value.split('#');
if (hsta[0] != '') {
if (hsta[0].replace(/\./g,'').replace(/\,/g,'').replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
return ttxao;
} else {
var newhtz=hsta[0].toHtmlEntities();
var inimter=newhtz.replace(/\&\#44\;/g,',').replace(/\&\#46\;/g,'.');
var insmtr=inimter.split('&#');
for (var jj=1; jj<insmtr.length; jj++) {
if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) >= '0' && String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) <= '9') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('0:' + inimter);
} else if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) == '.') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('1:' + inimter);
} else if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) == ',') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('2:' + inimter);
} else {
inimter=(inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', '.' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + '.')).replace(/\.\./g,'.').replace(/^\./g,'').replace(/\.$/g,'').replace(/\.\,\./g,',').replace(/\.\,/g,',').replace(/\,\./g,',');
//alert('3:' + inimter);
}
}
//ttxao.value=newhtz.replace(/\&\#44\;/g,',').replace(/\&\#46\;/g,'.').replace(/\&\#/g,'').replace(/\;/g,'') + (eval('' + hsta.length) > 1 ? '#' + hsta[1] : '');
ttxao.value=inimter.replace(/\&\#/g,'').replace(/\;/g,'') + (eval('' + hsta.length) > 1 ? '#' + hsta[1] : '');
//alert(newhtz + ' ' + ttxao.value);
}
}
}
return ttxao;
}

function maybeif(tao) {
if (tao.value.trim() != '' && tao.value.trim().indexOf('//') != -1) {
justvalidity=true;
document.getElementById('ifimc').src='//' + tao.value.trim().split('//')[1];
setTimeout(function(){ justvalidity=false; }, 8000);
}
}

… sometimes resorting to QR Codes as a representation of a URL should we not be able to extract any data from that URL, in a changed latest draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Element Type Tutorial is shown below.

Clairvoyance Game Element Type Tutorial

Clairvoyance Game Element Type Tutorial

Today’s blog posting work …

… to make those User Bonus Score questions and answer default suggestions have lots more variety.

Also, today, we use the oninput event means by which we can stop the user entering particular delimiter characters we hope they do not use defining Game Names and Game Nouns …


<input oninput='this.value=this.value.replace(/[+|"#]/g, " ");' style=width:90%; type=text placeholder='Game Name Words' onblur="if (this.value.trim() != '' && document.getElementById('two').value.trim() == '') { document.getElementById('two').value=this.value; }" value='' name=one id=one></input><br>
<input oninput='this.value=this.value.replace(/[+|"#]/g, " ");' style=width:90%; type=text placeholder='Game Noun(s)' value='' name=two id=two></input><br><hr></hr>

And, today, we allow the user to hashtag enter an HTML element type as the output element type output within the five table cells of the game, exemplified by


function fireup() {
var thisiw=theiw;
var zrect=document.getElementById('td1').getBoundingClientRect();
if (thisiw >= eval('' + thewords.length)) { thisiw=0; }
for (var ii=1; ii<=5; ii++) {
if (document.getElementById('td' + ii).outerHTML.indexOf('background') == -1 && window.parent == window.self) {
//alert(theelems[thisiw] + ' ... ' + zener_cards[eval(-1 + ii)]);
if (theelems[thisiw].indexOf('<img ') == 0) {
//document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + ' id=img' + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + ' id=img' + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
} else if (usereletype != '') {
document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + " id=img" + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
//alert('1:' + document.getElementById('td' + ii).innerHTML);
if (document.getElementById('img' + ii).title != '' && ('' + document.getElementById('img' + ii).innerHTML).replace(/^null/g,'').replace(/^undefined/g,'') == '') {
if ((document.getElementById('img' + ii).title + zener_cards[0]).indexOf('&#') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
if (dataeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
//alert(0);
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
//alert(10);
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (valueeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (srceltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else {
document.getElementById('img' + ii).innerHTML=document.getElementById('img' + ii).title.split('|')[1];
}
//alert('2:' + document.getElementById('td' + ii).innerHTML);
} else {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url(' + document.getElementById('img' + ii).title.split('|')[1] + ')';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
//alert('3:' + document.getElementById('td' + ii).outerHTML);
}
}

} else {
if (dataeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
//alert(0);
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
//alert(10);
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (valueeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (srceltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else {

document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + " id=img" + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
}
}
//document.getElementById('td' + ii).style.background="url('" + zener_cards[eval(-1 + ii)] + "')";
//document.getElementById('td' + ii).style.backgroundSize='contain';
//document.getElementById('td' + ii).style.backgroundRepeat='no-repeat';
//alert(ii);
}
}
}

… in …


Previous relevant Clairvoyance Game Scoring Bonus Tutorial is shown below.

Clairvoyance Game Scoring Bonus Tutorial

Clairvoyance Game Scoring Bonus Tutorial

When a game scores and it’s got a non-aspirational feel about it, it can turn off some potential players. And so, with this in mind, onto yesterday’s Clairvoyance Game User Definitions Tutorial we now offer some optional bonus scoring functionality to also involve either …

  • Maths questions
  • User created questions

Either player can ask for this additional challenge involving …


Previous relevant Clairvoyance Game User Definitions Tutorial is shown below.

Clairvoyance Game User Definitions Tutorial

Clairvoyance Game User Definitions Tutorial

The day before yesterday’s Clairvoyance Game Image Map Tutorial work gets incorporated into today’s work allowing a three type way, as per …

  1. Image Map HTML URL
  2. Emoji list of 5
  3. Image URL list of 5

… means by which a user might design their own game to add to the dropdown list, and store in …


window.localStorage

… within the realms of the web browser being used. Then that newly created user defined game can be shared when invoking email or SMS invitations, and can get added to in that Game type dropdown, where another “Your Own …” suboption brings up the HTML form (and there, some textarea element double click logics might help with the filling out, and/or “modelling the filling out” for you) where the user can create and control these definitions.

Feel free to try this all out within a changed seventh draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Image Map Tutorial is shown below.

Clairvoyance Game Image Map Tutorial

Clairvoyance Game Image Map Tutorial

With our Clairvoyance++ Game project of recent times, before yesterday’s Clairvoyance Game Waiting Tutorial there was the day before yesterday’s Clairvoyance Game Sharing Scores Tutorial, where we “objectified” the project. Today’s job is to add into that “objectify mix” …


Image Map

… integration, where the …

  • HTML containing the …
  • Image img element’s …
  • Map map element guillotining … via …
    1. area element shape=”rect” … or …
    2. area element shape=”poly”

    subelements

… can be referenced to fill in new Clairvoyance++ Game looking incarnations as well as a means, via background image of a newly “top part of webpage” HTML div element, clicking means by which the original image map action item can be reopened, as well.

We think, at this stage, that we want to offer the user some “own incarnation” functionality eventually, and we’d like to add this image map idea into the mix. We’ll see about that later, but for now we have the modelled new dropdown options below …


var zener_cards=['/circle_yellow.jpg#circle_yellow','/cross_red.jpg#cross_red','/waves_blue.jpg#waves_blue','/square_black.jpg#square_black','/star_green.jpg#star_green'];

var theword='Clairvoyance';
var thenoun='Zener Card';
var theelem="<img style='object-fit:contain;' src=";
var thewords=['Clairvoyance', 'Fruit', 'Food', 'Animal', 'Bird', 'Carpentry', 'London', 'India', 'Australian Indigenous Language', 'Cell'];
var theelems=["<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src="];
var theihs=[">", ">", ">", ">", ">", ">", ">", ">", ">", ">"];
var thenouns=['Zener Card', 'Fruit', 'Meal', 'Creature', 'Bird', 'Framework Feature', 'Day', 'State', 'Language Area', 'Cell Part'];
var theiw=(document.URL.indexOf('itype=') != -1 ? eval(-1 + eval('' + document.URL.split('itype=')[1].split('&')[0].split('#'))) : 0);

if (theiw > 0) {
zcblurb='';
document.title=document.title.replace('Clairvoyance ', thewords[theiw] + ' ');
if (thewords[theiw] == 'Food') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#x1f35b;';
zener_cards[1]+='|&#x1f371;';
zener_cards[2]+='|&#x1f358;';
zener_cards[3]+='|&#x1f359;';
zener_cards[4]+='|&#x1f363;';
} else if (thewords[theiw] == 'Fruit') { // '127825', '127825', '127818', '127827', '127821'
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#127817;';
zener_cards[1]+='|&#127825;';
zener_cards[2]+='|&#127818;';
zener_cards[3]+='|&#127827;';
zener_cards[4]+='|&#127821;';
} else if (thewords[theiw] == 'Animal') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#128018;';
zener_cards[1]+='|&#129421;';
zener_cards[2]+='|&#129447;';
zener_cards[3]+='|&#128054;';
zener_cards[4]+='|&#128021;';
} else if (thewords[theiw] == 'Bird') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/bird_quiz.htm" style="object-fit:contain;" src="';
} else {
theelems[theiw]='<img data-url="/bird_quiz.htm" style="object-fit:contain;" src="';
}
theihs[theiw]='>';
zener_cards[0]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#8,5,374,370';
zener_cards[1]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#374,5,930,370';
zener_cards[2]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#930,5,1164,370';
zener_cards[3]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#1164,5,1500,370';
zener_cards[4]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#5,680,374,1120';
} else if (thewords[theiw] == 'Carpentry') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/floor_wall_roof_framing_members.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/floor_wall_roof_framing_members.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'London') {
delay=8000;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/london_trip_via_map_element.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/london_trip_via_map_element.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'India') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/india_map.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/india_map.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'Australian Indigenous Language') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/ImageMap/Languages/aboriginal_language_regions.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/ImageMap/Languages/aboriginal_language_regions.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'Cell') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/the_cell.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/the_cell.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';

}
}

var sideas=['Awaiting Other Player Choosing a ' + thenouns[theiw] + ' to Guess','Select the ' + thenouns[theiw] + ' Your Player Partner Selected','Select a ' + thenouns[theiw] + ' You Are Asking Your Player Partner to Guess','Awaiting Guess from Your Player Partner','Awaiting a ' + thenouns[theiw] + ' Selection from Your Playing Partner'];

… working with the cropping and resizing smarts the HTML canvas element is capable of …


function imc(iois) {

var aconto=null, prefixing='', ipr=0, minx=0, miny=0, maxx=0, maxy=0, donesofar=',';
if (iois.src.indexOf('/About_Us.htm') == -1) {
aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
//alert('' + aconto.body.innerHTML.indexOf('<area ') + '!' + aconto.body.innerHTML.split(' shape="rect"').length + '?' + iois.src + ';' + aconto.body.innerHTML.split('<map ')[0].split('<img ')[eval(-1 + aconto.body.innerHTML.split('<map ')[0].split('<img ').length)] + ':' + aconto.body.innerHTML);
if (eval('' + aconto.body.innerHTML.indexOf('<map ')) > eval('' + aconto.body.innerHTML.indexOf('<img ')) && aconto.body.innerHTML.indexOf('<map ') != -1 && aconto.body.innerHTML.indexOf('<img ') != -1 && aconto.body.innerHTML.indexOf('<area ') != -1 && aconto.body.innerHTML.replace(/shape\=\"poly\"/g,'shape="rect"').indexOf('shape="rect"') != -1) {
//alert('000:' + '');
if (aconto.body.innerHTML.indexOf('shape="rect"') == -1) {
prefixing=' ';
//if (document.URL.indexOf('&debug=') != -1) { alert('yes'); }
}
wourl=iois.src;
coordsarr=aconto.body.innerHTML.replace(/shape\=\"poly\"/g,'shape="rect"').split('shape="rect"');
//alert('0000:' + coordsarr.length);
if (eval('' + coordsarr.length) > 5) {
//alert('00:' + '');
imname=aconto.body.innerHTML.split('<map ')[0].split('<img ')[eval(-1 + aconto.body.innerHTML.split('<map ')[0].split('<img ').length)];
//alert('0:' + imname);
imname=imname.split('src="')[1];
//alert('1:' + imname);
imname=imname.split('"')[0];
//alert('2:' + imname);
if ((imname + 'x').indexOf('//') != -1 || (imname + 'x').indexOf('data:') == 0) { // || (imname + 'x').substring(0,1) == '/') {
if ((imname + 'x').indexOf('data:') == 0) {
imname=imname;
} else {
imname='//' + imname.split('//')[1];
}
} else if ((imname + 'x').substring(0,1) == '/') {
if (iois.src.indexOf('//') != -1) {
imname='//' + iois.src.split('//')[1].split('/')[0] + '/' + imname.substring(1);
} else {
imname='//www.rjmprogramming.com.au/' + imname.substring(1);
}
} else if ((imname + 'xxxxxxxxx').substring(0,12) == '../../../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-5 + iois.src.split('/').length)], imname.substring(12) + '#');
} else if ((imname + 'xxxxxxxxx').substring(0,9) == '../../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-4 + iois.src.split('/').length)], imname.substring(9) + '#');
} else if ((imname + 'xxxxxx').substring(0,6) == '../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-3 + iois.src.split('/').length)], imname.substring(6) + '#');
} else if ((imname + 'xxx').substring(0,3) == '../') {
imname=iois.src.replace(iois.src.split('/')[eval(-2 + iois.src.split('/').length)], imname.substring(3) + '#');
} else if ((imname + 'xx').substring(0,1) == './') {
imname=iois.src.replace(iois.src.split('/')[eval(-1 + iois.src.split('/').length)], imname.substring(2));
} else {
imname=iois.src.replace(iois.src.split('/')[eval(-1 + iois.src.split('/').length)], imname.substring(0));
}
}

//alert(imname.split(' ')[0] + ' ' + coordsarr[1]);
imlist=document.getElementsByTagName('img');
tds=document.getElementsByTagName('td');
squaredim=eval('' + tds[0].getBoundingClientRect().width);
document.getElementById('dtop').style.background='linear-gradient(rgba(255,255,255,0.1),rgba(255,255,255,0.1)),url(' + imname.split(' ')[0] + ')';
document.getElementById('dtop').style.backgroundRepeat='no-repeat';
document.getElementById('dtop').style.backgroundSize='contain';
document.getElementById('dtop').style.backgroundPosition='right top';
document.getElementById('dtop').onclick=function(event){ event.stopPropagation(); window.open(wourl,'_blank','top=50,left=50,width=600,height=600'); };

var imgis=new Image();
imgis.onload = function(){
var ict=1, jct=1;
var zcanvas = document.createElement('canvas');
zcanvas.width = squaredim; //imgis.width;
zcanvas.height = squaredim; //imgis.height;
var zctx = zcanvas.getContext('2d');
if (!randomize) {
while (coordsarr[ict].indexOf(' coords="') == -1) {
ict++;
}
}
if (randomize) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
//alert('first ict=' + ict + ' ... ' + donesofar);
while (ict == 0 || (donesofar + ',').indexOf(',' + ict + ',') != -1) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
if (coordsarr[ict].indexOf(' coords="') == -1) {
if (donesofar != ',') {
ict=eval('' + donesofar.substring(1).split(',')[0]);
} else {
ict++;
}
}
}
donesofar+='' + ict + ',';
}
//for (ict=1; ict<=5; ict++) {
while (jct <= 5) {
//if (document.URL.indexOf('&debug=') != -1) { alert(coordsarr[ict]); }
coordsarr[ict]=coordsarr[ict].split(' coords="')[1].split('"')[0];
if (randomize || prefixing != '' || (eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])) > 10 && eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])) > 10)) {
//alert('zctx.drawImage("' + imname.split(' ')[0] + '",' + eval(coordsarr[ict].split(',')[0].split('"')[0]) + ',' + eval(coordsarr[ict].split(',')[1].split('"')[0]) + ',' + eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])) + ',' + eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])) + ',0,0' + ',' + tds[eval(-1 + ict)].getBoundingClientRect().width + ',' + tds[eval(-1 + ict)].getBoundingClientRect().width + ')');
if (prefixing != '') {
//if (document.URL.indexOf('&debug=') != -1) { alert('YES'); }
minx=0;
miny=0;
maxx=0;
maxy=0;
for (ipr=0; ipr<coordsarr[ict].split(',').length; ipr+=2) {
if (ipr == 0) {
minx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]);
maxx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]);
miny=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]);
maxy=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]);
} else {
if (eval(coordsarr[ict].split(',')[ipr].split('"')[0]) < minx) { minx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[ipr].split('"')[0]) > maxx) { maxx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]) < miny) { miny=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]) > maxy) { maxy=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]); }
}
}
prefixing='' + minx + ',' + miny + ',' + maxx + ',' + maxy;
//if (document.URL.indexOf('&debug=') != -1) { alert('prefixing=' + prefixing); }
coordsarr[ict]=prefixing.trim(); // + ',' + coordsarr[ict];
}
if (theelems[theiw].indexOf('object-fit:none') != -1 || theelems[theiw].indexOf('object-fit:Cover') != -1) {
//if (document.URL.indexOf('&debug=') != -1) { alert('Yes'); }
zcanvas.width = eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])); //imgis.width;
//if (document.URL.indexOf('&debug=') != -1) { alert('YeS'); }
zcanvas.height = eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])); //imgis.height;
//if (document.URL.indexOf('&debug=') != -1) { alert('YEs'); }
zctx.drawImage(imgis, eval(coordsarr[ict].split(',')[0].split('"')[0]), eval(coordsarr[ict].split(',')[1].split('"')[0]), eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])),0,0,eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])));
//if (document.URL.indexOf('&debug=') != -1) { alert('yeS'); }
} else {
zctx.drawImage(imgis, eval(coordsarr[ict].split(',')[0].split('"')[0]), eval(coordsarr[ict].split(',')[1].split('"')[0]), eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])),0,0,squaredim,squaredim);
}
xaltdu=zcanvas.toDataURL("image/jpeg", 0.1);
//alert(xaltdu);
//alert(imlist[eval(-1 + ict)].outerHTML);
//if (document.URL.indexOf('&debug=') != -1) { alert(xaltdu); }
imlist[eval(-1 + jct)].src=xaltdu;
//zener_cards[eval(-1 + jct)]+='' + xaltdu;
if (jct < 5) {
zcanvas.width = squaredim; //imgis.width;
zcanvas.height = squaredim; //imgis.height;
if (prefixing != '') { prefixing=' '; } else { prefixing=''; }
}
jct++;
//} else {
//alert(coordsarr[ict]);
}
if (!randomize) {
ict++;
if (document.URL.indexOf('&debug=') != -1) { alert('ict=' + ict + ' and jct=' + jct); }
} else {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
//alert('first ict=' + ict + ' ... ' + donesofar);
while (ict == 0 || (donesofar + ',').indexOf(',' + ict + ',') != -1) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
if (coordsarr[ict].indexOf(' coords="') == -1) {
if (donesofar != ',') {
ict=eval('' + donesofar.substring(1).split(',')[0]);
} else {
ict++;
}
}
}
donesofar+='' + ict + ',';
}
}
};

imgis.src=imname.split(' ')[0];

}
}
}
}
}

function imagemapcheck() {
if (theelems[theiw].indexOf(' data-url="') != -1 && theelems[theiw].indexOf(' data-url=""') == -1 && zener_cards[0].replace('#circle_yellow','').indexOf('#') == -1) {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].indexOf('#') == -1) {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].slice(-5).indexOf('.') == -1 && theelems[theiw].split(' data-url="')[1].split('"')[0].slice(-1) != '/') {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0] + '/#';
} else {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0] + '#';
}
} else {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].split('#')[0].slice(-5).indexOf('.') == -1 && theelems[theiw].split(' data-url="')[1].split('"')[0].split('#')[0].slice(-1) != '/') {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0].replace('#','/#');
} else {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0];
}
}
}
}

… in a changed sixth draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Waiting Tutorial is shown below.

Clairvoyance Game Waiting Tutorial

Clairvoyance Game Waiting Tutorial

The recent Clairvoyance Game Objectify Tutorial work is revisited today, with the news that we’ve introduced …

implied invitations

… when the user enters a “player name” (looking a lot like an IP address) from that list of “potential players online” that is not any form of their own IP address player name. It will be apparent to regular readers that this methodology was intended to be the “usual methodology” at the beginning of our project, and so “we’ll allow a leave pass” for you to ask …

How come this took so long?

And then we’d say …

Huh?!

And there you go! Just “keep those cards and letters” flowing in!

So what do we mean by “implied invitations”? Well, in between a user “Wait” answer and the next, any other user can ask to play that waiting user, and the next time out of the prompt window they may find they’re in the midst of a game of some sort, invited by another player. We hope this does not offend?!

The concept of a “formal invitation” still exists for the email or SMS collaboration conduits, we hasten to add.

And so “day ?whatevvvvvvvvvvveeeeerrrrrrrr” got us to …


Previous relevant Clairvoyance Game Objectify Tutorial is shown below.

Clairvoyance Game Objectify Tutorial

Clairvoyance Game Objectify Tutorial

Extending yesterday’s Clairvoyance Game Sharing Scores Tutorial, it’s not exactly OOP (Object Oriented Programming) we are doing, but what we’d describe as “objectify” the proceedings we’re attending to today. Take a look at the following Javascript initialization code (now versus before) …


var zener_cards=['/circle_yellow.jpg#circle_yellow','/cross_red.jpg#cross_red','/waves_blue.jpg#waves_blue','/square_black.jpg#square_black','/star_green.jpg#star_green'];

var theword='Clairvoyance';
var thenoun='Zener Card';
var theelem="<img style='object-fit:contain;' src=";
var thewords=['Clairvoyance', 'Fruit', 'Food'];
var theelems=["<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src="];
var theihs=[">", ">", ">"];
var thenouns=['Zener Card', 'Fruit', 'Food'];
var theiw=(document.URL.indexOf('itype=') != -1 ? eval(-1 + eval('' + document.URL.split('itype=')[1].split('&')[0].split('#'))) : 0);

var ppsuff='';
var youare='';
var otheris='';
var score=0, goes=0;
var woois=null;
var pick=-1, awaiting=false, holdon=false;
var bihnull=true;
var anchor=null;
var initval='';
var lastafterscore='';
var wherewrong=false;
var sharemyscore=false, allowsdone=false;
var zcblurb=' You can enter ? to find out more about the history of Zener Cards. ';

if (theiw > 0) {
zcblurb='';
document.title=document.title.replace('Clairvoyance ', thewords[theiw] + ' ');
if (thenouns[theiw] == 'Food') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#x1f35b;';
zener_cards[1]+='|&#x1f371;';
zener_cards[2]+='|&#x1f358;';
zener_cards[3]+='|&#x1f359;';
zener_cards[4]+='|&#x1f363;';
} else if (thenouns[theiw] == 'Fruit') { // '127825', '127825', '127818', '127827', '127821'
theelems[theiw]='&lt;button style=font-size:100px; title=';
theihs[theiw]='&gt;';
zener_cards[0]+='|&#127817;';
zener_cards[1]+='|&#127825;';
zener_cards[2]+='|&#127818;';
zener_cards[3]+='|&#127827;';
zener_cards[4]+='|&#127821;';
}
}


var sideas=['Awaiting Other Player Choosing a ' + thenouns[theiw] + ' to Guess','Select the ' + thenouns[theiw] + ' Your Player Partner Selected','Select a ' + thenouns[theiw] + ' You Are Asking Your Player Partner to Guess','Awaiting Guess from Your Player Partner','Awaiting a ' + thenouns[theiw] + ' Selection from Your Playing Partner'];

… helping build up HTML for a new dropdown (versus what was there before) …


function multimaybe() {
var selbit='', jsel=0;
if (eval('' + thenouns.length) > 1) {
selbit="<sup><select style=width:30px; onchange=\"if (eval('' + this.value) != eval(1 + eval('' + theiw))) { location.href=document.URL.split('?')[0].split('#')[0] + '?itype=' + this.value; }\"><option value=" + eval(1 + theiw) + ">?</option></select> </sup> ";
for (jsel=0; jsel<thenouns.length; jsel++) {
selbit=selbit.replace('</select>', '<option value=' + eval(1 + jsel) + '>' + thewords[jsel] + ' Game</option></select>');
}
}
return selbit;
}

… and then later within the HTML <body> section …


<script type=text/javascript>
document.write("<h1 id=muh1>" + thewords[theiw] + " Game " + multimaybe() + "<input type=checkbox id=allows style=display:none; onchange=chscal(this);><font size=1 id=fshare style=display:none;>Share Score</font></input> <input type=checkbox id=allowstwo style=display:none; onchange=chscaltwo(this);><font size=1 id=fsharetwo style=display:none;>Be Told Where You Went Wrong</font></input></h1>");
</script>

… and am sure you can see where an initial “Clairvoyance” noun “hardcoding” feel of logic gets expanded to an “array of nouns” (where lots of programmers will immediately shout “objects”), as an alternative way of thinking to the ways our Javascript functions are like “verbs”. If you “abstract” the “what was a hardcoding” into “a dynamically selectable list of nouns” this objectifying process can be quite useful.

And so “day six” got us to …


Previous relevant Clairvoyance Game Sharing Scores Tutorial is shown below.

Clairvoyance Game Sharing Scores Tutorial

Clairvoyance Game Sharing Scores Tutorial

Onto the day before yesterday’s (yes, another two dayer!) Clairvoyance Game Invitations Tutorial primarily we have a checkbox part regarding …

  • Be Told Where You Went Wrong … guessing within our two player Clairvoyance Game … easy peasy … but …
  • Share Your Score … was really difficult … go figure …

… though the latter did ask a lot regarding timing and the sleep patterns of the PHP interlocutor … ?

Let’s just “move on” … shall we?!

Also on the agenda was some colour coding … and who doesn’t like a bit of colour coding! We purloined CSS into play, with “the kind of kludgy / kind of cute (well, you had to be there)” introduction of a title attribute to the status wording element and then apply that CSS …


<style>
#tdstatus[title^='Awaiting Other '] {
border: 3px solid red;
}

#tdstatus[title^='Awaiting a '] {
border: 3px solid rgb(127,0,0);
}


#tdstatus[title^='Awaiting Guess '] {
border: 3px solid orange;
}

#tdstatus[title^='Select the '] {
border: 6px solid lightgreen;
}

#tdstatus[title^='Select a '] {
border: 6px solid green;
}

$tdstatus { padding: 5 5 5 5; }
</style>

We often find it the way, when it comes to colour coding, we borrow from “the traffic light creed” regarding the colours used, where a reddish colour means “hang on” and a greenish colour is an invitation to the user. One could also think of “beeps” or “notifications” here, but not with us here, as of yet.

And so “day four” and “day five” saw …


Previous relevant Clairvoyance Game Invitations Tutorial is shown below.

Clairvoyance Game Invitations Tutorial

Clairvoyance Game Invitations Tutorial

In yesterday’s Clairvoyance Game Tutorial, with our Clairvoyance Game, really a game for two, downplayed invitations to the end of the blog posting blurb. But really, invitations are the “be all and end all” for a two player game shared over the Internet and just using a “PHP and HTML/Javascript” level of sophistication.

And, of course, two days later (when we think it should have only been “one day later”), it might be me, but making this work for email or SMS invitations was not trivial, partly because …

  • we launched into this “phase two public invitational sharing” on a false premise … our “phase one window.open and window.opener” Javascript logics were flawed (further into the logic than the first foray, shall we say) … bad news … we reckon one out of two days “getting there” would have to be put down to the lack of testing on day one … whereas …
  • our thought that “phase two” is just phase one window.open and window.opener transfers to PHP writes Javascript equivalents was “more or less” true, but we all know “programming life” throws up unexpected roadblocks

… and that is the excuse today, which we are sticking to … so there, ngaaahhhh!

This calls into play the importance, often, of “project planning”, and the compartmentalizing of testing, including really tight unit testing, especially if your software plan has so much dependency in “day two” on the “day one” quality. As far as that goes, in our defence, regarding a networking web application, that this Clairvoyance Game “more or less is” (though yesterday’s work simplistically pared that down so that we never needed more than our local MAMP Apache/PHP web server involved) sometimes you find it is hard to recognize “units” within the big picture.

And so “day two” and “day three” were all about “online invitation” logic for email or SMS invitations in …


Previous relevant Clairvoyance Game Tutorial is shown below.

Clairvoyance Game Tutorial

Clairvoyance Game Tutorial

Are you sixth sensical? Can you read tea leaves? If it’s one out of two, that will do.

We’re starting down the road to a new …

Clairvoyance Game

… today, that on today’s first draft, as a design for two players …

  • starts you playing yourself, or a nearby other player willing to share windows on your one common web browser incarnation …
  • kind of ludicrous on this day one but the building blocks are there, they being …
    1. HTML and Javascript parent … talking to …
    2. PHP interlocutor

    … which we’re going to extend, on day two, simulating what a window.open and window.opener (just on client) can do, just with a few more calls, and sleeping

Two players take it in turns …

  1. selecting a Zener Card the other player is asked to guess
  2. other player trying to guess that Zener Card selected

… to score, or not, in this first draft Clairvoyance Game helped out by PHP first draft interlocutor.

In days to come, we think we’ll also be coding for email or SMS invitations to play, as well. This will be old news to some of you telepathic genii.

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

Clairvoyance Game Textarea Onblur Tutorial

Clairvoyance Game Textarea Onblur Tutorial

Clairvoyance Game Textarea Onblur Tutorial

Further to the day before yesterday’s Clairvoyance Game Element Type Tutorial it’s in that form allowing users to design their own Clairvoyance Game style of game we harness …

the powers of the onblur event

… that great event to intervene with when processing the content of …

  • many input type elements
  • textarea
  • myriad of innerHTML friendly elements involving global attribute contenteditable=true

via


<textarea onblur=maybeif(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='House'; document.getElementById('two').value='Thing'; " rows=2 style=width:90%; type=text placeholder='Image Map HTML URL eg. https://www.rjmprogramming.com.au/HTMLCSS/livingroom.htm' value='' name=three id=three></textarea><br><span> ... or ...</span><br>
<textarea onblur=numdotsonly(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='Counting Number'; document.getElementById('two').value='Number'; " rows=3 style=width:90%; type=text placeholder='Comma separated list of 5 Emoji Decimal HTML Entity Values eg. for Game Name Words value of Counting Number (where . can facilitate complex emojis and the #span creates span elements) could be 49.65039.8419,50.65039.8419,51.65039.8419,52.65039.8419,53.65039.8419#span' value='' name=four id=four></textarea><br><span> ... or ...</span><br>
<textarea onblur=perhapsiframes(this); title="Double click to populate with default suggestion" ondblclick="this.value=this.placeholder.split(String.fromCharCode(10))[eval(-1 + this.placeholder.split(String.fromCharCode(10)).length)]; document.getElementById('one').value='Fish'; document.getElementById('two').value='Fish'; " rows=3 style=width:90%; type=text placeholder='Comma separated list of 5 Image URLs eg. for Game Name Words value of Fish could be //fishesofaustralia.net.au/images/thumbnailimage/NarcetesErimelasAlcock.jpg,//fishesofaustralia.net.au/images/thumbnailimage/LutjansuBengalensisuwkwaj.jpg,//fishesofaustralia.net.au/images/thumbnailimage/GobiodonSpadix2Holotype.jpg,//fishesofaustralia.net.au/images/thumbnailimage/SebastapistesMonospinaRandallHolotype.jpg,//fishesofaustralia.net.au/images/thumbnailimage/AmblyeleotrisBellicaudaRandall.jpg' value='' name=five id=five></textarea><br><br>

… to allow for many more scenarios a user might apply entering in various URLs or text data or hashtagging “switches”, as per …


function perhapsiframes(tao) {
var badcnt=0, compext='', jj=0, potnew='', othercnt=0, otherthing='';
if (tao.value != '') {
var ims=tao.value.split('#');
if (eval('' + ims.length) < 2) {
potnew=tao.value + '#iframe';
var intrms=ims[0].replace(/\;base64\,/g,';base64c').replace(/\;utf8\,/g,';utf8c').split(',');
for (jj=0; jj<intrms.length; jj++) {
intrms[jj]=intrms[jj].replace(';base64c',';base64,').replace(';utf8c',';utf8,')
if (intrms[jj].indexOf('data:') == 0) {
if (intrms[jj].indexOf('data:image/') == -1) {
badcnt++;
if (jj == 0) {
otherthing=intrms[jj].split('data:')[1].split('/')[0];
othercnt++;
} else if (otherthing == intrms[jj].split('data:')[1].split('/')[0]) {
othercnt++;
}
}
} else if (intrms[jj].indexOf('/') != -1) {
if (intrms[jj].indexOf('.') == -1) {
badcnt++;
} else {
compext='.' + intrms[jj].split('.')[eval(-1 + intrms[jj].split('.').length)].split('?')[0].split('&')[0].split('#')[0].toLowerCase();
if (xexts.indexOf(compext) != -1) {
if (xtypes[eval('' + xexts.indexOf(compext))].indexOf('image/') != 0) {
badcnt++;
if (jj == 0) {
otherthing=xtypes[eval('' + xexts.indexOf(compext))].split('/')[0];
othercnt++;
} else if (otherthing == xtypes[eval('' + xexts.indexOf(compext))].split('/')[0]) {
othercnt++;
}
}
} else {
badcnt++;
}
}
}
}
}
//alert(badcnt);
var comma=',';
if (othercnt == eval('' + intrms.length)) {
potnew=potnew.replace('#iframe', '#' + otherthing.replace('text','embed'));
tao.value=potnew;
} else if (badcnt == eval('' + intrms.length)) {
for (jj=eval(-1 + intrms.length); jj>=0; jj--) {
if (jj == 0) { comma=''; }
if (intrms[jj].toLowerCase().indexOf('http') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(intrms[jj]));
} else if (intrms[jj].indexOf('//') != -1) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + intrms[jj].split('//')[1]));
} else if (intrms[jj].indexOf('/') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj]));
} else if (intrms[jj].indexOf('./') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj].substring(1)));
} else if (intrms[jj].indexOf('../') == 0) {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + intrms[jj].substring(2)));
} else {
potnew=potnew.replace(comma + intrms[jj], comma + '//www.rjmprogramming.com.au/recording_ideas.php?noinitialwo=open#' + encodeURIComponent(document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + '/' + intrms[jj]));
}
}
tao.value=potnew.replace(/\/\/www\.rjmprogramming\.com\.au\/recording\_ideas\.php\?/g, document.URL.split(':')[0] + '://www.rjmprogramming.com.au/recording_ideas.php?');
}
}
}

function numdotsonly(ttxao) {
if (ttxao.value != '') {
var hsta=ttxao.value.split('#');
if (hsta[0] != '') {
if (hsta[0].replace(/\./g,'').replace(/\,/g,'').replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
return ttxao;
} else {
var newhtz=hsta[0].toHtmlEntities();
var inimter=newhtz.replace(/\&\#44\;/g,',').replace(/\&\#46\;/g,'.');
var insmtr=inimter.split('&#');
for (var jj=1; jj<insmtr.length; jj++) {
if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) >= '0' && String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) <= '9') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('0:' + inimter);
} else if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) == '.') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('1:' + inimter);
} else if (String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])) == ',') {
inimter=inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', String.fromCharCode(eval('' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0])));
//alert('2:' + inimter);
} else {
inimter=(inimter.replace('&#' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + ';', '.' + insmtr[jj].split(';')[0].split('.')[0].split(',')[0] + '.')).replace(/\.\./g,'.').replace(/^\./g,'').replace(/\.$/g,'').replace(/\.\,\./g,',').replace(/\.\,/g,',').replace(/\,\./g,',');
//alert('3:' + inimter);
}
}
//ttxao.value=newhtz.replace(/\&\#44\;/g,',').replace(/\&\#46\;/g,'.').replace(/\&\#/g,'').replace(/\;/g,'') + (eval('' + hsta.length) > 1 ? '#' + hsta[1] : '');
ttxao.value=inimter.replace(/\&\#/g,'').replace(/\;/g,'') + (eval('' + hsta.length) > 1 ? '#' + hsta[1] : '');
//alert(newhtz + ' ' + ttxao.value);
}
}
}
return ttxao;
}

function maybeif(tao) {
if (tao.value.trim() != '' && tao.value.trim().indexOf('//') != -1) {
justvalidity=true;
document.getElementById('ifimc').src='//' + tao.value.trim().split('//')[1];
setTimeout(function(){ justvalidity=false; }, 8000);
}
}

… sometimes resorting to QR Codes as a representation of a URL should we not be able to extract any data from that URL, in a changed latest draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Element Type Tutorial is shown below.

Clairvoyance Game Element Type Tutorial

Clairvoyance Game Element Type Tutorial

Today’s blog posting work …

… to make those User Bonus Score questions and answer default suggestions have lots more variety.

Also, today, we use the oninput event means by which we can stop the user entering particular delimiter characters we hope they do not use defining Game Names and Game Nouns …


<input oninput='this.value=this.value.replace(/[+|"#]/g, " ");' style=width:90%; type=text placeholder='Game Name Words' onblur="if (this.value.trim() != '' && document.getElementById('two').value.trim() == '') { document.getElementById('two').value=this.value; }" value='' name=one id=one></input><br>
<input oninput='this.value=this.value.replace(/[+|"#]/g, " ");' style=width:90%; type=text placeholder='Game Noun(s)' value='' name=two id=two></input><br><hr></hr>

And, today, we allow the user to hashtag enter an HTML element type as the output element type output within the five table cells of the game, exemplified by


function fireup() {
var thisiw=theiw;
var zrect=document.getElementById('td1').getBoundingClientRect();
if (thisiw >= eval('' + thewords.length)) { thisiw=0; }
for (var ii=1; ii<=5; ii++) {
if (document.getElementById('td' + ii).outerHTML.indexOf('background') == -1 && window.parent == window.self) {
//alert(theelems[thisiw] + ' ... ' + zener_cards[eval(-1 + ii)]);
if (theelems[thisiw].indexOf('<img ') == 0) {
//document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + ' id=img' + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + ' id=img' + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
} else if (usereletype != '') {
document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + " id=img" + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
//alert('1:' + document.getElementById('td' + ii).innerHTML);
if (document.getElementById('img' + ii).title != '' && ('' + document.getElementById('img' + ii).innerHTML).replace(/^null/g,'').replace(/^undefined/g,'') == '') {
if ((document.getElementById('img' + ii).title + zener_cards[0]).indexOf('&#') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
if (dataeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
//alert(0);
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
//alert(10);
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (valueeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (srceltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else {
document.getElementById('img' + ii).innerHTML=document.getElementById('img' + ii).title.split('|')[1];
}
//alert('2:' + document.getElementById('td' + ii).innerHTML);
} else {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url(' + document.getElementById('img' + ii).title.split('|')[1] + ')';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
//alert('3:' + document.getElementById('td' + ii).outerHTML);
}
}

} else {
if (dataeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
//alert(0);
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
//alert(10);
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (valueeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (srceltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else {

document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + " id=img" + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
}
}
//document.getElementById('td' + ii).style.background="url('" + zener_cards[eval(-1 + ii)] + "')";
//document.getElementById('td' + ii).style.backgroundSize='contain';
//document.getElementById('td' + ii).style.backgroundRepeat='no-repeat';
//alert(ii);
}
}
}

… in …


Previous relevant Clairvoyance Game Scoring Bonus Tutorial is shown below.

Clairvoyance Game Scoring Bonus Tutorial

Clairvoyance Game Scoring Bonus Tutorial

When a game scores and it’s got a non-aspirational feel about it, it can turn off some potential players. And so, with this in mind, onto yesterday’s Clairvoyance Game User Definitions Tutorial we now offer some optional bonus scoring functionality to also involve either …

  • Maths questions
  • User created questions

Either player can ask for this additional challenge involving …


Previous relevant Clairvoyance Game User Definitions Tutorial is shown below.

Clairvoyance Game User Definitions Tutorial

Clairvoyance Game User Definitions Tutorial

The day before yesterday’s Clairvoyance Game Image Map Tutorial work gets incorporated into today’s work allowing a three type way, as per …

  1. Image Map HTML URL
  2. Emoji list of 5
  3. Image URL list of 5

… means by which a user might design their own game to add to the dropdown list, and store in …


window.localStorage

… within the realms of the web browser being used. Then that newly created user defined game can be shared when invoking email or SMS invitations, and can get added to in that Game type dropdown, where another “Your Own …” suboption brings up the HTML form (and there, some textarea element double click logics might help with the filling out, and/or “modelling the filling out” for you) where the user can create and control these definitions.

Feel free to try this all out within a changed seventh draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Image Map Tutorial is shown below.

Clairvoyance Game Image Map Tutorial

Clairvoyance Game Image Map Tutorial

With our Clairvoyance++ Game project of recent times, before yesterday’s Clairvoyance Game Waiting Tutorial there was the day before yesterday’s Clairvoyance Game Sharing Scores Tutorial, where we “objectified” the project. Today’s job is to add into that “objectify mix” …


Image Map

… integration, where the …

  • HTML containing the …
  • Image img element’s …
  • Map map element guillotining … via …
    1. area element shape=”rect” … or …
    2. area element shape=”poly”

    subelements

… can be referenced to fill in new Clairvoyance++ Game looking incarnations as well as a means, via background image of a newly “top part of webpage” HTML div element, clicking means by which the original image map action item can be reopened, as well.

We think, at this stage, that we want to offer the user some “own incarnation” functionality eventually, and we’d like to add this image map idea into the mix. We’ll see about that later, but for now we have the modelled new dropdown options below …


var zener_cards=['/circle_yellow.jpg#circle_yellow','/cross_red.jpg#cross_red','/waves_blue.jpg#waves_blue','/square_black.jpg#square_black','/star_green.jpg#star_green'];

var theword='Clairvoyance';
var thenoun='Zener Card';
var theelem="<img style='object-fit:contain;' src=";
var thewords=['Clairvoyance', 'Fruit', 'Food', 'Animal', 'Bird', 'Carpentry', 'London', 'India', 'Australian Indigenous Language', 'Cell'];
var theelems=["<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src="];
var theihs=[">", ">", ">", ">", ">", ">", ">", ">", ">", ">"];
var thenouns=['Zener Card', 'Fruit', 'Meal', 'Creature', 'Bird', 'Framework Feature', 'Day', 'State', 'Language Area', 'Cell Part'];
var theiw=(document.URL.indexOf('itype=') != -1 ? eval(-1 + eval('' + document.URL.split('itype=')[1].split('&')[0].split('#'))) : 0);

if (theiw > 0) {
zcblurb='';
document.title=document.title.replace('Clairvoyance ', thewords[theiw] + ' ');
if (thewords[theiw] == 'Food') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#x1f35b;';
zener_cards[1]+='|&#x1f371;';
zener_cards[2]+='|&#x1f358;';
zener_cards[3]+='|&#x1f359;';
zener_cards[4]+='|&#x1f363;';
} else if (thewords[theiw] == 'Fruit') { // '127825', '127825', '127818', '127827', '127821'
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#127817;';
zener_cards[1]+='|&#127825;';
zener_cards[2]+='|&#127818;';
zener_cards[3]+='|&#127827;';
zener_cards[4]+='|&#127821;';
} else if (thewords[theiw] == 'Animal') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#128018;';
zener_cards[1]+='|&#129421;';
zener_cards[2]+='|&#129447;';
zener_cards[3]+='|&#128054;';
zener_cards[4]+='|&#128021;';
} else if (thewords[theiw] == 'Bird') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/bird_quiz.htm" style="object-fit:contain;" src="';
} else {
theelems[theiw]='<img data-url="/bird_quiz.htm" style="object-fit:contain;" src="';
}
theihs[theiw]='>';
zener_cards[0]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#8,5,374,370';
zener_cards[1]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#374,5,930,370';
zener_cards[2]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#930,5,1164,370';
zener_cards[3]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#1164,5,1500,370';
zener_cards[4]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#5,680,374,1120';
} else if (thewords[theiw] == 'Carpentry') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/floor_wall_roof_framing_members.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/floor_wall_roof_framing_members.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'London') {
delay=8000;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/london_trip_via_map_element.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/london_trip_via_map_element.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'India') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/india_map.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/india_map.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'Australian Indigenous Language') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/ImageMap/Languages/aboriginal_language_regions.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/ImageMap/Languages/aboriginal_language_regions.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'Cell') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/the_cell.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/the_cell.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';

}
}

var sideas=['Awaiting Other Player Choosing a ' + thenouns[theiw] + ' to Guess','Select the ' + thenouns[theiw] + ' Your Player Partner Selected','Select a ' + thenouns[theiw] + ' You Are Asking Your Player Partner to Guess','Awaiting Guess from Your Player Partner','Awaiting a ' + thenouns[theiw] + ' Selection from Your Playing Partner'];

… working with the cropping and resizing smarts the HTML canvas element is capable of …


function imc(iois) {

var aconto=null, prefixing='', ipr=0, minx=0, miny=0, maxx=0, maxy=0, donesofar=',';
if (iois.src.indexOf('/About_Us.htm') == -1) {
aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
//alert('' + aconto.body.innerHTML.indexOf('<area ') + '!' + aconto.body.innerHTML.split(' shape="rect"').length + '?' + iois.src + ';' + aconto.body.innerHTML.split('<map ')[0].split('<img ')[eval(-1 + aconto.body.innerHTML.split('<map ')[0].split('<img ').length)] + ':' + aconto.body.innerHTML);
if (eval('' + aconto.body.innerHTML.indexOf('<map ')) > eval('' + aconto.body.innerHTML.indexOf('<img ')) && aconto.body.innerHTML.indexOf('<map ') != -1 && aconto.body.innerHTML.indexOf('<img ') != -1 && aconto.body.innerHTML.indexOf('<area ') != -1 && aconto.body.innerHTML.replace(/shape\=\"poly\"/g,'shape="rect"').indexOf('shape="rect"') != -1) {
//alert('000:' + '');
if (aconto.body.innerHTML.indexOf('shape="rect"') == -1) {
prefixing=' ';
//if (document.URL.indexOf('&debug=') != -1) { alert('yes'); }
}
wourl=iois.src;
coordsarr=aconto.body.innerHTML.replace(/shape\=\"poly\"/g,'shape="rect"').split('shape="rect"');
//alert('0000:' + coordsarr.length);
if (eval('' + coordsarr.length) > 5) {
//alert('00:' + '');
imname=aconto.body.innerHTML.split('<map ')[0].split('<img ')[eval(-1 + aconto.body.innerHTML.split('<map ')[0].split('<img ').length)];
//alert('0:' + imname);
imname=imname.split('src="')[1];
//alert('1:' + imname);
imname=imname.split('"')[0];
//alert('2:' + imname);
if ((imname + 'x').indexOf('//') != -1 || (imname + 'x').indexOf('data:') == 0) { // || (imname + 'x').substring(0,1) == '/') {
if ((imname + 'x').indexOf('data:') == 0) {
imname=imname;
} else {
imname='//' + imname.split('//')[1];
}
} else if ((imname + 'x').substring(0,1) == '/') {
if (iois.src.indexOf('//') != -1) {
imname='//' + iois.src.split('//')[1].split('/')[0] + '/' + imname.substring(1);
} else {
imname='//www.rjmprogramming.com.au/' + imname.substring(1);
}
} else if ((imname + 'xxxxxxxxx').substring(0,12) == '../../../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-5 + iois.src.split('/').length)], imname.substring(12) + '#');
} else if ((imname + 'xxxxxxxxx').substring(0,9) == '../../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-4 + iois.src.split('/').length)], imname.substring(9) + '#');
} else if ((imname + 'xxxxxx').substring(0,6) == '../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-3 + iois.src.split('/').length)], imname.substring(6) + '#');
} else if ((imname + 'xxx').substring(0,3) == '../') {
imname=iois.src.replace(iois.src.split('/')[eval(-2 + iois.src.split('/').length)], imname.substring(3) + '#');
} else if ((imname + 'xx').substring(0,1) == './') {
imname=iois.src.replace(iois.src.split('/')[eval(-1 + iois.src.split('/').length)], imname.substring(2));
} else {
imname=iois.src.replace(iois.src.split('/')[eval(-1 + iois.src.split('/').length)], imname.substring(0));
}
}

//alert(imname.split(' ')[0] + ' ' + coordsarr[1]);
imlist=document.getElementsByTagName('img');
tds=document.getElementsByTagName('td');
squaredim=eval('' + tds[0].getBoundingClientRect().width);
document.getElementById('dtop').style.background='linear-gradient(rgba(255,255,255,0.1),rgba(255,255,255,0.1)),url(' + imname.split(' ')[0] + ')';
document.getElementById('dtop').style.backgroundRepeat='no-repeat';
document.getElementById('dtop').style.backgroundSize='contain';
document.getElementById('dtop').style.backgroundPosition='right top';
document.getElementById('dtop').onclick=function(event){ event.stopPropagation(); window.open(wourl,'_blank','top=50,left=50,width=600,height=600'); };

var imgis=new Image();
imgis.onload = function(){
var ict=1, jct=1;
var zcanvas = document.createElement('canvas');
zcanvas.width = squaredim; //imgis.width;
zcanvas.height = squaredim; //imgis.height;
var zctx = zcanvas.getContext('2d');
if (!randomize) {
while (coordsarr[ict].indexOf(' coords="') == -1) {
ict++;
}
}
if (randomize) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
//alert('first ict=' + ict + ' ... ' + donesofar);
while (ict == 0 || (donesofar + ',').indexOf(',' + ict + ',') != -1) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
if (coordsarr[ict].indexOf(' coords="') == -1) {
if (donesofar != ',') {
ict=eval('' + donesofar.substring(1).split(',')[0]);
} else {
ict++;
}
}
}
donesofar+='' + ict + ',';
}
//for (ict=1; ict<=5; ict++) {
while (jct <= 5) {
//if (document.URL.indexOf('&debug=') != -1) { alert(coordsarr[ict]); }
coordsarr[ict]=coordsarr[ict].split(' coords="')[1].split('"')[0];
if (randomize || prefixing != '' || (eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])) > 10 && eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])) > 10)) {
//alert('zctx.drawImage("' + imname.split(' ')[0] + '",' + eval(coordsarr[ict].split(',')[0].split('"')[0]) + ',' + eval(coordsarr[ict].split(',')[1].split('"')[0]) + ',' + eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])) + ',' + eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])) + ',0,0' + ',' + tds[eval(-1 + ict)].getBoundingClientRect().width + ',' + tds[eval(-1 + ict)].getBoundingClientRect().width + ')');
if (prefixing != '') {
//if (document.URL.indexOf('&debug=') != -1) { alert('YES'); }
minx=0;
miny=0;
maxx=0;
maxy=0;
for (ipr=0; ipr<coordsarr[ict].split(',').length; ipr+=2) {
if (ipr == 0) {
minx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]);
maxx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]);
miny=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]);
maxy=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]);
} else {
if (eval(coordsarr[ict].split(',')[ipr].split('"')[0]) < minx) { minx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[ipr].split('"')[0]) > maxx) { maxx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]) < miny) { miny=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]) > maxy) { maxy=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]); }
}
}
prefixing='' + minx + ',' + miny + ',' + maxx + ',' + maxy;
//if (document.URL.indexOf('&debug=') != -1) { alert('prefixing=' + prefixing); }
coordsarr[ict]=prefixing.trim(); // + ',' + coordsarr[ict];
}
if (theelems[theiw].indexOf('object-fit:none') != -1 || theelems[theiw].indexOf('object-fit:Cover') != -1) {
//if (document.URL.indexOf('&debug=') != -1) { alert('Yes'); }
zcanvas.width = eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])); //imgis.width;
//if (document.URL.indexOf('&debug=') != -1) { alert('YeS'); }
zcanvas.height = eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])); //imgis.height;
//if (document.URL.indexOf('&debug=') != -1) { alert('YEs'); }
zctx.drawImage(imgis, eval(coordsarr[ict].split(',')[0].split('"')[0]), eval(coordsarr[ict].split(',')[1].split('"')[0]), eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])),0,0,eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])));
//if (document.URL.indexOf('&debug=') != -1) { alert('yeS'); }
} else {
zctx.drawImage(imgis, eval(coordsarr[ict].split(',')[0].split('"')[0]), eval(coordsarr[ict].split(',')[1].split('"')[0]), eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])),0,0,squaredim,squaredim);
}
xaltdu=zcanvas.toDataURL("image/jpeg", 0.1);
//alert(xaltdu);
//alert(imlist[eval(-1 + ict)].outerHTML);
//if (document.URL.indexOf('&debug=') != -1) { alert(xaltdu); }
imlist[eval(-1 + jct)].src=xaltdu;
//zener_cards[eval(-1 + jct)]+='' + xaltdu;
if (jct < 5) {
zcanvas.width = squaredim; //imgis.width;
zcanvas.height = squaredim; //imgis.height;
if (prefixing != '') { prefixing=' '; } else { prefixing=''; }
}
jct++;
//} else {
//alert(coordsarr[ict]);
}
if (!randomize) {
ict++;
if (document.URL.indexOf('&debug=') != -1) { alert('ict=' + ict + ' and jct=' + jct); }
} else {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
//alert('first ict=' + ict + ' ... ' + donesofar);
while (ict == 0 || (donesofar + ',').indexOf(',' + ict + ',') != -1) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
if (coordsarr[ict].indexOf(' coords="') == -1) {
if (donesofar != ',') {
ict=eval('' + donesofar.substring(1).split(',')[0]);
} else {
ict++;
}
}
}
donesofar+='' + ict + ',';
}
}
};

imgis.src=imname.split(' ')[0];

}
}
}
}
}

function imagemapcheck() {
if (theelems[theiw].indexOf(' data-url="') != -1 && theelems[theiw].indexOf(' data-url=""') == -1 && zener_cards[0].replace('#circle_yellow','').indexOf('#') == -1) {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].indexOf('#') == -1) {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].slice(-5).indexOf('.') == -1 && theelems[theiw].split(' data-url="')[1].split('"')[0].slice(-1) != '/') {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0] + '/#';
} else {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0] + '#';
}
} else {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].split('#')[0].slice(-5).indexOf('.') == -1 && theelems[theiw].split(' data-url="')[1].split('"')[0].split('#')[0].slice(-1) != '/') {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0].replace('#','/#');
} else {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0];
}
}
}
}

… in a changed sixth draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Waiting Tutorial is shown below.

Clairvoyance Game Waiting Tutorial

Clairvoyance Game Waiting Tutorial

The recent Clairvoyance Game Objectify Tutorial work is revisited today, with the news that we’ve introduced …

implied invitations

… when the user enters a “player name” (looking a lot like an IP address) from that list of “potential players online” that is not any form of their own IP address player name. It will be apparent to regular readers that this methodology was intended to be the “usual methodology” at the beginning of our project, and so “we’ll allow a leave pass” for you to ask …

How come this took so long?

And then we’d say …

Huh?!

And there you go! Just “keep those cards and letters” flowing in!

So what do we mean by “implied invitations”? Well, in between a user “Wait” answer and the next, any other user can ask to play that waiting user, and the next time out of the prompt window they may find they’re in the midst of a game of some sort, invited by another player. We hope this does not offend?!

The concept of a “formal invitation” still exists for the email or SMS collaboration conduits, we hasten to add.

And so “day ?whatevvvvvvvvvvveeeeerrrrrrrr” got us to …


Previous relevant Clairvoyance Game Objectify Tutorial is shown below.

Clairvoyance Game Objectify Tutorial

Clairvoyance Game Objectify Tutorial

Extending yesterday’s Clairvoyance Game Sharing Scores Tutorial, it’s not exactly OOP (Object Oriented Programming) we are doing, but what we’d describe as “objectify” the proceedings we’re attending to today. Take a look at the following Javascript initialization code (now versus before) …


var zener_cards=['/circle_yellow.jpg#circle_yellow','/cross_red.jpg#cross_red','/waves_blue.jpg#waves_blue','/square_black.jpg#square_black','/star_green.jpg#star_green'];

var theword='Clairvoyance';
var thenoun='Zener Card';
var theelem="<img style='object-fit:contain;' src=";
var thewords=['Clairvoyance', 'Fruit', 'Food'];
var theelems=["<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src="];
var theihs=[">", ">", ">"];
var thenouns=['Zener Card', 'Fruit', 'Food'];
var theiw=(document.URL.indexOf('itype=') != -1 ? eval(-1 + eval('' + document.URL.split('itype=')[1].split('&')[0].split('#'))) : 0);

var ppsuff='';
var youare='';
var otheris='';
var score=0, goes=0;
var woois=null;
var pick=-1, awaiting=false, holdon=false;
var bihnull=true;
var anchor=null;
var initval='';
var lastafterscore='';
var wherewrong=false;
var sharemyscore=false, allowsdone=false;
var zcblurb=' You can enter ? to find out more about the history of Zener Cards. ';

if (theiw > 0) {
zcblurb='';
document.title=document.title.replace('Clairvoyance ', thewords[theiw] + ' ');
if (thenouns[theiw] == 'Food') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#x1f35b;';
zener_cards[1]+='|&#x1f371;';
zener_cards[2]+='|&#x1f358;';
zener_cards[3]+='|&#x1f359;';
zener_cards[4]+='|&#x1f363;';
} else if (thenouns[theiw] == 'Fruit') { // '127825', '127825', '127818', '127827', '127821'
theelems[theiw]='&lt;button style=font-size:100px; title=';
theihs[theiw]='&gt;';
zener_cards[0]+='|&#127817;';
zener_cards[1]+='|&#127825;';
zener_cards[2]+='|&#127818;';
zener_cards[3]+='|&#127827;';
zener_cards[4]+='|&#127821;';
}
}


var sideas=['Awaiting Other Player Choosing a ' + thenouns[theiw] + ' to Guess','Select the ' + thenouns[theiw] + ' Your Player Partner Selected','Select a ' + thenouns[theiw] + ' You Are Asking Your Player Partner to Guess','Awaiting Guess from Your Player Partner','Awaiting a ' + thenouns[theiw] + ' Selection from Your Playing Partner'];

… helping build up HTML for a new dropdown (versus what was there before) …


function multimaybe() {
var selbit='', jsel=0;
if (eval('' + thenouns.length) > 1) {
selbit="<sup><select style=width:30px; onchange=\"if (eval('' + this.value) != eval(1 + eval('' + theiw))) { location.href=document.URL.split('?')[0].split('#')[0] + '?itype=' + this.value; }\"><option value=" + eval(1 + theiw) + ">?</option></select> </sup> ";
for (jsel=0; jsel<thenouns.length; jsel++) {
selbit=selbit.replace('</select>', '<option value=' + eval(1 + jsel) + '>' + thewords[jsel] + ' Game</option></select>');
}
}
return selbit;
}

… and then later within the HTML <body> section …


<script type=text/javascript>
document.write("<h1 id=muh1>" + thewords[theiw] + " Game " + multimaybe() + "<input type=checkbox id=allows style=display:none; onchange=chscal(this);><font size=1 id=fshare style=display:none;>Share Score</font></input> <input type=checkbox id=allowstwo style=display:none; onchange=chscaltwo(this);><font size=1 id=fsharetwo style=display:none;>Be Told Where You Went Wrong</font></input></h1>");
</script>

… and am sure you can see where an initial “Clairvoyance” noun “hardcoding” feel of logic gets expanded to an “array of nouns” (where lots of programmers will immediately shout “objects”), as an alternative way of thinking to the ways our Javascript functions are like “verbs”. If you “abstract” the “what was a hardcoding” into “a dynamically selectable list of nouns” this objectifying process can be quite useful.

And so “day six” got us to …


Previous relevant Clairvoyance Game Sharing Scores Tutorial is shown below.

Clairvoyance Game Sharing Scores Tutorial

Clairvoyance Game Sharing Scores Tutorial

Onto the day before yesterday’s (yes, another two dayer!) Clairvoyance Game Invitations Tutorial primarily we have a checkbox part regarding …

  • Be Told Where You Went Wrong … guessing within our two player Clairvoyance Game … easy peasy … but …
  • Share Your Score … was really difficult … go figure …

… though the latter did ask a lot regarding timing and the sleep patterns of the PHP interlocutor … ?

Let’s just “move on” … shall we?!

Also on the agenda was some colour coding … and who doesn’t like a bit of colour coding! We purloined CSS into play, with “the kind of kludgy / kind of cute (well, you had to be there)” introduction of a title attribute to the status wording element and then apply that CSS …


<style>
#tdstatus[title^='Awaiting Other '] {
border: 3px solid red;
}

#tdstatus[title^='Awaiting a '] {
border: 3px solid rgb(127,0,0);
}


#tdstatus[title^='Awaiting Guess '] {
border: 3px solid orange;
}

#tdstatus[title^='Select the '] {
border: 6px solid lightgreen;
}

#tdstatus[title^='Select a '] {
border: 6px solid green;
}

$tdstatus { padding: 5 5 5 5; }
</style>

We often find it the way, when it comes to colour coding, we borrow from “the traffic light creed” regarding the colours used, where a reddish colour means “hang on” and a greenish colour is an invitation to the user. One could also think of “beeps” or “notifications” here, but not with us here, as of yet.

And so “day four” and “day five” saw …


Previous relevant Clairvoyance Game Invitations Tutorial is shown below.

Clairvoyance Game Invitations Tutorial

Clairvoyance Game Invitations Tutorial

In yesterday’s Clairvoyance Game Tutorial, with our Clairvoyance Game, really a game for two, downplayed invitations to the end of the blog posting blurb. But really, invitations are the “be all and end all” for a two player game shared over the Internet and just using a “PHP and HTML/Javascript” level of sophistication.

And, of course, two days later (when we think it should have only been “one day later”), it might be me, but making this work for email or SMS invitations was not trivial, partly because …

  • we launched into this “phase two public invitational sharing” on a false premise … our “phase one window.open and window.opener” Javascript logics were flawed (further into the logic than the first foray, shall we say) … bad news … we reckon one out of two days “getting there” would have to be put down to the lack of testing on day one … whereas …
  • our thought that “phase two” is just phase one window.open and window.opener transfers to PHP writes Javascript equivalents was “more or less” true, but we all know “programming life” throws up unexpected roadblocks

… and that is the excuse today, which we are sticking to … so there, ngaaahhhh!

This calls into play the importance, often, of “project planning”, and the compartmentalizing of testing, including really tight unit testing, especially if your software plan has so much dependency in “day two” on the “day one” quality. As far as that goes, in our defence, regarding a networking web application, that this Clairvoyance Game “more or less is” (though yesterday’s work simplistically pared that down so that we never needed more than our local MAMP Apache/PHP web server involved) sometimes you find it is hard to recognize “units” within the big picture.

And so “day two” and “day three” were all about “online invitation” logic for email or SMS invitations in …


Previous relevant Clairvoyance Game Tutorial is shown below.

Clairvoyance Game Tutorial

Clairvoyance Game Tutorial

Are you sixth sensical? Can you read tea leaves? If it’s one out of two, that will do.

We’re starting down the road to a new …

Clairvoyance Game

… today, that on today’s first draft, as a design for two players …

  • starts you playing yourself, or a nearby other player willing to share windows on your one common web browser incarnation …
  • kind of ludicrous on this day one but the building blocks are there, they being …
    1. HTML and Javascript parent … talking to …
    2. PHP interlocutor

    … which we’re going to extend, on day two, simulating what a window.open and window.opener (just on client) can do, just with a few more calls, and sleeping

Two players take it in turns …

  1. selecting a Zener Card the other player is asked to guess
  2. other player trying to guess that Zener Card selected

… to score, or not, in this first draft Clairvoyance Game helped out by PHP first draft interlocutor.

In days to come, we think we’ll also be coding for email or SMS invitations to play, as well. This will be old news to some of you telepathic genii.

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

Canvas Methods Revisit Tutorial

Canvas Methods Revisit Tutorial

Canvas Methods Revisit Tutorial

When we started being “blown away” by the potential of the HTML5 canvas element coming into play quite some time ago now, it was a bit like …

Wow!! But where to start?

… and due to our naivety we were not in a position back then to break down what was “cut through” (or not that practical, perhaps) about the canvas element “methods” with any authority. Over the years, though, we are more equipped, so what we are setting out to do is …

  • start with, though written a while ago, still to this day, feels like an advanced canvas application (as explained at Canvas DrawImage First Parameter Primer Tutorial) involving video elements (ie. we got a lot of help, thanks all) … and use this template …
  • to work it the other way (via new dropdown elements), building on “what you might aspire to if you are a beginner with the canvas element” and display new options to emphasise the huuuuuuuuuuuuugely valuable canvas methods out there (yes, OOP methods, not functions, as such)

The first cab off the rank here is the …


[canvasContext].drawImage([inObjectThatSuits], [X co-ordinate], [Y co-ordinate]);

… simplest usage of that drawImage method (in “OOP land” this 3 argument call can be thought of as “not the same logic” as (what we are going to get to later, for example) a 9 argument call). A form is presented here, and you, the user, can see the effects of controlling the 3 arguments (and you’ll notice “no truck” is given to any 5 minute? arguments here).

Feel free to have a go yourself with the changed svg_to_canvas.html “what we’ll call” Canvas Showcase web application you can also try below …


Previous relevant Canvas DrawImage First Parameter Primer Tutorial is shown below.

Canvas DrawImage First Parameter Primer Tutorial

Canvas DrawImage First Parameter Primer Tutorial

Some time ago we presented a short tutorial about a great online product addressing a big area of interest to online users … online meetings. We showcased the great GoToMeeting, with GoToMeeting Primer Tutorial, and we remember using it to good effect among …

  • installing software remotely
  • diagnosing software and hardware issues remotely
  • discussing issues remotely
  • client liaison remotely

… at a job involving EDI solutions with SAP Business One and Accpac. But that is just the subject matter basis here. Today we really want to use some media from that subject matter basis and use it’s video media as the first argument to the wonderful, the stupendous Canvas drawImage() Method, specifically its fascinating first parameter

Syntax
Position the image on the canvas:

context.drawImage(img, x, y)
Position the image on the canvas, and specify width and height of the image:

context.drawImage(img, x, y, width, height)
Clip the image and position the clipped part on the canvas:

context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height)

Don’t be fooled! It is a method offering, thanks, so much more that just an

el interface intrinsicHeight(el) intrinsicWidth(el)
HTMLImageElement el.naturalWidth el.naturalHeight
SVGImageElement el.[… special case] el.[… special case]
HTMLVideoElement el.videoWidth el.videoHeight
HTMLCanvasElement el.width el.height
ImageBitmap el.width el.height
OffscreenCanvas el.width el.height

… but whaaaaatttttt?! What happens here assigning a video object as a first parameter to the canvas (context)’s drawImage method? It takes a snapshot image of the slide of the playing (and if not, the first image of that) video! That means, couch that in a codeline like …


setInterval(function(){ ctx.drawImage(ovid, 800, 0); }, 100);

… at the right time, and you can be playing a video into the canvas! Yay!!! Actually, we’ve done this before, and, call us innocents if you like, but this gave us the same thrill then, thanks to all the online contributors regarding heads up ideas here.

But we are “value adding” today. It hadn’t occurred to us that we could do this video to the right of the canvas and dedicate the left side to captions, and that over there, there was enough room to show the “whole blurb” … and nothing but the blurb, and that if we use …

  • HTML video element attribute … autostart=true
  • HTML video element attribute … autoplay=true
  • HTML video element attribute … loop=true

… even if they do not work right from the document.body onload event time, once the video play button is clicked, we could do without the actual video from then on, perhaps (we’ve allowed you to resurrect the video display, and have more work into the future, maybe, regarding the repercussions of this … we’ll see?!).

What form of caption source did we use? We happened to have a “.srt” format WebVTT file pertinent to the GoToMeeting video hanging about, and so we shoved it into the innards of an HTML textarea element, and coded it from there …


<html>
<head>
<title>SVG to Canvas - RJM Programming - May, 2024 ... thanks to https://jsfiddle.net/Na6X5/</title>
<style>
canvas {
border: 1px solid gray;
}
</style>
<script type='text/javascript'>
var divstrc='';
var timings=[];
var times=[];
var tstimes=[];
var blurbs=[];
var cf = "12px Verdana";
var thisy=20, thisi=0, thisc=0;
var can=null, ctx=null;
var collist=['black','blue','purple','magenta','darkred','darkgreen'];
var lenc=eval('' + collist.length);
var oppmode='none';

function tanal(intr) {
var pts=intr.split(':');
console.log(intr);
tstimes.push(eval(eval(pts[0] * 60 * 60 * 1000) + eval(pts[1] * 60 * 1000) + eval(pts[2] * 1000)));
return intr;
}

function onl() {
can = document.getElementById('canvas1');
ctx = can.getContext('2d');

var svg = document.getElementById('simage');
var oimg = document.getElementById('simg');
var ovid = document.getElementById('myvd');

divstrc=document.getElementById('divsrt').value;
timings=divstrc.split(' --> ');
//alert(timings.length);
times.push(tanal(timings[0].slice(-13).trim()));
for (var ii=1; ii<timings.length; ii++) {
if (1 == 2) { times.push(tanal(timings[ii].substring(0,13).trim())); }
if (eval(1 + ii) != eval('' + timings.length)) {
times.push(tanal(timings[ii].slice(-13).trim()));
} else {
times.push(tanal(timings[ii].substring(0,13).trim()));
}
blurbs.push(timings[ii].split(String.fromCharCode(10))[1]);
}

console.log(blurbs);
console.log(tstimes);

var img = new Image();
img.onload = function() {
//ctx.drawImage(svg, 0, 0);
//ctx.drawImage(img, 200, 0);
//ctx.drawImage(oimg, 400, 0);
//ovid.play();
setInterval(function(){ ctx.drawImage(ovid, 800, 0); }, 100);
}
//img.src = "http://upload.wikimedia.org/wikipedia/commons/d/d2/Svg_example_square.svg";
//img.src = "/hexagon.svg";
//img.src = "/homecircle.svg";
img.src=oimg.src;
}

function dotext() {
if (eval(1 + thisi) >= eval('' + tstimes.length)) {
thisc++;
if (thisc >= eval('' + collist.length)) {
collist.push(collist[eval(thisc % lenc)]);
}
return loadsrt('');
}
setTimeout(dotext, eval(tstimes[eval(1 + thisi)] - tstimes[eval(0 + thisi)]));
ctx.font = cf;
ctx.strokeStyle=collist[thisc];
ctx.strokeText(blurbs[thisi],20,thisy);
thisy+=15;
thisi++;
}

function loadsrt(dsp) {
thisi=0;
thisy=20;
setTimeout(dotext, tstimes[0]);
if (dsp != '') {
document.getElementById('mysummary').innerHTML='Please click to toggle video display ...';
}
return dsp;
}
</script>
</head>
<body onload="onl();">
<canvas style='background-color:yellow;' id="canvas1" width="1400" height="400"></canvas>

<div id=previd style="display:none;">
<svg id="mySVG" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect width="150" height="150" fill="rgb(0, 255, 0)" stroke-width="1" stroke="rgb(0, 0, 0)"/>
</svg>

<svg id="mySVGimage" width="300" height="300" viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" version="1.1">
<image id=simage href="/hexagon.svg" height="300" width="300" />
</svg>

<img id=simg src='data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve" height="100px" width="100px">
<g>
<path d="M28.1,36.6c4.6,1.9,12.2,1.6,20.9,1.1c8.9-0.4,19-0.9,28.9,0.9c6.3,1.2,11.9,3.1,16.8,6c-1.5-12.2-7.9-23.7-18.6-31.3 c-4.9-0.2-9.9,0.3-14.8,1.4C47.8,17.9,36.2,25.6,28.1,36.6z"/>
<path d="M70.3,9.8C57.5,3.4,42.8,3.6,30.5,9.5c-3,6-8.4,19.6-5.3,24.9c8.6-11.7,20.9-19.8,35.2-23.1C63.7,10.5,67,10,70.3,9.8z"/>
<path d="M16.5,51.3c0.6-1.7,1.2-3.4,2-5.1c-3.8-3.4-7.5-7-11-10.8c-2.1,6.1-2.8,12.5-2.3,18.7C9.6,51.1,13.4,50.2,16.5,51.3z"/>
<path d="M9,31.6c3.5,3.9,7.2,7.6,11.1,11.1c0.8-1.6,1.7-3.1,2.6-4.6c0.1-0.2,0.3-0.4,0.4-0.6c-2.9-3.3-3.1-9.2-0.6-17.6 c0.8-2.7,1.8-5.3,2.7-7.4c-5.2,3.4-9.8,8-13.3,13.7C10.8,27.9,9.8,29.7,9,31.6z"/>
<path d="M15.4,54.7c-2.6-1-6.1,0.7-9.7,3.4c1.2,6.6,3.9,13,8,18.5C13,69.3,13.5,61.8,15.4,54.7z"/>
<path d="M39.8,57.6C54.3,66.7,70,73,86.5,76.4c0.6-0.8,1.1-1.6,1.7-2.5c4.8-7.7,7-16.3,6.8-24.8c-13.8-9.3-31.3-8.4-45.8-7.7 c-9.5,0.5-17.8,0.9-23.2-1.7c-0.1,0.1-0.2,0.3-0.3,0.4c-1,1.7-2,3.4-2.9,5.1C28.2,49.7,33.8,53.9,39.8,57.6z"/>
<path d="M26.2,88.2c3.3,2,6.7,3.6,10.2,4.7c-3.5-6.2-6.3-12.6-8.8-18.5c-3.1-7.2-5.8-13.5-9-17.2c-1.9,8-2,16.4-0.3,24.7 C20.6,84.2,23.2,86.3,26.2,88.2z"/>
<path d="M30.9,73c2.9,6.8,6.1,14.4,10.5,21.2c15.6,3,32-2.3,42.6-14.6C67.7,76,52.2,69.6,37.9,60.7C32,57,26.5,53,21.3,48.6 c-0.6,1.5-1.2,3-1.7,4.6C24.1,57.1,27.3,64.5,30.9,73z"/>
</g>
</svg>'></img>
</div>

<details onclick=" document.getElementById('myvd').style.display=oppmode; if (oppmode == 'block') { oppmode='none'; } else { oppmode='block'; }" open><summary id=mysummary>Please click play button below ...</summary>
<video onplay="this.style.display=loadsrt('none');" id=myvd autoplay=true autostart=true loop=true controls><source src='/Mac/GoToMeeting/GoToMeeting.m4v' type='video/mp4'></source></video>
<div id=divhs style=display:inline-block;vertical-align:top;>
<h1>Video and Captions to Canvas</h1>
<h3>RJM Programming - May, 2024</h3>
<h4>Thanks to https://jsfiddle.net/Na6X5/</h4>
</div>
</details>

<textarea id=divsrt style="display:none;">
WEBVTT FILE

1
00:00:00.100 --> 00:00:01.000 D:vertical A:start
Welcome to our GoTo Meeting tutorial ...
{
"title": "GoTo Meeting tutorial image 1 of 5",
"description": "Welcome to our GoTo Meeting tutorial",
"src": "gm1.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

2
00:00:01.000 --> 00:00:04.000
... we've installed GoTo Meeting and started it up. We have done the invite so we will be the "Presenter" ...

3
00:00:04.000 --> 00:00:06.000
... we click "Show My Screen" ...
{
"title": "GoTo Meeting tutorial image 2 of 5",
"description": "Show My Screen",
"src": "gm2.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

4
00:00:06.000 --> 00:00:16.000
... which is enabled because we are the "Presenter". Now lets ready other things ready to make a connection ...

5
00:00:16.000 --> 00:00:22.000
... we click "Show My Webcam" and start Connecting ...
{
"title": "GoTo Meeting tutorial image 3 of 5",
"description": "Show My Webcam",
"src": "gm3.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

6
00:00:22.000 --> 00:00:24.000
... the GoTo Viewer appears showing you a view of the person you are meeting ...

7
00:00:24.000 --> 00:00:26.000
... we have "lift off" ...
{
"title": "GoTo Meeting tutorial image 4 of 5",
"description": "Lift Off",
"src": "gm4.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

8
00:00:26.000 --> 00:00:28.000
... lo and behold, we've called ourself ...

9
00:00:28.000 --> 00:00:32.000
... have a look at us looking at us ...

10
00:00:32.000 --> 00:00:52.000
... but don't let it blow your mind?!
{
"title": "GoTo Meeting tutorial image 5 of 5",
"description": "Don't blow your mind",
"src": "gm5.jpg",
"href": "http://www.rjmprogramming.com.au/PHP/videos"
}

11
00:00:52.000 --> 00:01:34.000
Leaving the GoTo Meeting now. See you again soon.

</textarea>

</body>
</html>

Yes, we started the day with a different idea, and end up where we are at with our first draft proof of concept Video to Canvas web application incarnation … again.


Previous relevant GoToMeeting Primer Tutorial is shown below.

GoToMeeting Primer Tutorial

GoToMeeting Primer Tutorial

Here is a tutorial that introduces you to GoToMeeting. GoToMeeting is a great user-friendly video conferencing software by Citrix.

For simple scenarios I’ve always felt comfortable with GoToMeeting for that video conferencing functionality, or for how I usually used it, remotely testing, troubleshooting and/or installing software on remote client sites. Other choices for all Windows scenarios, here are Remote Desktop, and for mixed scenarios, VNC.

GoToMeeting can work with a phone connection or by using the Microphone and Speakers at both ends of the connection. You can host the meeting or join the meeting, share your keyboard or mouse, share your display via a shared webcam, as necessary, meet straight away, or schedule it, or email an invitation … all in all there is a lot of great functionality. Like with Skype, audio and visual can be considered separate … from our tutorial session here is some audio, and here is some visual (ie. video).

Other such meeting ideas can be accessed via Skype, or WebEx Web Conferencing. All these are great ideas that can save companies lots of money on overseas trips!

Link to GoToMeeting “spiritual home” at GoToMeeting, which is owned by Citrix.

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

Clairvoyance Game Element Type Tutorial

Clairvoyance Game Element Type Tutorial

Clairvoyance Game Element Type Tutorial

Today’s blog posting work …

… to make those User Bonus Score questions and answer default suggestions have lots more variety.

Also, today, we use the oninput event means by which we can stop the user entering particular delimiter characters we hope they do not use defining Game Names and Game Nouns …


<input oninput='this.value=this.value.replace(/[+|"#]/g, " ");' style=width:90%; type=text placeholder='Game Name Words' onblur="if (this.value.trim() != '' && document.getElementById('two').value.trim() == '') { document.getElementById('two').value=this.value; }" value='' name=one id=one></input><br>
<input oninput='this.value=this.value.replace(/[+|"#]/g, " ");' style=width:90%; type=text placeholder='Game Noun(s)' value='' name=two id=two></input><br><hr></hr>

And, today, we allow the user to hashtag enter an HTML element type as the output element type output within the five table cells of the game, exemplified by


function fireup() {
var thisiw=theiw;
var zrect=document.getElementById('td1').getBoundingClientRect();
if (thisiw >= eval('' + thewords.length)) { thisiw=0; }
for (var ii=1; ii<=5; ii++) {
if (document.getElementById('td' + ii).outerHTML.indexOf('background') == -1 && window.parent == window.self) {
//alert(theelems[thisiw] + ' ... ' + zener_cards[eval(-1 + ii)]);
if (theelems[thisiw].indexOf('<img ') == 0) {
//document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + ' id=img' + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + ' id=img' + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
} else if (usereletype != '') {
document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + " id=img" + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
//alert('1:' + document.getElementById('td' + ii).innerHTML);
if (document.getElementById('img' + ii).title != '' && ('' + document.getElementById('img' + ii).innerHTML).replace(/^null/g,'').replace(/^undefined/g,'') == '') {
if ((document.getElementById('img' + ii).title + zener_cards[0]).indexOf('&#') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
if (dataeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
//alert(0);
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
//alert(10);
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (valueeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (srceltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.background='url("data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='" + zrect.width + "' height='" + zrect.height + "' viewport='0 0 100 100' style='fill:black;font-family:Verdana;font-size:100px;'><text x='5%' y='80%' xml:space='preserve'>" + document.getElementById('img' + ii).title.split('|')[1] + "</text></svg>"))) + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else {
document.getElementById('img' + ii).innerHTML=document.getElementById('img' + ii).title.split('|')[1];
}
//alert('2:' + document.getElementById('td' + ii).innerHTML);
} else {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url(' + document.getElementById('img' + ii).title.split('|')[1] + ')';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
//alert('3:' + document.getElementById('td' + ii).outerHTML);
}
}

} else {
if (dataeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
//alert(0);
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
//alert(10);
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (valueeltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else if (srceltypes.toLowerCase().indexOf(',' + usereletype + ',') != -1) {
document.getElementById('img' + ii).style.width='100%';
document.getElementById('img' + ii).style.height='100%';
document.getElementById('img' + ii).style.background='url("' + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1].replace('https:','').replace('http:','') + '")';
document.getElementById('img' + ii).style.backgroundRepeat='no-repeat';
document.getElementById('img' + ii).style.backgroundSize='contain';
} else {

document.getElementById('td' + ii).innerHTML=theelems[thisiw] + (theelems[thisiw].slice(-1) == '=' ? '' : '') + zener_cards[eval(-1 + ii)] + theelems[thisiw].slice(-1).replace('=','') + " id=img" + ii + " onclick=\"if (!awaiting && !holdon) { pick=changeover(eval(this.id.replace('img',''))); } else { alert('' + ' Sorry, not your turn, so please wait.'); }\"" + theihs[thisiw] + (zener_cards[[eval(-1 + ii)]] + '|').split('|')[1] + (theelems[thisiw].split(' ')[0] + '>').replace('<','</');
}
}
//document.getElementById('td' + ii).style.background="url('" + zener_cards[eval(-1 + ii)] + "')";
//document.getElementById('td' + ii).style.backgroundSize='contain';
//document.getElementById('td' + ii).style.backgroundRepeat='no-repeat';
//alert(ii);
}
}
}

… in …


Previous relevant Clairvoyance Game Scoring Bonus Tutorial is shown below.

Clairvoyance Game Scoring Bonus Tutorial

Clairvoyance Game Scoring Bonus Tutorial

When a game scores and it’s got a non-aspirational feel about it, it can turn off some potential players. And so, with this in mind, onto yesterday’s Clairvoyance Game User Definitions Tutorial we now offer some optional bonus scoring functionality to also involve either …

  • Maths questions
  • User created questions

Either player can ask for this additional challenge involving …


Previous relevant Clairvoyance Game User Definitions Tutorial is shown below.

Clairvoyance Game User Definitions Tutorial

Clairvoyance Game User Definitions Tutorial

The day before yesterday’s Clairvoyance Game Image Map Tutorial work gets incorporated into today’s work allowing a three type way, as per …

  1. Image Map HTML URL
  2. Emoji list of 5
  3. Image URL list of 5

… means by which a user might design their own game to add to the dropdown list, and store in …


window.localStorage

… within the realms of the web browser being used. Then that newly created user defined game can be shared when invoking email or SMS invitations, and can get added to in that Game type dropdown, where another “Your Own …” suboption brings up the HTML form (and there, some textarea element double click logics might help with the filling out, and/or “modelling the filling out” for you) where the user can create and control these definitions.

Feel free to try this all out within a changed seventh draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Image Map Tutorial is shown below.

Clairvoyance Game Image Map Tutorial

Clairvoyance Game Image Map Tutorial

With our Clairvoyance++ Game project of recent times, before yesterday’s Clairvoyance Game Waiting Tutorial there was the day before yesterday’s Clairvoyance Game Sharing Scores Tutorial, where we “objectified” the project. Today’s job is to add into that “objectify mix” …


Image Map

… integration, where the …

  • HTML containing the …
  • Image img element’s …
  • Map map element guillotining … via …
    1. area element shape=”rect” … or …
    2. area element shape=”poly”

    subelements

… can be referenced to fill in new Clairvoyance++ Game looking incarnations as well as a means, via background image of a newly “top part of webpage” HTML div element, clicking means by which the original image map action item can be reopened, as well.

We think, at this stage, that we want to offer the user some “own incarnation” functionality eventually, and we’d like to add this image map idea into the mix. We’ll see about that later, but for now we have the modelled new dropdown options below …


var zener_cards=['/circle_yellow.jpg#circle_yellow','/cross_red.jpg#cross_red','/waves_blue.jpg#waves_blue','/square_black.jpg#square_black','/star_green.jpg#star_green'];

var theword='Clairvoyance';
var thenoun='Zener Card';
var theelem="<img style='object-fit:contain;' src=";
var thewords=['Clairvoyance', 'Fruit', 'Food', 'Animal', 'Bird', 'Carpentry', 'London', 'India', 'Australian Indigenous Language', 'Cell'];
var theelems=["<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src="];
var theihs=[">", ">", ">", ">", ">", ">", ">", ">", ">", ">"];
var thenouns=['Zener Card', 'Fruit', 'Meal', 'Creature', 'Bird', 'Framework Feature', 'Day', 'State', 'Language Area', 'Cell Part'];
var theiw=(document.URL.indexOf('itype=') != -1 ? eval(-1 + eval('' + document.URL.split('itype=')[1].split('&')[0].split('#'))) : 0);

if (theiw > 0) {
zcblurb='';
document.title=document.title.replace('Clairvoyance ', thewords[theiw] + ' ');
if (thewords[theiw] == 'Food') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#x1f35b;';
zener_cards[1]+='|&#x1f371;';
zener_cards[2]+='|&#x1f358;';
zener_cards[3]+='|&#x1f359;';
zener_cards[4]+='|&#x1f363;';
} else if (thewords[theiw] == 'Fruit') { // '127825', '127825', '127818', '127827', '127821'
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#127817;';
zener_cards[1]+='|&#127825;';
zener_cards[2]+='|&#127818;';
zener_cards[3]+='|&#127827;';
zener_cards[4]+='|&#127821;';
} else if (thewords[theiw] == 'Animal') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#128018;';
zener_cards[1]+='|&#129421;';
zener_cards[2]+='|&#129447;';
zener_cards[3]+='|&#128054;';
zener_cards[4]+='|&#128021;';
} else if (thewords[theiw] == 'Bird') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/bird_quiz.htm" style="object-fit:contain;" src="';
} else {
theelems[theiw]='<img data-url="/bird_quiz.htm" style="object-fit:contain;" src="';
}
theihs[theiw]='>';
zener_cards[0]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#8,5,374,370';
zener_cards[1]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#374,5,930,370';
zener_cards[2]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#930,5,1164,370';
zener_cards[3]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#1164,5,1500,370';
zener_cards[4]+=''; // |//www.rjmprogramming.com.au/HTMLCSS/birdyquiz.jpeg#5,680,374,1120';
} else if (thewords[theiw] == 'Carpentry') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/floor_wall_roof_framing_members.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/floor_wall_roof_framing_members.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'London') {
delay=8000;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/london_trip_via_map_element.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/london_trip_via_map_element.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'India') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/india_map.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/india_map.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'Australian Indigenous Language') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/ImageMap/Languages/aboriginal_language_regions.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/ImageMap/Languages/aboriginal_language_regions.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';
} else if (thewords[theiw] == 'Cell') {
delay=8000;
randomize=true;
if (document.URL.indexOf('rjmprogramming.com.au/') != -1) {
theelems[theiw]='<img data-url="//www.rjmprogramming.com.au/HTMLCSS/the_cell.html" style="object-fit:Cover;" src="';
} else {
theelems[theiw]='<img data-url="/HTMLCSS/the_cell.html" style="object-fit:Cover;" src="';
}
theihs[theiw]='>';
zener_cards[0]+='';
zener_cards[1]+='';
zener_cards[2]+='';
zener_cards[3]+='';
zener_cards[4]+='';

}
}

var sideas=['Awaiting Other Player Choosing a ' + thenouns[theiw] + ' to Guess','Select the ' + thenouns[theiw] + ' Your Player Partner Selected','Select a ' + thenouns[theiw] + ' You Are Asking Your Player Partner to Guess','Awaiting Guess from Your Player Partner','Awaiting a ' + thenouns[theiw] + ' Selection from Your Playing Partner'];

… working with the cropping and resizing smarts the HTML canvas element is capable of …


function imc(iois) {

var aconto=null, prefixing='', ipr=0, minx=0, miny=0, maxx=0, maxy=0, donesofar=',';
if (iois.src.indexOf('/About_Us.htm') == -1) {
aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
//alert('' + aconto.body.innerHTML.indexOf('<area ') + '!' + aconto.body.innerHTML.split(' shape="rect"').length + '?' + iois.src + ';' + aconto.body.innerHTML.split('<map ')[0].split('<img ')[eval(-1 + aconto.body.innerHTML.split('<map ')[0].split('<img ').length)] + ':' + aconto.body.innerHTML);
if (eval('' + aconto.body.innerHTML.indexOf('<map ')) > eval('' + aconto.body.innerHTML.indexOf('<img ')) && aconto.body.innerHTML.indexOf('<map ') != -1 && aconto.body.innerHTML.indexOf('<img ') != -1 && aconto.body.innerHTML.indexOf('<area ') != -1 && aconto.body.innerHTML.replace(/shape\=\"poly\"/g,'shape="rect"').indexOf('shape="rect"') != -1) {
//alert('000:' + '');
if (aconto.body.innerHTML.indexOf('shape="rect"') == -1) {
prefixing=' ';
//if (document.URL.indexOf('&debug=') != -1) { alert('yes'); }
}
wourl=iois.src;
coordsarr=aconto.body.innerHTML.replace(/shape\=\"poly\"/g,'shape="rect"').split('shape="rect"');
//alert('0000:' + coordsarr.length);
if (eval('' + coordsarr.length) > 5) {
//alert('00:' + '');
imname=aconto.body.innerHTML.split('<map ')[0].split('<img ')[eval(-1 + aconto.body.innerHTML.split('<map ')[0].split('<img ').length)];
//alert('0:' + imname);
imname=imname.split('src="')[1];
//alert('1:' + imname);
imname=imname.split('"')[0];
//alert('2:' + imname);
if ((imname + 'x').indexOf('//') != -1 || (imname + 'x').indexOf('data:') == 0) { // || (imname + 'x').substring(0,1) == '/') {
if ((imname + 'x').indexOf('data:') == 0) {
imname=imname;
} else {
imname='//' + imname.split('//')[1];
}
} else if ((imname + 'x').substring(0,1) == '/') {
if (iois.src.indexOf('//') != -1) {
imname='//' + iois.src.split('//')[1].split('/')[0] + '/' + imname.substring(1);
} else {
imname='//www.rjmprogramming.com.au/' + imname.substring(1);
}
} else if ((imname + 'xxxxxxxxx').substring(0,12) == '../../../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-5 + iois.src.split('/').length)], imname.substring(12) + '#');
} else if ((imname + 'xxxxxxxxx').substring(0,9) == '../../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-4 + iois.src.split('/').length)], imname.substring(9) + '#');
} else if ((imname + 'xxxxxx').substring(0,6) == '../../') {
imname=iois.src.replace(iois.src.split('/')[eval(-3 + iois.src.split('/').length)], imname.substring(6) + '#');
} else if ((imname + 'xxx').substring(0,3) == '../') {
imname=iois.src.replace(iois.src.split('/')[eval(-2 + iois.src.split('/').length)], imname.substring(3) + '#');
} else if ((imname + 'xx').substring(0,1) == './') {
imname=iois.src.replace(iois.src.split('/')[eval(-1 + iois.src.split('/').length)], imname.substring(2));
} else {
imname=iois.src.replace(iois.src.split('/')[eval(-1 + iois.src.split('/').length)], imname.substring(0));
}
}

//alert(imname.split(' ')[0] + ' ' + coordsarr[1]);
imlist=document.getElementsByTagName('img');
tds=document.getElementsByTagName('td');
squaredim=eval('' + tds[0].getBoundingClientRect().width);
document.getElementById('dtop').style.background='linear-gradient(rgba(255,255,255,0.1),rgba(255,255,255,0.1)),url(' + imname.split(' ')[0] + ')';
document.getElementById('dtop').style.backgroundRepeat='no-repeat';
document.getElementById('dtop').style.backgroundSize='contain';
document.getElementById('dtop').style.backgroundPosition='right top';
document.getElementById('dtop').onclick=function(event){ event.stopPropagation(); window.open(wourl,'_blank','top=50,left=50,width=600,height=600'); };

var imgis=new Image();
imgis.onload = function(){
var ict=1, jct=1;
var zcanvas = document.createElement('canvas');
zcanvas.width = squaredim; //imgis.width;
zcanvas.height = squaredim; //imgis.height;
var zctx = zcanvas.getContext('2d');
if (!randomize) {
while (coordsarr[ict].indexOf(' coords="') == -1) {
ict++;
}
}
if (randomize) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
//alert('first ict=' + ict + ' ... ' + donesofar);
while (ict == 0 || (donesofar + ',').indexOf(',' + ict + ',') != -1) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
if (coordsarr[ict].indexOf(' coords="') == -1) {
if (donesofar != ',') {
ict=eval('' + donesofar.substring(1).split(',')[0]);
} else {
ict++;
}
}
}
donesofar+='' + ict + ',';
}
//for (ict=1; ict<=5; ict++) {
while (jct <= 5) {
//if (document.URL.indexOf('&debug=') != -1) { alert(coordsarr[ict]); }
coordsarr[ict]=coordsarr[ict].split(' coords="')[1].split('"')[0];
if (randomize || prefixing != '' || (eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])) > 10 && eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])) > 10)) {
//alert('zctx.drawImage("' + imname.split(' ')[0] + '",' + eval(coordsarr[ict].split(',')[0].split('"')[0]) + ',' + eval(coordsarr[ict].split(',')[1].split('"')[0]) + ',' + eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])) + ',' + eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])) + ',0,0' + ',' + tds[eval(-1 + ict)].getBoundingClientRect().width + ',' + tds[eval(-1 + ict)].getBoundingClientRect().width + ')');
if (prefixing != '') {
//if (document.URL.indexOf('&debug=') != -1) { alert('YES'); }
minx=0;
miny=0;
maxx=0;
maxy=0;
for (ipr=0; ipr<coordsarr[ict].split(',').length; ipr+=2) {
if (ipr == 0) {
minx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]);
maxx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]);
miny=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]);
maxy=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]);
} else {
if (eval(coordsarr[ict].split(',')[ipr].split('"')[0]) < minx) { minx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[ipr].split('"')[0]) > maxx) { maxx=eval(coordsarr[ict].split(',')[ipr].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]) < miny) { miny=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]); }
if (eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]) > maxy) { maxy=eval(coordsarr[ict].split(',')[eval(1 + ipr)].split('"')[0]); }
}
}
prefixing='' + minx + ',' + miny + ',' + maxx + ',' + maxy;
//if (document.URL.indexOf('&debug=') != -1) { alert('prefixing=' + prefixing); }
coordsarr[ict]=prefixing.trim(); // + ',' + coordsarr[ict];
}
if (theelems[theiw].indexOf('object-fit:none') != -1 || theelems[theiw].indexOf('object-fit:Cover') != -1) {
//if (document.URL.indexOf('&debug=') != -1) { alert('Yes'); }
zcanvas.width = eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])); //imgis.width;
//if (document.URL.indexOf('&debug=') != -1) { alert('YeS'); }
zcanvas.height = eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])); //imgis.height;
//if (document.URL.indexOf('&debug=') != -1) { alert('YEs'); }
zctx.drawImage(imgis, eval(coordsarr[ict].split(',')[0].split('"')[0]), eval(coordsarr[ict].split(',')[1].split('"')[0]), eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])),0,0,eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])));
//if (document.URL.indexOf('&debug=') != -1) { alert('yeS'); }
} else {
zctx.drawImage(imgis, eval(coordsarr[ict].split(',')[0].split('"')[0]), eval(coordsarr[ict].split(',')[1].split('"')[0]), eval(eval(coordsarr[ict].split(',')[2].split('"')[0]) - eval(coordsarr[ict].split(',')[0].split('"')[0])), eval(eval(coordsarr[ict].split(',')[3].split('"')[0]) - eval(coordsarr[ict].split(',')[1].split('"')[0])),0,0,squaredim,squaredim);
}
xaltdu=zcanvas.toDataURL("image/jpeg", 0.1);
//alert(xaltdu);
//alert(imlist[eval(-1 + ict)].outerHTML);
//if (document.URL.indexOf('&debug=') != -1) { alert(xaltdu); }
imlist[eval(-1 + jct)].src=xaltdu;
//zener_cards[eval(-1 + jct)]+='' + xaltdu;
if (jct < 5) {
zcanvas.width = squaredim; //imgis.width;
zcanvas.height = squaredim; //imgis.height;
if (prefixing != '') { prefixing=' '; } else { prefixing=''; }
}
jct++;
//} else {
//alert(coordsarr[ict]);
}
if (!randomize) {
ict++;
if (document.URL.indexOf('&debug=') != -1) { alert('ict=' + ict + ' and jct=' + jct); }
} else {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
//alert('first ict=' + ict + ' ... ' + donesofar);
while (ict == 0 || (donesofar + ',').indexOf(',' + ict + ',') != -1) {
ict=Math.floor(Math.random() * eval(-1 + eval('' + coordsarr.length)));
if (coordsarr[ict].indexOf(' coords="') == -1) {
if (donesofar != ',') {
ict=eval('' + donesofar.substring(1).split(',')[0]);
} else {
ict++;
}
}
}
donesofar+='' + ict + ',';
}
}
};

imgis.src=imname.split(' ')[0];

}
}
}
}
}

function imagemapcheck() {
if (theelems[theiw].indexOf(' data-url="') != -1 && theelems[theiw].indexOf(' data-url=""') == -1 && zener_cards[0].replace('#circle_yellow','').indexOf('#') == -1) {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].indexOf('#') == -1) {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].slice(-5).indexOf('.') == -1 && theelems[theiw].split(' data-url="')[1].split('"')[0].slice(-1) != '/') {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0] + '/#';
} else {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0] + '#';
}
} else {
if (theelems[theiw].split(' data-url="')[1].split('"')[0].split('#')[0].slice(-5).indexOf('.') == -1 && theelems[theiw].split(' data-url="')[1].split('"')[0].split('#')[0].slice(-1) != '/') {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0].replace('#','/#');
} else {
document.getElementById('ifimc').src=theelems[theiw].split(' data-url="')[1].split('"')[0];
}
}
}
}

… in a changed sixth draft Clairvoyance++ Game.


Previous relevant Clairvoyance Game Waiting Tutorial is shown below.

Clairvoyance Game Waiting Tutorial

Clairvoyance Game Waiting Tutorial

The recent Clairvoyance Game Objectify Tutorial work is revisited today, with the news that we’ve introduced …

implied invitations

… when the user enters a “player name” (looking a lot like an IP address) from that list of “potential players online” that is not any form of their own IP address player name. It will be apparent to regular readers that this methodology was intended to be the “usual methodology” at the beginning of our project, and so “we’ll allow a leave pass” for you to ask …

How come this took so long?

And then we’d say …

Huh?!

And there you go! Just “keep those cards and letters” flowing in!

So what do we mean by “implied invitations”? Well, in between a user “Wait” answer and the next, any other user can ask to play that waiting user, and the next time out of the prompt window they may find they’re in the midst of a game of some sort, invited by another player. We hope this does not offend?!

The concept of a “formal invitation” still exists for the email or SMS collaboration conduits, we hasten to add.

And so “day ?whatevvvvvvvvvvveeeeerrrrrrrr” got us to …


Previous relevant Clairvoyance Game Objectify Tutorial is shown below.

Clairvoyance Game Objectify Tutorial

Clairvoyance Game Objectify Tutorial

Extending yesterday’s Clairvoyance Game Sharing Scores Tutorial, it’s not exactly OOP (Object Oriented Programming) we are doing, but what we’d describe as “objectify” the proceedings we’re attending to today. Take a look at the following Javascript initialization code (now versus before) …


var zener_cards=['/circle_yellow.jpg#circle_yellow','/cross_red.jpg#cross_red','/waves_blue.jpg#waves_blue','/square_black.jpg#square_black','/star_green.jpg#star_green'];

var theword='Clairvoyance';
var thenoun='Zener Card';
var theelem="<img style='object-fit:contain;' src=";
var thewords=['Clairvoyance', 'Fruit', 'Food'];
var theelems=["<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src=", "<img style='object-fit:contain;' src="];
var theihs=[">", ">", ">"];
var thenouns=['Zener Card', 'Fruit', 'Food'];
var theiw=(document.URL.indexOf('itype=') != -1 ? eval(-1 + eval('' + document.URL.split('itype=')[1].split('&')[0].split('#'))) : 0);

var ppsuff='';
var youare='';
var otheris='';
var score=0, goes=0;
var woois=null;
var pick=-1, awaiting=false, holdon=false;
var bihnull=true;
var anchor=null;
var initval='';
var lastafterscore='';
var wherewrong=false;
var sharemyscore=false, allowsdone=false;
var zcblurb=' You can enter ? to find out more about the history of Zener Cards. ';

if (theiw > 0) {
zcblurb='';
document.title=document.title.replace('Clairvoyance ', thewords[theiw] + ' ');
if (thenouns[theiw] == 'Food') {
theelems[theiw]='<button style=font-size:100px; title=';
theihs[theiw]='>';
zener_cards[0]+='|&#x1f35b;';
zener_cards[1]+='|&#x1f371;';
zener_cards[2]+='|&#x1f358;';
zener_cards[3]+='|&#x1f359;';
zener_cards[4]+='|&#x1f363;';
} else if (thenouns[theiw] == 'Fruit') { // '127825', '127825', '127818', '127827', '127821'
theelems[theiw]='&lt;button style=font-size:100px; title=';
theihs[theiw]='&gt;';
zener_cards[0]+='|&#127817;';
zener_cards[1]+='|&#127825;';
zener_cards[2]+='|&#127818;';
zener_cards[3]+='|&#127827;';
zener_cards[4]+='|&#127821;';
}
}


var sideas=['Awaiting Other Player Choosing a ' + thenouns[theiw] + ' to Guess','Select the ' + thenouns[theiw] + ' Your Player Partner Selected','Select a ' + thenouns[theiw] + ' You Are Asking Your Player Partner to Guess','Awaiting Guess from Your Player Partner','Awaiting a ' + thenouns[theiw] + ' Selection from Your Playing Partner'];

… helping build up HTML for a new dropdown (versus what was there before) …


function multimaybe() {
var selbit='', jsel=0;
if (eval('' + thenouns.length) > 1) {
selbit="<sup><select style=width:30px; onchange=\"if (eval('' + this.value) != eval(1 + eval('' + theiw))) { location.href=document.URL.split('?')[0].split('#')[0] + '?itype=' + this.value; }\"><option value=" + eval(1 + theiw) + ">?</option></select> </sup> ";
for (jsel=0; jsel<thenouns.length; jsel++) {
selbit=selbit.replace('</select>', '<option value=' + eval(1 + jsel) + '>' + thewords[jsel] + ' Game</option></select>');
}
}
return selbit;
}

… and then later within the HTML <body> section …


<script type=text/javascript>
document.write("<h1 id=muh1>" + thewords[theiw] + " Game " + multimaybe() + "<input type=checkbox id=allows style=display:none; onchange=chscal(this);><font size=1 id=fshare style=display:none;>Share Score</font></input> <input type=checkbox id=allowstwo style=display:none; onchange=chscaltwo(this);><font size=1 id=fsharetwo style=display:none;>Be Told Where You Went Wrong</font></input></h1>");
</script>

… and am sure you can see where an initial “Clairvoyance” noun “hardcoding” feel of logic gets expanded to an “array of nouns” (where lots of programmers will immediately shout “objects”), as an alternative way of thinking to the ways our Javascript functions are like “verbs”. If you “abstract” the “what was a hardcoding” into “a dynamically selectable list of nouns” this objectifying process can be quite useful.

And so “day six” got us to …


Previous relevant Clairvoyance Game Sharing Scores Tutorial is shown below.

Clairvoyance Game Sharing Scores Tutorial

Clairvoyance Game Sharing Scores Tutorial

Onto the day before yesterday’s (yes, another two dayer!) Clairvoyance Game Invitations Tutorial primarily we have a checkbox part regarding …

  • Be Told Where You Went Wrong … guessing within our two player Clairvoyance Game … easy peasy … but …
  • Share Your Score … was really difficult … go figure …

… though the latter did ask a lot regarding timing and the sleep patterns of the PHP interlocutor … ?

Let’s just “move on” … shall we?!

Also on the agenda was some colour coding … and who doesn’t like a bit of colour coding! We purloined CSS into play, with “the kind of kludgy / kind of cute (well, you had to be there)” introduction of a title attribute to the status wording element and then apply that CSS …


<style>
#tdstatus[title^='Awaiting Other '] {
border: 3px solid red;
}

#tdstatus[title^='Awaiting a '] {
border: 3px solid rgb(127,0,0);
}


#tdstatus[title^='Awaiting Guess '] {
border: 3px solid orange;
}

#tdstatus[title^='Select the '] {
border: 6px solid lightgreen;
}

#tdstatus[title^='Select a '] {
border: 6px solid green;
}

$tdstatus { padding: 5 5 5 5; }
</style>

We often find it the way, when it comes to colour coding, we borrow from “the traffic light creed” regarding the colours used, where a reddish colour means “hang on” and a greenish colour is an invitation to the user. One could also think of “beeps” or “notifications” here, but not with us here, as of yet.

And so “day four” and “day five” saw …


Previous relevant Clairvoyance Game Invitations Tutorial is shown below.

Clairvoyance Game Invitations Tutorial

Clairvoyance Game Invitations Tutorial

In yesterday’s Clairvoyance Game Tutorial, with our Clairvoyance Game, really a game for two, downplayed invitations to the end of the blog posting blurb. But really, invitations are the “be all and end all” for a two player game shared over the Internet and just using a “PHP and HTML/Javascript” level of sophistication.

And, of course, two days later (when we think it should have only been “one day later”), it might be me, but making this work for email or SMS invitations was not trivial, partly because …

  • we launched into this “phase two public invitational sharing” on a false premise … our “phase one window.open and window.opener” Javascript logics were flawed (further into the logic than the first foray, shall we say) … bad news … we reckon one out of two days “getting there” would have to be put down to the lack of testing on day one … whereas …
  • our thought that “phase two” is just phase one window.open and window.opener transfers to PHP writes Javascript equivalents was “more or less” true, but we all know “programming life” throws up unexpected roadblocks

… and that is the excuse today, which we are sticking to … so there, ngaaahhhh!

This calls into play the importance, often, of “project planning”, and the compartmentalizing of testing, including really tight unit testing, especially if your software plan has so much dependency in “day two” on the “day one” quality. As far as that goes, in our defence, regarding a networking web application, that this Clairvoyance Game “more or less is” (though yesterday’s work simplistically pared that down so that we never needed more than our local MAMP Apache/PHP web server involved) sometimes you find it is hard to recognize “units” within the big picture.

And so “day two” and “day three” were all about “online invitation” logic for email or SMS invitations in …


Previous relevant Clairvoyance Game Tutorial is shown below.

Clairvoyance Game Tutorial

Clairvoyance Game Tutorial

Are you sixth sensical? Can you read tea leaves? If it’s one out of two, that will do.

We’re starting down the road to a new …

Clairvoyance Game

… today, that on today’s first draft, as a design for two players …

  • starts you playing yourself, or a nearby other player willing to share windows on your one common web browser incarnation …
  • kind of ludicrous on this day one but the building blocks are there, they being …
    1. HTML and Javascript parent … talking to …
    2. PHP interlocutor

    … which we’re going to extend, on day two, simulating what a window.open and window.opener (just on client) can do, just with a few more calls, and sleeping

Two players take it in turns …

  1. selecting a Zener Card the other player is asked to guess
  2. other player trying to guess that Zener Card selected

… to score, or not, in this first draft Clairvoyance Game helped out by PHP first draft interlocutor.

In days to come, we think we’ll also be coding for email or SMS invitations to play, as well. This will be old news to some of you telepathic genii.

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