// countries.js
// July, 2023
// RJM Programming
// Help out countries.html and countries.php
var pos3=0, pos4=0, tdid='', poligono, punto, coone='', prectis, dragdt=null, dropdt=null, drdpcnt=0, mfour='myh4', classo=null, gelo=null, noyes='yes';
var addtable='
';
// var poligono = [[2,9],[8,6],[12,10],[15,2],[10,4],[5,1]];
// var punto = [6, 5];
function pointInPolygon(polygon, point) { // thanks to https://community.appinventor.mit.edu/t/geofence-check-if-a-point-is-inside-a-polygon-javascript-map/57091
var odd = false;
for (var i = 0, j = polygon.length - 1; i < polygon.length; i++) {
if (((polygon[i][1] > point[1]) !== (polygon[j][1] > point[1]))
&& (point[0] < ((polygon[j][0] - polygon[i][0]) * (point[1] - polygon[i][1]) / (polygon[j][1] - polygon[i][1]) + polygon[i][0]))) {
odd = !odd;
}
j = i;
}
return odd;
}
function andlaterstill() {
if (9 == 6) { // temporary
if (tdid != '') {
document.getElementById(tdid).innerHTML=document.getElementById(tdid).innerHTML.substring(0,1);
} else if (document.getElementById('mytable').innerHTML.indexOf(clonedatatwo) != '') {
document.getElementById('myh1').innerHTML=document.getElementById('myh1').innerHTML.split('')[0] + '';
}
if (document.getElementsByTagName('div')[0].innerHTML.indexOf(clonedatatwo) != -1) {
document.getElementsByTagName('div')[0].innerHTML=document.getElementsByTagName('div')[0].innerHTML.replace(clonedatatwo,'');
} else if (document.getElementsByTagName('div')[0].innerHTML.indexOf(clonedatatwo.replace('dragging','')) != -1) {
document.getElementsByTagName('div')[0].innerHTML=document.getElementsByTagName('div')[0].innerHTML.replace(clonedatatwo.replace('dragging',''),'');
} else if (document.body.innerHTML.split('')[0].indexOf(' title=' + String.fromCharCode(34) + coone) != -1) {
divs[ii].innerHTML=divs[ii].innerHTML.replace('z-index:24;', 'z-index:123;').replace('lime;', 'rgba(200,200,200,0.3);');
divs[ii].name='d' + tdid.replace(/\ /g, '_');
}
}
}
function cntdrdp() {
drdpcnt++;
if (parent.document.getElementById('th' + drdpcnt)) {
parent.document.getElementById('th' + drdpcnt).style.backgroundColor='lightgreen';
setTimeout(cntdrdp, 1000);
}
}
function dolaterwo() {
window.opener.viaej=false;
}
function dolaternonwo() {
parent.viaej=false;
}
function andqlater() {
//alert('HeRe');
tdid='';
var ppig='[]', coo='', coos=[], ip=0;
var squares; //=window.opener.document.getElementsByTagName('area');
if (window.opener) {
if (window.opener.document.getElementsByTagName('body')[0]) {
squares=window.opener.document.getElementsByTagName('area');
} else if (window.parent) {
if (parent.document.getElementsByTagName('body')[0]) {
squares=parent.document.getElementsByTagName('area');
}
}
} else if (window.parent) {
if (parent.document.getElementsByTagName('body')[0]) {
squares=parent.document.getElementsByTagName('area');
}
}
for (var ii=1; ii<=squares.length; ii++) {
ppig='[]';
coos=squares[eval(-1 + ii)].coords.replace(/\ /g,',').split(',');
ppig='[[' + coos[0] + ',' + coos[1] + ']]';
for (ip=2; ip';
} else {
document.getElementById('myh1').innerHTML='';
}
if (eval(dropdt - dragdt) >= 10000) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
window.open('//maps.google.com/maps?z=15&t=m&q=loc:' + window.opener.derivethislat(pos4) + ',' + ('+' + window.opener.derivethislong(pos3)).replace('+-','-'),'_blank'); //,'top=210,left=' + eval(-380 + screen.width) + ',width=350,height=570');
} else {
window.open('//maps.google.com/maps?z=15&t=m&q=loc:' + window.opener.derivethislat(pos4) + ',' + ('+' + window.opener.derivethislong(pos3)).replace('+-','-'),'_blank','top=210,left=' + eval(-380 + screen.width) + ',width=350,height=570');
}
}
if (eval(dropdt - dragdt) >= 20000) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
window.open('//earth.google.com/web/search/' + window.opener.derivethislat(pos4) + ',' + ('+' + window.opener.derivethislong(pos3)).replace('+-','-'),'_blank'); //,'top=240,left=' + eval(-410 + screen.width) + ',width=350,height=540');
} else {
window.open('//earth.google.com/web/search/' + window.opener.derivethislat(pos4) + ',' + ('+' + window.opener.derivethislong(pos3)).replace('+-','-'),'_blank','top=240,left=' + eval(-410 + screen.width) + ',width=350,height=540');
}
}
} else if (window.parent) {
if (parent.document.getElementsByTagName('body')[0]) {
if (parent.document.URL.indexOf('/regions.') != -1) {
window.open('/PHP/tz_places.php?place=&latitude=' + encodeURIComponent('' + parent.derivethislat(pos4)) + '&longitude=' + encodeURIComponent('' + parent.derivethislong(pos3)) + '&ntztontz=y','_blank','top=180,left=' + eval(-350 + screen.width) + ',width=350,height=600');
} else {
window.open('//wikipedia.org/wiki/' + encodeURIComponent(tdid.replace(/\ /g,'_')),'_blank','top=180,left=' + eval(-350 + screen.width) + ',width=350,height=600');
}
if (eval(dropdt - dragdt) >= 5000) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
window.open('//maps.google.com/maps?z=15&t=m&q=loc:' + parent.derivethislat(pos4) + ',' + ('+' + parent.derivethislong(pos3)).replace('+-','-'),'_blank'); //,'top=210,left=' + eval(-380 + screen.width) + ',width=350,height=570');
} else {
window.open('//maps.google.com/maps?z=15&t=m&q=loc:' + parent.derivethislat(pos4) + ',' + ('+' + parent.derivethislong(pos3)).replace('+-','-'),'_blank','top=210,left=' + eval(-380 + screen.width) + ',width=350,height=570');
}
}
if (eval(dropdt - dragdt) >= 20000) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
window.open('//earth.google.com/web/search/' + parent.derivethislat(pos4) + ',' + ('+' + parent.derivethislong(pos3)).replace('+-','-'),'_blank'); //,'top=240,left=' + eval(-410 + screen.width) + ',width=350,height=540');
} else {
window.open('//earth.google.com/web/search/' + parent.derivethislat(pos4) + ',' + ('+' + parent.derivethislong(pos3)).replace('+-','-'),'_blank','top=240,left=' + eval(-410 + screen.width) + ',width=350,height=540');
}
}
}
}
} else if (window.parent) {
if (parent.document.getElementsByTagName('body')[0]) {
if (parent.document.URL.indexOf('/regions.') != -1) {
window.open('/PHP/tz_places.php?place=&latitude=' + encodeURIComponent('' + parent.derivethislat(pos4)) + '&longitude=' + encodeURIComponent('' + parent.derivethislong(pos3)) + '&ntztontz=y','_blank','top=180,left=' + eval(-350 + screen.width) + ',width=350,height=600');
} else {
window.open('//wikipedia.org/wiki/' + encodeURIComponent(tdid.replace(/\ /g,'_')),'_blank','top=180,left=' + eval(-350 + screen.width) + ',width=350,height=600');
}
if (eval(dropdt - dragdt) >= 10000) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
window.open('//maps.google.com/maps?z=15&t=m&q=loc:' + parent.derivethislat(pos4) + ',' + ('+' + parent.derivethislong(pos3)).replace('+-','-'),'_blank'); //,'top=210,left=' + eval(-380 + screen.width) + ',width=350,height=570');
} else {
window.open('//maps.google.com/maps?z=15&t=m&q=loc:' + parent.derivethislat(pos4) + ',' + ('+' + parent.derivethislong(pos3)).replace('+-','-'),'_blank','top=210,left=' + eval(-380 + screen.width) + ',width=350,height=570');
}
}
if (eval(dropdt - dragdt) >= 20000) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
window.open('//earth.google.com/web/search/' + parent.derivethislat(pos4) + ',' + ('+' + parent.derivethislong(pos3)).replace('+-','-'),'_blank'); //,'top=240,left=' + eval(-410 + screen.width) + ',width=350,height=540');
} else {
window.open('//earth.google.com/web/search/' + parent.derivethislat(pos4) + ',' + ('+' + parent.derivethislong(pos3)).replace('+-','-'),'_blank','top=240,left=' + eval(-410 + screen.width) + ',width=350,height=540');
}
}
}
}
return tdid;
}
}
}
console.log('tdid=' + tdid);
//setTimeout(andlaterstill, 100);
return '';
}
window.addEventListener("DOMContentLoaded", () => {
gelo=wod('body');
const source = document.querySelector("#mg");
if (source.title.indexOf('ong drag') == -1 && !classo) {
source.title+=' ... long drag (eg. more than 10 seconds) also opens a Google Maps webpage ... very long drag (eg. more than 20 seconds) also opens a Google Earth webpage';
}
if (noyes == noyes.toUpperCase()) {
source.style.border='1px dashed pink';
}
console.log('source.id=' + source.id);
//if (!navigator.userAgent.match(/iPad/i)) {
source.addEventListener("dragstart", (ev) => {
var elo=null;
dragdt=(new Date());
if (window.opener) {
if (window.opener.document.getElementsByTagName('body')[0]) {
if (window.opener.document.getElementById('iftr')) {
window.opener.document.getElementById('iftr').scrolling=noyes;
}
if (window.opener.document.getElementById('ifxtr')) {
window.opener.document.getElementById('ifxtr').scrolling=noyes;
}
elo=wod('body');
if (window.opener.document.getElementById('textareaaction')) {
addtable=window.opener.document.getElementById('textareaaction').value;
}
window.opener.document.getElementById(mfour).innerHTML=addtable;
} else if (window.parent) {
if (parent.document.getElementsByTagName('body')[0]) {
if (parent.document.getElementById('iftr')) {
parent.document.getElementById('iftr').scrolling=noyes;
}
if (parent.document.getElementById('ifxtr')) {
parent.document.getElementById('ifxtr').scrolling=noyes;
}
elo=wod('body');
if (parent.document.getElementById('textareaaction')) {
addtable=parent.document.getElementById('textareaaction').value;
}
if (typeof(parent.amdragging) === 'undefined' || typeof(parent.havedropped) === 'undefined') {
parent.document.getElementById(mfour).innerHTML=addtable;
}
}
}
} else if (window.parent) {
if (parent.document.getElementsByTagName('body')[0]) {
if (parent.document.getElementById('iftr')) {
parent.document.getElementById('iftr').scrolling=noyes;
}
if (parent.document.getElementById('ifxtr')) {
parent.document.getElementById('ifxtr').scrolling=noyes;
}
elo=wod('body');
if (parent.document.getElementById('textareaaction')) {
addtable=parent.document.getElementById('textareaaction').value;
}
if (typeof(parent.amdragging) === 'undefined' || typeof(parent.havedropped) === 'undefined') {
parent.document.getElementById(mfour).innerHTML=addtable;
}
}
}
drdpcnt=0;
setTimeout(cntdrdp, 1000);
console.log("dragStart");
if (typeof(parent.amdragging) !== 'undefined') { parent.amdragging=true; }
if (typeof(parent.havedropped) !== 'undefined') { parent.havedropped=false; }
// Change the source element's background color
// to show that drag has started
ev.currentTarget.classList.add("dragging");
// Clear the drag data cache (for all formats/types)
ev.dataTransfer.clearData();
// Set the drag's format and data.
// Use the event target's id for the data
ev.dataTransfer.setData("text/plain", ev.target.id);
//ev.dataTransfer.setData("text/html", ev.target.outerHTML);
});
source.addEventListener("dragend", (ev) =>
ev.target.classList.remove("dragging")
);
//}
const target = wod('body'); //window.opener.document.getElementsByTagName('body')[0];
if (!classo) { target.id='usemap'; }
//if (!navigator.userAgent.match(/iPad/i)) {
console.log('target.id=' + target.id);
target.addEventListener("dragover", (ev) => {
console.log("dragOver");
ev.preventDefault();
});
target.addEventListener("drop", (ev) => {
console.log("Drop ... " + ev.target.id + ' --- ' + ev.target.outerHTML);
dropdt=(new Date());
if (('' + ev.target.id) != '') {
if (typeof(parent.amdragging) !== 'undefined') { parent.amdragging=false; }
if (typeof(parent.havedropped) !== 'undefined') { parent.havedropped=true; }
if (('' + ev.target.outerHTML).indexOf(' document.location.reload());
});
function dragorig() {
if (document.getElementById('mg')) {
document.getElementById('mg').draggable='true';
} else {
setTimeout(dragorig, 5000);
}
}
// setTimeout(dragorig, 5000);