Word Find Game Underlay Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Word Find Game Underlay Tutorial

Word Find Game Underlay Tutorial

If you are a regular reader at this blog, you will know we discuss the CSS styling idea of โ€ฆ

โ€ฆ but there is essentially only the difference in the control of โ€œz-indexโ€ (and maybe โ€œopacityโ€) property different about the concepts, and to deploy to improve on for the start we made with yesterdayโ€™s Word Find Game Primer Tutorial.

โ€œUnderlayโ€ usefulness, to us, goes like this โ€ฆ

  • what you โ€œunderlayโ€ โ€ฆ for us within the new CSS styling โ€ฆ


    <style>

    textarea {

    font-family: Courier New;

    font-size: 20px;

    opacity: 0.9;

    z-index: 9;

    padding: 0 0 0 0;

    margin: 0 0 0 0;


    }



    #underlay {

    font-family: Courier New;

    font-size: 20px;

    opacity: 0.3;

    z-index: 1;

    padding: 0 0 0 0;

    margin: 0 0 0 0;

    }



    div.underlay {

    font-family: Courier New;

    font-size: 20px;

    opacity: 0.3;

    z-index: 2;

    padding: 0 0 0 0;

    margin: 0 0 0 0;

    }


    </style>


    โ€ฆ regimen โ€ฆ
  • has nothing to do with interactive entry, which should be more in your โ€œoverlayโ€ thinking, else the user is stumped โ€ฆ but โ€ฆ
  • can help with dynamically enhanced markup jobs that value add to the aesthetics of the webpage

โ€ฆ specifically showing the user โ€œwhere theyโ€™ve beenโ€ amongst the โ€œsea of lettersโ€ of ourchanged word_find_gameโšซhtml Word Find Game you can also try below.



Previous relevant Word Find Game Primer Tutorial is shown below.

Word Find Game Primer Tutorial

Word Find Game Primer Tutorial

Todayโ€™s โ€œWord Find Gameโ€ gets its inspirations from two sources โ€ฆ

Today we just do the โ€œproof of conceptโ€ first draft word_find_gameโšซhtml, because the Selection API highlighting really suits โ€ฆ

  • horizontal forwards
  • horizontal backwards

โ€ฆ word finding in theโœ‚game, but we also want to allow for โ€ฆ

  • vertical down
  • vertical up
  • diagonal right down
  • diagonal right up
  • diagonal left down
  • diagonal left up

โ€ฆ which can be handled, but in a pretty kludgy way โ€ฆ



function retry() {

if (('' + document.getElementById('nameif').title).trim() != '') {

document.getElementById('nameif').src=document.getElementById('nameif').title;

document.getElementById('nameif').title='';

} else {

document.getElementById('mytao').style.cursor=cscore('pointer', subscore);

}

}




function cscore(cursortype, ssc) {

if (ssc != 0) { goes++; }

if (ssc > 0) { score+=ssc; }

document.getElementById('score').innerHTML='' + score + '/' + goes;

subscore=0;

return cursortype;

}




function checkname(iois, iserror) {

var ifnd=-1, newname='';

var revsisc='', jrev=0;

console.log('checkname1');

if (iserror) {

if (iois.src.indexOf('second=') == -1 && iois.src.indexOf('iswordthere=') != -1) {

if (('' + iois.title).trim() != '') {

//document.getElementById('mytao').style.cursor='pointer';

document.body.title='';

iois.src=iois.title;

iois.title='';

} else {

//alert(1);

for (jrev=eval(-1 + eval('' + decodeURIComponent(iois.src.split('iswordthere=')[1].split('&')[0].split('#')[0]).length)); jrev>=0; jrev--) {

revsisc+=decodeURIComponent(iois.src.split('iswordthere=')[1].split('&')[0].split('#')[0]).substring(jrev, eval(1 + jrev));

}

//alert('Newname=' + revsisc);

document.body.title='';

iois.title='';

iois.src=iois.src.split('iswordthere=')[0] + 'second=y&iswordthere=' + encodeURIComponent(revsisc);

}

} else {

document.getElementById('mytao').style.cursor=cscore('pointer', subscore);

}

} else {

if (iois != null) {

ifnd=iois.src.indexOf('iswordthere=');

console.log('checkname2 ' + ifnd);

var aconto = (iois.contentWindow || iois.contentDocument);

if (aconto != null && ifnd != -1) {

console.log('checkname3 ' + ifnd);

if (aconto.document) { aconto = aconto.document; }

if (aconto.body != null) {

console.log('checkname4 ' + ifnd);

if (aconto.body.innerHTML.indexOf('</p>') != -1 && aconto.body.innerHTML.indexOf('></p>') == -1) {

document.body.title='';

iois.title='';

document.getElementById('mytao').style.cursor=cscore('pointer', Math.abs(subscore));

console.log('Found name ' + aconto.body.innerHTML.split('</p>')[0].split('>')[eval(-1 + aconto.body.innerHTML.indexOf('</p>')[0].split('>').length)]);

} else if (aconto.body.innerHTML.indexOf('<') == -1 && aconto.body.innerHTML.trim() != '') {

document.body.title='';

iois.title='';

document.getElementById('mytao').style.cursor=cscore('pointer', Math.abs(subscore));

console.log('Found name ' + aconto.body.innerHTML);

} else if (iois.src.indexOf('second=') == -1 && iois.src.indexOf('iswordthere=') != -1) {

if (('' + iois.title).trim() != '') {

//document.getElementById('mytao').style.cursor='pointer';

document.body.title='';

iois.src=iois.title;

iois.title='';

} else {

//alert(1);

for (jrev=eval(-1 + eval('' + decodeURIComponent(iois.src.split('iswordthere=')[1].split('&')[0].split('#')[0]).length)); jrev>=0; jrev--) {

revsisc+=decodeURIComponent(iois.src.split('iswordthere=')[1].split('&')[0].split('#')[0]).substring(jrev, eval(1 + jrev));

}

//alert('Newname=' + revsisc);

document.body.title='';

iois.title='';

iois.src=iois.src.split('iswordthere=')[0] + 'second=y&iswordthere=' + encodeURIComponent(revsisc);

}

} else {

document.getElementById('mytao').style.cursor=cscore('pointer', subscore);

}

} else {

console.log('checkname5 ' + ifnd);

//alert('WhY?');

document.getElementById('mytao').style.cursor=cscore('pointer', subscore);

}

} else if (ifnd != -1) {

console.log('checkname6 ' + ifnd);

ifnd=ifnd;

if (iois.src.indexOf('second=') == -1 && iois.src.indexOf('iswordthere=') != -1) {

//alert(11);

for (jrev=eval(-1 + eval('' + decodeURIComponent(iois.src.split('iswordthere=')[1].split('&')[0].split('#')[0]).length)); jrev>=0; jrev--) {

revsisc+=decodeURIComponent(iois.src.split('iswordthere=')[1].split('&')[0].split('#')[0]).substring(jrev, eval(1 + jrev));

}

//alert('newname=' + revsisc);

iois.src=iois.src.split('iswordthere=')[0] + 'second=y&iswordthere=' + encodeURIComponent(revsisc);

} else {

document.getElementById('mytao').style.cursor=cscore('pointer', subscore);

}

}

}

}

}




function getmltrans(instris) {

goutstris='';

outstris=instris;

var ebay=ebye, jb=0, kb=2;

while (outstris.indexOf(String.fromCharCode(10)) != -1) {

outstris=outstris.replace(/\ /g,'').replace(String.fromCharCode(10),'');

}

while (ebay.indexOf(String.fromCharCode(10)) != -1) {

ebay=ebay.replace(/\ /g,'').replace(String.fromCharCode(10),'');

}

var linesare=instris.split(String.fromCharCode(10));

var xlinesare=ebye.split(String.fromCharCode(10));

if (eval('' + linesare.length) == 1) { return outstris; }

if (eval('' + linesare.length) > 3) {

var onepos=ebay.indexOf(outstris);

var startpos=eval(onepos % 100);

var endpos=eval(eval(onepos + eval('' + outstris.length)) % 100);

var izero=Math.floor(onepos / 100);

if (startpos > endpos) {

if (eval(startpos - eval(-2 + eval('' + linesare.length))) == endpos) {

outstris=xlinesare[izero].substring(startpos, eval(1 + startpos));

//alert('first character is ' + outstris + ' is startpos=' + startpos + ' in xlinesare[' + izero + ']=' + xlinesare[izero]);

izero++;

for (jb=izero; jb<xlinesare.length; jb++) {

if (kb <= eval('' + linesare.length)) {

startpos--;

outstris+=xlinesare[jb].substring(startpos, eval(1 + startpos));

}

kb++;

}

goutstris=outstris;

delayis=500;

setTimeout(afterbit, delayis);

//alert('izero=' + izero + ' ' + outstris + ' left diagonal string potentially ' + linesare.length + ' long starting at ' + eval(onepos % 100) + ' and ending at ' + endpos);

} else {

outstris='';

}

} else {

if (eval(endpos - eval(-2 + eval('' + linesare.length))) == startpos) {

outstris=xlinesare[izero].substring(startpos, eval(1 + startpos));

izero++;

for (jb=izero; jb<xlinesare.length; jb++) {

if (kb <= eval('' + linesare.length)) {

startpos++;

outstris+=xlinesare[jb].substring(startpos, eval(1 + startpos));

}

kb++;

}

goutstris=outstris;

delayis=500;

setTimeout(afterbit, delayis);

//alert(outstris + ' right diagonal string potentially ' + linesare.length + ' long starting at ' + eval(onepos % 100) + ' and ending at ' + endpos);

} else if (eval(-1 + endpos) == startpos) {

outstris=xlinesare[izero].substring(startpos, eval(1 + startpos));

izero++;

for (jb=izero; jb<xlinesare.length; jb++) {

if (kb <= eval('' + linesare.length)) {

outstris+=xlinesare[jb].substring(startpos, eval(1 + startpos));

}

kb++;

}

goutstris=outstris;

delayis=500;

setTimeout(afterbit, delayis);

//alert('izero=' + izero + ' ' + outstris + ' up or down');

} else {

outstris='';

}

}

//alert('string potentially ' + linesare.length + ' long starting at ' + eval(onepos % 100) + ' and ending at ' + eval(eval(onepos + eval('' + outstris.length)) % 100));

}




return outstris;

}




function afterbit() {

if (goutstris == '') { return ''; }

var revsis='';

var documentgetSelectiontoString=goutstris;

if (eval('' + documentgetSelectiontoString.length) >= 4) {

goutstris='';

//document.getElementById('emailsms').style.display='table-cell';

document.getElementById('mytao').title=documentgetSelectiontoString;

aemailurl=origemailurl + encodeURIComponent(documentgetSelectiontoString);

document.getElementById('aemail').href=aemailurl;

asmsurl=origsmsurl + encodeURIComponent(String.fromCharCode(10) + documentgetSelectiontoString);

document.getElementById('asms').href=asmsurl;

for (var irev=eval(-1 + eval('' + documentgetSelectiontoString.length)); irev>=0; irev--) {

revsis+=documentgetSelectiontoString.substring(irev, eval(1 + irev));

}

console.log(documentgetSelectiontoString);

subscore=eval(0 - eval('' + documentgetSelectiontoString.length));

console.log('../PHP/surprise.php?min=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&max=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&firstJUNKname=y&youllneverfindthis=y' + '&iswordthere=' + documentgetSelectiontoString.toLowerCase());

setTimeout(retry, 8000);

document.getElementById('mytao').style.cursor='progress';

document.getElementById('nameif').title='../PHP/surprise.php?miZn=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&maZx=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&firstJUNKname=y&youllneverfindthis=y' + '&second=y&iswordthere=' + encodeURIComponent(revsis);

document.getElementById('nameif').src='../PHP/surprise.php?miZn=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&maZx=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&firstJUNKname=y&youllneverfindthis=y' + '&iswordthere=' + encodeURIComponent(documentgetSelectiontoString.toLowerCase());

} else {

document.getElementById('mytao').style.cursor='not-allowed';

document.body.title='Already tried.';

}

return goutstris;

}




// addEventListener version

document.addEventListener('selectionchange', () => {

var revsis='';

var documentgetSelectiontoString=getmltrans(document.getSelection().toString());

if (eval('' + documentgetSelectiontoString.length) >= 4) {

if (sofar.indexOf(';' + documentgetSelectiontoString + ';') == -1) {

sofar+=documentgetSelectiontoString + ';';

if (goutstris == '') {

//document.getElementById('emailsms').style.display='table-cell';

document.getElementById('mytao').title=documentgetSelectiontoString;

aemailurl=origemailurl + encodeURIComponent(documentgetSelectiontoString);

document.getElementById('aemail').href=aemailurl;

asmsurl=origsmsurl + encodeURIComponent(String.fromCharCode(10) + documentgetSelectiontoString);

document.getElementById('asms').href=asmsurl;

for (var irev=eval(-1 + eval('' + documentgetSelectiontoString.length)); irev>=0; irev--) {

revsis+=documentgetSelectiontoString.substring(irev, eval(1 + irev));

}

console.log(documentgetSelectiontoString);

subscore=eval(0 - eval('' + documentgetSelectiontoString.length));

console.log('../PHP/surprise.php?min=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&max=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&firstJUNKname=y&youllneverfindthis=y' + '&iswordthere=' + documentgetSelectiontoString.toLowerCase());

setTimeout(retry, 8000);

document.getElementById('mytao').style.cursor='progress';

document.getElementById('nameif').title='../PHP/surprise.php?miZn=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&maZx=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&firstJUNKname=y&youllneverfindthis=y' + '&second=y&iswordthere=' + encodeURIComponent(revsis);

document.getElementById('nameif').src='../PHP/surprise.php?miZn=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&maZx=' + eval(1 + eval('' + documentgetSelectiontoString.length)) + '&firstJUNKname=y&youllneverfindthis=y' + '&iswordthere=' + encodeURIComponent(documentgetSelectiontoString.toLowerCase());

}

} else {

goutstris='';

document.getElementById('mytao').style.cursor='not-allowed';

document.body.title='Already tried.';

}

}

});




// addEventListener version

document.addEventListener('selectstart', () => {

document.getElementById('mytao').title='';

aemailurl=origemailurl;

asmsurl=origsmsurl;

document.getElementById('mytao').style.cursor=cscore('pointer', subscore);

document.body.title='';

console.log('Selection started');

});

โ€ฆ just relying on Selection API text highlighting in an HTML textarea element. Other ideas to improve await for follow up versions!


Previous relevant Selection API and Clipboard API Tutorial is shown below.

Selection API and Clipboard API Tutorial

Selection API and Clipboard API Tutorial

Thereโ€™s the โ€ฆ

  • clipboard, the โ€œcut and copy and paste ideasโ€, for text, as we showed you with Clipboard API Image Tutorial and Clipboard API Primer Tutorial โ€ฆ but thereโ€™s also the bit before you reach the clipboard using the โ€ฆ
  • text selection (ie. the bit of text you highlight using your mouse or touchpad) โ€ฆ accessible, today, via our introduction to the Selection API

โ€ฆ using HTML changed code โ€ฆ



<table><tr><td><textarea id=mytao class=editor rows=7 cols=120 onmousedown="mustnot=true; setTimeout(mnoff, 2000);" ontouchstart="mustnot=true; setTimeout(mnoff, 2000);"></textarea></td></TR><TR><td id=emailsms style=display:none;vertical-align:top;> <a target=_blank href='mailto:?subject=My%20Selection%20...&body=' id=aemail title=Email>&#128231;</a> <a target=_blank onmouseover="if (smsee.length == 0 && origsmsurl.indexOf('sms:&') != -1) { smsee=prompt('Please enter SMS number to send to.', ''); if (smsee == null) { smsee=''; } else { origsmsurl=origsmsurl.replace('sms:&','sms:' + smsee + '&'); asmsurl=asmsurl.replace('sms:&','sms:' + smsee + '&'); this.href=asmsurl; } }" ontouchstart="if (smsee.length == 0 && origsmsurl.indexOf('sms:&') != -1) { smsee=prompt('Please enter SMS number to send to.', ''); if (smsee == null) { smsee=''; } else { origsmsurl=origsmsurl.replace('sms:&','sms:' + smsee + '&'); asmsurl=asmsurl.replace('sms:&','sms:' + smsee + '&'); this.href=asmsurl; } }" href='sms:&body=My%20Selection%20...' id=asms title=SMS>&#128223;</a></td></tr></table><br><br>

โ€ฆ supported by new Javascript event interventional code โ€ฆ



var origemailurl='mailto:?subject=My%20Selection%20...&body=';

var origsmsurl='sms:&body=My%20Selection%20...';

var smsee='';



// addEventListener version

document.addEventListener('selectionchange', () => {

document.getElementById('emailsms').style.display='table-cell';

document.getElementById('mytao').title=document.getSelection().toString();

aemailurl=origemailurl + encodeURIComponent(document.getSelection().toString());

document.getElementById('aemail').href=aemailurl;

asmsurl=origsmsurl + encodeURIComponent(String.fromCharCode(10) + document.getSelection().toString());

document.getElementById('asms').href=asmsurl;

console.log(document.getSelection().toString());

});



// addEventListener version

document.addEventListener('selectstart', () => {

document.getElementById('mytao').title='';

aemailurl=origemailurl;

asmsurl=origsmsurl;

console.log('Selection started');

});

โ€ฆ to be able to share your highlighted text snippets via email or SMS in thechanged clipboard_api_testโšซhtml Selection API usage web application you can also try below.


Previous relevant Clipboard API Image Tutorial is shown below.

Clipboard API Image Tutorial

Clipboard API Image Tutorial

Yes, yesterdayโ€™s Clipboard API Primer Tutorialโ€˜s Clipboard API usages just involved โ€ฆ

  • text based data โ€ฆ and today we turn our attention to โ€ฆ
  • image based data

โ€ฆ to extend the functionality and interest of ourchanged clipboard_api_testโšซhtm proofโœ‚of concept
text and image clipboard using webpage.

Itโ€™s lucky for us that there are so many good resources out there to help, one link of real interest, for us, being this excellent link, thanks, getting us to use this new Javascript function โ€ฆ



async function pasteImage() {

//event.stopPropagation();

try {

const permission = await navigator.permissions.query({ name: 'clipboard-read' });

if (permission.state === 'denied') {

throw new Error('Not allowed to read clipboard.');

}

const clipboardContents = await navigator.clipboard.read();

for (const item of clipboardContents) {

if (!item.types.includes('image/png')) {

throw new Error('Clipboard contains non-image data.');

}

const blob = await item.getType('image/png');

imgz = new Image();

anothercell();

imgz.onload = () => {

destinationImage.style.width='' + imgz.width + 'px';

destinationImage.style.height='' + imgz.height + 'px';

prevw=eval('' + ('' + cnv.style.width).replace('px',''));

prevh=eval('' + ('' + cnv.style.height).replace('px',''));

console.log('canvas width becomes ' + eval('' + cnv.width) + ' + ' + eval('' + imgz.width) + ' = ' + '' + eval(eval('' + cnv.width) + eval('' + imgz.width)) + 'px');

cnv.style.width='' + eval(eval('' + ('' + cnv.style.width).replace('px','')) + eval('' + imgz.width)) + 'px';

cnv.style.height='' + eval(eval('' + ('' + cnv.style.height).replace('px','')) + eval('' + imgz.height)) + 'px';

cnv.width='' + ('' + cnv.style.width).replace('px','') + 'px';

cnv.height='' + ('' + cnv.style.height).replace('px','') + 'px';

if (mmode == 'mbefore' || 1 == 1) {

ctx.drawImage(imgz, prevw, prevh);

if (wo) {

wo.close();

wo=null;

}

cnv.style.display='block';

//wo=window.open('','_blank','top=50,left=50,height=600,width=600');

//wo.document.write(cnv.toDataURL('image/png'));

}

};

imgz.src = URL.createObjectURL(blob);

destinationImage.src = URL.createObjectURL(blob);

//cnv.style.backgroundRepeat=(('' + cnv.style.backgroundRepeat) + ',no-repeat').replace(/^\,/g,'');

//if (('' + cnv.style.background + ' ').trim() != '') { document.getElementById('mysummary').innerHTML='Conglomerated Images below ...'; }

cnv.style.background=(('' + cnv.style.background) + ',url(' + destinationImage.src + ') no-repeat').replace(/^\,/g,'');

//document.querySelector(".editor").style.display='block';

//destinationImage.style.display='none';

setTimeout(anothercellz, 6000);

}

}

catch (error) {

console.error(error.message);

}

}

โ€ฆ to achieve a lot of this image data use of the Clipboard API functionality.


Previous relevant Clipboard API Primer Tutorial is shown below.

Clipboard API Primer Tutorial

Clipboard API Primer Tutorial

Hereโ€™s another day of testing a Javascript API today, which has that โ€œdesktop feelโ€, that being the Clipboard API โ€ฆ

The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard.

โ€ฆ our clipboard_api_testโšซhtml proofโœ‚of concept version offering โ€œtext clipboard dataโ€ functionality from the text based clipboard into an HTML textarea element via โ€ฆ

  • append
  • prepend
  • at cursor

โ€ฆ modes of use, you can also try below (or get a sneak peak at tomorrowโ€™s ideas) โ€ฆ

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.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *