So far it might have been hard for some users to visualize โcolouring inโ a blank canvas. As such, today, onto yesterdayโs Colouring In Drag and Drop Mobile Tutorial weโre now offering โฆ
- ability to define a tabular background image via a browsed for image โฆ or โฆ
- ability to define a tabular background image via a user defined image URL
โฆ and add a new โopacityโ setting โฆ
function torgba(inc, opa) {
var i, j=0, csess="rgba(:::1.0)", alp="0123456789abcdef", factor=16;
for (i=0; i<=inc.replace('#','').length; i++) {
if (i == 1) {
csess=csess.replace('rgba(:','rgba(' + (j + alp.toLowerCase().indexOf(inc.toLowerCase().replace('#','').substring(i,(i + 1)))) + ':');
j=0;
} else if (i == 3) {
csess=csess.replace('::',':' + (j + alp.toLowerCase().indexOf(inc.toLowerCase().replace('#','').substring(i,(i + 1)))) + ':');
j=0;
} else if (i == 5) {
csess=csess.replace('::',':' + (j + alp.toLowerCase().indexOf(inc.toLowerCase().replace('#','').substring(i,(i + 1)))) + ':');
j=0;
} else {
j=j + (factor * alp.toLowerCase().indexOf(inc.toLowerCase().replace('#','').substring(i,(i + 1))));
}
csess = csess.replace(":1.0)",":" + opa + ")");
}
return csess.replace(/\:/g,',');
}
function opit(ijval) {
if (document.getElementById('opmeter')) {
if (eval(1.00 - document.getElementById('opmeter').value) != 0.00) {
return torgba(ijval, document.getElementById('opmeter').value);
}
}
return ijval;
}
โฆ all of which we can envisage could have users, at the very least, using this โColouring Inโ web application for โฆ
- a scribbling or doodling mechanism (on a blank canvas)
- colouring in via a background image with clip art linework, perhaps โฆ
- create a postcard (type of creation) via a background image, perhaps browsed for (or using the Take Photo or Video option for mobile) on your device, and overlay some scribbled (or doodled) wording
Codewise โฆ
- achanged experimental_drag_and_drop
htm Experimental Drag and Drop clientside HTML and Javascript basis โฆ helps out โฆ
- achanged colouring_in_was_numbers_guessing_game
php PHP coded Colouring
In Game you can also try for yourself, below โฆ
โฆ helped with these mobile platform tweaks. We thank https://i.pinimg.com/736x/86/98/2d/86982d9ee1582bb7a4e730f11ebed3f4.jpg for the background image used (and fed into that image URL textbox to make happen) in todayโs tutorial animated GIF presentation.
Previous relevant Colouring In Drag and Drop Mobile Tutorial is shown below.
Yesterdayโs Colouring In Drag and Drop Sharing Tutorial sharing and collaboration code for our latest Colouring In web application was tested on our MacBook Air laptop only. As you can imagine, that can mean that code working there is not always going to work the same way on mobile touch devices, but it was not, as it panned out for us, regarding the reason we thought it would be about. We thought โฆ
- itโs bound to be an issue with dragging event workings regarding mobile โฆ but it took us quite some time to stop burying our head in the sand and, instead, โkeeping it simple, Seรฑorโ (ie. the KISS principle, and yes, Seรฑor is not a spelling mistake, thank you very much for your concern) โฆ and testing another โdumber soundingโ but panning out to be true, in this case โฆ
- issue was to do with table cell widths and heights for table cells with no content acts differently for mobile than non-mobile (effectively scrunching cells up)
โฆ the trigger for us being that the โdropโ event.target.id kept on showing up as โmytableโ. That happened hours ago! We beavered away with x,y proportional co-ordinate calculations and eventually after all that not helping (for 2 maybe 3 hours), started applying a table cell border, which gave crazy results, and then it tweaked?! Sheeeeesssshhhhh!
Can you teach yourself the KISS principle? Maybe you get better over time. Another opinion can be great, though, with that alternative view, you hadnโt even thought of, often the result of such conversations.
Back to today, we โฆ
Made sure table โtrโ row elements were for a better defined (proportionate to table) width โฆ |
---|
<?php
?> |
Made sure table โtdโ cell elements were proportional โฆ initially, expressed in โviewportโ (percentage style) dimension terms โฆ |
<style>
</style> |
โฆ and if not the default number of cells across and down โฆ |
|
Codewise โฆ
- achanged experimental_drag_and_drop
htm Experimental Drag and Drop clientside HTML and Javascript basis โฆ helps out โฆ
- achanged colouring_in_was_numbers_guessing_game
php PHP coded Colouring
In Game you can also try for yourself, below โฆ
โฆ helped with these mobile platform tweaks.
Previous relevant Colouring In Drag and Drop Sharing Tutorial is shown below.
Weโre hoping yesterdayโs Colouring In Drag and Drop Settings Tutorial new Colouring In web application is seen as a creativeโs tool. As such, youโre going to want to share and collaborate โฆ some of you, that is?!
Youโre going to want to hashtag โฆ oops โฆ weโre going to want to hashtag. Yes, there is lots of data to share, but it worries us even involving hashtagging, how much there is, underlying, regarding that table element acting a bit like a televisionโs pixels. How do you effectively share even a snapshot of that?
But the difference between us and the television is, at least for a lot of peopleโs creations, the table is likely to be untouched, so canโt we โnicknameโ these repeated table cell scenarios? If you just said โindeedโ, weโd concur! Take a look at some global Javascript variables we thought might help โฆ
var defemail='';
var defsms='', snum=null, sparewes=null;
var prefixnickchar='.';
var prefixfor='<td class="tdone" id="';
var suffixnickchar='-';
var suffixfor='" class="tdone" style="text-align:center;" data-answer="1"></td>';
โฆ and for those untouched cells youโre saving more than (because of encryption) the length difference between the โnickcharsโ above and their โfixforโ counterparts for each โboringโ table cell encountered. And all this eases our mind somewhat, as a design, realized, on the way to the emailee or smsee this way โฆ
function doemail(inidea) {
var bihbig='';
var azx=top.document.getElementById('xae' + 'mail');
//alert(33);
if (!azx) { azx=top.document.createElement("a"); }
//alert(3333);
//if (1 == 1) {
//document.getElementById('divas').appendChild(azx);
//} else {
top.document.body.appendChild(azx);
//}
//(334);
azx.style = "display: none";
//alert(2334);
azx.target = "_top";
//alert(6334);
azx.id = 'xae' + 'mail';
if (inidea.indexOf('@') == -1) {
inidea=('' + prompt('Please enter Email address to send to.', defemail));
if (inidea == null) { inidea=''; }
}
if (inidea.indexOf('@') == -1) { return ''; }
bihbig=document.body.innerHTML;
while (bihbig.indexOf(suffixfor) != -1) {
bihbig=bihbig.replace(suffixfor, suffixnickchar);
}
while (bihbig.indexOf(prefixfor + 'td') != -1) {
bihbig=bihbig.replace(prefixfor + 'td', prefixnickchar + 'td');
}
//if (1 == 6 && bihbig.indexOf('</he' + 'ad>') != -1 || bihbig.indexOf('<b' + 'o' + 'dy') != -1 || bihbig.indexOf('<h' + '1') == 0) {
//azx.href = 'mailto:' + inidea + '?subject=' + encodeURIComponent(document.getElementsByTagName('h1')[0].innerText.split('&')[0].split('<')[0].replace(/\`/g,'').replace(/^Events\ in\ /g, 'Events in Month ').substring(0)) + '&body=' + encodeURIComponent(document.URL.replace('php#', 'php?').replace('#', '&') + '#cibih=' + encodeURIComponent(encodeURIComponent(bihbig))); //encodeURIComponent(document.URL.split('#')[0] + '<h2' + document.body.innerHTML.split('<h2')[1]));
//} else {
if (sparewes) {
azx.href = 'mailto:' + inidea + '?subject=' + encodeURIComponent(sparewes.document.getElementsByTagName('h1')[0].innerText.split('&')[0].split('<')[0].replace(/\`/g,'').replace(/^Events\ in\ /g, 'Events in Month ').substring(0)) + '&body=' + encodeURIComponent(document.URL.replace('php#', 'php?').replace('#', '&') + '#cibih=' + encodeURIComponent(encodeURIComponent(bihbig))); //encodeURIComponent(document.URL.split('#')[0] + '<h2' + sparewes.document.body.innerHTML.split('<h2')[1]));
} else {
azx.href = 'mailto:' + inidea + '?subject=' + encodeURIComponent(document.getElementsByTagName('h1')[0].innerText.split('&')[0].split('<')[0].replace(/\`/g,'').replace(/^Events\ in\ /g, 'Events in Month ').substring(0)) + '&body=' + encodeURIComponent(document.URL.replace('php#', 'php?').replace('#', '&') + '#cibih=' + encodeURIComponent(encodeURIComponent(bihbig))); //encodeURIComponent(document.URL.split('#')[0] + '<h2' + document.body.innerHTML.split('<h2')[1]));
}
//}
azx.click();
return '';
}
function dosms() {
var bihbig='';
if (('' + window.localStorage.getItem('colouringincollaboratoremailee')).replace(/^null/g,'').replace(/^undefined/g,'') != '') {
defemail=window.localStorage.getItem('colouringincollaboratoremailee');
}
if (('' + window.localStorage.getItem('colouringincollaboratorsmsno')).replace(/^null/g,'').replace(/^undefined/g,'') != '') {
defsms=window.localStorage.removeItem('colouringincollaboratorsmsno');
}
if (eval('' + ('sms:' + snum + '&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '#cibih=' + encodeURIComponent(parent.hfanalyze()))).length) >= 18000) {
snum=('' + prompt('Please enter SMS number to send to. We suspect message is too long for an SMS and if you enter an email address here instead, we will try to send an email instead. Append space(s) to remember, whatever you enter, for next time.', snum)).replace(/^null/g, (defemail.indexOf('@') != -1 ? defemail : (defsms != '' ? defsms : '')) );
} else {
snum=('' + prompt('Please enter SMS number to send to. Append space(s) to remember for next time.', snum)).replace(/^null/g, (defsms != '' ? defsms : (defemail.indexOf('@') != -1 ? defemail : '')));
}
if (snum == null) { snum=''; }
if (snum.indexOf('@') != -1) {
if (snum.trim() != snum) {
snum=snum.trim();
if (('' + window.localStorage.getItem('colouringincollaboratoremailee')).replace(/^null/g,'').replace(/^undefined/g,'') != '') {
window.localStorage.removeItem('colouringincollaboratoremailee');
}
window.localStorage.setItem('colouringincollaboratoremailee', snum);
defemail=snum;
}
return doemail(snum);
} else if (snum.trim() != '' && snum.trim().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,'').trim() == '') {
//alert('Snum=' + snum + '?');
if (snum.trim() != snum) {
snum=snum.trim();
if (('' + window.localStorage.getItem('colouringincollaboratorsmsno')).replace(/^null/g,'').replace(/^undefined/g,'') != '') {
window.localStorage.removeItem('colouringincollaboratorsmsno');
}
window.localStorage.setItem('colouringincollaboratorsmsno', snum);
defsms=snum;
}
bihbig=document.body.innerHTML;
while (bihbig.indexOf(suffixfor) != -1) {
bihbig=bihbig.replace(suffixfor, suffixnickchar);
}
while (bihbig.indexOf(prefixfor + 'td') != -1) {
bihbig=bihbig.replace(prefixfor + 'td', prefixnickchar + 'td');
}
var azx=top.document.getElementById('xas' + 'ms');
if (azx == null) { azx=top.document.createElement("a"); }
//if (1 == 1) {
// document.getElementById('divas').appendChild(azx);
//} else {
top.document.body.appendChild(azx);
// }
azx.id = 'xas' + 'ms';
azx.target = "_top";
azx.style = "display: none";
azx.href = 'sms:' + snum + '&body=' + encodeURIComponent(document.URL.replace('php#', 'php?').replace('#', '&') + '#cibih=' + encodeURIComponent(encodeURIComponent(bihbig)));
azx.click();
}
return '';
}
โฆ and when arriving back from an emaileeโs or smseeโs link click โฆ
function cibihcheck() {
var partslh=('' + location.hash).split('#ci' + 'bih=');
if (eval('' + partslh.length) > 1) {
var bihbig=decodeURIComponent(decodeURIComponent(partslh[1]));
bihbig=bihbig.replace(/\.td/g, prefixfor + 'td');
bihbig=bihbig.replace(/0\-/g, '0' + suffixfor);
bihbig=bihbig.replace(/1\-/g, '1' + suffixfor);
bihbig=bihbig.replace(/2\-/g, '2' + suffixfor);
bihbig=bihbig.replace(/3\-/g, '3' + suffixfor);
bihbig=bihbig.replace(/4\-/g, '4' + suffixfor);
bihbig=bihbig.replace(/5\-/g, '5' + suffixfor);
bihbig=bihbig.replace(/6\-/g, '6' + suffixfor);
bihbig=bihbig.replace(/7\-/g, '7' + suffixfor);
bihbig=bihbig.replace(/8\-/g, '8' + suffixfor);
bihbig=bihbig.replace(/9\-/g, '9' + suffixfor);
document.body.innerHTML=bihbig;
}
}
Codewise โฆ
- achanged experimental_drag_and_drop
htm Experimental Drag and Drop clientside HTML and Javascript basis โฆ helps out โฆ
- achanged colouring_in_was_numbers_guessing_game
php PHP coded Colouring
In Game you can also try for yourself, below โฆ
โฆ helped with this sense of collaboration.
Previous relevant Colouring In Drag and Drop Settings Tutorial is shown below.
Onto the start for our Colouring In web application via yesterdayโs Colouring In Canvas Clone of Numbers Guessing Game Tutorial weโre starting to enhance, on top of that โclone levelโ functionality, via two new settings with two approaches to the management of data, regarding, those being โฆ
- number of table cells across (that programmatically is made to be the same number of cells, as down) โฆ we deal with via a get ? (or &) address line URL arrangement โฆ whereas โฆ
- pen โwidthโ can be 1 or 2 (where 2 colours in the 1+8=9 surrounding cells of a dragged over cell) โฆ we deal with via a hashtag arrangement
Why the difference in approach? Letโs start with hashtag methodologies. This arrangement can leave everything about a webpage, in place, regarding the user actions on a webpage, while the Javascript can detect that change in โฆ
location.hash
โฆ dynamically. In other words some dragging canvas drawings with pen โwidthโ 2 can be combined with some using pen โwidthโ 1 in the same user creation.
But when the data management involves get ? (or &) address line URL arrangements, this involves navigation to a new incarnation of the webpage creation logic, effectively wiping the webpage slate clean. This is apt for the โnumber of table cells acrossโ data item, because the HTML content of the table element is not just affected, but is totally structured, according to this user setting.
Lately, more and more, weโve been hashtagging data to dynamically created โaโ link โmailto:โ email or โsms:โ SMS communication body webpage URL links. An email link or SMS link, from the recipientโs point of view is a โbrand new startโ that can address either or both of these data conduit arrangements, weโre getting happier and happier to discover โฆ
// ondragover event function code snippet below ...
ev.target.style.backgroundColor='' + document.getElementById('ddcolour').value;
if (decodeURIComponent(('' + location.hash)).indexOf('fontweight=') != -1) {
ifontweight=eval('' + ('' + decodeURIComponent(('' + location.hash))).split('fontweight=')[1].substring(0,1));
} else if (document.getElementById('numfontweight')) {
ifontweight=eval('' + document.getElementById('numfontweight').value);
}
if (ifontweight == 2) { // colour in 8 surrounding cells, as applicable
var minusthree=-3;
if (document.getElementById('numacross')) {
minusthree=eval(-1 * eval('' + document.getElementById('numacross').value.length));
}
var tdx=eval(('' + ev.target.id).substring(2).split('_')[0].replace(/^0/g,'').replace(/^0/g,''));
var tdy=eval(('' + ev.target.id).split('_')[1].replace(/^0/g,'').replace(/^0/g,''));
if (document.getElementById('td' + ('000' + eval(-1 + tdx)).slice(minusthree) + '_' + ('000' + eval(-1 + tdy)).slice(minusthree))) {
document.getElementById('td' + ('000' + eval(-1 + tdx)).slice(minusthree) + '_' + ('000' + eval(-1 + tdy)).slice(minusthree)).style.backgroundColor='' + document.getElementById('ddcolour').value;
}
if (document.getElementById('td' + ('000' + eval(-1 + tdx)).slice(minusthree) + '_' + ('000' + eval(0 + tdy)).slice(minusthree))) {
document.getElementById('td' + ('000' + eval(-1 + tdx)).slice(minusthree) + '_' + ('000' + eval(0 + tdy)).slice(minusthree)).style.backgroundColor='' + document.getElementById('ddcolour').value;
}
if (document.getElementById('td' + ('000' + eval(-1 + tdx)).slice(minusthree) + '_' + ('000' + eval(1 + tdy)).slice(minusthree))) {
document.getElementById('td' + ('000' + eval(-1 + tdx)).slice(minusthree) + '_' + ('000' + eval(1 + tdy)).slice(minusthree)).style.backgroundColor='' + document.getElementById('ddcolour').value;
}
if (document.getElementById('td' + ('000' + eval(0 + tdx)).slice(minusthree) + '_' + ('000' + eval(-1 + tdy)).slice(minusthree))) {
document.getElementById('td' + ('000' + eval(0 + tdx)).slice(minusthree) + '_' + ('000' + eval(-1 + tdy)).slice(minusthree)).style.backgroundColor='' + document.getElementById('ddcolour').value;
}
if (document.getElementById('td' + ('000' + eval(0 + tdx)).slice(minusthree) + '_' + ('000' + eval(1 + tdy)).slice(minusthree))) {
document.getElementById('td' + ('000' + eval(0 + tdx)).slice(minusthree) + '_' + ('000' + eval(1 + tdy)).slice(minusthree)).style.backgroundColor='' + document.getElementById('ddcolour').value;
}
if (document.getElementById('td' + ('000' + eval(1 + tdx)).slice(minusthree) + '_' + ('000' + eval(-1 + tdy)).slice(minusthree))) {
document.getElementById('td' + ('000' + eval(1 + tdx)).slice(minusthree) + '_' + ('000' + eval(-1 + tdy)).slice(minusthree)).style.backgroundColor='' + document.getElementById('ddcolour').value;
}
if (document.getElementById('td' + ('000' + eval(1 + tdx)).slice(minusthree) + '_' + ('000' + eval(0 + tdy)).slice(minusthree))) {
document.getElementById('td' + ('000' + eval(1 + tdx)).slice(minusthree) + '_' + ('000' + eval(0 + tdy)).slice(minusthree)).style.backgroundColor='' + document.getElementById('ddcolour').value;
}
if (document.getElementById('td' + ('000' + eval(1 + tdx)).slice(minusthree) + '_' + ('000' + eval(1 + tdy)).slice(minusthree))) {
document.getElementById('td' + ('000' + eval(1 + tdx)).slice(minusthree) + '_' + ('000' + eval(1 + tdy)).slice(minusthree)).style.backgroundColor='' + document.getElementById('ddcolour').value;
}
}
Codewise โฆ
- achanged experimental_drag_and_drop
htm Experimental Drag and Drop clientside HTML and Javascript basis โฆ helps out โฆ
- achanged colouring_in_was_numbers_guessing_game
php PHP coded Colouring
In Game you can also try for yourself, below โฆ
Did you know?
Our recent Earth Scanner project was conducted during our โHashtagging Enlightenment Periodโ, whereby, around here, the โฆ
What the Hep?
โฆ greeting, is code for โHave yourself a happy and fruitful hashtagging dayโ โฆ but we digress. In amongst itโs code there was an example codeline โฆ
var nontz=('' + location.search + ('' + location.hash).replace(/^\#/g,'')).split('nontz=')[1] ? decodeURIComponent(('' + location.search + ('' + location.hash).replace(/^\#/g,'')).split('nontz=')[1].split('&')[0].split('#')[0]) : '';
โฆ exemplifying, how more and more, weโre happy with setting (or other types of incoming) data coming from get (? and & ( eg. ?nontz=Alice_Springs%7C133.8807%7C_23.6980%7C )) arguments via location.search and/or hashtagged data coming from location.hash ( eg. #nontz=Alice_Springs%7C133.8807%7C_23.6980%7C ) above, either or both, perhaps, used in an email or SMS body URL link.
Previous relevant Colouring In Canvas Clone of Numbers Guessing Game Tutorial is shown below.
As the blog posting title suggests, cloned from yesterdayโs Numbers Guessing Game Dragover Tutorial โฆ
- Numbers Guessing Game dragover โvalue addโ proof of concept work โฆ comes โฆ
- Colouring In Canvas drag and (faux) drop web application
โฆ where a โcanvasโ palette (which is really an HTML table element made up of lots of table cells, rather than an HTML5 canvas element). Why this design? Well, each table cell element can be identified as an individual โdragged overโ element. โDragged overโ by what? Well, we turn some โdraggableโ wording in the basis HTML into โฆ
- an emoji pen
piece of text โฆ and next to that we add โฆ
- an input type=color Colour Picker to choose a pen colour โฆ and because the โondragoverโ event is so sensitive, we also add an optionally used, or not โฆ
- input type=number defining any delay (in seconds) before the โondragoverโ colouring in kicks in, from when it could first of happened, as the pen crosses over into the palette โฆ along with โฆ
- input type=number countdown of the delay
- achanged experimental_drag_and_drop
htm Experimental Drag and Drop clientside HTML and Javascript basis โฆ helps out โฆ
- a new Colouring In howwe got there colouring_in_was_numbers_guessing_game
php PHP coded new
web application you can also try for yourself, below โฆ
- drag and drop methodology โฆ
- dragover event โฆ value adding where โฆ
- drop element(s) are cells of an HTML table element (also a drop element)
- allow for the number of table cells to be other than 9 (with Animal Mineral Vegetable Game Tutorial where it is 3 in total) โฆ and today โฆ
- allow the number of cells across in a column not be 3
- moulding and manipulating (eg. arranging โcallbackโ logic means, as used below) that $templategame โtemplateโ for our purposes โฆ nga ha ha ha ha ha ha ha ha โฆ but we digress โฆ
- simply โฆ
<?php
echo $templategame;
?>
โฆ outputs a webpage โฆ - and on the way back to play again, we use $_GET[โscoreโ] and $_GET[โsecsโ] (in experimental_drag_and_drop
html HTML and Javascript and CSS game
web application) to keep the ball rolling back to the game specific PHP we use โฆ
location.href=document.getElementById('callback').value + '?score=' + score + '&secs=' + secs; - beyond our ken
- outside our usual subject matter
โฆ so that the user can use โdragoverโ event means by which to create their own โcolouring in creationโ!
Codewise โฆ
Previous relevant Numbers Guessing Game Dragover Tutorial is shown below.
Today weโre honing in on โฆ
โฆ as our interest. We scouted around for the best โdesign matchโ and came up with the arrangements existing when we presented Numbers Guessing Game Tutorial some time ago now.
And if we succeed with some form of value adding here, we have another idea for the ideas weโre presenting today. Spoiler alert! Yes, it can be made to be useful.
As such weโve โฆ
Added toggleable โshow where contemplatedโ value added border where dragover logic |
---|
<?php
?> |
Tweaked dragover logic |
|
Flag any continued โshow where contemplatedโ interest |
|
โฆ to, as the user requests, add some table cell border enhancements (as our โvalue addingโ) to ourtweaked thirddraft PHP game (helped out by thechanged experimental_drag_and_drop
htm Experimental Drag and Drop clientside HTML and Javascript basis), as the user drags the draggable element over the table droppable element and its cohort table cell elements.
Previous relevant Numbers Guessing Game Tutorial is shown below.
Weโve been working on aspects to the genericity of the table that is โฆ
The Drop Zone
โฆ do do โฆ do do โฆ do do โฆ do do โฆ do do do do do do do do do do do do โฆ yesterdayโs threat โnow so yesterdayโ being โฆ
โฆ in a (very difficult) Numbers Guessing game for numbers from 1 to 99 that regular readers may be familiar with as the (same content (and mentioned at this link โฆ thanks โฆ) as the) Numbers Guessing game at this blog, but presented using a Drag and Drop modus operandi.
Feel free to try our firstdraft PHP game, which leans on achanged experimental_drag_and_drop
htm HTML and Javascript and CSS game
web application basis, is also playable below โฆ
Stop Press
On your smaller devices we found the Numbers Guessing Game a bit hard to use. As such, we researched and played around with โdrag and dropโ cursor ideas unsuccessfully to end up, instead, not thinking about the cursor (albeit, we find that idea cuter) but rather styling the target table cellโs background colour and informing the user of that up at the top button wording in ourchanged seconddraft PHP game, which leans on ourchanged experimental_drag_and_drop
htm HTML and Javascript and CSS helperโฆ
var lastbco=null;
const target = document.querySelector("#target");
target.addEventListener("dragover", (ev) => {
if (lastbco) { lastbco.style.backgroundColor='white'; lastbco=null; }
console.log("dragOver " + ev.target.id + ' ' + ('' + ev.target.style.backgroundColor).replace('white','') + ' ' + document.body.innerHTML.indexOf('tab' + 'lece' + 'llb' + 'c'));
ev.preventDefault();
if (('' + ev.target.id).indexOf('td') == 0 && ('' + ev.target.style.backgroundColor).trim().replace('white','') == '' && document.body.innerHTML.indexOf('Numbe' + 'rs Guessi' + 'ng Ga' + 'me') != -1) {
//document.getElementById(sourceid).style.opacity='0.6';
lastbco=ev.target;
ev.target.style.backgroundColor='pink';
if (document.getElementById('mybut')) {
if (document.getElementById('mybut').innerHTML.indexOf(' .. ') == -1) {
document.getElementById('mybut').innerHTML=document.getElementById('mybut').innerHTML.replace(' Game Game', ' Game');
document.getElementById('mybut').innerHTML+=' .. current guess is ' + ev.target.innerHTML;
} else {
document.getElementById('mybut').innerHTML=document.getElementById('mybut').innerHTML.split(' .. ')[0] + ' .. current guess is ' + ev.target.innerHTML;
}
}
}
//document.getElementById(sourceid).style.cursor='progress';
//ev.target.style.cursor='progress';
//ev.target.dataTransfer.dropEffect = 'progress';
});
Previous relevant Planet Moon Game Tutorial is shown below.
Another thing that there is nine of (as contentious as it is regarding Pluto) is Planets in the Solar System, revolving around the Sun. And so, in keeping with a lot of the same design as yesterdayโs Enneagram Type Game Tutorial we have a Planet Moon Game to present for you to play around with today.
Again, PHP uses a framework of Experimental Drag and Drop HTML and Javascript and CSS, mainly via one PHP codeline โฆ
<?php
$templategame=file_get_contents('./experimental_drag_and_drop.htm');
?>
โฆ and, perhaps, your curiosity that we have not โpassedโ data via $_GET[] or $_POST[] arguments, but rather just the simple act of โฆ
โฆ in our firstdraft PHP game, which leans on achanged experimental_drag_and_drop
html HTML and Javascript and CSS game
web application basis, is also playable below โฆ
Stop Press
We fully concur with any adage that goes โฆ
You learn most from your mistakes
โฆ just as weโre curious about โthe things that go wrongโ, and not having them repeat! Same with pooches!
Take our firstto seconddraft PHP game (to the opera, would be preferable). We wondered why, occasionally, with the โfirst draftโ it would hang. It took us a half day to realize, as you could yourself have tweaked to a lot quicker if you had followed the adage โฆ
Hanging issues mostly team up with code within a loop
The situation, weโve reasoned, is that we had that PHP $badlist variable store a comma separated list of planets with either zero moons or more than one moon randomly selected representing it. Weโd assumed, yesterday, not that weโd put it in words, but in logic, that this list would not (have the same length or) be the same as a (new $goodlist variable) list of planets with either zero moons or selected while collecting the random list of Moon/Planet combinations โฆ ie. we assumed in the list would be a Planet with only one of its Moons randomly selected โฆ mistake!!! Better is โฆ
<?php
$goodlist=',Mercury,Venus,';
$badlist=',Mercury,Venus,';
while (strlen($goodlist) == strlen($badlist)) {
$goodlist=',Mercury,Venus,';
$badlist=',Mercury,Venus,';
$correctans=rand(0,8);
$sofar=';';
for ($i=0; $i<9; $i++) {
$j=rand(0, (-1 + sizeof($wikidesignations)));
if ($crandlist == '') {
$crandlist='' . $j;
$sofar.=$wikidescriptions[$j] . ';';
if (strpos($goodlist, $wikidescriptions[$j]) === false) { $goodlist.=$wikidescriptions[$j] . ','; }
} else if (strpos((',' . $crandlist . ','), (',' . $j . ',')) !== false) { // || strpos($sofar, ';' . $wikidescriptions[$j] . ';') !== false) {
while (strpos((',' . $crandlist . ','), (',' . $j . ',')) !== false) { // || strpos($sofar, ';' . $wikidescriptions[$j] . ';') !== false) {
$j=rand(0, (-1 + sizeof($wikidesignations)));
}
$crandlist.=',' . $j;
$sofar.=$wikidescriptions[$j] . ';';
if (strpos($goodlist, $wikidescriptions[$j]) === false) { $goodlist.=$wikidescriptions[$j] . ','; }
} else {
if (strpos($sofar, ';' . $wikidescriptions[$j] . ';') !== false) { $badlist.=$wikidescriptions[$j] . ','; }
$crandlist.=',' . $j;
$sofar.=$wikidescriptions[$j] . ';';
if (strpos($goodlist, $wikidescriptions[$j]) === false) { $goodlist.=$wikidescriptions[$j] . ','; }
}
}
}
?>
Previous relevant Enneagram Type Game Tutorial is shown below.
A lot of us wonder what goes towards making up our personalities. We remember doing a Myers-Briggs test for some job as part of the vetting process. We thought weโd write another experimental drag and drop game, like yesterdayโs Australian Street Type Game Tutorial, regarding โฆ
โฆ of human personalities, and we found a webpage linking these categorizations to Hollywood Movie Stars for you to get the gist of the ideas. We also thank Wikipedia as our source for Movie Star images.
It being a topic โฆ
โฆ you may be wondering how we stumbled upon the idea? We let Google autocomplete our โฆ
โฆ search textbox typing, fully expecting โCarolโ? to be at the top of the list when we saw โฆ
โฆ to flesh out a family of โgame interestโ, we hope?!
Our firstdraft PHP game is also playable below โฆ
Previous relevant Australian Street Type Game Tutorial is shown below.
The experimental drag and drop theme continues on today, after Experimental Drag and Drop Game Tutorialโs debut game application, with a Wikipedia inspired โAustralian Street Typeโ game today.
Huh?! Well, you know those street names that baffle? Or are we easily baffleable?! Anyway, you had to be there. And if you ever feel youโre alone with an interest, just look it up in Wikipedia or Google and youโre almost sure to find out โฆ
you are not alone
Yes, our Wikipedia page mentioned Australian Street Type Designations with their lawyerly Australian Street Type Descriptions. Who could ask for more? Well?!
To make this happen we wrote some PHP, which leans on achanged experimental_drag_and_drophtml HTML and Javascript and CSS game
web application basis, or template, to mould and bend towards our purpose โฆ nga ha ha!
Our firstdraft PHP game is also playable below โฆ
Previous relevant Experimental Drag and Drop Game Tutorial is shown below.
It can be interesting turning a โconceptโ (or even a โproof of conceptโ web application) into an, on the side, โgameโ web application, and that way, learn whatโs possible via user action. This is how we felt about yesterdayโs Experimental Drag and Drop Primer Tutorial and that teamed with the wonder about how we could add some useful complexity to our โExperimental Drag and Dropโ web applicationโs โฆ
Drop Zone
Can โinheritanceโ be harnessed to make it work for some complexity of nested HTML elements inside that โDrop Zoneโ element when the document.bodyโs onload event happens? We wondered whether a Brady Bunch style 3ร3 table could be the go? And whether the nine cells could have a โscoreโ associated with them, and that set of scores be changing over time to make the game more challenging and interesting? Well โฆ
Yes
โฆ is the answer regardingmaking a game out of a proof of concept with our experimental_drag_and_drophtml HTML and Javascript and CSS game
web application (also shown below) using these techniques, about which we think some of you readers will be interested?!
Previous relevant Experimental Drag and Drop Primer Tutorial is shown below.
Weโve added the word experimental into todayโs blog posting title, mainly because our first of two inspirational webpage sources (last modified on 23/02/2023) regarding somewhat alternative โDrag and Dropโ functionalities told us, regarding the DataTransfer object informational โDataTransferโ webpage โฆ
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
โฆ but our testing of the methodologies on various platforms hasnโt totally failed yet on any of the several desktop and mobile platform scenarios weโve tried. On mobile, we just held on for a sustained touch (down) to make it possible. So maybe the industry has caught up with the ideas? Weโre hoping so, because โdrag and dropโ is a kind of natural thing online users think of to do, and people associate it with โgetting things doneโ we reckon.
Anyway, we relied on the great source code of the second of two inspirational webpages DataTransfer: setData() method, thanks โฆ
The DataTransfer.setData() method sets the drag operationโs drag data to the specified data and type. If data for the given type does not exist, it is added at the end of the drag data store, such that the last item in the types list will be the new type. If data for the given type already exists, the existing data is replaced in the same position. That is, the order of the types list is not changed when replacing data of the same type.
โฆ to getus going with our โproofof conceptโ web
application (also shown below) using these techniques, about which we think some of you readers will be interested?!
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.