Australian Geographical Quiz Context Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Australian Geographical Quiz Context Tutorial

Australian Geographical Quiz Context Tutorial

We are continuing on with our Australian Geographic quiz today, building on our Australian Geographical Quiz Primer Tutorial start yesterday, with some added functionality to assist with โ€œfinding out moreโ€. Which is natural for us when we come upon information we have never heard of before. What the โ€œnetโ€ has most helped us out with in this respect is its potential as a reference source with โ€ฆ

  • Search Engine websites
  • Encyclopaedic websites such as Wikipedia
  • Research websites
  • Education websites
  • Video repositories

โ€ฆ and today we are going to (allow an) interface to the search functionality of the Australian Geographic website, in addition to the biggest online Video repository, YouTube, and use their great API to embed YouTube videos within HTML iframe elements on your webpage. Perusing YouTube you may have noticed that for many years now at YouTube Share button options, there have been ways to have YouTube help you to โ€œcutโ€ the video embedding HTML code necessary to display a video. That is the basis behind the API, but the API also facilitates โ€ฆ

  • Sequencing videos
  • Stop and start and pause
  • Durations
  • Titles
  • Volume
  • Resizing

โ€ฆ and weโ€™d like to direct you to YouTube API Iframe Synchronicity Resizing Tutorial for further reading here.

Now, as far as โ€œcontextโ€ goes, coming back to our blog posting title today, sometimes a map can be a bit of an overwhelmingly big thing to take in as the one data source, so weโ€™ve also added as an โ€œinterfacingโ€ additional functionality option, the chance for the user to latch onto the work we did with map legends and talked about at Legend for and from HTML Map Element Web Server Tutorial and other related blog postings. Legends turn the map โ€œbigโ€ picture into a whole lot of place specific small pictures, with the advantage today, at least with the โ€œDifficultโ€ mode of play, the Australian states are colour coded, so in the legend you can display it will โ€œlobโ€ you onto your specific place of interest, and the background colouring will give you some hints as to where this is in the context of the โ€œbigger pictureโ€ map also displayed for you to the left of the map legend.

To understand this more in โ€œcontextโ€ โ€ฆ chortle, chortle โ€ฆ why not try the Australian Geography quiz yourself at this liveโœ‚run link? Or perhaps peruse the HTML and Javascript code you could call agmapโšซhtm changed in thisway for todayโ€™s added functionalities? Also changing that little bit for the concept of processing incoming document.URL URLs containing a specially constructed โ€œAustralian Geography Quizโ€ โ€œbrandedโ€ hashtag (#) appendage as the means to highlight a โ€œlobbed toโ€ legend placename was the HTML code you could call legend_via_mapโšซhtm changing in thisway to achieve that interfacing logic.



Previous relevant Australian Geographical Quiz Primer Tutorial is shown below.

Australian Geographical Quiz Primer Tutorial

Australian Geographical Quiz Primer Tutorial

We have some similar ideas going on today, with our new web application quiz/game, to those of ESL Vocabulary Getting Warmer Image Tutorial as shown below, as can be summarised by โ€ฆ

  • use of the one underlying background image โ€ฆ coupled with โ€ฆ
  • use of HTML map element on top of that โ€ฆ created via โ€ฆ
  • the brilliant, the stupendous Mobilefish website helper โ€ฆ thanks โ€ฆ to arrive at a โ€ฆ
  • โ€œgetting warmerโ€ type of quiz related, today, to Australian Geography

โ€ฆ the underlying map image for which weโ€™ve based on one from the stupendous, the brilliant Australian Geographic magazine and website, so thanks.

A thing different in todayโ€™s work, apart from the inherent different look and array manipulations you look and act differently with, over time, with the code, is that we have two images โ€ฆ

  1. original image photographed with an iPad โ€ฆ for an โ€œEasierโ€ gameplay level of difficulty โ€ฆ as well as a โ€ฆ
  2. โ€œconfused upโ€/โ€messed upโ€ โ€ฆ call it what you will โ€ฆ image version put through a session on Gimp to โ€ฆ
    • Free Select Cut โ€ฆ and โ€ฆ
    • Free Select Gaussian Blur

    โ€ฆ in order to arrive at an image for a โ€œDifficultโ€ gameplay level of difficulty (where there is less on the map image to help the user

โ€ฆ presented to the player of the web application โ€œAustralian Geographyโ€ game in an HTML select โ€œdropdownโ€ choice.

The other bit extra weโ€™ve done today, because the HTML map element has not been designed to cover the whole rectangle of the image, is to harness the document.body onclick event (fired off via the HTML <body onload=โ€™atstart();โ€™ ontouchstart=โ€™icheck(event);โ€™ onclick=โ€™icheck(event);โ€™>) to check for (web application game) clicks (or touches) that are not โ€ฆ

  • HTML select element based clicks โ€ฆ nor โ€ฆ
  • other HTML map element HTML area element clicks

โ€ฆ and if so, record that click eventโ€™s mouse (x,y) co-ordinates and report on this in a similar way to the โ€œHTML map element HTML area element clicksโ€, except that we have no link to a name for their click (whereas we can glean a name off the HTML area element alt property for those HTML map element HTML area element clicks), and so we inform the user of the โ€œnearestโ€ place they clicked (or touched) near โ€ฆ as per (Javascript DOM code) โ€ฆ



function icheck(evt) {

if (realclick) {

var x,y;

if (evt.clientX || evt.clientY) {

x = evt.clientX;

y = evt.clientY;

} else {

x = evt.pageX;

y = evt.pageY;

}

var distco=((x - midcoords[placepick][0]) * (x - midcoords[placepick][0])) + ((y - midcoords[placepick][1]) * (y - midcoords[placepick][1]));

var halfpoint='';



var davw=' ... you are very cold ';

if (distco <= verywarm) {

halfpoint='0.5';

davw=' ... you are very warm (and its possible there is an overlap, so you score the 0.5 choosing this with OK button) ';

} else if (distco <= warm) {

davw=' ... you are warm ';

} else if (distco <= cool) {

davw=' ... you are cool ';

} else if (distco <= cold) {

davw=' ... you are cold ';

}



var nearestplace='';

var nearestdistco=-1;

for (var jwhich=0; jwhich<midcoords.length; jwhich++) {

distco=((midcoords[jwhich][0] - x) * (midcoords[jwhich][0] - x)) + ((midcoords[jwhich][1] - y) * (midcoords[jwhich][1] - y));

if (jwhich == 0) {

nearestplace=places[jwhich].replace(/_/g,' ');

nearestdistco=distco;

} else if (distco < nearestdistco) {

nearestplace=places[jwhich].replace(/_/g,' ');

nearestdistco=distco;

}

}

goes++;

var ans=prompt('You clicked nearest to ' + nearestplace + ' but we wanted you to identify ' + placechosen.replace(/_/g,' ') + davw + ' ... try again ... or ... Choose to Cancel', halfpoint);

if (ans == null) {

//alert(92);

setTimeout(pickone,2000);

} else if (ans == '0.5') {

score+=0.5;

setTimeout(pickone,2000);

}

setTimeout(resetit, 200);

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

}

return '';

}

The Javascript realclick global variable above is set to false by those other HTML select element and/or HTML map element area element click (or touch) events, and then a โ€œsetTimeout(resetit,1000);โ€ (for example) would put realclick global variable back to its usual true value.

Why not try the Australian Geography quiz yourself at this liveโœ‚run link? Or peruse the HTML and Javascript code you could call agmapโšซhtml perhaps? By the way, this quiz is designed not to ask about the more populous regions or places of Australia, but more your outback or national park or adventure thought places.


Previous relevant ESL Vocabulary Getting Warmer Image Tutorial is shown below.

ESL Vocabulary Getting Warmer Image Tutorial

ESL Vocabulary Getting Warmer Image Tutorial

Our last visit to our series of HTML map element tutorials, today, building on yesterdayโ€™s ESL Vocabulary Getting Warmer Game Tutorial as shown below, concentrates back on the HTML img element that the HTML map element relies on.

The reason for this, is that, today, we allow for the โ€œsceneโ€ of the ESL Vocabulary lesson to change, and we need to resize things, but not to do with any HTML map element dimensions, but rather the underlying HTML img elementโ€™s Javascript DOM โ€ฆ

  • document.getElementById([imgId]).width
  • document.getElementById([imgId]).height

โ€ฆ at which point you might be saying โ€ฆ doh! โ€ฆ and you might be right โ€œdohโ€ing in such a Willy Nilly way โ€ฆ but in lots of other applications it is document.getElementById([imgId]).style.width and document.getElementById([imgId]).style.height you deal with. All this begs the question: โ€œHow did you create the HTML map elements in the first place?โ€ โ€ฆ especially as the โ€œfirst placeโ€ was โ€œUnder the Stairsโ€ โ€ฆ and thereโ€™s not much room there? โ€ฆ very minor and lame chortle, chortle.

Well, this tutorial wants to introduce (or reintroduce) you to a wonderful service run by mobilefish to help you out โ€ฆ all together now โ€ฆ thanks MOBILEFISH โ€ฆ take a look here โ€ฆ can you see the possibilities?!

We, personally, revisited the wonderful Mobilefish website, to create a Whereโ€™s Wally โ€œsceneโ€ (thanks to the Telegraph UKโ€™s โ€œWhereโ€™s Wally? celebrates 25th birthdayโ€ articleโ€™s image of this webpage) for you to try the second of the HTML map modes of use we have been raving about lately as per โ€ฆ

  1. a jigsaw โ€œoverlayโ€ to the underlying image (in that we try to cover the whole area of the image with clickable HTML area โ€œpolygonโ€ segments (the so called โ€œClick and be Promptedโ€ mode of use)) โ€ฆ but if the user selects a โ€œFind Prompted Objectโ€ mode of use that same HTML map element is reworked to become like โ€ฆ
  2. a โ€œWhereโ€™s Wallyโ€ scenario where the computer prompts the user for what they should click on, where the HTML map element has one defined HTML area tag plus one other default โ€œnonhrefโ€ HTML area tag

โ€ฆ and there โ€ฆ we hope you see how the โ€œGetting Warmerโ€ is very applicable as an idea. By the way, you will see out there in Open Source land places where you can get great Javascript libraries whose code would cover what you need here too.

So think โ€œoverlayโ€, the HTML map tag being a well established overlay method linking image data with co-ordinate intelligence.

HTML and Javascript codewise the original under_the_stairsโšซhtml is unchanged from the way it was way way below, and today it is joined by others of its ilk in different scenes (all unchanged), but today, with our changing ESL Vocabulary scenarios, it is used within an HTML iframe element using our Client Pre-emptive Iframe techniques to glean HTML map information, and then reworked as necessary directly into that iframe, and the HTML and Javascript for this is pre_under_the_stairsโšซhtml changed from yesterday as per thislink.

This could all become very much clearer when you try a liveโœ‚run and we hope it leaves you with some more ideas to try out yourself in a project you are working on.


Previous relevant ESL Vocabulary Getting Warmer Game Tutorial is shown below.

ESL Vocabulary Getting Warmer Game Tutorial

As we saw yesterday, the HTML map element can be used in a variety of ways, two of which we hone in on with todayโ€™s ESL Vocabulary Getting Warmer Game Tutorial, a variation on yesterdayโ€™s ESL Under The Stairs Game Overlay Primer Tutorial as shown below, where we add Javascript functionality to effectively find the shortest distance of a point to a polygon co-ordinate โ€œsetโ€, and a revisit of our previous English Learning โ€“ Vocabulary โ€“ Under The Stairs as shown way below. The HTML map element can be โ€ฆ

  1. a jigsaw โ€œoverlayโ€ to the underlying image (in that we try to cover the whole area of the image with clickable HTML area โ€œpolygonโ€ segments (the so called โ€œClick and be Promptedโ€ mode of use)) โ€ฆ but if the user selects a โ€œFind Prompted Objectโ€ mode of use that same HTML map element is reworked to become like โ€ฆ
  2. a โ€œWhereโ€™s Wallyโ€ scenario where the computer prompts the user for what they should click on, where the HTML map element has one defined HTML area tag plus one other default โ€œnonhrefโ€ HTML area tag

In that second mode of use today, we add a bit of fun by adding that โ€œgetting warmerโ€ type of โ€œbizzoโ€ (sorry to get technical) to our game.

To do this, as weโ€™ve mentioned, we find the shortest distance of a point to a polygon co-ordinate โ€œsetโ€ by โ€ฆ

  1. leave the HTML map to determine when a point is inside its first โ€œpolygonโ€ section, and for all the rest, via that other โ€œnohrefโ€ HTML area elementโ€™s onclick event, we arrange some Javascript that โ€ฆ
  2. breaks the problem into sets of 3 co-ordinate (x,y) arrangements for each polygon line segment (brought up to 3 by the point chosen by the user) โ€ฆ
  3. for each of these consider the three points as a triangle and use Heronโ€™s Formula to calculate the triangle area


    function herons_formula_triangle_area(x1, y1, x2, y2, x3, y3) {

    var a=Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

    var b=Math.sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));

    var c=Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));

    var s=eval((a + b + c) / 2.0);

    return Math.sqrt(s * (s - a) * (s - b) * (s - c));

    }

    โ€ฆ
  4. the base value in โ€œarea=base x height / 2โ€ (area of a triangle) can be calculated as the line segment length (square root of the x co-ordinate difference squared plus the y co-ordinate difference squared)


    function find_dist(x1, y1, x2, y2) {

    return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

    }

    โ€ฆ
  5. so height=area x 2 / base โ€ฆ


    function calcdist() {

    var theseobjs, area=0.0, base=0.0, height=0.0, smallestijh=-1;

    var thesexy;

    eval("aconto.getElementById('" + midis + "').title='other';");

    smallesth=-1.0;

    theseobjs=objects[snum].split(';');

    thesexy=theseobjs[1].split(',');

    for (var ijh=2; ijh<eval(-2 + (thesexy.length / 1)); ijh+=2) {

    area=herons_formula_triangle_area(x, y, thesexy[eval(-2 + ijh)], thesexy[eval(-1 + ijh)], thesexy[ijh], thesexy[eval(1 + ijh)]);

    base=find_dist(thesexy[eval(-2 + ijh)], thesexy[eval(-1 + ijh)], thesexy[ijh], thesexy[eval(1 + ijh)]);

    height=eval((2.0 * area) / base);

    if (eval(height) < eval(smallesth) || eval(smallesth) < 0.0) {

    smallesth=height;

    }

    }

    var cnf;

    if (eval(smallesth) < 3) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is boiling. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 10) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is very hot. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 20) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is very warm. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 40) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is warm. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 80) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is lukewarm. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 120) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is cool. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 160) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is cold. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 160) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is freezing. Cancel gives up, other answer will give dictionary view.","");

    }

    if (cnf == null) {

    eval("aconto.getElementById('" + midis + "').title='';");

    } else {

    if (cnf.length == 0) {

    cnf=cnf;

    return true;

    } else {

    eval("aconto.getElementById('" + midis + "').title='lookup';");

    }

    }

    return false;

    }

  6. and our shortest distance can be thought of as the smallest of these โ€œheightโ€ values (and you can see how we did this above)

โ€ฆ and then the concept of โ€œboilingโ€ vs โ€œvery warmโ€ etcetera etcetera should be worked out by trying it out (with alert box help).

Again, with todayโ€™s work, we are in the area of study of โ€œoverlayโ€, the HTML map tag being a well established overlay method linking image data with co-ordinate intelligence, still a useful idea we think.

HTML and Javascript codewise the original under_the_stairsโšซhtml is unchanged from the way it was way below, but today, with our changed scenario, it is used within an HTML iframe element using our Client Pre-emptive Iframe techniques to glean HTML map information, and then reworked as necessary directly into that iframe, and the HTML and Javascript for this is pre_under_the_stairsโšซhtml changed from yesterday as per thislink.

This could all become very much clearer when you try a liveโœ‚run and we hope it leaves you with some ideas to try out yourself in a project you are working on.


Previous relevant ESL Under The Stairs Game Overlay Primer Tutorial is shown below.

ESL Under The Stairs Game Overlay Primer Tutorial

The HTML map element can be used in a variety of ways, two of which we hone in on with todayโ€™s ESL Vocabulary game โ€œUnder the Stairsโ€, a revisit of our previous English Learning โ€“ Vocabulary โ€“ Under The Stairs is shown below, where that same HTML map element used then, today, starts as โ€ฆ

  1. a jigsaw โ€œoverlayโ€ to the underlying image (in that we try to cover the whole area of the image with clickable HTML area โ€œpolygonโ€ segments (the so called โ€œClick and be Promptedโ€ mode of use)) โ€ฆ but if the user selects a โ€œFind Prompted Objectโ€ mode of use that same HTML map element is reworked to become like โ€ฆ
  2. a โ€œWhereโ€™s Wallyโ€ scenario where the computer prompts the user for what they should click on, where the HTML map element has one defined HTML area tag plus one other default โ€œnonhrefโ€ HTML area tag

Again, we are in the area of study of โ€œoverlayโ€, the HTML map tag being a well established overlay method linking image data with co-ordinate intelligence, still a useful idea we think.

HTML and Javascript codewise the original under_the_stairsโšซhtml is unchanged from the way it was below, but today, with our changed scenario, it is used within an HTML iframe element using our Client Pre-emptive Iframe techniques to glean HTML map information, and then reworked as necessary directly into that iframe, and the HTML and Javascript for this is pre_under_the_stairsโšซhtml channeling those oft-mentioned CSS techniques โ€ฆ

  1. position:absolute property
  2. z-index
  3. opacity

The โ€œoverlayโ€ concept comes into play, too, for the user to control the mode of use of the web application (ie. its HTML map elementโ€™s mode of use) via an HTML select tag โ€œoverlayedโ€ on top of an HTML iframe element which exists that way for 20 seconds allowing the user to choose that other mode of use should they be interested.

This could all become much clearer when you try a liveโœ‚run and we hope it leaves you with some ideas to try out yourself in a project you are working on.


Previous relevant English Learning โ€“ Vocabulary โ€“ Under The Stairs is shown below.

click map

English Learning - Vocabulary - Under The Stairs


Click to start class. How many things can you name?

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.

Australian Geographical Quiz Primer Tutorial

Australian Geographical Quiz Primer Tutorial

We have some similar ideas going on today, with our new web application quiz/game, to those of ESL Vocabulary Getting Warmer Image Tutorial as shown below, as can be summarised by โ€ฆ

  • use of the one underlying background image โ€ฆ coupled with โ€ฆ
  • use of HTML map element on top of that โ€ฆ created via โ€ฆ
  • the brilliant, the stupendous Mobilefish website helper โ€ฆ to arrive at a โ€ฆ
  • โ€œgetting warmerโ€ type of quiz related, today, to Australian Geography

โ€ฆ the underlying map image for which weโ€™ve based on one from the stupendous, the brilliant Australian Geographic magazine, so thanks.

A thing different in todayโ€™s work, apart from the inherit different look and array manipulations you look and act differently with, over time, with the code, is that we have two images โ€ฆ

  1. original image photographed with an iPad โ€ฆ for an โ€œEasierโ€ gameplay level of difficulty โ€ฆ as well as a โ€ฆ
  2. โ€œconfused upโ€/โ€messed upโ€ โ€ฆ call it what you will โ€ฆ image version put through a session on Gimp to โ€ฆ
    • Free Select Cut โ€ฆ and โ€ฆ
    • Free Select Gaussian Blur

    โ€ฆ in order to arrive at an image for a โ€œDifficultโ€ gameplay level of difficulty (where there is less on the map image to help the user

โ€ฆ presented to the player of the web application โ€œAustralian Geographyโ€ game in an HTML select โ€œdropdownโ€ choice.

The other bit extra weโ€™ve done today, because the HTML map element has not been designed to cover the whole rectangle of the image, is to harness the document.body onclick event (fired off via the HTML <body onload=โ€™atstart();โ€™ onclick=โ€™icheck(event);โ€™>) to check for (web application game) clicks (or touches) that are not โ€ฆ

  • HTML select element based clicks โ€ฆ nor โ€ฆ
  • other HTML map element HTML area element clicks

โ€ฆ and if so, record that click eventโ€™s mouse (x,y) co-ordinates and report on this in a similar way to the โ€œHTML map element HTML area element clicksโ€, except that we have no link to a name for their click (whereas we can glean a name off the HTML area element alt property for those HTML map element HTML area element clicks), and so we inform the user of the โ€œnearestโ€ place they clicked (or touched) near โ€ฆ as per (Javascript DOM code) โ€ฆ



function icheck(evt) {

if (realclick) {

var x,y;

if (evt.clientX || evt.clientY) {

x = evt.clientX;

y = evt.clientY;

} else {

x = evt.pageX;

y = evt.pageY;

}

var distco=((x - midcoords[placepick][0]) * (x - midcoords[placepick][0])) + ((y - midcoords[placepick][1]) * (y - midcoords[placepick][1]));

var halfpoint='';



var davw=' ... you are very cold ';

if (distco <= verywarm) {

halfpoint='0.5';

davw=' ... you are very warm (and its possible there is an overlap, so you score the 0.5 choosing this with OK button) ';

} else if (distco <= warm) {

davw=' ... you are warm ';

} else if (distco <= cool) {

davw=' ... you are cool ';

} else if (distco <= cold) {

davw=' ... you are cold ';

}



var nearestplace='';

var nearestdistco=-1;

for (var jwhich=0; jwhich<midcoords.length; jwhich++) {

distco=((midcoords[jwhich][0] - x) * (midcoords[jwhich][0] - x)) + ((midcoords[jwhich][1] - y) * (midcoords[jwhich][1] - y));

if (jwhich == 0) {

nearestplace=places[jwhich].replace(/_/g,' ');

nearestdistco=distco;

} else if (distco < nearestdistco) {

nearestplace=places[jwhich].replace(/_/g,' ');

nearestdistco=distco;

}

}

goes++;

var ans=prompt('You clicked nearest to ' + nearestplace + ' but we wanted you to identify ' + placechosen.replace(/_/g,' ') + davw + ' ... try again ... or ... Choose to Cancel', halfpoint);

if (ans == null) {

//alert(92);

setTimeout(pickone,2000);

} else if (ans == '0.5') {

score+=0.5;

setTimeout(pickone,2000);

}

setTimeout(resetit, 200);

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

}

return '';

}

The Javascript realclick global variable above is set to false by those other HTML select element and/or HTML map element area element click (or touch) events, and then a โ€œsetTimeout(resetit,1000); (for example) would put realclick global variable back to its usual true value.

Why not try the Australian Geography quiz yourself at this liveโœ‚run link? Or peruse the HTML and Javascript code you could call agmapโšซhtml perhaps? By the way, this quiz is designed not to ask about the more populous regions or places of Australia, but more your outback or national park or adventure thought places.


Previous relevant ESL Vocabulary Getting Warmer Image Tutorial is shown below.

ESL Vocabulary Getting Warmer Image Tutorial

ESL Vocabulary Getting Warmer Image Tutorial

Our last visit to our series of HTML map element tutorials, today, building on yesterdayโ€™s ESL Vocabulary Getting Warmer Game Tutorial as shown below, concentrates back on the HTML img element that the HTML map element relies on.

The reason for this, is that, today, we allow for the โ€œsceneโ€ of the ESL Vocabulary lesson to change, and we need to resize things, but not to do with any HTML map element dimensions, but rather the underlying HTML img elementโ€™s Javascript DOM โ€ฆ

  • document.getElementById([imgId]).width
  • document.getElementById([imgId]).height

โ€ฆ at which point you might be saying โ€ฆ doh! โ€ฆ and you might be right โ€œdohโ€ing in such a Willy Nilly way โ€ฆ but in lots of other applications it is document.getElementById([imgId]).style.width and document.getElementById([imgId]).style.height you deal with. All this begs the question: โ€œHow did you create the HTML map elements in the first place?โ€ โ€ฆ especially as the โ€œfirst placeโ€ was โ€œUnder the Stairsโ€ โ€ฆ and thereโ€™s not much room there? โ€ฆ very minor and lame chortle, chortle.

Well, this tutorial wants to introduce (or reintroduce) you to a wonderful service run by mobilefish to help you out โ€ฆ all together now โ€ฆ thanks MOBILEFISH โ€ฆ take a look here โ€ฆ can you see the possibilities?!

We, personally, revisited the wonderful Mobilefish website, to create a Whereโ€™s Wally โ€œsceneโ€ (thanks to the Telegraph UKโ€™s โ€œWhereโ€™s Wally? celebrates 25th birthdayโ€ articleโ€™s image of this webpage) for you to try the second of the HTML map modes of use we have been raving about lately as per โ€ฆ

  1. a jigsaw โ€œoverlayโ€ to the underlying image (in that we try to cover the whole area of the image with clickable HTML area โ€œpolygonโ€ segments (the so called โ€œClick and be Promptedโ€ mode of use)) โ€ฆ but if the user selects a โ€œFind Prompted Objectโ€ mode of use that same HTML map element is reworked to become like โ€ฆ
  2. a โ€œWhereโ€™s Wallyโ€ scenario where the computer prompts the user for what they should click on, where the HTML map element has one defined HTML area tag plus one other default โ€œnonhrefโ€ HTML area tag

โ€ฆ and there โ€ฆ we hope you see how the โ€œGetting Warmerโ€ is very applicable as an idea. By the way, you will see out there in Open Source land places where you can get great Javascript libraries whose code would cover what you need here too.

So think โ€œoverlayโ€, the HTML map tag being a well established overlay method linking image data with co-ordinate intelligence.

HTML and Javascript codewise the original under_the_stairsโšซhtml is unchanged from the way it was way way below, and today it is joined by others of its ilk in different scenes (all unchanged), but today, with our changing ESL Vocabulary scenarios, it is used within an HTML iframe element using our Client Pre-emptive Iframe techniques to glean HTML map information, and then reworked as necessary directly into that iframe, and the HTML and Javascript for this is pre_under_the_stairsโšซhtml changed from yesterday as per thislink.

This could all become very much clearer when you try a liveโœ‚run and we hope it leaves you with some more ideas to try out yourself in a project you are working on.


Previous relevant ESL Vocabulary Getting Warmer Game Tutorial is shown below.

ESL Vocabulary Getting Warmer Game Tutorial

As we saw yesterday, the HTML map element can be used in a variety of ways, two of which we hone in on with todayโ€™s ESL Vocabulary Getting Warmer Game Tutorial, a variation on yesterdayโ€™s ESL Under The Stairs Game Overlay Primer Tutorial as shown below, where we add Javascript functionality to effectively find the shortest distance of a point to a polygon co-ordinate โ€œsetโ€, and a revisit of our previous English Learning โ€“ Vocabulary โ€“ Under The Stairs as shown way below. The HTML map element can be โ€ฆ

  1. a jigsaw โ€œoverlayโ€ to the underlying image (in that we try to cover the whole area of the image with clickable HTML area โ€œpolygonโ€ segments (the so called โ€œClick and be Promptedโ€ mode of use)) โ€ฆ but if the user selects a โ€œFind Prompted Objectโ€ mode of use that same HTML map element is reworked to become like โ€ฆ
  2. a โ€œWhereโ€™s Wallyโ€ scenario where the computer prompts the user for what they should click on, where the HTML map element has one defined HTML area tag plus one other default โ€œnonhrefโ€ HTML area tag

In that second mode of use today, we add a bit of fun by adding that โ€œgetting warmerโ€ type of โ€œbizzoโ€ (sorry to get technical) to our game.

To do this, as weโ€™ve mentioned, we find the shortest distance of a point to a polygon co-ordinate โ€œsetโ€ by โ€ฆ

  1. leave the HTML map to determine when a point is inside its first โ€œpolygonโ€ section, and for all the rest, via that other โ€œnohrefโ€ HTML area elementโ€™s onclick event, we arrange some Javascript that โ€ฆ
  2. breaks the problem into sets of 3 co-ordinate (x,y) arrangements for each polygon line segment (brought up to 3 by the point chosen by the user) โ€ฆ
  3. for each of these consider the three points as a triangle and use Heronโ€™s Formula to calculate the triangle area


    function herons_formula_triangle_area(x1, y1, x2, y2, x3, y3) {

    var a=Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

    var b=Math.sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));

    var c=Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));

    var s=eval((a + b + c) / 2.0);

    return Math.sqrt(s * (s - a) * (s - b) * (s - c));

    }

    โ€ฆ
  4. the base value in โ€œarea=base x height / 2โ€ (area of a triangle) can be calculated as the line segment length (square root of the x co-ordinate difference squared plus the y co-ordinate difference squared)


    function find_dist(x1, y1, x2, y2) {

    return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

    }

    โ€ฆ
  5. so height=area x 2 / base โ€ฆ


    function calcdist() {

    var theseobjs, area=0.0, base=0.0, height=0.0, smallestijh=-1;

    var thesexy;

    eval("aconto.getElementById('" + midis + "').title='other';");

    smallesth=-1.0;

    theseobjs=objects[snum].split(';');

    thesexy=theseobjs[1].split(',');

    for (var ijh=2; ijh<eval(-2 + (thesexy.length / 1)); ijh+=2) {

    area=herons_formula_triangle_area(x, y, thesexy[eval(-2 + ijh)], thesexy[eval(-1 + ijh)], thesexy[ijh], thesexy[eval(1 + ijh)]);

    base=find_dist(thesexy[eval(-2 + ijh)], thesexy[eval(-1 + ijh)], thesexy[ijh], thesexy[eval(1 + ijh)]);

    height=eval((2.0 * area) / base);

    if (eval(height) < eval(smallesth) || eval(smallesth) < 0.0) {

    smallesth=height;

    }

    }

    var cnf;

    if (eval(smallesth) < 3) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is boiling. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 10) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is very hot. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 20) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is very warm. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 40) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is warm. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 80) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is lukewarm. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 120) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is cool. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 160) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is cold. Cancel gives up, other answer will give dictionary view.","");

    } else if (eval(smallesth) < 160) {

    cnf=prompt("Sorry, this is not " + thisobj + ", and it is freezing. Cancel gives up, other answer will give dictionary view.","");

    }

    if (cnf == null) {

    eval("aconto.getElementById('" + midis + "').title='';");

    } else {

    if (cnf.length == 0) {

    cnf=cnf;

    return true;

    } else {

    eval("aconto.getElementById('" + midis + "').title='lookup';");

    }

    }

    return false;

    }

  6. and our shortest distance can be thought of as the smallest of these โ€œheightโ€ values (and you can see how we did this above)

โ€ฆ and then the concept of โ€œboilingโ€ vs โ€œvery warmโ€ etcetera etcetera should be worked out by trying it out (with alert box help).

Again, with todayโ€™s work, we are in the area of study of โ€œoverlayโ€, the HTML map tag being a well established overlay method linking image data with co-ordinate intelligence, still a useful idea we think.

HTML and Javascript codewise the original under_the_stairsโšซhtml is unchanged from the way it was way below, but today, with our changed scenario, it is used within an HTML iframe element using our Client Pre-emptive Iframe techniques to glean HTML map information, and then reworked as necessary directly into that iframe, and the HTML and Javascript for this is pre_under_the_stairsโšซhtml changed from yesterday as per thislink.

This could all become very much clearer when you try a liveโœ‚run and we hope it leaves you with some ideas to try out yourself in a project you are working on.


Previous relevant ESL Under The Stairs Game Overlay Primer Tutorial is shown below.

ESL Under The Stairs Game Overlay Primer Tutorial

The HTML map element can be used in a variety of ways, two of which we hone in on with todayโ€™s ESL Vocabulary game โ€œUnder the Stairsโ€, a revisit of our previous English Learning โ€“ Vocabulary โ€“ Under The Stairs is shown below, where that same HTML map element used then, today, starts as โ€ฆ

  1. a jigsaw โ€œoverlayโ€ to the underlying image (in that we try to cover the whole area of the image with clickable HTML area โ€œpolygonโ€ segments (the so called โ€œClick and be Promptedโ€ mode of use)) โ€ฆ but if the user selects a โ€œFind Prompted Objectโ€ mode of use that same HTML map element is reworked to become like โ€ฆ
  2. a โ€œWhereโ€™s Wallyโ€ scenario where the computer prompts the user for what they should click on, where the HTML map element has one defined HTML area tag plus one other default โ€œnonhrefโ€ HTML area tag

Again, we are in the area of study of โ€œoverlayโ€, the HTML map tag being a well established overlay method linking image data with co-ordinate intelligence, still a useful idea we think.

HTML and Javascript codewise the original under_the_stairsโšซhtml is unchanged from the way it was below, but today, with our changed scenario, it is used within an HTML iframe element using our Client Pre-emptive Iframe techniques to glean HTML map information, and then reworked as necessary directly into that iframe, and the HTML and Javascript for this is pre_under_the_stairsโšซhtml channeling those oft-mentioned CSS techniques โ€ฆ

  1. position:absolute property
  2. z-index
  3. opacity

The โ€œoverlayโ€ concept comes into play, too, for the user to control the mode of use of the web application (ie. its HTML map elementโ€™s mode of use) via an HTML select tag โ€œoverlayedโ€ on top of an HTML iframe element which exists that way for 20 seconds allowing the user to choose that other mode of use should they be interested.

This could all become much clearer when you try a liveโœ‚run and we hope it leaves you with some ideas to try out yourself in a project you are working on.


Previous relevant English Learning โ€“ Vocabulary โ€“ Under The Stairs is shown below.

click map

English Learning - Vocabulary - Under The Stairs


Click to start class. How many things can you name?

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.

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 *