Region Picker Post Tutorial

Region Picker Post Tutorial

Region Picker Post Tutorial

Yesterday’s Region Picker Hover Tutorial‘s navigations worked off (what we like to call) a GET argument methodology regarding URLs (involving ? and & controlled arguments on the address bar URL) it calls on Image Chart data creators. But even with the ISO-3166 codes (effectively nicknames) used, some countries have lots of regional codes associated with them, and the GET limitations to URL length (for our website less than 1000) means we have to open the door to other approaches for these long URL calls.

Luckily what we are calling is PHP and it can accept POST arguments (ie. $_POST[] array members as distinct from $_GET[] “?” and “&” GET argument members).

Here’s what the scenario looks like for Romania before our fix today …

… and below, the improved scenario after …

To make this happen, we funnel the relevant window.open call through our inhouse “wrapper” Javascript function …

<?php echo ”

function windowopen(a1, a2, a3) {
if (eval('' + a1.length) > 800 && a1.indexOf('?returnxytoparent=') != -1) {
document.getElementById('callreturnxytoparent').value=decodeURIComponent(a1.split('?returnxytoparent=')[1]);
document.getElementById('postcc').submit();
document.getElementById('fif').style.display='block';
document.getElementById('fif').style.width='470px';
document.getElementById('fif').style.height='800px';
location.href='#prefif';
return null;
}
return window.open(a1, a2, a3);
}

?>

… using an HTML form element …


<form target=fif id=postcc action='//www.rjmprogramming.com.au/PHP/GeoChart/image_chart.php' method=POST style=display:none;>
<input type=hidden name=returnxytoparent id=callreturnxytoparent value=''></input>
<input style=display:none; type=submit id=bfif value=Submit></input>
</form>

… targetting, after a form submit action, a named HTML iframe element …


<iframe name=fif id=fif style=display:none; src='//www.rjmprogramming.com.au/PHP/GeoChart/image_chart.php'></iframe>

… sitting within the table of the webpage, and hashtag navigated to should the need arise in our changed “seventh draft” Region Picker.


Previous relevant Region Picker Hover Tutorial is shown below.

Region Picker Hover Tutorial

Region Picker Hover Tutorial

Yesterday’s Region Picker Popup Menu Tutorial introduced, what to us, is …

  • interesting onclick logic associated with the popup window, suiting both mobile and non-mobile platforms … but we can not resist introducing “hover” non-mobile ideas in the category of …
  • interesting onmouseover onmousemove logic … today …

… which, on paper, sounds trivial. But not so, in this scenario. You may recall we started using PHP GD‘s imagecolorat function as a first “port of call” idea with our Clayton’s image map simulation ideas, where this idea may be just okay for discrete onclick scenarios, but not for any non-mobile “hover” scenario. We need another approach. And then it tweaked to us, start (with thisonl document.body onload event logic below) using an HTML canvas element …

<?php echo ”

function thisonl() {
elem = document.getElementById('mycanvas');
context = elem.getContext('2d');
setTimeout(canvasize, 5000);
}

function canvasize() { //(ioel) {
var ioel=document.getElementById('ici');
context.drawImage(document.getElementById('ici'), 0, 0);
document.getElementById('moreturnxytoparent').value=elem.toDataURL('image/jpeg', 0.4);
return true;
}

“; ?>

… and follow the excellent advice at this excellent link regarding the use of [canvasElement].getImageData() function to now go

<?php echo ”

function rgbToHex(r, g, b) { // thanks to https://stackoverflow.com/questions/6735470/get-pixel-color-from-canvas-on-mousemove
if (r > 255 || g > 255 || b > 255)
throw 'Invalid color component';
return ((r << 16) | (g << 8) | b).toString(16);
}



function filloutform(e,isclick) {
var p='', hex='', myid='';


e = e || window.event;
e.preventDefault();

if (e.touches) {
if (e.touches[0].pageX) {
x = e.touches[0].pageX;
y = e.touches[0].pageY;
} else {
x = e.touches[0].clientX;
y = e.touches[0].clientY;
}
console.log('pos3=' + pos3 + ',pos4=' + pos4);
} else if (e.clientX || e.clientY) {
x = e.clientX;
y = e.clientY;
} else {
x = e.pageX;
x = e.pageY;
}


if (eval('' + x) > 2 && eval('' + y) > 2) {
document.getElementById('ix').value='' + x;
document.getElementById('iy').value='' + y;
if (document.getElementById('imode').value == 'click' && isclick != 0) {
document.getElementById('imode').value='click';
p = context.getImageData(x, y, 1, 1).data;
hex = ('#' + ('000000' + rgbToHex(p[0], p[1], p[2])).slice(-6)).toUpperCase();
document.getElementById('moimode').value='mouseover';
myid='';
if (document.getElementById('myp').innerHTML.indexOf(hex) != -1) {
myid=document.getElementById('myp').innerHTML.split(hex)[0].split(' id=\"')[eval(-1 + document.getElementById('myp').innerHTML.split(hex)[0].split(' id=\"').length)].split('\"')[0];
document.getElementById('ici').title=document.getElementById(myid).title;
document.getElementById(myid).click();
} else if (document.getElementById('myp').innerHTML.indexOf(hex.toLowerCase()) != -1) {
myid=document.getElementById('myp').innerHTML.split(hex.toLowerCase())[0].split(' id=\"')[eval(-1 + document.getElementById('myp').innerHTML.split(hex.toLowerCase())[0].split(' id=\"').length)].split('\"')[0];
//document.title='x=' + x + ' and y=' + y + ' ' + hex;
document.getElementById('ici').title=document.getElementById(myid).title;
document.getElementById(myid).click();
} else if (hex.toUpperCase() != 'D0D0D0' && hex.toUpperCase() != 'FFFFFF' && hex.toUpperCase() != 'B3BCC0' && hex.toUpperCase() != 'BCBCBC') {
if (document.getElementById('ici').title != origtitle) {
gmenu('', document.getElementById('ici').title);
} else {

//document.getElementById('blastcol').click();
document.getElementById('myform').submit();
}
}

} else {
document.getElementById('moix').value='' + x;
document.getElementById('moiy').value='' + y;
p = context.getImageData(x, y, 1, 1).data;
hex = ('#' + ('000000' + rgbToHex(p[0], p[1], p[2])).slice(-6)).toUpperCase();
document.getElementById('moimode').value='mouseover';
myid='';
if (document.getElementById('myp').innerHTML.indexOf(hex) != -1) {
myid=document.getElementById('myp').innerHTML.split(hex)[0].split(' id=\"')[eval(-1 + document.getElementById('myp').innerHTML.split(hex)[0].split(' id=\"').length)].split('\"')[0];
document.getElementById('ici').title=document.getElementById(myid).title;
} else if (document.getElementById('myp').innerHTML.indexOf(hex.toLowerCase()) != -1) {
myid=document.getElementById('myp').innerHTML.split(hex.toLowerCase())[0].split(' id=\"')[eval(-1 + document.getElementById('myp').innerHTML.split(hex.toLowerCase())[0].split(' id=\"').length)].split('\"')[0];
//document.title='x=' + x + ' and y=' + y + ' ' + hex;
document.getElementById('ici').title=document.getElementById(myid).title;
} else if (document.getElementById('ici').title == origtitle) {
//document.getElementById('moblastcol').click();
document.getElementById('myformmo').submit();
}
}

}
}

“; ?>

… to keep up with the clientside (only, now) “hover” solution we’re preferring right now (and maybe even this time tomorrow?!)

And this suits non-mobile users used to seeing useful information as they hover over an element, and in a map element’s case, the equivalent of the “smarts” an image map might offer, except that in today’s case, thanks to colour coding … not an image map in sight!

Codewise we needed …

… to make this happen.


Previous relevant Region Picker Popup Menu Tutorial is shown below.

Region Picker Popup Menu Tutorial

Region Picker Popup Menu Tutorial

Yesterday we left off with …

Am sure some of you are onto tomorrow’s plan, given today’s work?! We’ll see what tomorrow brings!

… and we feel we might have “put the mockers” on ourselves, because, as you may have read, Geo Chart Image Chart is due for deprecation soon. In fact, the regime at the moment is fewer and fewer hours up, and we’ll have to turn our attention to alternatives. But what out there can do those regional views where the map effectively hugs the bounds of the data … brilliant, and we think hard to do with your normal Google Charts suite of software? As well as the image element result, even though we need to try out the “ready event” normal Google Charts “print” way to achieve this. So much more useful than involving Javascript. And more fun to work with too, it being a conduit to HTML canvas usage.

Anyway, here we are late in our day with a window of opportunity, and While You See a Chance, Take It we reckon.

And what yesterday’s Region Picker Double Click Tutorial gave us a good framework for is PHP method=GET and PHP method=POST uses of argument returnxytoparent along with our new GD imagecolorat function friend in the changed image_chart.php Google Chart Image Chart Map Chart interfacer

  • double click button to create popup window with same look as background image version …
  • but now that call, wraps the URL that it used to call in an encoded returnxytoparent argument guise, using …
    <?php

    if (isset($_GET['returnxytoparent'])) {
    $imgurl=str_replace('+',' ',urldecode($_GET['returnxytoparent']));
    echo "<html>
    <head>
    <style> * { margin:0 0 0 0; padding:0 0 0 0; } </style>
    <scr" . "ipt type=text/javascript>
    var x=0, y=0, isclear=true;

    function filloutform(e) {

    e = e || window.event;
    e.preventDefault();

    if (e.touches) {
    if (e.touches[0].pageX) {
    x = e.touches[0].pageX;
    y = e.touches[0].pageY;
    } else {
    x = e.touches[0].clientX;
    y = e.touches[0].clientY;
    }
    console.log('pos3=' + pos3 + ',pos4=' + pos4);
    } else if (e.clientX || e.clientY) {
    x = e.clientX;
    y = e.clientY;
    } else {
    x = e.pageX;
    x = e.pageY;
    }

    if (x > 0) {
    document.getElementById('ix').value='' + x;
    document.getElementById('iy').value='' + y;
    if (document.getElementById('imode').value == 'click') {
    //document.getElementById('blastcol').click();
    document.getElementById('myform').submit();
    }
    }
    }

    function gmenu(rcodeis, erdescis) {
    var rdescis=decodeURIComponent(erdescis);
    if (rcodeis.trim() != '' && rdescis.trim() != '') {
    var rans=prompt('What do you want to do with region ' + rdescis + '? ' + String.fromCharCode(10) + String.fromCharCode(10) + 'W - Wikipedia look up ' + String.fromCharCode(10) + 'Y - YouTube look up ' + String.fromCharCode(10) + 'G - Google look up ' + String.fromCharCode(10) + String.fromCharCode(10), '');
    if (rans == null) { rans=''; }
    if ((rans + ' ').toUpperCase().substring(0,1) == 'W') {
    window.open('//wikipedia.org/wiki/' + encodeURIComponent(rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')).replace(/\%20/g,'_'),'_blank','top=10,left=10,width=600,height=600');
    } else if ((rans + ' ').toUpperCase().substring(0,1) == 'Y') {
    window.open('//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=' + encodeURIComponent(' ' + rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')),'_blank','top=10,left=10,width=600,height=600');
    } else if ((rans + ' ').toUpperCase().substring(0,1) == 'G') {
    window.open('//www.google.com/search?q=' + encodeURIComponent(rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')) + '&tbm=isch','_blank','top=10,left=10,width=600,height=600');
    }
    }
    }

    </scr" . "ipt>
    </head>
    <body onclick=\" document.getElementById('lastcol').value=''; isclear=false; document.getElementById('imode').value='click'; filloutform(event);\" onload=\" if (window.opener) { document.getElementById('myp').innerHTML=window.opener.document.getElementById('myp').innerHTML; document.getElementById('patparent').value=window.opener.document.getElementById('myp').innerHTML; } \">
    <img id=ici onmouseover=\" if (isclear) { document.getElementById('imode').value='mouseover'; filloutform(event); }\" src='" . $imgurl . "' title='Optionally click in relevant region for menu'></img>
    <input title='' id=lastcol value='' type=hidden></input>
    <form id=myform onsubmit=\" return true;\" style=display:none; target=iflastcol method=POST action=./image_chart.php>
    <input name=returnxytoparent id=returnxytoparent value='" . $imgurl . "' type=hidden></input>
    <input name=ix id=ix value='0' type=hidden></input>
    <input name=iy id=iy value='0' type=hidden></input>
    <input name=imode id=imode value='mouseover' type=hidden></input>
    <input name=patparent id=patparent value='' type=hidden></input>
    <input type=submit style=display:none; id=blastcol></input>
    </form>
    <iframe name=iflastcol id=iflastcol style=display:none; src=./image_chart.php></iframe>
    <p id=myp style=display:none;></p>
    </body>
    </html>";
    exit;
    } else if (isset($_POST['returnxytoparent']) && isset($_POST['ix']) && isset($_POST['iy'])) {
    $alp="0123456789ABCDEF"; //=map&chs=600x450&
    //echo "<html><body onload=\" alert('" . str_replace('+',' ',urldecode($_POST['returnxytoparent'])) . "'); \"></body></html>";
    //exit;
    $imgurl='http://chart.googleapis.com/chart?' . str_replace('=map&chld=', '=map&chs=455x350&chld=', explode('?', str_replace('+',' ',urldecode($_POST['returnxytoparent'])))[1]);
    //echo "<html><body onload=\" alert('" . $imgurl . "'); \"></body></html>";
    //exit;
    $im = imagecreatefromstring(file_get_contents($imgurl));
    $tlrgb = imagecolorat($im, $_POST['ix'], $_POST['iy']);
    $topclick='';
    if ($tlrgb) {
    //echo '<html><body onload=" alert(4); "></body></html>';
    //exit;
    $tlr = ($tlrgb >> 16) & 0xFF;
    $tlg = ($tlrgb >> 8) & 0xFF;
    $tlb = $tlrgb & 0xFF;
    $blchex=substr(substr($alp,($tlr / 16)),0,1) . substr(substr($alp,($tlr % 16)),0,1) . substr(substr($alp,($tlg / 16)),0,1) . substr(substr($alp,($tlg % 16)),0,1) . substr(substr($alp,($tlb / 16)),0,1) . substr(substr($alp,($tlb % 16)),0,1);
    $isclick=false;
    if (isset($_POST['patparent']) && isset($_POST['imode'])) {
    $pat=str_replace('+',' ',urldecode($_POST['patparent']));
    if ($_POST['imode'] == 'click') {
    if (strpos(str_replace('+',' ',urldecode($_POST['patparent'])), '#' . strtoupper($blchex)) !== false) {
    $topclick=" parent.document.getElementById('" . explode('"', explode(' id="', explode('#' . strtoupper($blchex), $pat)[0])[-1 + sizeof(explode(' id="', explode('#' . strtoupper($blchex), $pat)[0]))] )[0] . "').click(); ";
    } else if (strpos(str_replace('+',' ',urldecode($_POST['patparent'])), '#' . strtolower($blchex)) !== false) {
    $topclick=" parent.document.getElementById('" . explode('"', explode(' id="', explode('#' . strtolower($blchex), $pat)[0])[-1 + sizeof(explode(' id="', explode('#' . strtolower($blchex), $pat)[0]))] )[0] . "').click(); ";
    }
    }
    }
    echo '<html><body onload=" parent.document.getElementById(' . "'lastcol'" . ').title=' . "'" . $_POST['imode'] . "'" . '; parent.document.getElementById(' . "'lastcol'" . ').value=' . "'" . $blchex . "'" . '; ' . $topclick . ' "></body></html>';
    } //else {
    //echo '<html><body onload=" alert(234); "></body></html>';
    //exit;
    //}
    imagedestroy($im);
    exit;
    }

    ?>
  • to be able to offer, “onclick”, a colour coded region (on the map) piece of functionality

… achieving a Clayton’s image map scenario in the changed “fifth draft” Region Picker.


Previous relevant Region Picker Double Click Tutorial is shown below.

Region Picker Double Click Tutorial

Region Picker Double Click Tutorial

You might have gleaned from recent blog posts in the thread leading up to yesterday’s Region Picker Hashtag Navigation Tutorial that, regarding web applications/webpages, even though a few years back we’d have been horrified to say it …

  • we like to use the ondblclick event (especially in a multi-purpose button press way) … and in this context …
  • we don’t mind having to use event.stopPropagation() anymore (ie. we used to not get sleep for days worrying about it) (when you want to stop the event bubbling down to a parent element) …
  • we like to use colour coding … and …
  • we don’t mind window.open (with a third argument and so, on non-mobile is a) popup window usage

But that’s just us. We’ll leave it to you to look into all these more, as far as favour, or not, goes with the search engines.

We see the ondblclick event as being in the same line of thinking as the onclick event is (doh!) in the sense that mobile and non-mobile platforms understand it, as distinct from the divide between the touch “gesture” events and the mouse events. And it may be just me, but web browsers seem better with it these days. Maybe just wishful thinking on that last point, for me, though?!

Today, we’ve got another “multipurpose scenario” for an ondblclick event logic coding …


if (sofar != '') {
if (window.self == window.parent && eval('' + screen.width) > 1000) {
document.getElementById('rmore').innerHTML=prebut + '<button id=mychart ondblclick="event.stopPropagation(); dcdomc();" onclick=domc(); style=background-color:' + iccol + ';>Image Chart Map Chart <br><font size=1>(double click uses new window)</font><br> ... showing ...</button><br><br><p id=myp title="' + sofardetail + '">' + sofar.replace(/\|/g, '<br>');
} else {
document.getElementById('subrmore').innerHTML=prebut + '<button id=mychart ondblclick="event.stopPropagation(); dcdomc();" onclick=domc(); style=background-color:' + iccol + ';>Image Chart Map Chart <br><font size=1>(double click uses new window)</font><br> ... showing ...</button><br><br><p id=myp title="' + sofardetail + '">' + sofar.replace(/\|/g, '<br>');
}
}

… calling new


function dcdomc() {
// <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
//var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
if (document.getElementById('mychart')) {
document.getElementById('mychart').style.backgroundColor='orange';
iccol='orange';
}
if (document.getElementById('mychchart')) {
document.getElementById('mychchart').style.backgroundColor='orange';
jccol='orange';
}
var theurlis='//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar);
dbwo=window.open(theurlis,'_blank','top=50,left=50,width=600,height=600');

document.getElementById('tdleft').style.backgroundImage='URL("' + theurlis + '")';
document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
document.getElementById('tdleft').style.backgroundPosition='right top';
} else {
document.getElementById('tdleft').style.backgroundPosition='center top';
}
document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
opacitytoggling(1.0, 0.1);
setTimeout(function(){ opacitytoggling(1.0, -0.1); }, 2100);
if (!dbdone) {
dbdone=true;
//document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
//document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
//document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
}
window.scrollTo(0,0);
}

… in the changed “fourth draft” Region Picker, where we are building up a menu system tailored to region/country lookups.

Am sure some of you are onto tomorrow’s plan, given today’s work?! We’ll see what tomorrow brings!


Previous relevant Region Picker Geo Chart Integration Tutorial is shown below.

Region Picker Geo Chart Integration Tutorial

Region Picker Geo Chart Integration Tutorial

We’re tickled pink with our integration of yesterday’s Region Picker Primer Tutorial

  • Region Picker web application … into …
  • Geo Chart interfacer

… in that we’ve done better than the natural Geo Chart navigation without the Region Picker, which navigates to a new URL slapped onto the same web browser tab. With our integration we have …

  • Geo Chart interfacer parent “base layer” (with as little as one prompt window required) … and if called upon “above this” …
  • Region Picker web application nested in an “overlay iframe” (with large CSS z-index value covering the whole screen) … asks (for as little as) one more verifying prompt window question … and that same tab window content becomes the final …
  • Geo Chart interfacer result web page

And seeing the country regional codes in play, the possibilities mount up here! The user just includes …

&regionpicker

… in a prompt window answer to start using Region Pickers in their user inputs.

Codewise we needed …

  • to change “second draft” Region Picker … might ask that one verifying prompt window in …

    function gcdomc() {
    var clauses='', popularity='Popularity', extras='';
    // <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
    //var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
    if (document.getElementById('mychchart')) {
    document.getElementById('mychchart').style.backgroundColor='orange';
    jccol='orange';
    }
    if (gwl == '' && document.URL.indexOf('?') != -1) {
    gwl='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?' + document.URL.split('?')[1].split('#')[0].replace(/\&data\=$/g, '');
    if (document.URL.indexOf('popularity=') != -1) {
    popularity=decodeURIComponent(document.URL.split('popularity=')[1].split('&')[0].split('#')[0]);
    }
    }
    var agwl=gwl.split('&');
    for (var iig=1; iig<agwl.length; iig++) {
    if (iig == 1) { clauses=String.fromCharCode(10); }
    if (agwl[iig] != 'data=' && agwl[iig].indexOf('regionpicker') == -1) {
    clauses+='&' + agwl[iig] + String.fromCharCode(10);
    }
    }
    //if (clauses != '') { clauses+=String.fromCharCode(10); }
    gwocont=sofar;
    if (gwocont != '') {
    var xgwocont=null;
    if (1 == 1) {
    var setstuff='';
    if (gwl.indexOf('&data=') == -1) { setstuff='&data='; } else { extras=' (if &data= change prefix that in below appropriately)'; }
    var plis=('' + gwocont).split('|');
    for (var iplis=0; iplis<plis.length; iplis++) {
    if (setstuff == '') {
    setstuff='%20[~' + plis[iplis] + '~,2]';
    } else {
    setstuff+='%20,%20[~' + plis[iplis] + '~,2]';
    }
    }
    try {
    xgwocont=prompt('Please amend as necessary where each of those 2 values are what we have so far assigned for the ' + popularity + ' value for each region/country. As necessary add in any amended ' + clauses + ' ideas too' + extras + '.', setstuff);
    } catch(hjgdf) { xgwocont=null; }
    }
    if (xgwocont == null) { lastgwcont=gwocont; xgwocont=''; }
    gwocont=xgwocont;
    if (xgwocont != '') {
    //alert('gwl=' + gwl);
    var lateragwl=xgwocont.replace(/\ /g, '%20').split('&');
    for (var jig=1; jig<lateragwl.length; jig++) {
    if (gwl.indexOf('&' + lateragwl[jig].split('=')[0] + '=') != -1) {
    gwl=gwl.replace('&' + lateragwl[jig].split('=')[0] + '=' + gwl.split('&' + lateragwl[jig].split('=')[0] + '=')[1].split('&')[0].split('#')[0], '');
    }
    }
    lhref=ourtoolong(gwl + xgwocont.replace(/\ /g, '%20'));
    if (lhref != '') {
    location.href=lhref;
    }
    }
    }
    document.getElementById('tdleft').style.backgroundImage='URL("//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar) + '")';
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
    document.getElementById('tdleft').style.backgroundPosition='right top';
    } else {
    document.getElementById('tdleft').style.backgroundPosition='center top';
    }
    document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (!dbdone) {
    dbdone=true;
    //document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    }
    window.scrollTo(0,0);
    }

    … and …
  • to change geo_chart.php Geo Chart interfacer … calls on the Region Picker in this new Javascript function …
    <?php echo ”

    function winopen(oneurl, twotarget, threerest) {
    var hmore='';
    if (gwl != '' && gwl.indexOf('?') != -1 && oneurl.indexOf(gwl) == -1 && oneurl.indexOf('?') != -1) {
    //alert(oneurl + '&' + gwl.split('?')[1]);
    if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    }
    document.getElementById(twotarget).src=oneurl + '&' + gwl.split('?')[1] + hmore;
    } else if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    document.getElementById(twotarget).src=oneurl + hmore;
    } else {
    document.getElementById(twotarget).src=oneurl;
    }
    return document.getElementById(twotarget);
    }

    “; ?>


Previous relevant Region Picker Primer Tutorial is shown below.

Region Picker Primer Tutorial

Region Picker Primer Tutorial

All the Geo Chart and Image Chart Map Chart work recently, along with Wikipedia ISO-3166 regional and country coding help (thanks), has set us on the road towards a …


Region Picker

… online tool, which we envisage will …

  • initially be a standalone HTML webpage … and later be …
  • integrated into the user input phase of the Geo Chart interfacer

So here we are today with the “first draft” standalone version, where we’ve used Pulldown Menus, you can read more about at HTML/CSS/Javascript Pulldown Menus Javascript Tutorial, to construct a Region/Country ISO code vertical bar delimited list of regions/continents that you can display in an Image Chart Map Chart …

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


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


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


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


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


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


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

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

Region Picker Hover Tutorial

Region Picker Hover Tutorial

Region Picker Hover Tutorial

Yesterday’s Region Picker Popup Menu Tutorial introduced, what to us, is …

  • interesting onclick logic associated with the popup window, suiting both mobile and non-mobile platforms … but we can not resist introducing “hover” non-mobile ideas in the category of …
  • interesting onmouseover onmousemove logic … today …

… which, on paper, sounds trivial. But not so, in this scenario. You may recall we started using PHP GD‘s imagecolorat function as a first “port of call” idea with our Clayton’s image map simulation ideas, where this idea may be just okay for discrete onclick scenarios, but not for any non-mobile “hover” scenario. We need another approach. And then it tweaked to us, start (with thisonl document.body onload event logic below) using an HTML canvas element …

<?php echo ”

function thisonl() {
elem = document.getElementById('mycanvas');
context = elem.getContext('2d');
setTimeout(canvasize, 5000);
}

function canvasize() { //(ioel) {
var ioel=document.getElementById('ici');
context.drawImage(document.getElementById('ici'), 0, 0);
document.getElementById('moreturnxytoparent').value=elem.toDataURL('image/jpeg', 0.4);
return true;
}

“; ?>

… and follow the excellent advice at this excellent link regarding the use of [canvasElement].getImageData() function to now go

<?php echo ”

function rgbToHex(r, g, b) { // thanks to https://stackoverflow.com/questions/6735470/get-pixel-color-from-canvas-on-mousemove
if (r > 255 || g > 255 || b > 255)
throw 'Invalid color component';
return ((r << 16) | (g << 8) | b).toString(16);
}



function filloutform(e,isclick) {
var p='', hex='', myid='';


e = e || window.event;
e.preventDefault();

if (e.touches) {
if (e.touches[0].pageX) {
x = e.touches[0].pageX;
y = e.touches[0].pageY;
} else {
x = e.touches[0].clientX;
y = e.touches[0].clientY;
}
console.log('pos3=' + pos3 + ',pos4=' + pos4);
} else if (e.clientX || e.clientY) {
x = e.clientX;
y = e.clientY;
} else {
x = e.pageX;
x = e.pageY;
}


if (eval('' + x) > 2 && eval('' + y) > 2) {
document.getElementById('ix').value='' + x;
document.getElementById('iy').value='' + y;
if (document.getElementById('imode').value == 'click' && isclick != 0) {
document.getElementById('imode').value='click';
p = context.getImageData(x, y, 1, 1).data;
hex = ('#' + ('000000' + rgbToHex(p[0], p[1], p[2])).slice(-6)).toUpperCase();
document.getElementById('moimode').value='mouseover';
myid='';
if (document.getElementById('myp').innerHTML.indexOf(hex) != -1) {
myid=document.getElementById('myp').innerHTML.split(hex)[0].split(' id=\"')[eval(-1 + document.getElementById('myp').innerHTML.split(hex)[0].split(' id=\"').length)].split('\"')[0];
document.getElementById('ici').title=document.getElementById(myid).title;
document.getElementById(myid).click();
} else if (document.getElementById('myp').innerHTML.indexOf(hex.toLowerCase()) != -1) {
myid=document.getElementById('myp').innerHTML.split(hex.toLowerCase())[0].split(' id=\"')[eval(-1 + document.getElementById('myp').innerHTML.split(hex.toLowerCase())[0].split(' id=\"').length)].split('\"')[0];
//document.title='x=' + x + ' and y=' + y + ' ' + hex;
document.getElementById('ici').title=document.getElementById(myid).title;
document.getElementById(myid).click();
} else if (hex.toUpperCase() != 'D0D0D0' && hex.toUpperCase() != 'FFFFFF' && hex.toUpperCase() != 'B3BCC0' && hex.toUpperCase() != 'BCBCBC') {
if (document.getElementById('ici').title != origtitle) {
gmenu('', document.getElementById('ici').title);
} else {

//document.getElementById('blastcol').click();
document.getElementById('myform').submit();
}
}

} else {
document.getElementById('moix').value='' + x;
document.getElementById('moiy').value='' + y;
p = context.getImageData(x, y, 1, 1).data;
hex = ('#' + ('000000' + rgbToHex(p[0], p[1], p[2])).slice(-6)).toUpperCase();
document.getElementById('moimode').value='mouseover';
myid='';
if (document.getElementById('myp').innerHTML.indexOf(hex) != -1) {
myid=document.getElementById('myp').innerHTML.split(hex)[0].split(' id=\"')[eval(-1 + document.getElementById('myp').innerHTML.split(hex)[0].split(' id=\"').length)].split('\"')[0];
document.getElementById('ici').title=document.getElementById(myid).title;
} else if (document.getElementById('myp').innerHTML.indexOf(hex.toLowerCase()) != -1) {
myid=document.getElementById('myp').innerHTML.split(hex.toLowerCase())[0].split(' id=\"')[eval(-1 + document.getElementById('myp').innerHTML.split(hex.toLowerCase())[0].split(' id=\"').length)].split('\"')[0];
//document.title='x=' + x + ' and y=' + y + ' ' + hex;
document.getElementById('ici').title=document.getElementById(myid).title;
} else if (document.getElementById('ici').title == origtitle) {
//document.getElementById('moblastcol').click();
document.getElementById('myformmo').submit();
}
}

}
}

“; ?>

… to keep up with the clientside (only, now) “hover” solution we’re preferring right now (and maybe even this time tomorrow?!)

And this suits non-mobile users used to seeing useful information as they hover over an element, and in a map element’s case, the equivalent of the “smarts” an image map might offer, except that in today’s case, thanks to colour coding … not an image map in sight!

Codewise we needed …

… to make this happen.


Previous relevant Region Picker Popup Menu Tutorial is shown below.

Region Picker Popup Menu Tutorial

Region Picker Popup Menu Tutorial

Yesterday we left off with …

Am sure some of you are onto tomorrow’s plan, given today’s work?! We’ll see what tomorrow brings!

… and we feel we might have “put the mockers” on ourselves, because, as you may have read, Geo Chart Image Chart is due for deprecation soon. In fact, the regime at the moment is fewer and fewer hours up, and we’ll have to turn our attention to alternatives. But what out there can do those regional views where the map effectively hugs the bounds of the data … brilliant, and we think hard to do with your normal Google Charts suite of software? As well as the image element result, even though we need to try out the “ready event” normal Google Charts “print” way to achieve this. So much more useful than involving Javascript. And more fun to work with too, it being a conduit to HTML canvas usage.

Anyway, here we are late in our day with a window of opportunity, and While You See a Chance, Take It we reckon.

And what yesterday’s Region Picker Double Click Tutorial gave us a good framework for is PHP method=GET and PHP method=POST uses of argument returnxytoparent along with our new GD imagecolorat function friend in the changed image_chart.php Google Chart Image Chart Map Chart interfacer

  • double click button to create popup window with same look as background image version …
  • but now that call, wraps the URL that it used to call in an encoded returnxytoparent argument guise, using …
    <?php

    if (isset($_GET['returnxytoparent'])) {
    $imgurl=str_replace('+',' ',urldecode($_GET['returnxytoparent']));
    echo "<html>
    <head>
    <style> * { margin:0 0 0 0; padding:0 0 0 0; } </style>
    <scr" . "ipt type=text/javascript>
    var x=0, y=0, isclear=true;

    function filloutform(e) {

    e = e || window.event;
    e.preventDefault();

    if (e.touches) {
    if (e.touches[0].pageX) {
    x = e.touches[0].pageX;
    y = e.touches[0].pageY;
    } else {
    x = e.touches[0].clientX;
    y = e.touches[0].clientY;
    }
    console.log('pos3=' + pos3 + ',pos4=' + pos4);
    } else if (e.clientX || e.clientY) {
    x = e.clientX;
    y = e.clientY;
    } else {
    x = e.pageX;
    x = e.pageY;
    }

    if (x > 0) {
    document.getElementById('ix').value='' + x;
    document.getElementById('iy').value='' + y;
    if (document.getElementById('imode').value == 'click') {
    //document.getElementById('blastcol').click();
    document.getElementById('myform').submit();
    }
    }
    }

    function gmenu(rcodeis, erdescis) {
    var rdescis=decodeURIComponent(erdescis);
    if (rcodeis.trim() != '' && rdescis.trim() != '') {
    var rans=prompt('What do you want to do with region ' + rdescis + '? ' + String.fromCharCode(10) + String.fromCharCode(10) + 'W - Wikipedia look up ' + String.fromCharCode(10) + 'Y - YouTube look up ' + String.fromCharCode(10) + 'G - Google look up ' + String.fromCharCode(10) + String.fromCharCode(10), '');
    if (rans == null) { rans=''; }
    if ((rans + ' ').toUpperCase().substring(0,1) == 'W') {
    window.open('//wikipedia.org/wiki/' + encodeURIComponent(rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')).replace(/\%20/g,'_'),'_blank','top=10,left=10,width=600,height=600');
    } else if ((rans + ' ').toUpperCase().substring(0,1) == 'Y') {
    window.open('//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=' + encodeURIComponent(' ' + rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')),'_blank','top=10,left=10,width=600,height=600');
    } else if ((rans + ' ').toUpperCase().substring(0,1) == 'G') {
    window.open('//www.google.com/search?q=' + encodeURIComponent(rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')) + '&tbm=isch','_blank','top=10,left=10,width=600,height=600');
    }
    }
    }

    </scr" . "ipt>
    </head>
    <body onclick=\" document.getElementById('lastcol').value=''; isclear=false; document.getElementById('imode').value='click'; filloutform(event);\" onload=\" if (window.opener) { document.getElementById('myp').innerHTML=window.opener.document.getElementById('myp').innerHTML; document.getElementById('patparent').value=window.opener.document.getElementById('myp').innerHTML; } \">
    <img id=ici onmouseover=\" if (isclear) { document.getElementById('imode').value='mouseover'; filloutform(event); }\" src='" . $imgurl . "' title='Optionally click in relevant region for menu'></img>
    <input title='' id=lastcol value='' type=hidden></input>
    <form id=myform onsubmit=\" return true;\" style=display:none; target=iflastcol method=POST action=./image_chart.php>
    <input name=returnxytoparent id=returnxytoparent value='" . $imgurl . "' type=hidden></input>
    <input name=ix id=ix value='0' type=hidden></input>
    <input name=iy id=iy value='0' type=hidden></input>
    <input name=imode id=imode value='mouseover' type=hidden></input>
    <input name=patparent id=patparent value='' type=hidden></input>
    <input type=submit style=display:none; id=blastcol></input>
    </form>
    <iframe name=iflastcol id=iflastcol style=display:none; src=./image_chart.php></iframe>
    <p id=myp style=display:none;></p>
    </body>
    </html>";
    exit;
    } else if (isset($_POST['returnxytoparent']) && isset($_POST['ix']) && isset($_POST['iy'])) {
    $alp="0123456789ABCDEF"; //=map&chs=600x450&
    //echo "<html><body onload=\" alert('" . str_replace('+',' ',urldecode($_POST['returnxytoparent'])) . "'); \"></body></html>";
    //exit;
    $imgurl='http://chart.googleapis.com/chart?' . str_replace('=map&chld=', '=map&chs=455x350&chld=', explode('?', str_replace('+',' ',urldecode($_POST['returnxytoparent'])))[1]);
    //echo "<html><body onload=\" alert('" . $imgurl . "'); \"></body></html>";
    //exit;
    $im = imagecreatefromstring(file_get_contents($imgurl));
    $tlrgb = imagecolorat($im, $_POST['ix'], $_POST['iy']);
    $topclick='';
    if ($tlrgb) {
    //echo '<html><body onload=" alert(4); "></body></html>';
    //exit;
    $tlr = ($tlrgb >> 16) & 0xFF;
    $tlg = ($tlrgb >> 8) & 0xFF;
    $tlb = $tlrgb & 0xFF;
    $blchex=substr(substr($alp,($tlr / 16)),0,1) . substr(substr($alp,($tlr % 16)),0,1) . substr(substr($alp,($tlg / 16)),0,1) . substr(substr($alp,($tlg % 16)),0,1) . substr(substr($alp,($tlb / 16)),0,1) . substr(substr($alp,($tlb % 16)),0,1);
    $isclick=false;
    if (isset($_POST['patparent']) && isset($_POST['imode'])) {
    $pat=str_replace('+',' ',urldecode($_POST['patparent']));
    if ($_POST['imode'] == 'click') {
    if (strpos(str_replace('+',' ',urldecode($_POST['patparent'])), '#' . strtoupper($blchex)) !== false) {
    $topclick=" parent.document.getElementById('" . explode('"', explode(' id="', explode('#' . strtoupper($blchex), $pat)[0])[-1 + sizeof(explode(' id="', explode('#' . strtoupper($blchex), $pat)[0]))] )[0] . "').click(); ";
    } else if (strpos(str_replace('+',' ',urldecode($_POST['patparent'])), '#' . strtolower($blchex)) !== false) {
    $topclick=" parent.document.getElementById('" . explode('"', explode(' id="', explode('#' . strtolower($blchex), $pat)[0])[-1 + sizeof(explode(' id="', explode('#' . strtolower($blchex), $pat)[0]))] )[0] . "').click(); ";
    }
    }
    }
    echo '<html><body onload=" parent.document.getElementById(' . "'lastcol'" . ').title=' . "'" . $_POST['imode'] . "'" . '; parent.document.getElementById(' . "'lastcol'" . ').value=' . "'" . $blchex . "'" . '; ' . $topclick . ' "></body></html>';
    } //else {
    //echo '<html><body onload=" alert(234); "></body></html>';
    //exit;
    //}
    imagedestroy($im);
    exit;
    }

    ?>
  • to be able to offer, “onclick”, a colour coded region (on the map) piece of functionality

… achieving a Clayton’s image map scenario in the changed “fifth draft” Region Picker.


Previous relevant Region Picker Double Click Tutorial is shown below.

Region Picker Double Click Tutorial

Region Picker Double Click Tutorial

You might have gleaned from recent blog posts in the thread leading up to yesterday’s Region Picker Hashtag Navigation Tutorial that, regarding web applications/webpages, even though a few years back we’d have been horrified to say it …

  • we like to use the ondblclick event (especially in a multi-purpose button press way) … and in this context …
  • we don’t mind having to use event.stopPropagation() anymore (ie. we used to not get sleep for days worrying about it) (when you want to stop the event bubbling down to a parent element) …
  • we like to use colour coding … and …
  • we don’t mind window.open (with a third argument and so, on non-mobile is a) popup window usage

But that’s just us. We’ll leave it to you to look into all these more, as far as favour, or not, goes with the search engines.

We see the ondblclick event as being in the same line of thinking as the onclick event is (doh!) in the sense that mobile and non-mobile platforms understand it, as distinct from the divide between the touch “gesture” events and the mouse events. And it may be just me, but web browsers seem better with it these days. Maybe just wishful thinking on that last point, for me, though?!

Today, we’ve got another “multipurpose scenario” for an ondblclick event logic coding …


if (sofar != '') {
if (window.self == window.parent && eval('' + screen.width) > 1000) {
document.getElementById('rmore').innerHTML=prebut + '<button id=mychart ondblclick="event.stopPropagation(); dcdomc();" onclick=domc(); style=background-color:' + iccol + ';>Image Chart Map Chart <br><font size=1>(double click uses new window)</font><br> ... showing ...</button><br><br><p id=myp title="' + sofardetail + '">' + sofar.replace(/\|/g, '<br>');
} else {
document.getElementById('subrmore').innerHTML=prebut + '<button id=mychart ondblclick="event.stopPropagation(); dcdomc();" onclick=domc(); style=background-color:' + iccol + ';>Image Chart Map Chart <br><font size=1>(double click uses new window)</font><br> ... showing ...</button><br><br><p id=myp title="' + sofardetail + '">' + sofar.replace(/\|/g, '<br>');
}
}

… calling new


function dcdomc() {
// <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
//var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
if (document.getElementById('mychart')) {
document.getElementById('mychart').style.backgroundColor='orange';
iccol='orange';
}
if (document.getElementById('mychchart')) {
document.getElementById('mychchart').style.backgroundColor='orange';
jccol='orange';
}
var theurlis='//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar);
dbwo=window.open(theurlis,'_blank','top=50,left=50,width=600,height=600');

document.getElementById('tdleft').style.backgroundImage='URL("' + theurlis + '")';
document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
document.getElementById('tdleft').style.backgroundPosition='right top';
} else {
document.getElementById('tdleft').style.backgroundPosition='center top';
}
document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
opacitytoggling(1.0, 0.1);
setTimeout(function(){ opacitytoggling(1.0, -0.1); }, 2100);
if (!dbdone) {
dbdone=true;
//document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
//document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
//document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
}
window.scrollTo(0,0);
}

… in the changed “fourth draft” Region Picker, where we are building up a menu system tailored to region/country lookups.

Am sure some of you are onto tomorrow’s plan, given today’s work?! We’ll see what tomorrow brings!


Previous relevant Region Picker Geo Chart Integration Tutorial is shown below.

Region Picker Geo Chart Integration Tutorial

Region Picker Geo Chart Integration Tutorial

We’re tickled pink with our integration of yesterday’s Region Picker Primer Tutorial

  • Region Picker web application … into …
  • Geo Chart interfacer

… in that we’ve done better than the natural Geo Chart navigation without the Region Picker, which navigates to a new URL slapped onto the same web browser tab. With our integration we have …

  • Geo Chart interfacer parent “base layer” (with as little as one prompt window required) … and if called upon “above this” …
  • Region Picker web application nested in an “overlay iframe” (with large CSS z-index value covering the whole screen) … asks (for as little as) one more verifying prompt window question … and that same tab window content becomes the final …
  • Geo Chart interfacer result web page

And seeing the country regional codes in play, the possibilities mount up here! The user just includes …

&regionpicker

… in a prompt window answer to start using Region Pickers in their user inputs.

Codewise we needed …

  • to change “second draft” Region Picker … might ask that one verifying prompt window in …

    function gcdomc() {
    var clauses='', popularity='Popularity', extras='';
    // <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
    //var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
    if (document.getElementById('mychchart')) {
    document.getElementById('mychchart').style.backgroundColor='orange';
    jccol='orange';
    }
    if (gwl == '' && document.URL.indexOf('?') != -1) {
    gwl='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?' + document.URL.split('?')[1].split('#')[0].replace(/\&data\=$/g, '');
    if (document.URL.indexOf('popularity=') != -1) {
    popularity=decodeURIComponent(document.URL.split('popularity=')[1].split('&')[0].split('#')[0]);
    }
    }
    var agwl=gwl.split('&');
    for (var iig=1; iig<agwl.length; iig++) {
    if (iig == 1) { clauses=String.fromCharCode(10); }
    if (agwl[iig] != 'data=' && agwl[iig].indexOf('regionpicker') == -1) {
    clauses+='&' + agwl[iig] + String.fromCharCode(10);
    }
    }
    //if (clauses != '') { clauses+=String.fromCharCode(10); }
    gwocont=sofar;
    if (gwocont != '') {
    var xgwocont=null;
    if (1 == 1) {
    var setstuff='';
    if (gwl.indexOf('&data=') == -1) { setstuff='&data='; } else { extras=' (if &data= change prefix that in below appropriately)'; }
    var plis=('' + gwocont).split('|');
    for (var iplis=0; iplis<plis.length; iplis++) {
    if (setstuff == '') {
    setstuff='%20[~' + plis[iplis] + '~,2]';
    } else {
    setstuff+='%20,%20[~' + plis[iplis] + '~,2]';
    }
    }
    try {
    xgwocont=prompt('Please amend as necessary where each of those 2 values are what we have so far assigned for the ' + popularity + ' value for each region/country. As necessary add in any amended ' + clauses + ' ideas too' + extras + '.', setstuff);
    } catch(hjgdf) { xgwocont=null; }
    }
    if (xgwocont == null) { lastgwcont=gwocont; xgwocont=''; }
    gwocont=xgwocont;
    if (xgwocont != '') {
    //alert('gwl=' + gwl);
    var lateragwl=xgwocont.replace(/\ /g, '%20').split('&');
    for (var jig=1; jig<lateragwl.length; jig++) {
    if (gwl.indexOf('&' + lateragwl[jig].split('=')[0] + '=') != -1) {
    gwl=gwl.replace('&' + lateragwl[jig].split('=')[0] + '=' + gwl.split('&' + lateragwl[jig].split('=')[0] + '=')[1].split('&')[0].split('#')[0], '');
    }
    }
    lhref=ourtoolong(gwl + xgwocont.replace(/\ /g, '%20'));
    if (lhref != '') {
    location.href=lhref;
    }
    }
    }
    document.getElementById('tdleft').style.backgroundImage='URL("//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar) + '")';
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
    document.getElementById('tdleft').style.backgroundPosition='right top';
    } else {
    document.getElementById('tdleft').style.backgroundPosition='center top';
    }
    document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (!dbdone) {
    dbdone=true;
    //document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    }
    window.scrollTo(0,0);
    }

    … and …
  • to change geo_chart.php Geo Chart interfacer … calls on the Region Picker in this new Javascript function …
    <?php echo ”

    function winopen(oneurl, twotarget, threerest) {
    var hmore='';
    if (gwl != '' && gwl.indexOf('?') != -1 && oneurl.indexOf(gwl) == -1 && oneurl.indexOf('?') != -1) {
    //alert(oneurl + '&' + gwl.split('?')[1]);
    if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    }
    document.getElementById(twotarget).src=oneurl + '&' + gwl.split('?')[1] + hmore;
    } else if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    document.getElementById(twotarget).src=oneurl + hmore;
    } else {
    document.getElementById(twotarget).src=oneurl;
    }
    return document.getElementById(twotarget);
    }

    “; ?>


Previous relevant Region Picker Primer Tutorial is shown below.

Region Picker Primer Tutorial

Region Picker Primer Tutorial

All the Geo Chart and Image Chart Map Chart work recently, along with Wikipedia ISO-3166 regional and country coding help (thanks), has set us on the road towards a …


Region Picker

… online tool, which we envisage will …

  • initially be a standalone HTML webpage … and later be …
  • integrated into the user input phase of the Geo Chart interfacer

So here we are today with the “first draft” standalone version, where we’ve used Pulldown Menus, you can read more about at HTML/CSS/Javascript Pulldown Menus Javascript Tutorial, to construct a Region/Country ISO code vertical bar delimited list of regions/continents that you can display in an Image Chart Map Chart …

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


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


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


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


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


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

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

Region Picker Popup Menu Tutorial

Region Picker Popup Menu Tutorial

Region Picker Popup Menu Tutorial

Yesterday we left off with …

Am sure some of you are onto tomorrow’s plan, given today’s work?! We’ll see what tomorrow brings!

… and we feel we might have “put the mockers” on ourselves, because, as you may have read, Geo Chart Image Chart is due for deprecation soon. In fact, the regime at the moment is fewer and fewer hours up, and we’ll have to turn our attention to alternatives. But what out there can do those regional views where the map effectively hugs the bounds of the data … brilliant, and we think hard to do with your normal Google Charts suite of software? As well as the image element result, even though we need to try out the “ready event” normal Google Charts “print” way to achieve this. So much more useful than involving Javascript. And more fun to work with too, it being a conduit to HTML canvas usage.

Anyway, here we are late in our day with a window of opportunity, and While You See a Chance, Take It we reckon.

And what yesterday’s Region Picker Double Click Tutorial gave us a good framework for is PHP method=GET and PHP method=POST uses of argument returnxytoparent along with our new GD imagecolorat function friend in the changed image_chart.php Google Chart Image Chart Map Chart interfacer

  • double click button to create popup window with same look as background image version …
  • but now that call, wraps the URL that it used to call in an encoded returnxytoparent argument guise, using …
    <?php

    if (isset($_GET['returnxytoparent'])) {
    $imgurl=str_replace('+',' ',urldecode($_GET['returnxytoparent']));
    echo "<html>
    <head>
    <style> * { margin:0 0 0 0; padding:0 0 0 0; } </style>
    <scr" . "ipt type=text/javascript>
    var x=0, y=0, isclear=true;

    function filloutform(e) {

    e = e || window.event;
    e.preventDefault();

    if (e.touches) {
    if (e.touches[0].pageX) {
    x = e.touches[0].pageX;
    y = e.touches[0].pageY;
    } else {
    x = e.touches[0].clientX;
    y = e.touches[0].clientY;
    }
    console.log('pos3=' + pos3 + ',pos4=' + pos4);
    } else if (e.clientX || e.clientY) {
    x = e.clientX;
    y = e.clientY;
    } else {
    x = e.pageX;
    x = e.pageY;
    }

    if (x > 0) {
    document.getElementById('ix').value='' + x;
    document.getElementById('iy').value='' + y;
    if (document.getElementById('imode').value == 'click') {
    //document.getElementById('blastcol').click();
    document.getElementById('myform').submit();
    }
    }
    }

    function gmenu(rcodeis, erdescis) {
    var rdescis=decodeURIComponent(erdescis);
    if (rcodeis.trim() != '' && rdescis.trim() != '') {
    var rans=prompt('What do you want to do with region ' + rdescis + '? ' + String.fromCharCode(10) + String.fromCharCode(10) + 'W - Wikipedia look up ' + String.fromCharCode(10) + 'Y - YouTube look up ' + String.fromCharCode(10) + 'G - Google look up ' + String.fromCharCode(10) + String.fromCharCode(10), '');
    if (rans == null) { rans=''; }
    if ((rans + ' ').toUpperCase().substring(0,1) == 'W') {
    window.open('//wikipedia.org/wiki/' + encodeURIComponent(rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')).replace(/\%20/g,'_'),'_blank','top=10,left=10,width=600,height=600');
    } else if ((rans + ' ').toUpperCase().substring(0,1) == 'Y') {
    window.open('//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=' + encodeURIComponent(' ' + rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')),'_blank','top=10,left=10,width=600,height=600');
    } else if ((rans + ' ').toUpperCase().substring(0,1) == 'G') {
    window.open('//www.google.com/search?q=' + encodeURIComponent(rdescis.replace(/\ \(/g,', ').replace(/\)$/g,'')) + '&tbm=isch','_blank','top=10,left=10,width=600,height=600');
    }
    }
    }

    </scr" . "ipt>
    </head>
    <body onclick=\" document.getElementById('lastcol').value=''; isclear=false; document.getElementById('imode').value='click'; filloutform(event);\" onload=\" if (window.opener) { document.getElementById('myp').innerHTML=window.opener.document.getElementById('myp').innerHTML; document.getElementById('patparent').value=window.opener.document.getElementById('myp').innerHTML; } \">
    <img id=ici onmouseover=\" if (isclear) { document.getElementById('imode').value='mouseover'; filloutform(event); }\" src='" . $imgurl . "' title='Optionally click in relevant region for menu'></img>
    <input title='' id=lastcol value='' type=hidden></input>
    <form id=myform onsubmit=\" return true;\" style=display:none; target=iflastcol method=POST action=./image_chart.php>
    <input name=returnxytoparent id=returnxytoparent value='" . $imgurl . "' type=hidden></input>
    <input name=ix id=ix value='0' type=hidden></input>
    <input name=iy id=iy value='0' type=hidden></input>
    <input name=imode id=imode value='mouseover' type=hidden></input>
    <input name=patparent id=patparent value='' type=hidden></input>
    <input type=submit style=display:none; id=blastcol></input>
    </form>
    <iframe name=iflastcol id=iflastcol style=display:none; src=./image_chart.php></iframe>
    <p id=myp style=display:none;></p>
    </body>
    </html>";
    exit;
    } else if (isset($_POST['returnxytoparent']) && isset($_POST['ix']) && isset($_POST['iy'])) {
    $alp="0123456789ABCDEF"; //=map&chs=600x450&
    //echo "<html><body onload=\" alert('" . str_replace('+',' ',urldecode($_POST['returnxytoparent'])) . "'); \"></body></html>";
    //exit;
    $imgurl='http://chart.googleapis.com/chart?' . str_replace('=map&chld=', '=map&chs=455x350&chld=', explode('?', str_replace('+',' ',urldecode($_POST['returnxytoparent'])))[1]);
    //echo "<html><body onload=\" alert('" . $imgurl . "'); \"></body></html>";
    //exit;
    $im = imagecreatefromstring(file_get_contents($imgurl));
    $tlrgb = imagecolorat($im, $_POST['ix'], $_POST['iy']);
    $topclick='';
    if ($tlrgb) {
    //echo '<html><body onload=" alert(4); "></body></html>';
    //exit;
    $tlr = ($tlrgb >> 16) & 0xFF;
    $tlg = ($tlrgb >> 8) & 0xFF;
    $tlb = $tlrgb & 0xFF;
    $blchex=substr(substr($alp,($tlr / 16)),0,1) . substr(substr($alp,($tlr % 16)),0,1) . substr(substr($alp,($tlg / 16)),0,1) . substr(substr($alp,($tlg % 16)),0,1) . substr(substr($alp,($tlb / 16)),0,1) . substr(substr($alp,($tlb % 16)),0,1);
    $isclick=false;
    if (isset($_POST['patparent']) && isset($_POST['imode'])) {
    $pat=str_replace('+',' ',urldecode($_POST['patparent']));
    if ($_POST['imode'] == 'click') {
    if (strpos(str_replace('+',' ',urldecode($_POST['patparent'])), '#' . strtoupper($blchex)) !== false) {
    $topclick=" parent.document.getElementById('" . explode('"', explode(' id="', explode('#' . strtoupper($blchex), $pat)[0])[-1 + sizeof(explode(' id="', explode('#' . strtoupper($blchex), $pat)[0]))] )[0] . "').click(); ";
    } else if (strpos(str_replace('+',' ',urldecode($_POST['patparent'])), '#' . strtolower($blchex)) !== false) {
    $topclick=" parent.document.getElementById('" . explode('"', explode(' id="', explode('#' . strtolower($blchex), $pat)[0])[-1 + sizeof(explode(' id="', explode('#' . strtolower($blchex), $pat)[0]))] )[0] . "').click(); ";
    }
    }
    }
    echo '<html><body onload=" parent.document.getElementById(' . "'lastcol'" . ').title=' . "'" . $_POST['imode'] . "'" . '; parent.document.getElementById(' . "'lastcol'" . ').value=' . "'" . $blchex . "'" . '; ' . $topclick . ' "></body></html>';
    } //else {
    //echo '<html><body onload=" alert(234); "></body></html>';
    //exit;
    //}
    imagedestroy($im);
    exit;
    }

    ?>
  • to be able to offer, “onclick”, a colour coded region (on the map) piece of functionality

… achieving a Clayton’s image map scenario in the changed “fifth draft” Region Picker.


Previous relevant Region Picker Double Click Tutorial is shown below.

Region Picker Double Click Tutorial

Region Picker Double Click Tutorial

You might have gleaned from recent blog posts in the thread leading up to yesterday’s Region Picker Hashtag Navigation Tutorial that, regarding web applications/webpages, even though a few years back we’d have been horrified to say it …

  • we like to use the ondblclick event (especially in a multi-purpose button press way) … and in this context …
  • we don’t mind having to use event.stopPropagation() anymore (ie. we used to not get sleep for days worrying about it) (when you want to stop the event bubbling down to a parent element) …
  • we like to use colour coding … and …
  • we don’t mind window.open (with a third argument and so, on non-mobile is a) popup window usage

But that’s just us. We’ll leave it to you to look into all these more, as far as favour, or not, goes with the search engines.

We see the ondblclick event as being in the same line of thinking as the onclick event is (doh!) in the sense that mobile and non-mobile platforms understand it, as distinct from the divide between the touch “gesture” events and the mouse events. And it may be just me, but web browsers seem better with it these days. Maybe just wishful thinking on that last point, for me, though?!

Today, we’ve got another “multipurpose scenario” for an ondblclick event logic coding …


if (sofar != '') {
if (window.self == window.parent && eval('' + screen.width) > 1000) {
document.getElementById('rmore').innerHTML=prebut + '<button id=mychart ondblclick="event.stopPropagation(); dcdomc();" onclick=domc(); style=background-color:' + iccol + ';>Image Chart Map Chart <br><font size=1>(double click uses new window)</font><br> ... showing ...</button><br><br><p id=myp title="' + sofardetail + '">' + sofar.replace(/\|/g, '<br>');
} else {
document.getElementById('subrmore').innerHTML=prebut + '<button id=mychart ondblclick="event.stopPropagation(); dcdomc();" onclick=domc(); style=background-color:' + iccol + ';>Image Chart Map Chart <br><font size=1>(double click uses new window)</font><br> ... showing ...</button><br><br><p id=myp title="' + sofardetail + '">' + sofar.replace(/\|/g, '<br>');
}
}

… calling new


function dcdomc() {
// <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
//var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
if (document.getElementById('mychart')) {
document.getElementById('mychart').style.backgroundColor='orange';
iccol='orange';
}
if (document.getElementById('mychchart')) {
document.getElementById('mychchart').style.backgroundColor='orange';
jccol='orange';
}
var theurlis='//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar);
dbwo=window.open(theurlis,'_blank','top=50,left=50,width=600,height=600');

document.getElementById('tdleft').style.backgroundImage='URL("' + theurlis + '")';
document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
document.getElementById('tdleft').style.backgroundPosition='right top';
} else {
document.getElementById('tdleft').style.backgroundPosition='center top';
}
document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
opacitytoggling(1.0, 0.1);
setTimeout(function(){ opacitytoggling(1.0, -0.1); }, 2100);
if (!dbdone) {
dbdone=true;
//document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
//document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
//document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
}
window.scrollTo(0,0);
}

… in the changed “fourth draft” Region Picker, where we are building up a menu system tailored to region/country lookups.

Am sure some of you are onto tomorrow’s plan, given today’s work?! We’ll see what tomorrow brings!


Previous relevant Region Picker Geo Chart Integration Tutorial is shown below.

Region Picker Geo Chart Integration Tutorial

Region Picker Geo Chart Integration Tutorial

We’re tickled pink with our integration of yesterday’s Region Picker Primer Tutorial

  • Region Picker web application … into …
  • Geo Chart interfacer

… in that we’ve done better than the natural Geo Chart navigation without the Region Picker, which navigates to a new URL slapped onto the same web browser tab. With our integration we have …

  • Geo Chart interfacer parent “base layer” (with as little as one prompt window required) … and if called upon “above this” …
  • Region Picker web application nested in an “overlay iframe” (with large CSS z-index value covering the whole screen) … asks (for as little as) one more verifying prompt window question … and that same tab window content becomes the final …
  • Geo Chart interfacer result web page

And seeing the country regional codes in play, the possibilities mount up here! The user just includes …

&regionpicker

… in a prompt window answer to start using Region Pickers in their user inputs.

Codewise we needed …

  • to change “second draft” Region Picker … might ask that one verifying prompt window in …

    function gcdomc() {
    var clauses='', popularity='Popularity', extras='';
    // <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
    //var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
    if (document.getElementById('mychchart')) {
    document.getElementById('mychchart').style.backgroundColor='orange';
    jccol='orange';
    }
    if (gwl == '' && document.URL.indexOf('?') != -1) {
    gwl='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?' + document.URL.split('?')[1].split('#')[0].replace(/\&data\=$/g, '');
    if (document.URL.indexOf('popularity=') != -1) {
    popularity=decodeURIComponent(document.URL.split('popularity=')[1].split('&')[0].split('#')[0]);
    }
    }
    var agwl=gwl.split('&');
    for (var iig=1; iig<agwl.length; iig++) {
    if (iig == 1) { clauses=String.fromCharCode(10); }
    if (agwl[iig] != 'data=' && agwl[iig].indexOf('regionpicker') == -1) {
    clauses+='&' + agwl[iig] + String.fromCharCode(10);
    }
    }
    //if (clauses != '') { clauses+=String.fromCharCode(10); }
    gwocont=sofar;
    if (gwocont != '') {
    var xgwocont=null;
    if (1 == 1) {
    var setstuff='';
    if (gwl.indexOf('&data=') == -1) { setstuff='&data='; } else { extras=' (if &data= change prefix that in below appropriately)'; }
    var plis=('' + gwocont).split('|');
    for (var iplis=0; iplis<plis.length; iplis++) {
    if (setstuff == '') {
    setstuff='%20[~' + plis[iplis] + '~,2]';
    } else {
    setstuff+='%20,%20[~' + plis[iplis] + '~,2]';
    }
    }
    try {
    xgwocont=prompt('Please amend as necessary where each of those 2 values are what we have so far assigned for the ' + popularity + ' value for each region/country. As necessary add in any amended ' + clauses + ' ideas too' + extras + '.', setstuff);
    } catch(hjgdf) { xgwocont=null; }
    }
    if (xgwocont == null) { lastgwcont=gwocont; xgwocont=''; }
    gwocont=xgwocont;
    if (xgwocont != '') {
    //alert('gwl=' + gwl);
    var lateragwl=xgwocont.replace(/\ /g, '%20').split('&');
    for (var jig=1; jig<lateragwl.length; jig++) {
    if (gwl.indexOf('&' + lateragwl[jig].split('=')[0] + '=') != -1) {
    gwl=gwl.replace('&' + lateragwl[jig].split('=')[0] + '=' + gwl.split('&' + lateragwl[jig].split('=')[0] + '=')[1].split('&')[0].split('#')[0], '');
    }
    }
    lhref=ourtoolong(gwl + xgwocont.replace(/\ /g, '%20'));
    if (lhref != '') {
    location.href=lhref;
    }
    }
    }
    document.getElementById('tdleft').style.backgroundImage='URL("//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar) + '")';
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
    document.getElementById('tdleft').style.backgroundPosition='right top';
    } else {
    document.getElementById('tdleft').style.backgroundPosition='center top';
    }
    document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (!dbdone) {
    dbdone=true;
    //document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    }
    window.scrollTo(0,0);
    }

    … and …
  • to change geo_chart.php Geo Chart interfacer … calls on the Region Picker in this new Javascript function …
    <?php echo ”

    function winopen(oneurl, twotarget, threerest) {
    var hmore='';
    if (gwl != '' && gwl.indexOf('?') != -1 && oneurl.indexOf(gwl) == -1 && oneurl.indexOf('?') != -1) {
    //alert(oneurl + '&' + gwl.split('?')[1]);
    if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    }
    document.getElementById(twotarget).src=oneurl + '&' + gwl.split('?')[1] + hmore;
    } else if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    document.getElementById(twotarget).src=oneurl + hmore;
    } else {
    document.getElementById(twotarget).src=oneurl;
    }
    return document.getElementById(twotarget);
    }

    “; ?>


Previous relevant Region Picker Primer Tutorial is shown below.

Region Picker Primer Tutorial

Region Picker Primer Tutorial

All the Geo Chart and Image Chart Map Chart work recently, along with Wikipedia ISO-3166 regional and country coding help (thanks), has set us on the road towards a …


Region Picker

… online tool, which we envisage will …

  • initially be a standalone HTML webpage … and later be …
  • integrated into the user input phase of the Geo Chart interfacer

So here we are today with the “first draft” standalone version, where we’ve used Pulldown Menus, you can read more about at HTML/CSS/Javascript Pulldown Menus Javascript Tutorial, to construct a Region/Country ISO code vertical bar delimited list of regions/continents that you can display in an Image Chart Map Chart …

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


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


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


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


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

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

Region Picker Double Click Tutorial

Region Picker Double Click Tutorial

Region Picker Double Click Tutorial

You might have gleaned from recent blog posts in the thread leading up to yesterday’s Region Picker Hashtag Navigation Tutorial that, regarding web applications/webpages, even though a few years back we’d have been horrified to say it …

  • we like to use the ondblclick event (especially in a multi-purpose button press way) … and in this context …
  • we don’t mind having to use event.stopPropagation() anymore (ie. we used to not get sleep for days worrying about it) (when you want to stop the event bubbling down to a parent element) …
  • we like to use colour coding … and …
  • we don’t mind window.open (with a third argument and so, on non-mobile is a) popup window usage

But that’s just us. We’ll leave it to you to look into all these more, as far as favour, or not, goes with the search engines.

We see the ondblclick event as being in the same line of thinking as the onclick event is (doh!) in the sense that mobile and non-mobile platforms understand it, as distinct from the divide between the touch “gesture” events and the mouse events. And it may be just me, but web browsers seem better with it these days. Maybe just wishful thinking on that last point, for me, though?!

Today, we’ve got another “multipurpose scenario” for an ondblclick event logic coding …


if (sofar != '') {
if (window.self == window.parent && eval('' + screen.width) > 1000) {
document.getElementById('rmore').innerHTML=prebut + '<button id=mychart ondblclick="event.stopPropagation(); dcdomc();" onclick=domc(); style=background-color:' + iccol + ';>Image Chart Map Chart <br><font size=1>(double click uses new window)</font><br> ... showing ...</button><br><br><p id=myp title="' + sofardetail + '">' + sofar.replace(/\|/g, '<br>');
} else {
document.getElementById('subrmore').innerHTML=prebut + '<button id=mychart ondblclick="event.stopPropagation(); dcdomc();" onclick=domc(); style=background-color:' + iccol + ';>Image Chart Map Chart <br><font size=1>(double click uses new window)</font><br> ... showing ...</button><br><br><p id=myp title="' + sofardetail + '">' + sofar.replace(/\|/g, '<br>');
}
}

… calling new


function dcdomc() {
// <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
//var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
if (document.getElementById('mychart')) {
document.getElementById('mychart').style.backgroundColor='orange';
iccol='orange';
}
if (document.getElementById('mychchart')) {
document.getElementById('mychchart').style.backgroundColor='orange';
jccol='orange';
}
var theurlis='//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar);
dbwo=window.open(theurlis,'_blank','top=50,left=50,width=600,height=600');

document.getElementById('tdleft').style.backgroundImage='URL("' + theurlis + '")';
document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
document.getElementById('tdleft').style.backgroundPosition='right top';
} else {
document.getElementById('tdleft').style.backgroundPosition='center top';
}
document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
opacitytoggling(1.0, 0.1);
setTimeout(function(){ opacitytoggling(1.0, -0.1); }, 2100);
if (!dbdone) {
dbdone=true;
//document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
//document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
//document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
}
window.scrollTo(0,0);
}

… in the changed “fourth draft” Region Picker, where we are building up a menu system tailored to region/country lookups.

Am sure some of you are onto tomorrow’s plan, given today’s work?! We’ll see what tomorrow brings!


Previous relevant Region Picker Geo Chart Integration Tutorial is shown below.

Region Picker Geo Chart Integration Tutorial

Region Picker Geo Chart Integration Tutorial

We’re tickled pink with our integration of yesterday’s Region Picker Primer Tutorial

  • Region Picker web application … into …
  • Geo Chart interfacer

… in that we’ve done better than the natural Geo Chart navigation without the Region Picker, which navigates to a new URL slapped onto the same web browser tab. With our integration we have …

  • Geo Chart interfacer parent “base layer” (with as little as one prompt window required) … and if called upon “above this” …
  • Region Picker web application nested in an “overlay iframe” (with large CSS z-index value covering the whole screen) … asks (for as little as) one more verifying prompt window question … and that same tab window content becomes the final …
  • Geo Chart interfacer result web page

And seeing the country regional codes in play, the possibilities mount up here! The user just includes …

&regionpicker

… in a prompt window answer to start using Region Pickers in their user inputs.

Codewise we needed …

  • to change “second draft” Region Picker … might ask that one verifying prompt window in …

    function gcdomc() {
    var clauses='', popularity='Popularity', extras='';
    // <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
    //var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
    if (document.getElementById('mychchart')) {
    document.getElementById('mychchart').style.backgroundColor='orange';
    jccol='orange';
    }
    if (gwl == '' && document.URL.indexOf('?') != -1) {
    gwl='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?' + document.URL.split('?')[1].split('#')[0].replace(/\&data\=$/g, '');
    if (document.URL.indexOf('popularity=') != -1) {
    popularity=decodeURIComponent(document.URL.split('popularity=')[1].split('&')[0].split('#')[0]);
    }
    }
    var agwl=gwl.split('&');
    for (var iig=1; iig<agwl.length; iig++) {
    if (iig == 1) { clauses=String.fromCharCode(10); }
    if (agwl[iig] != 'data=' && agwl[iig].indexOf('regionpicker') == -1) {
    clauses+='&' + agwl[iig] + String.fromCharCode(10);
    }
    }
    //if (clauses != '') { clauses+=String.fromCharCode(10); }
    gwocont=sofar;
    if (gwocont != '') {
    var xgwocont=null;
    if (1 == 1) {
    var setstuff='';
    if (gwl.indexOf('&data=') == -1) { setstuff='&data='; } else { extras=' (if &data= change prefix that in below appropriately)'; }
    var plis=('' + gwocont).split('|');
    for (var iplis=0; iplis<plis.length; iplis++) {
    if (setstuff == '') {
    setstuff='%20[~' + plis[iplis] + '~,2]';
    } else {
    setstuff+='%20,%20[~' + plis[iplis] + '~,2]';
    }
    }
    try {
    xgwocont=prompt('Please amend as necessary where each of those 2 values are what we have so far assigned for the ' + popularity + ' value for each region/country. As necessary add in any amended ' + clauses + ' ideas too' + extras + '.', setstuff);
    } catch(hjgdf) { xgwocont=null; }
    }
    if (xgwocont == null) { lastgwcont=gwocont; xgwocont=''; }
    gwocont=xgwocont;
    if (xgwocont != '') {
    //alert('gwl=' + gwl);
    var lateragwl=xgwocont.replace(/\ /g, '%20').split('&');
    for (var jig=1; jig<lateragwl.length; jig++) {
    if (gwl.indexOf('&' + lateragwl[jig].split('=')[0] + '=') != -1) {
    gwl=gwl.replace('&' + lateragwl[jig].split('=')[0] + '=' + gwl.split('&' + lateragwl[jig].split('=')[0] + '=')[1].split('&')[0].split('#')[0], '');
    }
    }
    lhref=ourtoolong(gwl + xgwocont.replace(/\ /g, '%20'));
    if (lhref != '') {
    location.href=lhref;
    }
    }
    }
    document.getElementById('tdleft').style.backgroundImage='URL("//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar) + '")';
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
    document.getElementById('tdleft').style.backgroundPosition='right top';
    } else {
    document.getElementById('tdleft').style.backgroundPosition='center top';
    }
    document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (!dbdone) {
    dbdone=true;
    //document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    }
    window.scrollTo(0,0);
    }

    … and …
  • to change geo_chart.php Geo Chart interfacer … calls on the Region Picker in this new Javascript function …
    <?php echo ”

    function winopen(oneurl, twotarget, threerest) {
    var hmore='';
    if (gwl != '' && gwl.indexOf('?') != -1 && oneurl.indexOf(gwl) == -1 && oneurl.indexOf('?') != -1) {
    //alert(oneurl + '&' + gwl.split('?')[1]);
    if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    }
    document.getElementById(twotarget).src=oneurl + '&' + gwl.split('?')[1] + hmore;
    } else if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    document.getElementById(twotarget).src=oneurl + hmore;
    } else {
    document.getElementById(twotarget).src=oneurl;
    }
    return document.getElementById(twotarget);
    }

    “; ?>


Previous relevant Region Picker Primer Tutorial is shown below.

Region Picker Primer Tutorial

Region Picker Primer Tutorial

All the Geo Chart and Image Chart Map Chart work recently, along with Wikipedia ISO-3166 regional and country coding help (thanks), has set us on the road towards a …


Region Picker

… online tool, which we envisage will …

  • initially be a standalone HTML webpage … and later be …
  • integrated into the user input phase of the Geo Chart interfacer

So here we are today with the “first draft” standalone version, where we’ve used Pulldown Menus, you can read more about at HTML/CSS/Javascript Pulldown Menus Javascript Tutorial, to construct a Region/Country ISO code vertical bar delimited list of regions/continents that you can display in an Image Chart Map Chart …

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


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


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


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

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

Region Picker Hashtag Navigation Tutorial

Region Picker Hashtag Navigation Tutorial

Region Picker Hashtag Navigation Tutorial

Isn’t yesterday’s Region Picker Geo Chart Integration Tutorial already full of hashtag navigation? Yes, very much so. There are lots of areas where we try to control scrolling positions and background image positions, with varying degrees of success, the narrower the screen width, the harder it is to achieve a happy scenario for every user. Hence, today’s ….

  • new dynamic opacity changes …

    function opacitytoggling(morestartingat, less) {
    var doct='here at opacitytoggling ... ';
    if (Math.abs(eval('' + morestartingat) - 1.0) < 0.015) {
    if (less < 0) {
    if (document.getElementById('more')) {
    document.getElementById('more').style.opacity='0.98';
    doct+='0.98';
    }
    if (document.getElementById('subrmore')) {
    document.getElementById('subrmore').style.opacity='0.98';
    doct+='0.98';
    }
    nextless=less;
    //document.title=doct;
    setTimeout(function(){ opacitytoggling(0.98, nextless); }, 400);
    } else {
    nextless=-0.101;
    if (document.getElementById('more')) {
    document.getElementById('more').style.opacity='1.0';
    doct+='1.0';
    }
    if (document.getElementById('subrmore')) {
    document.getElementById('subrmore').style.opacity='1.0';
    doct+='1.0';
    }
    }
    // document.title=doct;
    } else if (eval(Math.abs(eval('' + nextless)) - 0.1) < 0.0004) {
    nextless=less;
    nextval=eval(less + eval('' + morestartingat));
    if (nextval < 0.0) {
    nextless=0.1;
    nextval=eval(eval('' + morestartingat) + 0.1);
    if (document.getElementById('more')) {
    document.getElementById('more').style.opacity='' + (nextval == 0.08 ? 0.0 : nextval);
    doct+=nextval;
    }
    if (document.getElementById('subrmore')) {
    document.getElementById('subrmore').style.opacity='' + (nextval == 0.08 ? 0.0 : nextval);
    doct+=nextval;
    }
    //document.title=doct;
    if (nextval == 0.18) {
    setTimeout(function(){ opacitytoggling(nextval, nextless); }, 12000);
    } else {
    setTimeout(function(){ opacitytoggling(nextval, nextless); }, 2000);
    }
    } else if (nextval > 1.0) {
    nextless=-0.1;
    nextval=eval(-0.1 + eval('' + morestarting));
    if (document.getElementById('more')) {
    document.getElementById('more').style.opacity='' + (nextval == 0.08 ? 0.0 : nextval);
    }
    if (document.getElementById('subrmore')) {
    document.getElementById('subrmore').style.opacity='' + (nextval == 0.08 ? 0.0 : nextval);
    doct+=nextval;
    }
    //document.title=doct;
    if (nextval == 0.18) {
    setTimeout(function(){ opacitytoggling(nextval, nextless); }, 12000);
    } else {
    setTimeout(function(){ opacitytoggling(nextval, nextless); }, 2000);
    }
    } else {
    if (document.getElementById('more')) {
    document.getElementById('more').style.opacity='' + (nextval == 0.08 ? 0.0 : nextval);
    doct+=nextval;
    }
    if (document.getElementById('subrmore')) {
    document.getElementById('subrmore').style.opacity='' + (nextval == 0.08 ? 0.0 : nextval);
    doct+=nextval;
    }
    //document.title=doct;
    if (nextval == 0.18) {
    setTimeout(function(){ opacitytoggling(nextval, nextless); }, 12000);
    } else {
    setTimeout(function(){ opacitytoggling(nextval, nextless); }, 2000);
    }
    }
    } //else {
    //document.title=doct;
    //}

    }

    … to help see through to any backgrounded image charts … and adding to hashtag based functionality …
  • a new letter based set of “a” hashtag navigation links to be able to navigate down to the first country with a letter start

    for(var xi=0; xi<xelms.length; xi++){
    if (eval(('' + xelms[xi].id).length) == 3) {
    if (('' + xelms[xi].innerHTML).substring(0).substring(0,1) >= nexttodo) {
    ournext=('' + xelms[xi].innerHTML).substring(0).substring(0,1)
    //alert('nexttodo=' + nexttodo + ' andpleasedonotbeequalveryoften ournext=' + ournext + ' and ' + xelms[xi].id);
    while (nexttodo < ournext) {
    nextih+=' <a style=color:blue;z-index:786; href="#' + xelms[xi].id + '">' + nexttodo + '</a>';
    nexttodo=String.fromCharCode(1 + nexttodo.charCodeAt(0));
    //alert('Nexttodo=' + nexttodo + ' and ournext=' + ournext + ' and ' + xelms[xi].id);
    }
    if (nexttodo <= 'Z') {
    nextih+=' <a style=color:blue;z-index:786; href="#' + xelms[xi].id + '">' + nexttodo + '</a>';
    nexttodo=String.fromCharCode(1 + nexttodo.charCodeAt(0));
    }
    } //else {
    //alert('no for nexttodo=' + nexttodo + ' and ournext=' + ournext + ' and ' + xelms[xi].id);
    //}
    }

    // rest of usual code in the for loop follows
    }

    … and, a nuance, sure, but …
  • now “and that same tab window content becomes the final” is still the case but if the URL is small enough we now go

    top.location.href=lhref;

    … so that a user might have a chance for their own retweaks back at the web browser’s address bar

Small changes, but fixes to some of the annoyances in the changed “third draft” Region Picker.


Previous relevant Region Picker Geo Chart Integration Tutorial is shown below.

Region Picker Geo Chart Integration Tutorial

Region Picker Geo Chart Integration Tutorial

We’re tickled pink with our integration of yesterday’s Region Picker Primer Tutorial

  • Region Picker web application … into …
  • Geo Chart interfacer

… in that we’ve done better than the natural Geo Chart navigation without the Region Picker, which navigates to a new URL slapped onto the same web browser tab. With our integration we have …

  • Geo Chart interfacer parent “base layer” (with as little as one prompt window required) … and if called upon “above this” …
  • Region Picker web application nested in an “overlay iframe” (with large CSS z-index value covering the whole screen) … asks (for as little as) one more verifying prompt window question … and that same tab window content becomes the final …
  • Geo Chart interfacer result web page

And seeing the country regional codes in play, the possibilities mount up here! The user just includes …

&regionpicker

… in a prompt window answer to start using Region Pickers in their user inputs.

Codewise we needed …

  • to change “second draft” Region Picker … might ask that one verifying prompt window in …

    function gcdomc() {
    var clauses='', popularity='Popularity', extras='';
    // <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
    //var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
    if (document.getElementById('mychchart')) {
    document.getElementById('mychchart').style.backgroundColor='orange';
    jccol='orange';
    }
    if (gwl == '' && document.URL.indexOf('?') != -1) {
    gwl='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?' + document.URL.split('?')[1].split('#')[0].replace(/\&data\=$/g, '');
    if (document.URL.indexOf('popularity=') != -1) {
    popularity=decodeURIComponent(document.URL.split('popularity=')[1].split('&')[0].split('#')[0]);
    }
    }
    var agwl=gwl.split('&');
    for (var iig=1; iig<agwl.length; iig++) {
    if (iig == 1) { clauses=String.fromCharCode(10); }
    if (agwl[iig] != 'data=' && agwl[iig].indexOf('regionpicker') == -1) {
    clauses+='&' + agwl[iig] + String.fromCharCode(10);
    }
    }
    //if (clauses != '') { clauses+=String.fromCharCode(10); }
    gwocont=sofar;
    if (gwocont != '') {
    var xgwocont=null;
    if (1 == 1) {
    var setstuff='';
    if (gwl.indexOf('&data=') == -1) { setstuff='&data='; } else { extras=' (if &data= change prefix that in below appropriately)'; }
    var plis=('' + gwocont).split('|');
    for (var iplis=0; iplis<plis.length; iplis++) {
    if (setstuff == '') {
    setstuff='%20[~' + plis[iplis] + '~,2]';
    } else {
    setstuff+='%20,%20[~' + plis[iplis] + '~,2]';
    }
    }
    try {
    xgwocont=prompt('Please amend as necessary where each of those 2 values are what we have so far assigned for the ' + popularity + ' value for each region/country. As necessary add in any amended ' + clauses + ' ideas too' + extras + '.', setstuff);
    } catch(hjgdf) { xgwocont=null; }
    }
    if (xgwocont == null) { lastgwcont=gwocont; xgwocont=''; }
    gwocont=xgwocont;
    if (xgwocont != '') {
    //alert('gwl=' + gwl);
    var lateragwl=xgwocont.replace(/\ /g, '%20').split('&');
    for (var jig=1; jig<lateragwl.length; jig++) {
    if (gwl.indexOf('&' + lateragwl[jig].split('=')[0] + '=') != -1) {
    gwl=gwl.replace('&' + lateragwl[jig].split('=')[0] + '=' + gwl.split('&' + lateragwl[jig].split('=')[0] + '=')[1].split('&')[0].split('#')[0], '');
    }
    }
    lhref=ourtoolong(gwl + xgwocont.replace(/\ /g, '%20'));
    if (lhref != '') {
    location.href=lhref;
    }
    }
    }
    document.getElementById('tdleft').style.backgroundImage='URL("//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar) + '")';
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
    document.getElementById('tdleft').style.backgroundPosition='right top';
    } else {
    document.getElementById('tdleft').style.backgroundPosition='center top';
    }
    document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (!dbdone) {
    dbdone=true;
    //document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    }
    window.scrollTo(0,0);
    }

    … and …
  • to change geo_chart.php Geo Chart interfacer … calls on the Region Picker in this new Javascript function …
    <?php echo ”

    function winopen(oneurl, twotarget, threerest) {
    var hmore='';
    if (gwl != '' && gwl.indexOf('?') != -1 && oneurl.indexOf(gwl) == -1 && oneurl.indexOf('?') != -1) {
    //alert(oneurl + '&' + gwl.split('?')[1]);
    if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    }
    document.getElementById(twotarget).src=oneurl + '&' + gwl.split('?')[1] + hmore;
    } else if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    document.getElementById(twotarget).src=oneurl + hmore;
    } else {
    document.getElementById(twotarget).src=oneurl;
    }
    return document.getElementById(twotarget);
    }

    “; ?>


Previous relevant Region Picker Primer Tutorial is shown below.

Region Picker Primer Tutorial

Region Picker Primer Tutorial

All the Geo Chart and Image Chart Map Chart work recently, along with Wikipedia ISO-3166 regional and country coding help (thanks), has set us on the road towards a …


Region Picker

… online tool, which we envisage will …

  • initially be a standalone HTML webpage … and later be …
  • integrated into the user input phase of the Geo Chart interfacer

So here we are today with the “first draft” standalone version, where we’ve used Pulldown Menus, you can read more about at HTML/CSS/Javascript Pulldown Menus Javascript Tutorial, to construct a Region/Country ISO code vertical bar delimited list of regions/continents that you can display in an Image Chart Map Chart …

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


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


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

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

Region Picker Geo Chart Integration Tutorial

Region Picker Geo Chart Integration Tutorial

Region Picker Geo Chart Integration Tutorial

We’re tickled pink with our integration of yesterday’s Region Picker Primer Tutorial

  • Region Picker web application … into …
  • Geo Chart interfacer

… in that we’ve done better than the natural Geo Chart navigation without the Region Picker, which navigates to a new URL slapped onto the same web browser tab. With our integration we have …

  • Geo Chart interfacer parent “base layer” (with as little as one prompt window required) … and if called upon “above this” …
  • Region Picker web application nested in an “overlay iframe” (with large CSS z-index value covering the whole screen) … asks (for as little as) one more verifying prompt window question … and that same tab window content becomes the final …
  • Geo Chart interfacer result web page

And seeing the country regional codes in play, the possibilities mount up here! The user just includes …

&regionpicker

… in a prompt window answer to start using Region Pickers in their user inputs.

Codewise we needed …

  • to change “second draft” Region Picker … might ask that one verifying prompt window in …

    function gcdomc() {
    var clauses='', popularity='Popularity', extras='';
    // <img data-onload="canvit(this);" onclick="if (atstart) { normalcall=false; ask(null); normalcall=true; atstart=false; } else { ask(event); }" title="Google Chart Image Chart " +="" cname="" '="" image="" ...="" to="" modify,="" please="" click'="" id="myvenn" width="455" height="350" data-style="display:block;width:455px;height:743px;background:url(//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&ufr=_4179574);background-size:cover;" src="//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=AU-NT%7CAU-NSW%7CAU-SA%7CNZ%7CIN&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274&ufr=_4179574" usemap="#mymap">
    //var x=prompt('www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274', 'www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274');
    if (document.getElementById('mychchart')) {
    document.getElementById('mychchart').style.backgroundColor='orange';
    jccol='orange';
    }
    if (gwl == '' && document.URL.indexOf('?') != -1) {
    gwl='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?' + document.URL.split('?')[1].split('#')[0].replace(/\&data\=$/g, '');
    if (document.URL.indexOf('popularity=') != -1) {
    popularity=decodeURIComponent(document.URL.split('popularity=')[1].split('&')[0].split('#')[0]);
    }
    }
    var agwl=gwl.split('&');
    for (var iig=1; iig<agwl.length; iig++) {
    if (iig == 1) { clauses=String.fromCharCode(10); }
    if (agwl[iig] != 'data=' && agwl[iig].indexOf('regionpicker') == -1) {
    clauses+='&' + agwl[iig] + String.fromCharCode(10);
    }
    }
    //if (clauses != '') { clauses+=String.fromCharCode(10); }
    gwocont=sofar;
    if (gwocont != '') {
    var xgwocont=null;
    if (1 == 1) {
    var setstuff='';
    if (gwl.indexOf('&data=') == -1) { setstuff='&data='; } else { extras=' (if &data= change prefix that in below appropriately)'; }
    var plis=('' + gwocont).split('|');
    for (var iplis=0; iplis<plis.length; iplis++) {
    if (setstuff == '') {
    setstuff='%20[~' + plis[iplis] + '~,2]';
    } else {
    setstuff+='%20,%20[~' + plis[iplis] + '~,2]';
    }
    }
    try {
    xgwocont=prompt('Please amend as necessary where each of those 2 values are what we have so far assigned for the ' + popularity + ' value for each region/country. As necessary add in any amended ' + clauses + ' ideas too' + extras + '.', setstuff);
    } catch(hjgdf) { xgwocont=null; }
    }
    if (xgwocont == null) { lastgwcont=gwocont; xgwocont=''; }
    gwocont=xgwocont;
    if (xgwocont != '') {
    //alert('gwl=' + gwl);
    var lateragwl=xgwocont.replace(/\ /g, '%20').split('&');
    for (var jig=1; jig<lateragwl.length; jig++) {
    if (gwl.indexOf('&' + lateragwl[jig].split('=')[0] + '=') != -1) {
    gwl=gwl.replace('&' + lateragwl[jig].split('=')[0] + '=' + gwl.split('&' + lateragwl[jig].split('=')[0] + '=')[1].split('&')[0].split('#')[0], '');
    }
    }
    lhref=ourtoolong(gwl + xgwocont.replace(/\ /g, '%20'));
    if (lhref != '') {
    location.href=lhref;
    }
    }
    }
    document.getElementById('tdleft').style.backgroundImage='URL("//www.rjmprogramming.com.au/ITblog/455/350/?cht=map&chld=' + encodeURIComponent(sofar) + '&chco=' + enough('B3BCC0|5781AE|FF0000|FFC726|885E80|518274|A3BCC0|4781AE|EF0000|EFC726|785E80|418274',sofar) + '")';
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (window.self == window.parent && eval('' + screen.width) > 1000 || document.URL.indexOf('?right=') != -1) {
    document.getElementById('tdleft').style.backgroundPosition='right top';
    } else {
    document.getElementById('tdleft').style.backgroundPosition='center top';
    }
    document.getElementById('tdleft').title='Double click for new window version of ...' + String.fromCharCode(10) + String.fromCharCode(10) + sofardetail.replace(/\|/g, String.fromCharCode(10));
    document.getElementById('tdleft').style.backgroundRepeat='no-repeat';
    if (!dbdone) {
    dbdone=true;
    //document.getElementById('tdleft').ondblclick=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.getElementById('tdleft').oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.backgroundImage.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    //document.body.oncontextmenu=function(){ window.open(document.getElementById('tdleft').style.background.split('URL("')[1].split('"')[0],'_blank','top=50,left=50,width=700,height=600'); };
    }
    window.scrollTo(0,0);
    }

    … and …
  • to change geo_chart.php Geo Chart interfacer … calls on the Region Picker in this new Javascript function …
    <?php echo ”

    function winopen(oneurl, twotarget, threerest) {
    var hmore='';
    if (gwl != '' && gwl.indexOf('?') != -1 && oneurl.indexOf(gwl) == -1 && oneurl.indexOf('?') != -1) {
    //alert(oneurl + '&' + gwl.split('?')[1]);
    if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    }
    document.getElementById(twotarget).src=oneurl + '&' + gwl.split('?')[1] + hmore;
    } else if (decodeURIComponent(('' + location.hash)).indexOf('title=') != -1) {
    hmore='&' + decodeURIComponent(('' + location.hash).replace(/^\#/g, '')).replace(/\ /g,'%20');
    if (hmore.indexOf('&width=') == -1) { hmore+='&width=556'; }
    if (hmore.indexOf('&height=') == -1) { hmore+='&height=347'; }
    if (hmore.indexOf('&country=') == -1) { hmore+='&country=Country'; }
    if (hmore.indexOf('&popularity=') == -1) { hmore+='&popularity=Popularity'; }
    if (hmore.indexOf('&data=') == -1) { hmore+='&data='; }
    document.getElementById(twotarget).src=oneurl + hmore;
    } else {
    document.getElementById(twotarget).src=oneurl;
    }
    return document.getElementById(twotarget);
    }

    “; ?>


Previous relevant Region Picker Primer Tutorial is shown below.

Region Picker Primer Tutorial

Region Picker Primer Tutorial

All the Geo Chart and Image Chart Map Chart work recently, along with Wikipedia ISO-3166 regional and country coding help (thanks), has set us on the road towards a …


Region Picker

… online tool, which we envisage will …

  • initially be a standalone HTML webpage … and later be …
  • integrated into the user input phase of the Geo Chart interfacer

So here we are today with the “first draft” standalone version, where we’ve used Pulldown Menus, you can read more about at HTML/CSS/Javascript Pulldown Menus Javascript Tutorial, to construct a Region/Country ISO code vertical bar delimited list of regions/continents that you can display in an Image Chart Map Chart …

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


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

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

Region Picker Primer Tutorial

Region Picker Primer Tutorial

Region Picker Primer Tutorial

All the Geo Chart and Image Chart Map Chart work recently, along with Wikipedia ISO-3166 regional and country coding help (thanks), has set us on the road towards a …


Region Picker

… online tool, which we envisage will …

  • initially be a standalone HTML webpage … and later be …
  • integrated into the user input phase of the Geo Chart interfacer

So here we are today with the “first draft” standalone version, where we’ve used Pulldown Menus, you can read more about at HTML/CSS/Javascript Pulldown Menus Javascript Tutorial, to construct a Region/Country ISO code vertical bar delimited list of regions/continents that you can display in an Image Chart Map Chart …

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

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

SOS Game Keyboard Tutorial

SOS Game Keyboard Tutorial

SOS Game Keyboard Tutorial

We’re not sure why we didn’t think about it in the first round of SOS Game creation sessions, but, further to the recent SOS Game Cursor Tutorial

  • cursor non-mobile improvements … today we have …
  • CSS margin tweaks
    <style>

    #wunderlay {
    font-family: Courier New;
    font-size: 20px;
    opacity: 0.3;
    z-index: 11;
    padding: 0 0 0 0;
    margin: 0 0 0 -12;
    -webkit-animation: glow 1s linear infinite alternate;
    -moz-animation: glow 1s linear infinite alternate;
    animation: glow 1s linear infinite alternate;
    }

    #underlay {
    font-family: Courier New;
    font-size: 20px;
    opacity: 0.3;
    z-index: 1;
    padding: 0 0 0 0;
    margin: 0 0 0 -12;
    color: transparent;
    }

    </style>
    … allowing for a more accurate cell transition calculation … by, on non-mobile, nullifying the left glow … and …
  • keyboard non-mobile functionality extensions

And it is that last “keyboard” strategy we want to hone in on today. Occasionally you come across a game where the “keyboard” use is apt, but fewer and fewer of these HTML5 games (that are not apps) benefit on mobile platforms, in this way. It can mean, though, that “huddling around the one device” with more than one player of the game, becomes more feasible, and this SOS Game “of recent tweaks” is a great candidate, it being …

  • only key characters “S” and “O” need to be coded for

    var lastspan=null;

    function didclick(e, spano, istm) {
    var ourlet='';
    if (istm == 0 && lastspan) {
    if (('' + lastspan.outerHTML).indexOf('<span') == -1) { return true; }
    //document.title='' + e.keyCode;
    var char = e.which || e.keyCode
    if (('' + e.keyCode) == '79' && istm == 0) {
    ourlet='O';
    spano=lastspan;
    } else if (('' + e.keyCode) == '83' && istm == 0) {
    ourlet='S';
    spano=lastspan;
    } else if (('' + e.keyCode) != 'undefined' && istm == 0) {
    return true;
    }
    }

    if (document.getElementById('names')) {
    if (document.getElementById('names').value == '' && document.getElementById('names').placeholder.indexOf(',') != -1) {
    document.getElementById('names').value=document.getElementById('names').placeholder;
    //alert(1);
    document.getElementById('numsel').value='' + document.getElementById('names').value.split(',').length;
    //alert(document.getElementById('numsel').value);
    nparrange(document.getElementById('numsel'));
    //alert(11);
    document.getElementById('smore').innerHTML=notify('Your go ' + anames[curplayer]);
    }
    }
    console.log('1');
    if (spano.innerHTML.toLowerCase() == 's' || spano.innerHTML.toLowerCase() == 'o') { return true; }
    console.log('2');
    var rtis=spano.getBoundingClientRect();
    console.log('3');
    e = e || window.event;
    e.preventDefault();

    if (e.touches) {
    if (e.touches[0].pageX) {
    xx = e.touches[0].pageX;
    yy = e.touches[0].pageY;
    } else {
    xx = e.touches[0].clientX;
    yy = e.touches[0].clientY;
    }
    //console.log('pos3=' + pos3 + ',pos4=' + pos4);
    } else if (e.clientX || e.clientY) {
    xx = e.clientX;
    yy = e.clientY;
    } else {
    xx = e.pageX;
    yy = e.pageY;
    }

    var thislet=' ';
    var locsubscore=0;
    var thisi=eval(spano.id.replace('span',''));
    if (ourlet == 'S' || (eval(yy - rtis.top) <= eval(rtis.bottom - yy) && ourlet != 'O')) { // s
    thislet='S';
    spano.innerHTML=thislet;
    spano.style.color='rgb(128,0,128)'; //'#000000';
    } else {
    thislet='O';
    spano.innerHTML=thislet;
    spano.style.color='#0000ff';
    }
    sbs=[];
    if (eval(thisi % 100) >= 2) { // forwards we are at end
    if ((sb(document.getElementById('span' + eval(-2 + thisi))).innerHTML + sb(document.getElementById('span' + eval(-1 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }
    sbs=[];
    if (eval(thisi % 100) >= 1 && eval(thisi % 100) <= 98) { // forwards we are in the middle
    if ((sb(document.getElementById('span' + eval(-1 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(1 + thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }
    sbs=[];
    if (eval(thisi % 100) <= 97) { // forwards we are at start
    if ((sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(1 + thisi))).innerHTML + sb(document.getElementById('span' + eval(2 + thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }

    if (updownallowed) {
    sbs=[];
    if (eval(thisi / 100) >= 2) { // down we are at end
    if ((sb(document.getElementById('span' + eval(-200 + thisi))).innerHTML + sb(document.getElementById('span' + eval(-100 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }
    sbs=[];
    if (eval(thisi / 100) >= 1 && eval(thisi / 100) <= 18) { // down we are in the middle
    if ((sb(document.getElementById('span' + eval(-100 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(100 + thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }
    sbs=[];
    if (eval(thisi / 100) <= 17) { // down we are at start
    if ((sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(100 + thisi))).innerHTML + sb(document.getElementById('span' + eval(200 + thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }
    }

    if (diagonalsallowed) {
    sbs=[];
    if (eval(thisi / 100) >= 2 && eval(thisi % 100) >= 2) { // diagonally we are at end
    if ((sb(document.getElementById('span' + eval(-202 + thisi))).innerHTML + sb(document.getElementById('span' + eval(-101 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    sbs=[];
    if ((sb(document.getElementById('span' + eval(-198 + thisi))).innerHTML + sb(document.getElementById('span' + eval(-99 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }
    sbs=[];
    if (eval(thisi / 100) >= 1 && eval(thisi / 100) <= 18 && eval(thisi % 100) >= 1 && eval(thisi % 100) <= 98) { // diagonally we are in the middle
    if ((sb(document.getElementById('span' + eval(-101 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(101 + thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    sbs=[];
    if ((sb(document.getElementById('span' + eval(-99 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(99 + thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }
    sbs=[];
    if (eval(thisi / 100) <= 17 && eval(thisi % 100) <= 97) { // diagonally we are at start
    if ((sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(101 + thisi))).innerHTML + sb(document.getElementById('span' + eval(202 + thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    sbs=[];
    if ((sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(99 + thisi))).innerHTML + sb(document.getElementById('span' + eval(198 + thisi))).innerHTML) == 'SOS') {
    sbord();
    locsubscore++;
    }
    }
    }
    sbs=[];

    if (locsubscore > 0) {
    //alert('locsubscore=' + locsubscore + ' yy=' + yy + ' rtis.top=' + rtis.top + ' rtis.y=' + rtis.y + ' rtis.bottom=' + rtis.bottom);
    changeu=false;
    subscore=locsubscore;
    return cscore('pointer', locsubscore);
    } else {
    subscore=0;
    changeu=true;
    //alert('change');
    return cscore('pointer', 0);
    }


    var newi=eval(spano.id.replace('span',''));
    var documentgetSelectiontoString='', revsis='';
    var wlen=0, ijh=0;
    if (setsoftwo.length == 0) {
    setsoftwo.push(newi);
    document.getElementById('span' + newi).style.backgroundColor='yellow';
    } else {
    console.log('Newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
    if (Math.floor(newi / 100) == Math.floor(setsoftwo[0] / 100)) {
    wlen=eval(1 + Math.abs(eval(setsoftwo[0] - newi)));
    if (wlen == 3) { // >= 4) {
    for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh++) {
    documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
    revsis=document.getElementById('span' + ijh).innerHTML + revsis;
    document.getElementById('span' + ijh).style.backgroundColor='orange';
    document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
    document.getElementById('span' + ijh).style.cursor='progress';
    }
    subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
    findingnemo='';
    if (!backwardsallowed) {
    setTimeout(retry, 2000);
    document.getElementById('nameif').title='';
    } else {
    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());
    setsoftwo=[];
    } else {
    document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
    setsoftwo=[];
    setsoftwo.push(newi);
    document.getElementById('span' + newi).style.backgroundColor='yellow';
    console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
    notify('Sorry, but too short.');
    }

    } else if (eval(newi % 100) == eval(setsoftwo[0] % 100)) {
    if (updownallowed) {
    console.log('up down');
    wlen=eval(1 + Math.abs(eval(Math.floor(setsoftwo[0] / 100) - Math.floor(newi / 100))));
    console.log('newi=' + newi + ' and wlen=' + wlen + ' via setsoftwo[0]=' + setsoftwo[0]);
    if (wlen == 3) { // >= 4) {
    for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh+=100) {
    documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
    revsis=document.getElementById('span' + ijh).innerHTML + revsis;
    document.getElementById('span' + ijh).style.backgroundColor='orange';
    document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
    document.getElementById('span' + ijh).style.cursor='progress';
    }
    subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
    findingnemo='';
    if (!backwardsallowed) {
    setTimeout(retry, 2000);
    document.getElementById('nameif').title='';
    } else {
    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());
    setsoftwo=[];
    } else {
    document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
    setsoftwo=[];
    setsoftwo.push(newi);
    document.getElementById('span' + newi).style.backgroundColor='yellow';
    console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
    notify('Sorry, need four or more letters.');
    }

    } else {
    document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
    setsoftwo=[];
    setsoftwo.push(newi);
    document.getElementById('span' + newi).style.backgroundColor='yellow';
    console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
    notify('Sorry, no up or downs allowed.');
    }

    } else if (Math.abs(Math.floor(eval(newi / 100)) - Math.floor(eval(setsoftwo[0] / 100))) == Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100))) {
    if (diagonalsallowed) {
    console.log('diagonal');

    wlen=eval(1 + Math.abs(eval(Math.floor(setsoftwo[0] / 100) - Math.floor(newi / 100))));
    console.log('newi=' + newi + ' and wlen=' + wlen + ' via setsoftwo[0]=' + setsoftwo[0]);
    if (wlen == 3) { // >= 4) {
    for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh+=eval(eval(Math.max(setsoftwo[0], newi) - Math.min(setsoftwo[0], newi)) / eval(-1 + wlen))) {
    documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
    revsis=document.getElementById('span' + ijh).innerHTML + revsis;
    document.getElementById('span' + ijh).style.backgroundColor='orange';
    document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
    document.getElementById('span' + ijh).style.cursor='progress';
    }
    subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
    findingnemo='';
    if (!backwardsallowed) {
    setTimeout(retry, 2000);
    document.getElementById('nameif').title='';
    } else {
    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());
    setsoftwo=[];
    } else {
    document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
    setsoftwo=[];
    setsoftwo.push(newi);
    document.getElementById('span' + newi).style.backgroundColor='yellow';
    console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
    notify('Too short, sorry.');
    }

    } else {
    document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
    setsoftwo=[];
    setsoftwo.push(newi);
    document.getElementById('span' + newi).style.backgroundColor='yellow';
    console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
    notify('Sorry, no diagonals allowed.');
    }

    } else {
    document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
    setsoftwo=[];
    setsoftwo.push(newi);
    document.getElementById('span' + newi).style.backgroundColor='yellow';
    console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
    }
    }
    //alert('id=' + spano.id + ' ' + spano.innerHTML);
    }

    function dummyspit(ev) {
    lastspan=e.target;
    return true;
    }
  • onkeydown event can serve the purpose in a “hotkey” way, making things a lot easier … and what we have done in the past and reiterate today, having gone down the wrong garden path before the better one, is …
  • the additional “onkeydown” event can belong to the document.body

    <body onkeydown=didclick(event,lastspan,0); data-onclick='bc(event);' title='' onload="sdodit(); setTimeout(mytaow, 2000); if (('' + navigator.platform.toUpperCase()).indexOf('MAC') >= 0) { document.getElementById('names').title+=' Append with spaces to try using MAMP HTTP://localhost:8888/macos_say_record.php supervision of macOS say text to audio commentary.'; }">

    … element rather than an individual event for each game span “cell” … and …
  • though not as cutesy wutesy codewise as we’d hoped, the “onkeydown” logic can co-exist with “onclick” (for each span “cell”) Javascript function, as shown above, the last parameter 1 for real click and 0 for keyboard call

… it being a comfort that the “keyboard” logic merges in with so much of the established “onclick” logic that has been working in the past in the changed sos_game.html SOS Game for interested parties.


Previous relevant SOS Game Cursor Tutorial is shown below.

SOS Game Cursor Tutorial

SOS Game Cursor Tutorial

In the online woooorrrrllllddd, non-mobile platforms have a whole “hover” woooorrrrllllddd forsaken by the mobile platforms. In that woooorrrrllllddd you can “decorate” or personalize your cursor, that “character” (or perhaps more if you involve SVG+XML protocol cursor customized definitions) which follows your mouse position around the screen.

The event “onmouseover” is called that once on a detection of that hovering concerning an HTML element you are interested in. Event “onmouseover” is not called again until a re-entry happens (and an “onmouseout” event happens as the mouse leaves the environs of your element having previously caused an “onmouseover” event to be called).

If the position remains of interest during that time between an “onmouseover” and an “onmouseout” event be of interest, as it is for us, today, retweaking our recent SOS Game (last talked about with SOS Game Primer Tutorial) functionality, we need to start taking an interest in that element’s “onmousemove” event, called by the system every time the mouse moves within the realms of your HTML element of interest.

Our SOS Game differentiates an “S” user play, from a user “O” play via whether the click (and now hover) positioning is at the top and bottom of the relevant table cell element respectively, decorated by a linear gradient helping background image, with the hovering, as well.

Can the event logic be quick enough? We’ll let you judge for yourself. Probably your impatient players will occasionally fall foul of this hovering advice, but for the main part, we found it helped explain how the game works, having these SVG defined “S” and “O” SVG text cursor customizations happen for our non-mobile SOS Game players out there.

Javascript wise, we fleshed out the (previously not fleshed out) function sback as below, in a way that made it compatible to calls from “onmousemove” events as well as the “onmouseover” events it had already been deployed for


function sback(e,spo) {
var moxx=0, moyy=0;
var rstis=spo.getBoundingClientRect();
//spo.style.backgroundImage='url("data:image/svg+xml;utf8,<svg xmlns=' + "'" + 'http://www.w3.org/2000/svg' + "'" + ' width=' + "'" + rstis.width + "'" + ' height=' + "'" + rstis.height + "'" + ' viewport=' + "'" + '0 0 100 100' + "'" + '><text y=' + "'" + '0%' + "'" + '>S</text><text y=' + "'" + '50%' + "'" + '>O</text></svg>");';
//spo.style.backgroundRepeat='no-repeat';
//spo.style.backgroundSize='contain';


//elemLeft = spo.offsetLeft;
//elemTop = spo.offsetTop;

e = e || window.event;
e.preventDefault();

if (e.touches) {
if (e.touches[0].pageX) {
moxx = e.touches[0].pageX + document.body.scrollLeft * 0 - elemLeft;
moyy = e.touches[0].pageY + document.body.scrollTop * 0 - elemTop;
} else {
moxx = e.touches[0].clientX + document.body.scrollLeft * 0 - elemLeft;
moyy = e.touches[0].clientY + document.body.scrollTop * 0 - elemTop;
}
//console.log('pos3=' + pos3 + ',pos4=' + pos4);
} else if (e.clientX || e.clientY) {
moxx = e.clientX + document.body.scrollLeft * 0 - elemLeft;
moyy = e.clientY + document.body.scrollTop * 0 - elemTop;
} else {
moxx = e.pageX + document.body.scrollLeft * 0 - elemLeft;
moyy = e.pageY + document.body.scrollTop * 0 - elemTop;
}

if (Math.abs(eval('' + moyy) - eval('' + rstis.top)) <= Math.abs(eval('' + moyy) - eval('' + rstis.bottom))) {
spo.style.cursor='url("data:image/svg+xml;utf8,<svg xmlns=' + "'" + 'http://www.w3.org/2000/svg' + "'" + ' width=' + "'" + rstis.width + "'" + ' height=' + "'" + rstis.height + "'" + ' viewport=' + "'" + '0 0 100 100' + "'" + '><text y=' + "'" + '50%' + "'" + ' stroke=' + "'" + 'gray' + "'" + '>S</text></svg>") 16 0, progress';
} else {
spo.style.cursor='url("data:image/svg+xml;utf8,<svg xmlns=' + "'" + 'http://www.w3.org/2000/svg' + "'" + ' width=' + "'" + rstis.width + "'" + ' height=' + "'" + rstis.height + "'" + ' viewport=' + "'" + '0 0 100 100' + "'" + '><text y=' + "'" + '50%' + "'" + ' stroke=' + "'" + 'gray' + "'" + '>O</text></svg>") 16 0, progress';
}

}

… to make this “ever so mild” makeover of our SOS Game happen involving a changed sos_game.html for interested parties.


Previous relevant SOS Game Primer Tutorial is shown below.

SOS Game Primer Tutorial

SOS Game Primer Tutorial

Even though it took too long to get to yesterday’s Word Find Game Viewport Tutorial‘s Word Find Game’s level of satisfaction, for us, it was always going to be worth it, because when you overengineer it can mean cloning off that into another useful web application is a “paring down” exercise, more than anything, and this is infinitely easier than “a reinvention of the wheel” scenario, especially where it comes to “cross platform” game usage “user experience” issues.

The fun bit of such an approach, in thinking about what we end up with today is the thought that a …

  • Word Find Game … could be cloned or morphed into a …
  • SOS Game

… we remember from our days at high school, in less than a day. The memory of the SOS Game did not extend to the detail, and so we thank How to Play – SOS for reminders about the status of diagonality, while up versus down and forwards versus backwards concerns were a bit “per se” regarding “SOS”!

It was the confluence of one “onclick” type event to cover, regarding span elements set out in a grid initialized to a non-breaking space ( ie. &nbsp; ) …

  • fill in contents as “S”
  • fill in contents as “O”

… that set us to determining for the span “cell” click, was it positioned …

  • in the top half means “S” … or …
  • in the bottom half means “O”

? This had us converging on changes to the “clicks” mode onclick event Javascript logic …


function didclick(e, spano) {
if (document.getElementById('names')) {
if (document.getElementById('names').value == '' && document.getElementById('names').placeholder.indexOf(',') != -1) {
document.getElementById('names').value=document.getElementById('names').placeholder;
//alert(1);
document.getElementById('numsel').value='' + document.getElementById('names').value.split(',').length;
//alert(document.getElementById('numsel').value);
nparrange(document.getElementById('numsel'));
//alert(11);
document.getElementById('smore').innerHTML=notify('Your go ' + anames[curplayer]);
}
}
console.log('1');
if (spano.innerHTML.toLowerCase() == 's' || spano.innerHTML.toLowerCase() == 'o') { return true; }
console.log('2');
var rtis=spano.getBoundingClientRect();
console.log('3');
e = e || window.event;
e.preventDefault();

if (e.touches) {
if (e.touches[0].pageX) {
xx = e.touches[0].pageX;
yy = e.touches[0].pageY;
} else {
xx = e.touches[0].clientX;
yy = e.touches[0].clientY;
}
//console.log('pos3=' + pos3 + ',pos4=' + pos4);
} else if (e.clientX || e.clientY) {
xx = e.clientX;
yy = e.clientY;
} else {
xx = e.pageX;
yy = e.pageY;
}



var thislet=' ';
var locsubscore=0;
var thisi=eval(spano.id.replace('span',''));
if (eval(yy - rtis.top) <= eval(rtis.bottom - yy)) { // s
thislet='S';
spano.innerHTML=thislet;
spano.style.color='rgb(128,0,128)'; //'#000000';
} else {
thislet='O';
spano.innerHTML=thislet;
spano.style.color='#0000ff';
}
sbs=[];
if (eval(thisi % 100) >= 2) { // forwards we are at end
if ((sb(document.getElementById('span' + eval(-2 + thisi))).innerHTML + sb(document.getElementById('span' + eval(-1 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}
sbs=[];
if (eval(thisi % 100) >= 1 && eval(thisi % 100) <= 98) { // forwards we are in the middle
if ((sb(document.getElementById('span' + eval(-1 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(1 + thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}
sbs=[];
if (eval(thisi % 100) <= 97) { // forwards we are at start
if ((sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(1 + thisi))).innerHTML + sb(document.getElementById('span' + eval(2 + thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}


if (updownallowed) {
sbs=[];
if (eval(thisi / 100) >= 2) { // down we are at end
if ((sb(document.getElementById('span' + eval(-200 + thisi))).innerHTML + sb(document.getElementById('span' + eval(-100 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}
sbs=[];
if (eval(thisi / 100) >= 1 && eval(thisi / 100) <= 18) { // down we are in the middle
if ((sb(document.getElementById('span' + eval(-100 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(100 + thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}
sbs=[];
if (eval(thisi / 100) <= 17) { // down we are at start
if ((sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(100 + thisi))).innerHTML + sb(document.getElementById('span' + eval(200 + thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}
}

if (diagonalsallowed) {
sbs=[];
if (eval(thisi / 100) >= 2 && eval(thisi % 100) >= 2) { // diagonally we are at end
if ((sb(document.getElementById('span' + eval(-202 + thisi))).innerHTML + sb(document.getElementById('span' + eval(-101 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
sbs=[];
if ((sb(document.getElementById('span' + eval(-198 + thisi))).innerHTML + sb(document.getElementById('span' + eval(-99 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}
sbs=[];
if (eval(thisi / 100) >= 1 && eval(thisi / 100) <= 18 && eval(thisi % 100) >= 1 && eval(thisi % 100) <= 98) { // diagonally we are in the middle
if ((sb(document.getElementById('span' + eval(-101 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(101 + thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
sbs=[];
if ((sb(document.getElementById('span' + eval(-99 + thisi))).innerHTML + sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(99 + thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}
sbs=[];
if (eval(thisi / 100) <= 17 && eval(thisi % 100) <= 97) { // diagonally we are at start
if ((sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(101 + thisi))).innerHTML + sb(document.getElementById('span' + eval(202 + thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
sbs=[];
if ((sb(document.getElementById('span' + eval(thisi))).innerHTML + sb(document.getElementById('span' + eval(99 + thisi))).innerHTML + sb(document.getElementById('span' + eval(198 + thisi))).innerHTML) == 'SOS') {
sbord();
locsubscore++;
}
}
}
sbs=[];

if (locsubscore > 0) {
//alert('locsubscore=' + locsubscore + ' yy=' + yy + ' rtis.top=' + rtis.top + ' rtis.y=' + rtis.y + ' rtis.bottom=' + rtis.bottom);
changeu=false;
subscore=locsubscore;
return cscore('pointer', locsubscore);
} else {
subscore=0;
changeu=true;
//alert('change');
return cscore('pointer', 0);
}



var newi=eval(spano.id.replace('span',''));
var documentgetSelectiontoString='', revsis='';
var wlen=0, ijh=0;
if (setsoftwo.length == 0) {
setsoftwo.push(newi);
document.getElementById('span' + newi).style.backgroundColor='yellow';
} else {
console.log('Newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
if (Math.floor(newi / 100) == Math.floor(setsoftwo[0] / 100)) {
wlen=eval(1 + Math.abs(eval(setsoftwo[0] - newi)));
if (wlen == 3) { // >= 4) {
for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh++) {
documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
revsis=document.getElementById('span' + ijh).innerHTML + revsis;
document.getElementById('span' + ijh).style.backgroundColor='orange';
document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
document.getElementById('span' + ijh).style.cursor='progress';
}
subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
findingnemo='';
if (!backwardsallowed) {
setTimeout(retry, 2000);
document.getElementById('nameif').title='';
} else {
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());
setsoftwo=[];
} else {
document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
setsoftwo=[];
setsoftwo.push(newi);
document.getElementById('span' + newi).style.backgroundColor='yellow';
console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
notify('Sorry, but too short.');
}

} else if (eval(newi % 100) == eval(setsoftwo[0] % 100)) {
if (updownallowed) {
console.log('up down');
wlen=eval(1 + Math.abs(eval(Math.floor(setsoftwo[0] / 100) - Math.floor(newi / 100))));
console.log('newi=' + newi + ' and wlen=' + wlen + ' via setsoftwo[0]=' + setsoftwo[0]);
if (wlen == 3) { // >= 4) {
for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh+=100) {
documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
revsis=document.getElementById('span' + ijh).innerHTML + revsis;
document.getElementById('span' + ijh).style.backgroundColor='orange';
document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
document.getElementById('span' + ijh).style.cursor='progress';
}
subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
findingnemo='';
if (!backwardsallowed) {
setTimeout(retry, 2000);
document.getElementById('nameif').title='';
} else {
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());
setsoftwo=[];
} else {
document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
setsoftwo=[];
setsoftwo.push(newi);
document.getElementById('span' + newi).style.backgroundColor='yellow';
console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
notify('Sorry, need four or more letters.');
}

} else {
document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
setsoftwo=[];
setsoftwo.push(newi);
document.getElementById('span' + newi).style.backgroundColor='yellow';
console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
notify('Sorry, no up or downs allowed.');
}

} else if (Math.abs(Math.floor(eval(newi / 100)) - Math.floor(eval(setsoftwo[0] / 100))) == Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100))) {
if (diagonalsallowed) {
console.log('diagonal');

wlen=eval(1 + Math.abs(eval(Math.floor(setsoftwo[0] / 100) - Math.floor(newi / 100))));
console.log('newi=' + newi + ' and wlen=' + wlen + ' via setsoftwo[0]=' + setsoftwo[0]);
if (wlen == 3) { // >= 4) {
for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh+=eval(eval(Math.max(setsoftwo[0], newi) - Math.min(setsoftwo[0], newi)) / eval(-1 + wlen))) {
documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
revsis=document.getElementById('span' + ijh).innerHTML + revsis;
document.getElementById('span' + ijh).style.backgroundColor='orange';
document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
document.getElementById('span' + ijh).style.cursor='progress';
}
subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
findingnemo='';
if (!backwardsallowed) {
setTimeout(retry, 2000);
document.getElementById('nameif').title='';
} else {
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());
setsoftwo=[];
} else {
document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
setsoftwo=[];
setsoftwo.push(newi);
document.getElementById('span' + newi).style.backgroundColor='yellow';
console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
notify('Too short, sorry.');
}

} else {
document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
setsoftwo=[];
setsoftwo.push(newi);
document.getElementById('span' + newi).style.backgroundColor='yellow';
console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
notify('Sorry, no diagonals allowed.');
}

} else {
document.getElementById('span' + ('' + setsoftwo[0]).replace('span','')).style.backgroundColor='#f0f0f0';
setsoftwo=[];
setsoftwo.push(newi);
document.getElementById('span' + newi).style.backgroundColor='yellow';
console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
}
}
//alert('id=' + spano.id + ' ' + spano.innerHTML);
}

… which on non-mobile platforms compliments the CSS styling …

<style>

span.wunderlay:hover {
background-image: linear-gradient(to bottom, rgba(128,0,128,0.5) , rgba(0,0,255,0.5));
}

</style>

… quite nicely, in a colour coded sense, in the “how we got there” sos_game.html SOS Game you can also try below …


Previous relevant Word Find Game Aesthetics Tutorial is shown below.

Word Find Game Aesthetics Tutorial

Word Find Game Aesthetics Tutorial

CSS styling keeps getting better for webpages, with extended functionality, as proven when CSS3 came to being. Two styling features we find quite impactive are …

  • CSS animation … and …
  • CSS linear gradients

… we use, respectively, regarding …

  • “selection” textarea and “click” div of span elements … helping create a colour coded border “glow” 3D effect …

    <style>

    /* Thanks to https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_glowing_text */

    @-webkit-keyframes glow {
    from {
    box-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #e60073, 0 0 9px #e60073, 0 0 11px #e60073, 0 0 13px #e60073, 0 0 15px #e60073;
    }

    to {
    box-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #ff4da6, 0 0 10px #ff4da6, 0 0 12px #ff4da6, 0 0 14px #ff4da6, 0 0 16px #ff4da6;
    }
    }

    @-webkit-keyframes wglow {
    from {
    box-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #7300e6, 0 0 9px #7300e6, 0 0 11px #7300e6, 0 0 13px #7300e6, 0 0 15px #7300e6;
    }

    to {
    box-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #a64dff, 0 0 10px #a64dff, 0 0 12px #a64dff, 0 0 14px #a64dff, 0 0 16px #a64dff;
    }
    }


    textarea {
    font-family: Courier New;
    font-size: 20px;
    opacity: 0.9;
    z-index: 9;
    padding: 0 0 0 0;
    margin: 0 0 0 0;
    text-shadow: -1px 1px 1px #952dff;
    -webkit-animation: glow 1s linear infinite alternate;
    -moz-animation: glow 1s linear infinite alternate;
    animation: glow 1s linear infinite alternate;

    }


    #wunderlay {
    font-family: Courier New;
    font-size: 20px;
    opacity: 0.3;
    z-index: 11;
    padding: 0 0 0 0;
    margin: 0 0 0 0;
    -webkit-animation: glow 1s linear infinite alternate;
    -moz-animation: glow 1s linear infinite alternate;
    animation: glow 1s linear infinite alternate;

    }
    </style>

    … that is dynamically changed to “wglow” (and font-family Courier) should the user select “click” mode of interactive entry
  • background-image CSS property linear gradient background to dropdown and textbox element effect …

    <style>
    /* Thanks to https://medium.com/thirty-9/3-tips-for-using-subtle-css-gradients-f5691e453602 */

    body {
    background-image: linear-gradient(to right bottom, #ffffff, #fcfafc, #f9f6f8, #f8f1f3, #f6ecec);
    }


    #names {
    background-image: linear-gradient(to right bottom, #eeeeee, #ebe9eb, #e8e5e7, #e7e0e2, #e5dbdb);
    }


    select {
    background-image: linear-gradient(to right bottom, white, yellow, pink, silver, lightgray);
    }
    </style>

And so, improving on yesterday’s Word Find Game Mobile Tutorial we have in our changed word_find_game.html Word Find Game you can also try, yes, yet again, below.


Previous relevant Word Find Game Mobile Tutorial is shown below.

Word Find Game Mobile Tutorial

Word Find Game Mobile Tutorial

Yesterday’s Word Find Game Personalization Tutorial, and the Word Find Game from versions before all had an unwieldy relationship with mobile platforms. The …

  • selection, via Selection API, using HTML textarea, suits non-mobile well … but we think today’s newly coded for …
  • click, via HTML span element onclick logics, work better on mobile platforms

… and so we’ve coded for a new dropdown to offer both modus operandi as options, with new “click” modus operandi Javascript …


function didclick(spano) {
var newi=eval(spano.id.replace('span',''));
var documentgetSelectiontoString='', revsis='';
var wlen=0, ijh=0;
if (setsoftwo.length == 0) {
setsoftwo.push(newi);
document.getElementById('span' + newi).style.backgroundColor='yellow';
} else {
console.log('Newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
if (Math.floor(newi / 100) == Math.floor(setsoftwo[0] / 100)) {
wlen=eval(1 + Math.abs(eval(setsoftwo[0] - newi)));
if (wlen >= 4) {
for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh++) {
documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
revsis=document.getElementById('span' + ijh).innerHTML + revsis;
document.getElementById('span' + ijh).style.backgroundColor='orange';
document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
document.getElementById('span' + ijh).style.cursor='progress';
}
subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
findingnemo='';
if (!backwardsallowed) {
setTimeout(retry, 2000);
document.getElementById('nameif').title='';
} else {
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());
setsoftwo=[];
}
} else if (eval(newi % 100) == eval(setsoftwo[0] % 100)) {
if (updownallowed) {
console.log('up down');
wlen=eval(1 + Math.abs(eval(Math.floor(setsoftwo[0] / 100) - Math.floor(newi / 100))));
console.log('newi=' + newi + ' and wlen=' + wlen + ' via setsoftwo[0]=' + setsoftwo[0]);
if (wlen >= 4) {
for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh+=100) {
documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
revsis=document.getElementById('span' + ijh).innerHTML + revsis;
document.getElementById('span' + ijh).style.backgroundColor='orange';
document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
document.getElementById('span' + ijh).style.cursor='progress';
}
subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
findingnemo='';
if (!backwardsallowed) {
setTimeout(retry, 2000);
document.getElementById('nameif').title='';
} else {
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());
setsoftwo=[];
}
}
} else if (Math.abs(Math.floor(eval(newi / 100)) - Math.floor(eval(setsoftwo[0] / 100))) == Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100))) {
if (diagonalsallowed) {
console.log('diagonal');

wlen=eval(1 + Math.abs(eval(Math.floor(setsoftwo[0] / 100) - Math.floor(newi / 100))));
console.log('newi=' + newi + ' and wlen=' + wlen + ' via setsoftwo[0]=' + setsoftwo[0]);
if (wlen >= 4) {
for (ijh=Math.min(setsoftwo[0], newi); ijh<=Math.max(setsoftwo[0], newi); ijh+=eval(eval(Math.max(setsoftwo[0], newi) - Math.min(setsoftwo[0], newi)) / eval(-1 + wlen))) {
documentgetSelectiontoString+=document.getElementById('span' + ijh).innerHTML;
revsis=document.getElementById('span' + ijh).innerHTML + revsis;
document.getElementById('span' + ijh).style.backgroundColor='orange';
document.getElementById('span' + ijh).title=document.getElementById('span' + ijh).innerHTML;
document.getElementById('span' + ijh).style.cursor='progress';
}
subscore=eval(0 - eval('' + documentgetSelectiontoString.length));
findingnemo='';
if (!backwardsallowed) {
setTimeout(retry, 2000);
document.getElementById('nameif').title='';
} else {
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());
setsoftwo=[];
}
}
} else {
console.log('newi=' + newi + ' and down=' + Math.abs(eval(newi % 100) - eval(setsoftwo[0] % 100)) + ' and across=' + Math.abs(Math.floor(newi / 100) - Math.floor(setsoftwo[0] / 100)) + ' via setsoftwo[0]=' + setsoftwo[0]);
}
}
//alert('id=' + spano.id + ' ' + spano.innerHTML);
}

… in our changed word_find_game.html Word Find Game you can also try, yes, again, below.


Previous relevant Word Find Game Personalization Tutorial is shown below.

Word Find Game Underlay Tutorial

Word Find Game Personalization Tutorial

Yesterday’s Word Find Game Modes of Use Tutorial gave us the means by which we could have multiple players in our “Finding the Word” game, as a number. But many users prefer “names” to “numbers”. And so …

  • we start asking for an optional (comma separated) user name list … that if used …
  • starts looking for Notifications API functionality to keep the players informed about proceedings … and …
  • if underlying Navigator API navigator.platform points at an underlying macOS operating system, also offer the user the chance to turn notification wording to audio commentary, as well

… as per Javascript …


function notify(what) {
if (what.trim() != '' && anames[0].replace('Player 1','').trim() != '') {
if (what != lastwhat) {
lastwhat=what;
setTimeout(lwn, 8000);
document.getElementById('notif').src='./notifications_ideas.php?scheduledblurb=' + encodeURIComponent(what);
if (trysay) { //alert('HTTP://localhost:8888/macos_say_record.php?andsoonclose=y&docronwork=say%20' + encodeURIComponent(what));
window.open('HTTP://localhost:8888/macos_say_record.php?andsoonclose=y&docronwork=say%20' + encodeURIComponent(what), 'sayif', 'top=50,left=50,width=500,height=500');
}
}
}
return what;
}

… showing two different uses of two different invisible HTML iframe elements …


<iframe id=notif style='display:none;' src=></iframe>
<iframe id=sayif name=sayif style='display:none;' src=></iframe>

… in our changed word_find_game.html Word Find Game you can also try, yet again, below.


Previous relevant Word Find Game Modes of Use Tutorial is shown below.

Word Find Game Underlay Tutorial

Word Find Game Modes of Use Tutorial

Online games often feature …

  • degree of difficulty
  • number of player(s)

… modes of use that the user(s) can control. And so, with this in mind, to improve on yesterday’s Word Find Game Underlay Tutorial we’ve set out providing ways the users can control these two concepts via two new dropdowns …


<h1>Word Find Game <select onchange="restart(this);"><option value="hard">Hard</option><option value="easy">Easy</option><option value="easier">Easier</option><option value="easiest">Easiest</option></select> <span id=curbit>for</span> <select id=numsel onchange='nparrange(this);'><option value=1>1 player</option><option value=2>2 players</option><option value=3>3 players</option><option value=4>4 players</option><option value=5>5 players</option></select></h1>

… along with a span element showing the current player number all within that topmost h1 element, and helped out by two new dropdown (ie. select element) onchange event Javascript logics …


var numplayers=1;
var curplayer=0;
var ascores=[0], agoes=[0];
var backwardsallowed=true;
var updownallowed=true;
var diagonalsallowed=true;

var zdebye='';
var zzdebye='';
var lastzdebye='';
var goutstris='';
var delayis=0;
var sofar=';';
var score=0, goes=0, subscore=0;

function nparrange(sio) {
if (eval('' + sio.value) > eval('' + ascores.length)) {
while (eval('' + sio.value) > eval('' + ascores.length)) {
ascores.push(0);
agoes.push(0);
}
numplayers=eval('' + ascores.length);
document.getElementById('curbit').innerHTML='for <font color=green>' + eval(1 + eval('' + curplayer)) + '</font> of';
if (eval('' + ascores.length) > 1) {
var cscores='';
var cgoes='';
var betw='';
//if (eval(0 + eval('' + curplayer)) == 0) { betw='<font color=red>'; }
if (eval(1 + eval('' + curplayer)) >= eval('' + ascores.length)) { betw='<font color=red>'; }
for (var inp=0; inp<eval('' + ascores.length); inp++) {
if (eval('' + curplayer) == inp) {
cscores+=betw + '<font color=green>' + ascores[inp] + '</font>';
cgoes+=betw + '<font color=green>' + agoes[inp] + '</font>';
betw=':<font color=red>';
} else {
cscores+=betw + ascores[inp] + betw.replace(':','').replace('<font color=red>', '</font>').replace('<font color=green>', '</font>');
cgoes+=betw + agoes[inp] + betw.replace(':','').replace('<font color=red>', '</font>').replace('<font color=green>', '</font>');
//betw=':';
betw=(':' + betw.replace(':','')).replace('<font color=red>','').replace('<font color=green>','<font color=red>');
}
console.log('numplayers=' + numplayers + ' at ' + inp + ' vs curplayer=' + curplayer + ' ' + cscores + '/' + cgoes);
}
document.getElementById('score').innerHTML='' + cscores + '/' + cgoes;
//curplayer++;
//if (curplayer >= eval('' + ascores.length)) { curplayer=0; }
//scores=ascores[curplayer];
//goes=agoes[curplayer];
}
}
}

function restart(sio) {
var myblurb=document.getElementById('blurb').innerHTML; // Forwards, backwards, up, down, diagonal 4 letters or more highlight below
var setn=[8,1,1,3,11,1,2,1,8,0,0,3,1,5,7,1,0,5,3,5,3,1,1,0,1,0];
if (sio.value == 'hard') { location.href=document.URL; }
if (sio.value != 'hard' && eval('' + letters.length) == 26) {
myblurb=myblurb.replace(' letters ', ' more common set of letters ');
// A-9, B-2, C-2, D-4, E-12, F-2, G-3, H-2, I-9, J-1, K-1, L-4, M-2, N-6, O-8, P-2, Q-1, R-6, S-4, T-6, U-4, V-2, W-2, X-1, Y-2, Z-1
var kbye=eval('' + letters.length);
for (ibye=0; ibye<kbye; ibye++) {
for (jbye=1; jbye<=setn[ibye]; jbye++) {
letters.push(letters[ibye]);
}
}
}
if (sio.value == 'easiest') {
myblurb=myblurb.replace(', diagonal', '');
myblurb=myblurb.replace(', up, down', '');
myblurb=myblurb.replace(', backwards', '');
backwardsallowed=false;
updownallowed=false;
diagonalsallowed=false;
}
if (sio.value == 'easier') {
myblurb=myblurb.replace(', diagonal', '');
myblurb=myblurb.replace(', up, down', '');
myblurb=myblurb.replace('Forwards 4', 'Forwards, backwards 4');
backwardsallowed=true;
updownallowed=false;
diagonalsallowed=false;
}
if (sio.value == 'easy') {
myblurb=myblurb.replace('Forwards 4', 'Forwards, backwards, up, down, diagonal 4');
myblurb=myblurb.replace('Forwards, backwards 4', 'Forwards, backwards, up, down, diagonal 4');
backwardsallowed=true;
updownallowed=true;
diagonalsallowed=true;
}
document.getElementById('blurb').innerHTML=myblurb;
ebye='';
ibye=0;
jbye=0;
debye='';
aletter=' ';
for (ibye=0; ibye<20; ibye++) {
for (jbye=0; jbye<100; jbye++) {
aletter=letters[Math.floor(Math.random() * letters.length)];
ebye+=aletter;
debye+=aletter;
}
ebye+=String.fromCharCode(10);
debye+='<br>';
}
zdebye='';
zzdebye='';
lastzdebye='';
goutstris='';
delayis=0;
sofar=';';
document.getElementById('mytao').value=ebye;
var divs=document.getElementsByTagName('div');
for (kdivs=0; kdivs<divs.length; kdivs++) {
divs[kdivs].innerHTML='';
}
document.getElementById('underlay').innerHTML=debye;

}

… to help encourage some optional collaboration aspects to our changed word_find_game.html Word Find Game you can also try, again, below.


Previous relevant Word Find Game Underlay Tutorial is shown below.

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 our changed 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 the changed 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 our changed 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.


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


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


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


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


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


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


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


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

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