<!doctype html>
<html>
<head>
<title>World Clickaround - RJM Programming - April, 2015</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<script type='text/javascript' src='world.js' defer></script>
<script type='text/javascript'>
var ie = 11;
var mode = 1;
var amode = 1;
var elem;
var elemLeft = 0;
var cf = "18px Verdana";
var elemTop = 0;
var context;
var elements = [];
var img;
var london_x = 408.0, london_y = 255.0; // vs hobart 756,512
var londonx = 408.0, londony = 255.0; // hobart 42.8806 S, 147.3250 E
var x=0, y=0, lastx=0, lasty=0;
var qx=0, qy=0, qlastx=0, qlasty=0;
var clickno = 0;
var ourlat, ourlong;
var url = "http://www.rjmprogramming.com.au/PHP/Map/map.php?title=London&label=['Lat',&value='Lon','Name']&data=,[51.5072,-0.1275,~London~]";
var xlworld = 'world';
var xuworld = 'World';
var xuubits=document.URL.split('.htm');
var xuuubits=xuubits[0].split('/');
xlworld=xuuubits[eval(-1 + xuuubits.length)];
xuworld=xlworld.substring(0,1).toUpperCase() + xlworld.substring(1);
var retx = 0.0, rety = 0.0;
function prereturnxy(inlatinlongthis) {
//alert(inlatinlongthis.title);
var prestuff = inlatinlongthis.title.split(",");
if (prestuff.length == 2) {
//alert(prestuff[0]);
return returnxy(prestuff[0], prestuff[1]);
}
return "0.0,0.0";
}
function returnxy(inlat, inlong) {
var retval="0.0,0.0";
var ourx = eval((londonx + eval(((inlong) - (0.0)) * ((348.0 * (londonx / london_x))) / (147.325))));
var oury = eval((londony + eval(((inlat) - (51.5)) * ((257.0 * (londony / london_y))) / (-94.3806))));
retx = ourx;
rety = oury;
retval = ourx + "," + oury;
if (context != null) context.fillStyle = '#0000ff';
if (context != null) context.fillRect(retx, rety, 5, 5);
return retval;
}
function ask() {
var huh="";
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
huh=huh;
} else {
if (document.URL.indexOf('?') == -1) {
huh=prompt("If you've zoomed your window, please answer Y and then click on London to scale. Then click away at places where you want to go.", "");
}
}
if (huh == null) {
clickno = 1;
//document.getElementById('mypiframe').src = "intair.php?plot=y";
} else if (huh == "y" || huh == "Y") {
clickno = 0;
} else {
clickno = 1;
//document.getElementById('mypiframe').src = "intair.php?plot=y";
}
}
function couldbe() {
var name1='', name2='';
qy = location.search.split('lat=')[1] ? eval(location.search.split('lat=')[1].split('&')[0]) : 0;
qx = location.search.split('long=')[1] ? eval(location.search.split('long=')[1].split('&')[0]) : 0;
if (eval(qx) == 0 && eval(qy) == 0) {
qy = location.search.split('lat1=')[1] ? eval(location.search.split('lat1=')[1].split('&')[0]) : 0;
qx = location.search.split('long1=')[1] ? eval(location.search.split('long1=')[1].split('&')[0]) : 0;
}
if (document.URL.indexOf('2=0000.0') == -1) {
qlasty = location.search.split('lat2=')[1] ? eval(location.search.split('lat2=')[1].split('&')[0]) : 0;
qlastx = location.search.split('long2=')[1] ? eval(location.search.split('long2=')[1].split('&')[0]) : 0;
}
if (eval(qx) != 0 || eval(qy) != 0) {
name1 = location.search.split('name=')[1] ? location.search.split('name=')[1].split('&')[0] : '';
name1 = location.search.split('name1=')[1] ? location.search.split('name1=')[1].split('&')[0] : name1;
ourlat = qy;
ourlong = qx;
qx = eval(eval(ourlong) / 147.325 * eval((348.0 * (londonx / london_x))) + eval(londonx));
qy = eval((eval(ourlat) - eval(51.5)) / (-94.3806) * eval((257.0 * (londony / london_y))) + eval(londony));
if (context != null) {
context.strokeStyle='red'; //element.colour;
context.fillStyle='yellow'; //element.colour;
context.fillRect(qx, qy, 5,5);
if (name1.replace('undefined','') != '') {
context.strokeStyle='blue'; //element.colour;
context.font = "16px Verdana"; //cf;
context.strokeText(decodeURIComponent(name1),eval(qx + 7), eval(qy + 7));
}
context.strokeStyle='red'; //document.getElementById('mycolour').value;
}
}
if (eval(qlastx) != 0 || eval(qlasty) != 0) {
name2 = location.search.split('name2=')[1] ? location.search.split('name2=')[1].split('&')[0] : '';
ourlat = qlasty;
ourlong = qlastx;
qlastx = eval(eval(ourlong) / 147.325 * eval((348.0 * (londonx / london_x))) + eval(londonx));
qlasty = eval((eval(ourlat) - eval(51.5)) / (-94.3806) * eval((257.0 * (londony / london_y))) + eval(londony));
context.fillStyle='yellow'; //element.colour;
context.fillRect(qlastx, qlasty, 5,5);
if (name2.replace('undefined','') != '') {
if (context != null && name2.replace('undefined','') != '') {
context.strokeStyle='blue'; //document.getElementById('mycolour').value;
context.font = "16px Verdana"; //cf;
context.strokeText(decodeURIComponent(name2),eval(qlastx + 7), eval(qlasty + 7));
}
context.strokeStyle='red'; //document.getElementById('mycolour').value;
}
}
if ((qx != qlastx || qy != qlasty) && (Math.abs(qlastx) > 0.00001 || Math.abs(qlasty) > 0.00001)) {
if (document.getElementById('divannotation')) document.getElementById('divannotation').style.display='block';
if (document.getElementById('divannotation')) document.getElementById('myisubject').style.display = 'inline';
if (document.getElementById('divannotation')) document.getElementById('myiemail').style.display = 'inline';
if (context != null) {
var three=2;
while ((qx != qlastx || qy != qlasty) && (Math.abs(qlastx) > 0.00001 || Math.abs(qlasty) > 0.00001)) {
context.fillStyle='yellow'; //element.colour;
context.fillRect(qlastx, qlasty, 5,5);
if (name2.replace('undefined','') != '') {
if (context != null && name2.replace('undefined','') != '') {
context.strokeStyle='blue'; //document.getElementById('mycolour').value;
context.font = "16px Verdana"; //cf;
context.strokeText(decodeURIComponent(name2),eval(qlastx + 7), eval(qlasty + 7));
}
context.strokeStyle='red'; //document.getElementById('mycolour').value;
}
context.fillStyle='red'; //element.colour;
context.strokeStyle='red'; //document.getElementById('mycolour').value;
context.beginPath();
context.moveTo(qx,qy);
context.lineTo(qlastx,qlasty);
context.stroke();
qx=qlastx;
qy=qlasty;
three++;
qlasty = location.search.split('lat' + three + '=')[1] ? eval(location.search.split('lat' + three + '=')[1].split('&')[0]) : 0;
qlastx = location.search.split('long' + three + '=')[1] ? eval(location.search.split('long' + three + '=')[1].split('&')[0]) : 0;
name2 = location.search.split('name' + three + '=')[1] ? location.search.split('name' + three + '=')[1].split('&')[0] : '';
if (qlastx != 0 || qlasty != 0) {
ourlat = qlasty;
ourlong = qlastx;
qlastx = eval(eval(ourlong) / 147.325 * eval((348.0 * (londonx / london_x))) + eval(londonx));
qlasty = eval((eval(ourlat) - eval(51.5)) / (-94.3806) * eval((257.0 * (londony / london_y))) + eval(londony));
}
}
}
}
//x=0;
//y=0;
//lastx=0;
//lasty=0;
}
window.onload = function() {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
var hh = today.getHours();
var minm = today.getMinutes(); //January is 0!
var ss = today.getSeconds();
if (document.getElementById('myfname')) document.getElementById('myfname').value = xlworld + "_" + yyyy + "_" + mm + "_" + hh + "_" + minm + "_" + ss + ".png";
if (document.getElementById('myform')) document.getElementById('myform').action = document.getElementById('myform').action.replace('?mode=1', '');
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
if (document.getElementById('mode')) {
document.getElementById('mode').value = '';
document.getElementById('ismobile').value = 'y';
document.getElementById('myisubject').style.display = 'inline';
document.getElementById('myiemail').style.display = 'inline';
document.getElementById('myform').action = document.getElementById('myform').action.replace('?mode=1', '');
document.getElementById('myform').action = document.getElementById('myform').action.replace('mode=1', 'mode=');
//document.getElementById('myemail').href = '#' + document.getElementById('myemail').href;
}
}
ie = (function(){ // thanks to http://stackoverflow.com/questions/5574842/best-way-to-check-for-ie-less-than-9-in-javascript-without-library
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
all[0]
);
return v > 4 ? v : undef;
}());
img = document.getElementById("world");
if (ie < 9) {
document.getElementById('canvaselement').style.display = 'none';
document.getElementById('others').style.display = 'none';
context = null;
document.getElementById('world').style.display = 'block';
elem = document.getElementById('world');
// Add event listener for `click` events.
elem.attachEvent('onclick', function(event) {
if (x == 0 && y == 0 && lastx == 0 && lasty == 0) {
if (event.clientX || event.clientY) {
x = event.clientX - elemLeft;
y = event.clientY - elemTop;
} else {
x = event.pageX - elemLeft;
y = event.pageY - elemTop;
}
lastx=x;
lasty=y;
} else {
lastx=x;
lasty=y;
if (event.clientX || event.clientY) {
x = event.clientX - elemLeft;
y = event.clientY - elemTop;
} else {
x = event.pageX - elemLeft;
y = event.pageY - elemTop;
}
}
//alert(x + " " + y);
if (clickno == 0) {
londonx = x;
londony = y;
ourlong = eval(0.0 + (x - londonx) / (348.0 * (londonx / london_x)) * 147.325);
ourlat = eval(51.5 + (y - londony) / (257.0 * (londony / london_y)) * (-94.3806));
} else {
ourlong = eval(0.0 + (x - londonx) / (348.0 * (londonx / london_x)) * 147.325);
ourlat = eval(51.5 + (y - londony) / (257.0 * (londony / london_y)) * (-94.3806));
}
elements.push({
colour: '#ff0000',
width: 5,
height: 5,
top: y,
left: x
});
clickno = clickno + 1;
document.getElementById('myiframe').src = "http://www.rjmprogramming.com.au/PHP/Map/map.php?title=Your%20Place%20and%20Airports&label=['Lat',&value='Lon','Name']&data=,[" + ourlat.toFixed(5).replace(/0+$/, "") + "," + ourlong.toFixed(5).replace(/0+$/, "") + ",~Your%20Place~]"
document.getElementById('mypiframe').src = "intair.php?num=4&lat=" + ourlat + "&long=" + ourlong;
if (x != lastx || y != lasty) {
document.getElementById('divannotation').style.display='block';
document.getElementById('myisubject').style.display = 'inline';
document.getElementById('myiemail').style.display = 'inline';
}
});
} else {
elem = document.getElementById('canvaselement');
context = elem.getContext("2d");
context.drawImage(img,0,0);
couldbe();
elemLeft = elem.offsetLeft;
elemTop = elem.offsetTop;
// Add event listener for `click` events.
elem.addEventListener('click', function(event) {
if (x == 0 && y == 0 && lastx == 0 && lasty == 0) {
if (event.pageX || event.pageY) {
x = event.pageX - elemLeft;
y = event.pageY - elemTop;
} else {
x = event.clientX - elemLeft;
y = event.clientY - elemTop;
}
lastx=x;
lasty=y;
} else {
lastx=x;
lasty=y;
if (event.pageX || event.pageY) {
x = event.pageX - elemLeft;
y = event.pageY - elemTop;
} else {
x = event.clientX - elemLeft;
y = event.clientY - elemTop;
}
}
//alert(x + " " + y);
if (clickno == 0) {
londonx = x;
londony = y;
ourlong = eval(0.0 + (x - londonx) / (348.0 * (londonx / london_x)) * 147.325);
ourlat = eval(51.5 + (y - londony) / (257.0 * (londony / london_y)) * (-94.3806));
} else {
ourlong = eval(0.0 + (x - londonx) / (348.0 * (londonx / london_x)) * 147.325);
ourlat = eval(51.5 + (y - londony) / (257.0 * (londony / london_y)) * (-94.3806));
}
elements.push({
colour: '#ff0000',
width: 5,
height: 5,
top: y,
left: x
});
clickno = clickno + 1;
// Collision detection between clicked offset and element.
elements.forEach(function(element) {
//alert('clicked Element at ' + ourlong + ' ' + ourlat + ' ' + element.left + ',' + element.top + ' with width=' + element.width + ' and height=' + element.height + ' and colour=' + element.colour);
if (context != null) context.fillStyle = element.colour;
if (context != null) context.fillRect(element.left, element.top, element.width, element.height);
document.getElementById('myiframe').src = "http://www.rjmprogramming.com.au/PHP/Map/map.php?title=Your%20Place%20and%20Airports&label=['Lat',&value='Lon','Name']&data=,[" + ourlat.toFixed(5).replace(/0+$/, "") + "," + ourlong.toFixed(5).replace(/0+$/, "") + ",~Your%20Place~]"
});
document.getElementById('mypiframe').src = "intair.php?num=4&lat=" + ourlat + "&long=" + ourlong;
if (x != lastx || y != lasty) {
document.getElementById('divannotation').style.display='block';
document.getElementById('myisubject').style.display = 'inline';
document.getElementById('myiemail').style.display = 'inline';
}
});
}
setTimeout(ask, 1000);
}
</script>
</head>
<body>
<table><tr><td>
<canvas id="canvaselement" width=850 height=600 style="position: absolute; top:0; left:0; "></canvas></td><td>
<h1 style="position: absolute; top:0; left:860px; " align='center'>World Clickaround <select id='others' onchange=" location.href=this.value + '.htm';"><option value='world'> ... or ...</option><option value='australia'>Australia</option><option value="welcometonation">Welcome to Nation</option><option value='brazil'>Brazil</option><option value='china'>China</option><option value='germany'>Germany</option><option value='india'>India</option><option value='ireland'>Ireland</option><option value='nigeria'>Nigeria</option><option value='united_states'>United States</option><option value='world'>World</option></select></h1><br>
<iframe style="position: absolute; top:140px; left:860px; " id="myiframe" width=320 height=460 src="http://www.rjmprogramming.com.au/PHP/Map/map.php?title=London&label=['Lat',&value='Lon','Name']&data=,[51.5072,-0.1275,~London~]"></iframe>
<a id='mya' href='#' title='-42.8806,147.3250' onclick='prereturnxy(this);' style="position: absolute; top:1000px; left:860px; display:none;text-decoration:none; "> </a><iframe id='mypiframe' style='display:none;' src='intair.php' title='International Airport plot'></iframe>
</td></tr></table>
<img id="world" src="world.jpg" style="display:none;position: absolute; top:0; left:0; " />
</body>
</html>