The โone windowโ rather than (52 + 1) = 53 windows scenario set up as a possibility with yesterdayโs Just Javascript Card Order Game Mobile Tutorial had us wondering โฆ
โฆ a one window solution that saves the day for mobile and we see as a good candidate for โdefault-nessโ for non-mobile โฆ weโll let that one sink in for a day or so?!
โฆ and tomorrow is today. Weโve decided not to make the one window scenario the default for non-mobile platforms, but serve as a fallback for some of the scenarios mentioned below โฆ
- the user gets blocked from using the popup windows on their non-mobile platform web browser โฆ big possibility!
- the user clicks half way through the popup window incarnation the parent window โฆ all the child popups disappear behind โฆ annoying โฆ so โฆ
var flexible=false;
function secsu() {
var ewd;
if (secs == 0) {
if (document.URL.indexOf('onewindow=') != -1 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
flexible=false;
} else {
flexible=true;
console.log('Flexible=T');
}
setTimeout(blater, 2500);
}
if (eval('' + overallgoes) < 52) {
secs++;
} else if (document.title.indexOf('Congratulations') == -1) {
document.title+=' ... Congratulations! End of Game! Refresh webpage to try again.';
}
var decs=document.title.split('.');
if (eval('' + decs.length) >= 3) {
document.title=document.title.replace('.' + decs[2].split(' ')[0] + ' ', '.' + secs + ' ');
} else {
ps=document.title.split('/')[0].trim();
pg=document.title.split('/')[1].split(' ')[0];
if (ps.indexOf('.') == -1 || pg.indexOf('.') == -1) {
ps=eval('' + overallscore + '.' + psecs); //eval(document.title.split('/')[0].trim());
pg=eval('' + overallgoes + '.' + secs);
document.title=document.title.replace(document.title.split(' ')[0], '' + overallscore + '.' + psecs + '/' + '' + overallgoes + '.' + secs);
//console.log('document.title becomes ' + document.title);
} else {
ps=eval(ps);
pg=eval(pg);
}
}
if (flexible) {
if (document.hasFocus()) {
flexible=false;
console.log('Flexible=F');
lastzkq='';
lastzkl='';
owidth=oowidth;
oheight=ooheight;
for (var igh=0; igh<oplist.length; igh++) {
opltlistl[igh]=oopltlistl[igh];
opltlistt[igh]=oopltlistt[igh];
if (oplist[igh]) {
console.log('Flexible=F' + igh);
if (!oplist[igh].closed) {
try {
oplist[igh].close();
oplist[igh]=null;
} catch(ewd) {
}
} else {
oplist[igh]=null;
}
}
}
}
}
}
โฆ document.hasFocus() to the rescue again โฆ the multiple background images of yesterdayโs work being a default part of any incarnation, and whether the click event logic of yesterday becomes relevant depends on โฆ
- if user is a mobile platform user, always relevant
- user enters URL with argument like ?onewindow=y then is always relevant โฆ else โฆ
- a scenario as above means that from that point on, the multiple background image one window click on cards modus operandi becomes relevant
We improve the web browser conditions too, if a non-mobile user โclicks half way through the popup window incarnation the parent windowโ in that we programmatically close any open child popup windows! Phew!
Feel free to try this in thechanged cards_usefocushtml code behind the โJust Javascriptโ live
run with single window (good for mobile) or default
live run (for your platform, and if non-mobile it will try child popup windows).
Previous relevant Just Javascript Card Order Game Mobile Tutorial is shown below.
Yesterdayโs Just Javascript Card Order Game Tutorial mobile usage scenario was impractical, in that mobile platforms can not work popup windows in front of a parent window. Can we convert those non-mobile popup windows into โฆ well โฆ what exactly?
Well, in order to keep to our โJust Javascriptโ (ie. โNo Body Definitionโ) pledge with this project, we needed to simulate those popups as background image parts, in the sense that you can have multiple background images these days with your HTML. Even with html as your CSS styling selector โฆ it pans out โฆ we needed to prove that today.
Also, today, for the first time, we achieved via โฆ
- comma separated background-repeat: no-repeat; list
- comma separated background-size list (set popup width height list until last one bigger (based on screen.width screen.height) for the parent background image (no-repeat))
- comma separated background-position list (as per what window.open in non-mobile was using for left top until last oneโs 0px 0px)
- comma separated background-image list (as per what window.open in non-mobile was using for URL([imageURL]) until last oneโs linear-gradient(rgba(255,255,255,0.4),rgba(255,255,255,0.4)), url(//www.rjmprogramming.com.au/rjmquiz_plus.jpg))
โฆ as per (the previous โwindow.openโ becomes โwindowopenโ) โฆ
function windowopen(one, two, three) {
if (document.URL.indexOf('onewindow=') != -1 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
console.log('Here ' + kq);
opltlistl.push((three.split('left=')[1].split(',')[0].split(')')[0].split('.')[0] + '.' + one.split('spcp=')[1].split('&')[0]));
opltlistt.push((three.split('top=')[1].split(',')[0].split(')')[0].split('.')[0] + '.' + kq));
owidth=eval(three.split('width=')[1].split(',')[0].split(')')[0].split('.')[0]);
oheight=eval(three.split('width=')[1].split(',')[0].split(')')[0].split('.')[0]);
if (defstyle.indexOf('background: URL(') != -1) {
defstyle=defstyle.split('background: URL(')[0] + 'background-repeat:no-repeat;background-size:' + owidth + 'px ' + oheight + 'px;background-position:' + ('' + opltlistl[eval(-1 + opltlistl.length)]).split('.')[0] + 'px ' + ('' + opltlistt[eval(-1 + opltlistt.length)]).split('.')[0] + '' + 'px' + ';background-image: url(' + cards[eval('' + donelist[eval(-1 + donelist.length)])] + ') ' + (' ' + ('' + opltlistl[eval(-1 + opltlistl.length)]).split('.')[0] + 'px ' + ('' + opltlistt[eval(-1 + opltlistt.length)]).split('.')[0] + '' + 'px').substring(0,1) + '; } </style>'; // + ' ' + owidth + ' ' + oheight
} else {
defstyle=defstyle.replace(';background-image:', (',' + opltlistl[eval(-1 + opltlistl.length)]).split('.')[0] + 'px ' + ('' + opltlistt[eval(-1 + opltlistt.length)]).split('.')[0] + '' + 'px' + ';background-image:');
defstyle=defstyle.replace('no-repeat','no-repeat,no-repeat');
defstyle=defstyle.replace('background-size:' + owidth + 'px ' + oheight + 'px','background-size:' + owidth + 'px ' + oheight + 'px,' + owidth + 'px ' + oheight + 'px');
defstyle=defstyle.replace('; } </style>', ',url(' + cards[eval('' + donelist[eval(0 + ijk)])] + ') ' + (' ' + ('' + opltlistl[eval(-1 + opltlistl.length)]).split('.')[0] + 'px ' + ('' + opltlistt[eval(-1 + opltlistt.length)]).split('.')[0] + '' + 'px').substring(0,1) + '; } </style>'); // + ' ' + owidth + ' ' + oheight
}
return null;
}
return window.open(one, two, three);
}
โฆ a one window solution that saves the day for mobile and we see as a good candidate for โdefault-nessโ for non-mobile โฆ weโll let that one sink in for a day or so?!
We needed to add event logic we were not sure would work at the start of the day, and saw it working by the end, with โฆ
var iourx=-1, ioury=-1;
function blater() {
if (1 == 2 && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
window.addEventListener('touchstart', function(evt) {
evt.preventDefault();
var touches = evt.changedTouches;
//if (evt.touches) {
if (touches[0].pageX) {
iourx = touches[0].pageX;
ioury = touches[0].pageY;
} else if (touches[0].clientX) {
iourx = touches[0].clientX;
ioury = touches[0].clientY;
}
//alert('x:' + iourx);
//}
clickedmaybe();
}, false);
} else {
eles = document.querySelectorAll("*")
for (var ele of eles) {
console.log('yes well');
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
ele.addEventListener('touchstart', function(evt) {
evt.preventDefault();
var touches = evt.changedTouches;
//if (evt.touches) {
if (touches[0].pageX) {
iourx = touches[0].pageX;
ioury = touches[0].pageY;
} else if (touches[0].clientX) {
iourx = touches[0].clientX;
ioury = touches[0].clientY;
}
//alert('x:' + iourx);
//}
clickedmaybe();
}, false);
ele.addEventListener('touchmove', function(evt) {
evt.preventDefault();
var touches = evt.changedTouches;
//if (evt.touches) {
if (touches[0].pageX) {
iourx = touches[0].pageX;
ioury = touches[0].pageY;
} else if (touches[0].clientX) {
iourx = touches[0].clientX;
ioury = touches[0].clientY;
}
//alert('x:' + iourx);
//}
clickedmaybe();
}, false);
ele.addEventListener('click', function(evt) {
evt.preventDefault();
var touches = evt.changedTouches;
//if (evt.touches) {
if (touches[0].pageX) {
iourx = touches[0].pageX;
ioury = touches[0].pageY;
} else if (touches[0].clientX) {
iourx = touches[0].clientX;
ioury = touches[0].clientY;
}
//alert('x:' + iourx);
//}
clickedmaybe();
}, false);
} else {
ele.addEventListener('click', function(evt) {
if (evt.touches) {
if (evt.touches[0].pageX) {
iourx = evt.touches[0].pageX;
ioury = evt.touches[0].pageY;
} else {
iourx = evt.touches[0].clientX;
ioury = evt.touches[0].clientY;
}
//alert('' + iourx);
} else if (evt.clientX) {
iourx = evt.clientX; // - elemLeft;
ioury = evt.clientY; // - elemLeft;
} else if (!evt.touches) {
iourx = evt.pageX; // - elemLeft;
ioury = evt.pageX; // - elemLeft;
}
clickedmaybe();
//alert('here');
});
}
}
}
}
See this in thechanged cards_usefocushtml code behind the โJust Javascriptโ live
run with single window (good for mobile) or default
live run (for your platform) we, again, welcome you to try for yourself.
Previous relevant Just Javascript Card Order Game Tutorial is shown below.
Today weโve made the web application of yesterdayโs Just Javascript Quiz Drag Tutorial โdual purposeโ โฆ
- quiz โฆ as for yesterday, and before โฆ and as of today, making more use of the card organizational side to the popup windows we introduce โฆ
- card order game
This card order game asks you to force the focus of the correct popup window (to score in the Card Order Game) in the order as designated by the background image part we have added today, and supported by the following Javascript โmappingโ code โฆ
var dragorder=[], curdrag=0;
var cards=["//www.rjmprogramming.com.au/images/01s.gif?n=7",
"//www.rjmprogramming.com.au/images/02s.gif?n=16",
"//www.rjmprogramming.com.au/images/03s.gif?n=33",
"//www.rjmprogramming.com.au/images/04s.gif?n=29",
"//www.rjmprogramming.com.au/images/05s.gif?n=8",
"//www.rjmprogramming.com.au/images/06s.gif?n=35",
"//www.rjmprogramming.com.au/images/07s.gif?n=52",
"//www.rjmprogramming.com.au/images/08s.gif?n=51",
"//www.rjmprogramming.com.au/images/09s.gif?n=12",
"//www.rjmprogramming.com.au/images/10s.gif?n=30",
"//www.rjmprogramming.com.au/images/11s.gif?n=1",
"//www.rjmprogramming.com.au/images/12s.gif?n=36",
"//www.rjmprogramming.com.au/images/13s.gif?n=22",
"//www.rjmprogramming.com.au/images/01h.gif?n=32",
"//www.rjmprogramming.com.au/images/02h.gif?n=23",
"//www.rjmprogramming.com.au/images/03h.gif?n=3",
"//www.rjmprogramming.com.au/images/04h.gif?n=18",
"//www.rjmprogramming.com.au/images/05h.gif?n=28",
"//www.rjmprogramming.com.au/images/06h.gif?n=39",
"//www.rjmprogramming.com.au/images/07h.gif?n=45",
"//www.rjmprogramming.com.au/images/08h.gif?n=48",
"//www.rjmprogramming.com.au/images/09h.gif?n=50",
"//www.rjmprogramming.com.au/images/10h.gif?n=44",
"//www.rjmprogramming.com.au/images/11h.gif?n=4",
"//www.rjmprogramming.com.au/images/12h.gif?n=9",
"//www.rjmprogramming.com.au/images/13h.gif?n=5",
"//www.rjmprogramming.com.au/images/01d.gif?n=27",
"//www.rjmprogramming.com.au/images/02d.gif?n=41",
"//www.rjmprogramming.com.au/images/03d.gif?n=20",
"//www.rjmprogramming.com.au/images/04d.gif?n=11",
"//www.rjmprogramming.com.au/images/05d.gif?n=37",
"//www.rjmprogramming.com.au/images/06d.gif?n=49",
"//www.rjmprogramming.com.au/images/07d.gif?n=42",
"//www.rjmprogramming.com.au/images/08d.gif?n=6",
"//www.rjmprogramming.com.au/images/09d.gif?n=21",
"//www.rjmprogramming.com.au/images/10d.gif?n=31",
"//www.rjmprogramming.com.au/images/11d.gif?n=40",
"//www.rjmprogramming.com.au/images/12d.gif?n=43",
"//www.rjmprogramming.com.au/images/13d.gif?n=17",
"//www.rjmprogramming.com.au/images/01c.gif?n=46",
"//www.rjmprogramming.com.au/images/02c.gif?n=19",
"//www.rjmprogramming.com.au/images/03c.gif?n=47",
"//www.rjmprogramming.com.au/images/04c.gif?n=25",
"//www.rjmprogramming.com.au/images/05c.gif?n=10",
"//www.rjmprogramming.com.au/images/06c.gif?n=15",
"//www.rjmprogramming.com.au/images/07c.gif?n=13",
"//www.rjmprogramming.com.au/images/08c.gif?n=26",
"//www.rjmprogramming.com.au/images/09c.gif?n=38",
"//www.rjmprogramming.com.au/images/10c.gif?n=34",
"//www.rjmprogramming.com.au/images/11c.gif?n=2",
"//www.rjmprogramming.com.au/images/12c.gif?n=14",
"//www.rjmprogramming.com.au/images/13c.gif?n=24"];
for (var ic=1; ic<=cards.length; ic++) {
found=false;
for (var jc=1; jc<=cards.length; jc++) {
if ((cards[eval(-1 + jc)] + '~').indexOf('?n=' + ic + '~') != -1) {
dragorder.push(eval(-1 + jc));
cards[eval(-1 + jc)]=cards[eval(-1 + jc)].replace('?n=' + ic, '');
firstbit+=String.fromCodePoint(eval('' + spcps[eval(-1 + jc)].split('/')[0])) + ' ';
found=true;
}
}
}
โฆ and โmaking use ofโ this and the new codeline as popups are created โฆ oplist[eval(-1 + oplist.length)].document.name=โ + kl; we have โฆ
function ourprompt(tw, blb, bdef) {
var kijk;
if (oplist[eval('' + tw)].document.name == ('' + dragorder[eval('' + curdrag)]) && eval('' + curdrag) == eval('' + overallgoes)) {
console.log('Dragorder[' + curdrag + ']=' + dragorder[eval('' + curdrag)] + ' vs tw=' + tw + ' and overall;goes=' + overallgoes);
var decs=document.title.split('.');
curdrag++;
overallgoes++;
if (eval('' + decs.length) >= 3) {
document.title=document.title.replace('.' + decs[1] + '.', '.' + curdrag + '/' + overallgoes + '.');
}
oplist[eval('' + tw)].close();
return null;
}
// Quiz only code follows
}
โฆ code.
It must be in the correct order (and not interrupted by quiz answer completions) to score, and you are timed, so you can try improving over time, using a document.title score presentation as per โฆ
[QuizScore].[CardOrderGameScore]/[QuizAnswerAttemptCount].[SecondsElapsed] [MultiPlayerQuizScoreGoesBreakdown] is User: Score/Goes - RJM Programming - April, 2021
โฆ so that both usages for the web application can be accommodated for in thechanged cards_usefocushtml code behind the โJust Javascriptโ live
run we welcome you to try for yourself.
Previous relevant Just Javascript Quiz Drag Tutorial is shown below.
Adding to yesterdayโs Just Javascript Quiz CSS Styling Tutorial we have added some โฆ
- non-mobile platform, only โฆ
- drag and drop functionality โฆ for โฆ
- the child popup windows
โฆ achieved through the comparison of โฆ
- original [popupWindow].screenLeft and [popupWindow].screenTop โฆ initially, to โฆ
- [popupWindow].screenLeft and [popupWindow].screenTop over time
โฆ and if one popup is dragged to overlay another it is closed, or you, as the user, can just drag and drop for clarity, leaving the popup window of the next quiz question out in the open, perhaps.
In order to achieve this, and keep backward compatibility we needed to delay the quiz question prompt window via โฆ
- document.hasFocus() is true โฆ then if โฆ
- inhouse dragging checks clear it of overlaying another popup (in which case that popup is programmatically closed, allowing another popup to become the โfocus windowโ) โฆ then โฆ
- delay (by 8 seconds) the prompt window (and in that time the user can be dragging popups (but no popups were harmed in the making of this tutorial)) โฆ via โฆ
setTimeout(function() { hj=prompt(dp + window.opener.blurb(), def); if (hj == null) { hj=''; } else { hj=window.opener.assess(hj); } if (hj.replace(def,'') != '') { checka(hj); } else { setTimeout(pa,10000); } aminmiddle=false; }, 8000);
โฆ you can see in amongst thechanged cards_usefocushtml code behind the โJust Javascriptโ live
run you are welcome to try for yourself โฆ best on non-mobile.
Still โNo Body Definitionโ, โJust Javascriptโ!
Previous relevant Just Javascript Quiz CSS Styling Tutorial is shown below.
Our โJust Javascriptโ adage used throughout this blog posting thread, up until today, headed by yesterdayโs Just Javascript Quiz Content Management Tutorial needs more explanation. Really what we are trying to do might better be described as โNo Body Definitionโ (ie. no defined document.body) but have โฆ
- an HTML webpage (ie. within <html> and </html>) โฆ has โฆ
- <head> and </head> (ie. document.head) content which can be made up of (at least) title, style, script, link, meta tags
To assert โJust Javascriptโ is just to allow script content above, but what we should really say is โJust Head Contentโ but that is not nearly so marketable, is it now?!
The thing is, though, we can dynamically add title, style, link, meta tag content within the script content, and we do this more than statically define it, to feel better about our ethics saying โJust Javascriptโ.
Dynamically adding style CSS styling either โฆ
- using Javascript DOM (not available to us for document.getElementById([elementID] and nor can we use inline CSS via style=โ[CSSstyling]โ statically within HTML element code for that same reason) ideas today though โฆ remember โNo Body Definitionโ โฆ but โฆ
- we can append to <head> and </head> (for todayโs scenario) as per โฆ
document.head.innerHTML+="<style> html { background-color: yellow; font-size: 36px; background: URL('//www.rjmprogramming.com.au/rjmquiz.jpg'); background-size: cover; } </style>";
โฆ allowing (into the scope of our work CSS styling of) background (image(s)) and other background styling ideas that can get us past the anonymous feel the web application had before today. We tailored the background image above to suit our Quiz and help it be a bit more self explanatory โฆ thanks CSS styling! We add onto the child โcardโ popup windows, their own background image colour and pizazz, to cheer things up in CSSstyling enhanced cards_usefocushtml code behind the โJust Javascriptโ live
run.
You may well ask โฆ
What can we hang our hat on with CSS style selectors without a body element?
Well, we had to step out of our usual comfort zone of CSS styling thinking, and realize, even without that body element we can still use the html selector to โpoint atโ the entirety of your webpage of interest.
Previous relevant Just Javascript Quiz Content Management Tutorial is shown below.
It feels like an โonions of the 4th dimensionโ idea to allow the user to control the questions and answers behind the workings of yesterdayโs Just Javascript Quiz Multiple Users Tutorialโs web application, featuring โJust Javascriptโ.
Itโs not โJust Javascriptโ weโre keeping, itโs โJust HTMLโ client work rather than involving any serverside anything (eg.PHP) and yet this question and answer data could be quite sizeable. What can we use, given no PHP serverside, and given weโve decided not to navigate via Ajax/FormData techniques? How about โthe better than HTTP Cookiesโ twins โฆ
- sessionStorage โฆ and โฆ
- localStorage
Yep, set up a means by which these two can store and restore questions and answers entered by the user, using these storage methods above.
function reassess() {
var retv='', ewq;
var retcols=[];
var ir=0;
if (window.localStorage) {
try {
retv=('' + window.localStorage.getItem('cards_usefocus_local')).replace(/^null$/g,'');
if (retv != '') {
//alert('0:' + retv);
retcols=decodeURIComponent(retv).split('~');
sq=[];
asq=[];
for (ir=0; ir<retcols.length; ir++) {
sq.push(retcols[ir].split('?!')[0] + '?');
asq.push(retcols[ir].split('?!')[1]);
nomap=false;
given='';
}
return;
}
} catch(ewq) {
}
}
if (window.sessionStorage) {
try {
retv=('' + window.sessionStorage.getItem('cards_usefocus_session')).replace(/^null$/g,'');
if (retv != '') {
//alert('1:' + retv);
retcols=decodeURIComponent(retv).split('~');
sq=[];
asq=[];
for (ir=0; ir<retcols.length; ir++) {
sq.push(retcols[ir].split('?')[0] + '?');
asq.push(retcols[ir].split('?')[1]);
nomap=false;
given='';
}
return;
}
} catch(ewq) {
}
}
}
function assess(what) {
var ewq, retv='';
if (what.toLowerCase() == '?x') {
sslistq=[];
sslista=[];
if (window.sessionStorage) {
try {
window.sessionStorage.removeItem('cards_usefocus_session');
} catch(ewq) {
}
location.href=document.URL.split('#')[0].split('?')[0] + '?rand=' + Math.floor(Math.random() * 198765897);
return '';
}
return '';
} else if (what.toLowerCase() == '?!x') {
lslistq=[];
lslista=[];
if (window.localStorage) {
try {
window.localStorage.removeItem('cards_usefocus_local');
} catch(ewq) {
}
location.href=document.URL.split('#')[0].split('?')[0] + '?rand=' + Math.floor(Math.random() * 198765897);
return '';
}
return '';
} else if (what.toLowerCase().indexOf('?!') != -1) {
if (what.toLowerCase() == '?!') {
location.href=document.URL.split('#')[0].split('?')[0] + '?rand=' + Math.floor(Math.random() * 198765897);
return '';
}
if (window.localStorage) {
if (lslistq.length == 0) {
lslistq.push(what.split('?!')[0]);
lslista.push(what.split('?!')[1]);
window.localStorage.setItem('cards_usefocus_local', encodeURIComponent(what));
} else {
lslistq.push(what.split('?!')[0]);
lslista.push(what.split('?!')[1]);
window.localStorage.setItem('cards_usefocus_local', window.localStorage.getItem('cards_usefocus_local') + encodeURIComponent('~' + what));
}
}
return '';
} else if (what.toLowerCase().indexOf('?') != -1) {
if (what.toLowerCase() == '?') {
location.href=document.URL.split('#')[0].split('?')[0] + '?rand=' + Math.floor(Math.random() * 198765897);
return '';
}
if (window.sessionStorage) {
if (sslistq.length == 0) {
sslistq.push(what.split('?')[0]);
sslista.push(what.split('?')[1]);
window.sessionStorage.setItem('cards_usefocus_session', encodeURIComponent(what));
} else {
sslistq.push(what.split('?')[0]);
sslista.push(what.split('?')[1]);
window.sessionStorage.setItem('cards_usefocus_session', window.sessionStorage.getItem('cards_usefocus_session') + encodeURIComponent('~' + what));
}
}
return '';
} else {
firstbit='';
if (window.localStorage) {
try {
retv=('' + window.localStorage.getItem('cards_usefocus_local')).replace(/^null$/g,'');
if (retv != '' && nomap) { location.href=document.URL.split('#')[0].split('?')[0] + '?rand=' + Math.floor(Math.random() * 198765897); }
} catch(ewq) {
}
}
if (window.sessionStorage) {
try {
retv=('' + window.sessionStorage.getItem('cards_usefocus_session')).replace(/^null$/g,'');
if (retv != '' && nomap) { location.href=document.URL.split('#')[0].split('?')[0] + '?rand=' + Math.floor(Math.random() * 198765897); }
} catch(ewq) {
}
}
}
return what;
}
Thefairly significantly changed cards_usefocushtml code behind the โJust Javascriptโ live
run is worth a look, we figure, for up to 52 players who play in turn.
Previous relevant Just Javascript Quiz Multiple Users Tutorial is shown below.
Adding to yesterdayโs Just Javascript Quiz via Cards Tutorial we were surprised how difficult it was to stay with โJust Javascriptโ and allow for multiple player play.
We didnโt opt for the parent to ask about the number of players, curiously, but on the second quiz answer and on, offered any non first player the chance to identify themselves as a new player into the game by appending their answer with a space character.
The implication of that is that weโll want to run Javascript functions of the parent from the children as per โฆ
oplist[eval(-1 + oplist.length)].document.write("<link rel=icon href=" + cards[kl] + "><scr" + "ipt type='text/javascript'> var da='" + eval(0 + kq) + "'; var dp='Given answer is integer from 0 to 25 ... " + sq[kq] + "'; var def=String.fromCodePoint(" + spcps[eval('' + kl)].split('/')[0] + "); function checka(tpa) { var os=''; var ps=eval(window.opener.document.title.split('/')[0].trim()); var pg=eval(window.opener.document.title.split('/')[1].split(' ')[0]); if (tpa.trim() == da) { ps++; os=tpa.split(da)[1]; } else { pg++; os=tpa.split(tpa.trim())[1]; } window.opener.document.title=ps + os + '/' + pg + ' is User Score/Goes'; window.close(); } function pa() { if (document.hasFocus()) { var hj=prompt(dp + window.opener.blurb(), def); if (hj == null) { hj=''; } if (hj.replace(def,'') == '') { setTimeout(pa,1000); } else { checka(hj); } } else { setTimeout(pa,1000); } } pa(); </scr" + "ipt>");
โฆ accessing โฆ
function blurb() { // theblurb and wblurb are global variables changed elsewhere
if (wblurb == ' Hello Player 1' && theblurb == ' If you are player 2 rather than player 1 append space to your answer.') {
theblurb='';
wblurb='';
}
return theblurb + wblurb;
}
โฆ giving the rather curious behaviour whereby a Javascript prompt window can be dynamically different from one document.hasFocus() incarnation (ie. the user might go away and answer another โcardโ Number Quiz question) to another (even not attending to answering the Javascript prompt window) โฆ huh?!
Thesignificantly changed cards_usefocushtml code behind the โJust Javascriptโ live
run is worth a look, we figure, for up to 52 players who play in turn.
Previous relevant Just Javascript Quiz via Cards Tutorial is shown below.
Yesterdayโs Just Javascript Navigation Tutorial continues our interest in โJust Javascriptโ (or โNo Bodyโ) web applications.
We think todayโs โNumbers Quizโ via a โCard Deckโ organizational design ups the ante on all this. We realize now what we have been missing not having involved document.hasFocus() in any of our popup window scenarios. Today, at least on non-mobile, we involve 52 such popup windows each containing a โNumber Quizโ question presented as a Javascript prompt (sub-)window. This would not be feasible without document.hasFocus() as you can tell if you examine the cards_usefocushtml code behind the โJust Javascriptโ live
run best used on your non-mobile platforms where popup windows can sit in front of parent (and beside sibling) windows, whereas mobile platforms open new web browser tabs for all the 52 windows of (a card deck) design.
Look out, too, in the code above, for use of window.opener back reference from a popup window back to the parent window where the scoring data is held, and updated by each popup window because of that window.opener avaalability.
Previous relevant Just Javascript Navigation Tutorial is shown below.
The recent use we made of โฆ
document.createElement/click()
โฆ got us thinking of the โJust Javascriptโ (or No Body) blog posting thread headed by Just Javascript Webmail No Body Attachment Tutorial.
As such, today we present the very simple (but first time use of the interesting hasFocus) โproof of conceptโ โฆ
<html>
<head>
<script type='text/javascript'>
function dothis() {
var ais=null;
var urlis=' ';
while (urlis != '') {
if (document.hasFocus()) {
urlis=prompt('Enter URL that we will send you to (exit to stop)', '');
} else {
setTimeout(dothis, 2000); // urlis=' ';
return;
}
if (urlis == null) { urlis=''; }
if (urlis.toLowerCase() == 'exit') { return; }
if (urlis.trim() != '') {
if (urlis.substring(0,1) == '.') { // relative URL
urlis=document.URL.split('nobody.htm')[0] + urlis;
} else if (urlis.substring(0,1) == '/' && urlis.indexOf('//') == -1) { // relative URL
urlis=document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + '/' + urlis;
} else if (urlis.split('/')[0].indexOf('.') != -1) { // absolute URL
if (urlis.toLowerCase().indexOf('http') != 0) {
if (urlis.indexOf('//') == 0) {
urlis=document.URL.split('//')[0] + urlis;
} else {
urlis=document.URL.split('//')[0] + '//' + urlis;
}
}
} else { // relative URL
urlis=document.URL.split('nobody.htm')[0] + urlis;
}
ais=document.createElement('a');
ais.onclick=function() { window.open(urlis, '_blank', 'top=100,left=100,width=600,height=600'); };
if (1 == 2) { ais.href=urlis; }
ais.target='_blank';
ais.click();
}
}
setTimeout(dothis, 2000); // urlis=' ';
}
dothis();
</script>
</head>
</html>
โฆ nobodyhtmlโs live
run link for you to use a Javascript prompt popup windowโs user interaction results to navigate to a new webpage, as applicable. Bookmarklets may be scarce on the ground, but these โJust Javascriptโ ideas continue the Bookmarklet Spirit of the past!
Previous relevant Just Javascript Webmail No Body Attachment Tutorial is shown below.
A โhard linerโ for the proper use of โbusiness emailsโ could argue that an email without an attachment is not productive. Couldnโt you just have a face to face meeting instead, if there is just wording in the email (as we somewhat concur with, as an argument)? So yesterdayโs Just Javascript Webmail No Body Tutorial had that limitation of no email attachment logic, which we remedy today.
And this is where PHPโs wonderful file_get_contents (function) means by which we garner (URL) content โฆ
- definitely works with โrelative URLsโ relative to HTTP://www.rjmprogramming.com.au/HTMLCSS/ where todayโs unchanged webmail_nobody
html resides โฆ in โparsing parlanceโ โฆ
"relative (URL)" to the left of any # or ? of what lies to the left of the most right hand "/" (of what the address bar URL is of the webpage you are on)
โฆ so that โฆ- โrelative URLsโ starting with โ./โ (followed by the filename, or just the filename (as you can see us using in todayโs tutorial picture)) refer to the web server directory corresponding to โHTTP://www.rjmprogramming.com.au/HTMLCSS/โ โฆ whereas, for example โฆ
- โrelative URLsโ starting with โ../โ (followed by the filename) refer to the web server directory corresponding to โHTTP://www.rjmprogramming.com.au/โ โฆ for example
โฆ and โฆ
- might work for โabsolute URLsโ (those that start with https: or HTTP: or even // (that we beg you not to confuse with Windows UNC pathnames) that infer a transport protocol of the transport protocol (out of https: or HTTP: or even file:) that got you to the webpage you are currently on), the โmightโ being far more likely on โabsolute URLsโ pointing to the same domain as indicated on the URL of the address bar of the webpage you are currently on
Upshot is, the user in their email Body section definitions (still no HTML body though!), can throw into any word they use, an โabsolute URLโ of interest, or a โrelative URLโ of interest, of files they want to attach (as attachments, doh!) in their email.
Depending on the email rules though, there are limits as to the amount of attachment data allowed. Weโll leave that to you intrepid โexplorers of the Netโ to discover for yourselves. On this subject though, have you noticed that with the Photos (or Gallery) app Share options, the Email option drops off when you have highlighted a large number of photos or videos or audios to share? Thatโs that email limit coming into play.
So feel free to try this HTML-body-less web application liverun to see what we mean here. Though the parent HTML is unchanged today, the new (email) attachment functionality needed achanged PHP emailhtml
php to make this happen.
Did you know?
This (relative URL) โ../โ navigation backwards up the hierarchy of the web server directories will, if repeated (ie. nested to โ../../โ etcetera) too many times, get you into uncharted unnavigable (web server directory) places relative to that web server web siteโs Document Root (below which you can not access in public webpages, normally). But when you perform similar thinking with โabsolute URLsโ and go โHTTP://www.rjmprogramming.com.au/HTMLCSS/../../../blahdeblah.jpgโ (in a web browser address bar) for instance, you cannot get into trouble, as you just donโt get beyond this sending you to (attempt the reference to) โHTTP://www.rjmprogramming.com.au/blahdeblah.jpgโ because on this rjmprogramming.com.au Apache domain the correspondence of the Document Root (web server directory) is to โHTTP://www.rjmprogramming.com.au/โ as the place you are not allowed (and cannot) go below in the hierarchy tree.
Previous relevant Just Javascript Webmail No Body Tutorial is shown below.
Were you around and interested in our series of about three blog postings in the series on the theme of creating webpage functionality of some interest, involving no Javascript, when we presented Missing Javascript Audio on Unmute Tutorial? Well, today, itโs the turn of โjust Javascriptโ, which is sort of like what Bookmarklets were about.
With todayโs โjust Javascriptโ we have to qualify that a little for our webmail emailing sender application with the architecture โฆ
- parent webpage with only document.head and apart from a document.title just a script Javascript tag of content (using Javascript prompt windows to ask for user information) โฆ
- sending (POSTing) data via โฆ
- Ajax XMLHttpRequest object โฆ as the conduit for โฆ
- FormData object
โฆ to ourchanged โฆ
- PHP communication emailing tool emailhtml
php โฆ and out to โฆ
- the emailee (out there in the big wide woooorrrrrllllldddd)
Guess we find it interesting that you can do all this (sending of email to emailee recipients) with no document.body in sight.
So take a look at that parent webmail_nobodyhtmlโs live
run link to see what we mean here, and/or watch the video below โฆ
Previous relevant Missing Javascript Audio on Unmute Tutorial is shown below.
Our โthird cab off the rankโ following on from yesterdayโs Missing Javascript Stop Watch Tutorial โmissing Javascriptโ ideas is an HTML div nesting scenario using just โฆ
- HTML
- CSS
โฆ again, with some or all of the โusualsโ below โฆ
- calc method to assist with defining width and height and size dimensions along with operator โ+โ and/or โ-โ offset calculation opportunities, and which weโd have used the Javascript window.getComputedStyle and/or [element].getBoundingClientRect methods to cover this (in a much more unwieldy way, as you would probably surmise)
- CSS variables we started talking about here at CSS Variables Primer Tutorial
- CSS3 @keyframes rules we first talked about at CSS3 @keyframes Rule Primer Tutorial that assist with animations that we can make work via โฆ
- CSS3 transitions for scheduled functionality (weโd have used Javascript setTimeout (and setInterval) methods to cover the same โterritoryโ) we first talked about at CSS3 Transition Primer Tutorial โฆ specified with CSS Criteria involving โฆ
- CSS Selectors :after and :before (and often, as for todayโs work, with the content: CSS property) first talked about here with WordPress Bullet Point CSS Styling Primer Tutorial โฆ and, today โฆ
- CSS3 transform propertyโs rotate (and translate and scale) settings (for the puppy dog body movements) โฆ as well as the idea that โฆ
- On non mobile platforms you can set up the playing of โaudioโ data via the use of an HTML audio tag with the properties โฆ
- controls
- autostart
- loop
- muted
Stop Press
Above is all fine and good for non-mobile but not so good for mobile, so to keep all happy with the one click, still, is to transfer HTML coding from โฆ
<audio id='myaudio' title='Got a sock in my mouth, so you might want to unmute me!' type='audio/mp3' style="display:none;margin-left:-350px;opacity:0.1;" autostart muted loop controls src="Puppy-sounds.mp3" />โฆ to โฆ
<!--audio id='myaudio' title='Got a sock in my mouth, so you might want to unmute me!' type='audio/mp3' style="display:none;margin-left:-350px;opacity:0.1;" autostart muted loop controls src="Puppy-sounds.mp3" /-->
<audio id='myaudiotwo' title='Got a sock in my mouth, so you might want to unmute me!' type='audio/mp3' style="margin-left:-350px;opacity:0.1;" autostart="0" loop controls src="Puppy-sounds.mp3" />โฆ and a src= URL data source (as we thank this link for today), or data URI if preferred (which we do for todayโs image data from this link, thanks (when we were researching animated GIF data URIs (which we may return to at a later date))
โฆ that sets up the scenario that all the user has to do to hear the audio is to click the โmutedโ control button, without needing the usual Javascript play() methods โฆ but not on mobile!
Feel free to let the puppyplay, that uses the HTML and CSS (but no Javascript) of the_nested
html and based largely on the previous HTML Nested Centering via Multiple Select Tutorial so that thesechanges reflect how we got to the first draft of todayโs work. Maybe some of the ideas are of interest. We hope so!
Previous relevant Missing Javascript Stop Watch Tutorial is shown below.
Following on from yesterdayโs Missing Javascript Primer Tutorial our second โcab off the rankโ for โmissing Javascriptโ ideas is a stop watch featuring just โฆ
- HTML
- CSS
โฆ again, setting up document.body load instigated โฆ
- calc method to assist with defining width and height and size dimensions along with operator โ+โ and/or โ-โ offset calculation opportunities, and which weโd have used the Javascript window.getComputedStyle and/or [element].getBoundingClientRect methods to cover this (in a much more unwieldy way, as you would probably surmise)
- CSS variables we started talking about here at CSS Variables Primer Tutorial
- CSS3 @keyframes rules we first talked about at CSS3 @keyframes Rule Primer Tutorial that assist with animations that we can make work via โฆ
- CSS3 transitions for scheduled functionality (weโd have used Javascript setTimeout (and setInterval) methods to cover the same โterritoryโ) we first talked about at CSS3 Transition Primer Tutorial โฆ specified with CSS Criteria involving โฆ
- CSS Selectors :after and :before (and often, as for todayโs work, with the content: CSS property) first talked about here with WordPress Bullet Point CSS Styling Primer Tutorial โฆ and, today โฆ
- CSS3 transform propertyโs rotate setting (for the stop watch hand movements)
โฆ which we needed to do to make multiple animations happen, but we used animation-delay:5s; to delay its start. The hands (second and minute, hence the two animations) are โoverlayโ โฆ
- position:absolute property
- z-index
โฆ feeling HTML horizontal rule elements that also feature linear gradients, to emphasise (in red) the โpointy endโ of the โhand conversationโ (good on walls with shadows โฆ but we digress).
Feel free to let loose the stopwatch that uses the HTML and CSS (but no Javascript) of stop_watch
html for todayโs instructional information. Thanks to Clipart โ stop watch for the great clip art used.
Previous relevant Missing Javascript Primer Tutorial is shown below.
If you were to ask me which programming component is most vital to web application development, Iโd not be Robinson Crusoe in saying โฆ
Without a doubt, Javascript
โฆ and with that thought in mind we have a two pronged motive to see how far we go developing some web applications that โdonโt use Javascriptโ, calling into play the โฆ
- meaning of โmissingโ, as in, our code is โmissingโ Javascript โฆ as well as how I feel with the masochism of the exercise, calling into play the โฆ
- meaning of โmissingโ, as in, itโs hard work writing meaningful web applications without Javascript โฆ but I guess weโll learn a bit from the exercise of โsee where we goโ, allowing for the fact, not today, but down the track, that we will allow the use of server-side languages such as PHP
Okay, so, given that restriction, letโs see todayโs challenge, to just use, in a web application โฆ
- HTML
- CSS
โฆ and here is where we have to point out that CSS3 introduced to us some functionality that improves the prospects for web application design โinterestโ without using Javascript (though it is hard to convince me even so, that I am not โmissingโ Javascript) here. CSS3 introduced to us โฆ
- calc method to assist with defining width and height and size dimensions along with operator โ+โ and/or โ-โ offset calculation opportunities, and which weโd have used the Javascript window.getComputedStyle and/or [element].getBoundingClientRect methods to cover this (in a much more unwieldy way, as you would probably surmise)
- CSS variables we started talking about here at CSS Variables Primer Tutorial
- CSS3 @keyframes rules we first talked about at CSS3 @keyframes Rule Primer Tutorial that assist with animations that we can make work via โฆ
- CSS3 transitions for scheduled functionality (weโd have used Javascript setTimeout (and setInterval) methods to cover the same โterritoryโ) we first talked about at CSS3 Transition Primer Tutorial โฆ specified with CSS Criteria involving โฆ
- CSS Selectors :after and :before (and often, as for todayโs work, with the content: CSS property) first talked about here with WordPress Bullet Point CSS Styling Primer Tutorial
โฆ and we use all of these in our Festive Season themed web application today, you can try at this liverunโs calc_use
html (free of any Javascript (but โwhyโ springs to mind โฆ because it is NOT there, perhaps?)).
Hereโs the other thing about today. Our long sought after โjust make the body background be semi-transparentโ but not its foreground parts, was solved, for us via the great advice of โฆ
- https://stackoverflow.com/questions/35669563/changing-the-opacity-of-background-image-in-css was a great link regarding semi-transparent background via CSS like โฆ
body {
background: URL(https://www.woodwardenglish.com/wp-content/uploads/2013/12/12-days-of-christmas.jpg) no-repeat center center fixed;
background-size: contain;
}
.banner {
background: rgba(220,220,255,0.8);
} - https://developer.mozilla.org/en-US/docs/Web/CSS/:root taught me how the :root { } CSS descriptor was a good place to define CSS (global) variables, thanks
- https://developer.mozilla.org/en-US/docs/Web/CSS/calc taught me lots regarding how to use CSS calc method, thanks
- https://codepen.io/robinrendle/embed/MaVPbo?height=300&theme-id=1&embed-version=2&slug-hash=MaVPbo&default-tab=result&user=robinrendle taught me lots of setting up the animation and transitioning in CSS, thanks
- https://www.google.com.au/search?q=lyrics+to+twelve+days+of+christmas&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&dcr=0&ei=Z0U8WpLKEobp8wfejKjQDg is a great link to some lyrics, thanks
- https://www.woodwardenglish.com/wp-content/uploads/2013/12/12-days-of-christmas.jpg was link to very useful background image, thanks
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.