You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

841 lines
26 KiB
JavaScript

';';';';';';';';';';';
var map;
var mapTypeIds;
var msg;
var buttons;
var counter;
var lastMarker = null;
var serverMarker;
var myMarker;
var linePath;
var linePathArray = new Array();
var pluginInstalled = false;
var pluginEnabled = false;
var pluginVersion = '';
var pluginMIME = 'application/real-ip-lookup';
function scanForPlugin() {
try {
if (navigator.mimeTypes[pluginMIME]) pluginInstalled = true; else pluginInstalled = false;
if (navigator.mimeTypes[pluginMIME].enabledPlugin) pluginEnabled = true; else pluginEnabled = false;
ver = navigator.mimeTypes[pluginMIME].enabledPlugin.description.split('[');
if (ver.length == 2)
{
ver = ver[1].split(']');
if (ver.length == 2) pluginVersion = ver[0];
}
} catch(e) {
pluginInstalled = false;
pluginEnabled = false;
}
}
function getParam(name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null) return ''; else return decodeURI(results[1]);
}
function saveToCache(host, data) {
if (data != '')
widget.preferences.setItem(host, data);
}
function loadFromCache(host, ip) {
return widget.preferences.getItem('host_' + host + '_' + ip);
}
function gd4ip(data, hop, noruua) {
// opera.postError('hop: ' + hop + ', data: ' + data);
if (data == 'timeout')
{
var latlng = new google.maps.LatLng(0, 0);
linePathArray[hop] = latlng;
}
else
{
try { data = JSON.parse(data) } catch(e) { data = JSON.parse('{}') }
noruua = noruua || 0;
var cc = data.countryCode;
var ia = data.ipAddress;
if (data.statusCode != 'OK' || cc == '') widget.preferences.removeItem('host_tracert_' + ia);
if ((cc.toLowerCase() == 'ru' || cc.toLowerCase() == 'ua' || cc == '') & noruua != 1)
{
var cdata = loadFromCache('tracertRUUA', ia);
if (!cdata)
{
var req = new XMLHttpRequest();
req.onreadystatechange = function()
{
if (req.readyState == 4)
{
clearTimeout(reqTimeout);
if (req.responseText != '')
var xmldata = (new XMLSerializer()).serializeToString(req.responseXML);
else
var xmldata = '';
if (xmldata.indexOf('RU') != -1 || xmldata.indexOf('UA') != -1)
{
saveToCache('host_tracertRUUA_' + ia, xmldata);
gd4ipRUUA(xmldata, hop);
} else gd4ip(data, hop, 1);
}
}
if (ia != '')
{
req.open('GET', 'http://ipgeobase.ru:7020/geo?ip=' + ia, true);
var timeoutFunc = function(){
req.abort();
gd4ip(data, hop, 1);
}
var reqTimeout = setTimeout(timeoutFunc, 10000);
req.send(null);
}
} else
if (cdata.indexOf('RU') != -1 || cdata.indexOf('UA') != -1)
gd4ipRUUA(cdata, hop);
else
gd4ip(data, hop, 1);
}
else
{
if (lastMarker == null)
var latlng = new google.maps.LatLng(getParam('lat2'), getParam('long2'));
else
{
if (data == 'timeout')
var latlng = new google.maps.LatLng(0, 0);
else
var latlng = new google.maps.LatLng(data.latitude, data.longitude);
}
linePathArray[hop] = latlng;
lastMarker = hop;
}
}
}
function gd4ipRUUA(data, hop) {
var xmlobj = (new DOMParser()).parseFromString(data, 'text/xml');
var iptag = xmlobj.getElementsByTagName('ip')[0];
if (lastMarker == null)
var latlng = new google.maps.LatLng(getParam('lat2'), getParam('long2'));
else
var latlng = new google.maps.LatLng(iptag.getElementsByTagName('lat')[0].textContent, iptag.getElementsByTagName('lng')[0].textContent);
linePathArray[hop] = latlng;
lastMarker = hop;
}
function visualTrace(ip, hops) {
if (counter >= 30)
{
$(msg).remove();
buttons.show('fade');
return;
}
if (linePathArray.length < hops)
{
$(msg).html('' + i18n.tracert_wait + (30 - counter).toString() + ' ' + i18n.tracert_sec + '...');
counter++;
setTimeout(function() { visualTrace(ip, hops) }, 1000, ip, hops);
return;
}
$(msg).html('' + i18n.tracert_vis + '');
serverMarker.setMap(null);
myMarker.setMap(null);
linePath.setMap(null);
google.maps.event.clearListeners(linePath, 'mouseover');
google.maps.event.clearListeners(linePath, 'mousemove');
google.maps.event.clearListeners(linePath, 'mouseout');
switch (widget.preferences.gd4ip_visproc) {
case '1': var delay = 1000; break;
case '2': var delay = 0; break;
default: var delay = 1000;
}
var tocorrect = 0;
var lastpoint;
var lastvalidindex;
for (var k = 0; k < linePathArray.length; k++)
{
try {
if (!linePathArray[k]) continue;
if (linePathArray[k].lat() != 0 & linePathArray[k].lng() != 0 & typeof linePathArray[k] != 'undefined')
lastvalidindex = k;
} catch(e) {
opera.postError(e.message);
$(msg).remove();
buttons.show('fade');
}
}
for (var j = 0; j < linePathArray.length; j++)
try {
var latlngj = linePathArray[j];
if (j == 0 & !latlngj) break;
if (latlngj.lat() == 0 || latlngj.lng() == 0 || typeof latlngj == 'undefined') tocorrect++; else
if (j == 0)
{
var myOptions = {
scaleControl: true,
zoom: 4,
center: new google.maps.LatLng(0,0),
mapTypeId: map.getMapTypeId(),
mapTypeControlOptions: { mapTypeIds: mapTypeIds }
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
MapSetTypes();
google.maps.event.addListener(map, "maptypeid_changed", toggleOverlay);
var visPath = new google.maps.Polyline({
clickable: false,
geodesic: true,
map: map,
strokeColor: '#7CD430',
strokeOpacity: 0.5,
strokeWeight: 4
});
if (delay == 1000) map.panTo(latlngj);
lastpoint = latlngj;
visPath.getPath().push(latlngj);
var marker = 'marker2.png';
var startMarker = new google.maps.Marker({
position: latlngj,
icon: marker,
map: map,
title: ip,
zIndex: 0
});
} else {
lastpoint = latlngj;
setTimeout(function(latlngj, j, ip) {
if (j == lastvalidindex)
{
$(msg).remove();
buttons.show('fade');
}
if (delay == 1000) map.panTo(latlngj);
visPath.getPath().push(latlngj);
var marker = 'marker3.png';
var nextMarker = new google.maps.Marker({
position: latlngj,
icon: marker,
map: map,
title: j.toString()
});
var labeloffset = 0;
for (var i = j - 1; i >= 0; i--)
if (latlngj.equals(linePathArray[i])) labeloffset -= 20;
var labelOptions = {
content: j.toString(),
boxStyle: {
backgroundColor: "#BFF5A1",
opacity: 0.8,
border: "1px solid #27351F",
textAlign: "center",
fontSize: "12px",
fontWeight: 'normal',
fontFamily: 'Arial',
width: "20px",
height: "15px",
padding: "2px",
margin: 0,
zIndex: 100 + j
},
disableAutoPan: true,
pixelOffset: new google.maps.Size(-13, -40 + labeloffset),
position: latlngj,
closeBoxURL: '',
isHidden: false,
pane: 'mapPane',
enableEventPropagation: true
};
var ibLabel = new InfoBox(labelOptions);
ibLabel.open(map);
}, delay * (j + 1 - tocorrect), latlngj, j, ip);
}
} catch(e) {
opera.postError(e.message);
$(msg).remove();
buttons.show('fade');
}
if (delay == 0 & typeof lastpoint != 'undefined') map.panTo(lastpoint);
}
function fetchData(ip, hop) {
var cdata = loadFromCache('tracert', ip);
// opera.postError('ip: ' + ip + '| hop: ' + hop + ' | cdata: ' + cdata);
if (ip == '0.0.0.0') gd4ip('timeout', hop); else
if (!cdata)
{
var req = new XMLHttpRequest();
req.onreadystatechange = function()
{
if (req.readyState == 4 & req.status == 200)
{
//opera.postError('hop: ' + hop + ' | cdata: ' + req.responseText);
saveToCache('host_tracert_' + ip, req.responseText);
if (req.responseText != '') gd4ip(req.responseText, hop);
}
}
if (ip != '')
req.open('GET', 'http://api.ipinfodb.com/v3/ip-city/?key=5e0283124cdb3106600b706da5a3846d3b10675a8a68076459ceb4bc3722fec5&ip='+ip+'&format=json', true);
req.send(null);
} else gd4ip(cdata, hop);
}
function doCallback(ip, lookup)
{
var tracert = JSON.parse('{}');
// function callbackFunction(result) {
// opera.postError('result: ' + result);
// tracert = JSON.parse(result);
// }
try {
lastMarker = null;
linePathArray = new Array();
counter = 0;
var plugin = document.getElementById('plugin');
var MyIPTools = plugin.MyIPTools();
var resp;
resp = MyIPTools.hostTracertInit(ip);
if (resp == '' || typeof resp == 'undefined') opera.postError('Error: no Init confirmation'); else
{
fetchData(ip, 0);
buttons.hide();
$('.ui-dialog-buttonset').append(msg);
msg.innerHTML = '' + i18n.tracert_getdata +'';
$(msg).css({'height': '100%', 'padding': '15px'});
trbody = document.getElementById('trbody');
trbody.innerHTML = '';
newtr = document.createElement('tr');
if (lookup)
newtr.innerHTML = 'Hopt1t2t3HostIP
else
newtr.innerHTML = 'Hopt1t2t3IP
trbody.appendChild(newtr);
try { resp = JSON.parse(resp) } catch(e) { resp = JSON.parse('{}') }
var tocount = 0;
if (resp.Status != 'OK') opera.postError('Init: ' + resp.Error);
for(var i = 1; i <= 30; i++)
{
resp = MyIPTools.hostTracert(ip, i, lookup);
if (resp != '' & typeof resp != 'undefined')
{
if (tocount == 5) break;
try { resp = JSON.parse(resp) } catch(e) { resp = JSON.parse('{}') }
if (typeof resp.Error != 'undefined' & resp.Error != '')
{
opera.postError('Error: ' + resp.Error);
break;
}
if (resp.hop < i) break;
if (typeof resp.response != 'undefined' & resp.response != '')
{
tocount++;
resp.saddr = i18n.tracert_timeout;
resp.hostname = '-';
fetchData('0.0.0.0', i);
}
else
{
fetchData(resp.saddr, i);
tocount = 0;
}
var newtr = document.createElement('tr');
newtr.innerHTML = '' + resp.hop + '
if (resp.retr1 == '*')
newtr.innerHTML += '*
else
newtr.innerHTML += '' + resp.retr1 + ' ' + i18n.tracert_ms + '
if (resp.retr2 == '*')
newtr.innerHTML += '*
else
newtr.innerHTML += '' + resp.retr2 + ' ' + i18n.tracert_ms + '
if (resp.retr3 == '*')
newtr.innerHTML += '*
else
newtr.innerHTML += '' + resp.retr3 + ' ' + i18n.tracert_ms + '
if (lookup)
newtr.innerHTML += '' + resp.hostname + '' + resp.saddr + '
else
newtr.innerHTML += '' + resp.saddr + '
$(newtr).appendTo($(trbody)).hide().fadeIn('fast');
trarea.scrollTop = trarea.scrollHeight;
} else break;
}
resp = MyIPTools.hostTracertUnInit();
if (resp != '' & typeof resp != 'undefined')
try { resp = JSON.parse(resp) } catch(e) { resp = JSON.parse('{}') }
else
opera.postError('Error: no UnInit confirmation');
if (resp.Status != 'OK') opera.postError('UnInit: ' + resp.Error);
setTimeout(function() { visualTrace(ip, i) }, 1000, ip, i);
}
} catch(e) {
opera.postError(e.message);
buttons.show('fade');
alert(i18n.plugin_error);
}
}
function MapSetTypes()
{
map.mapTypes.set('OSM0', new google.maps.ImageMapType({
alt: 'wikimapia.org',
isPng: true,
getTileUrl: function(coord, zoom) {
if (i18n.code == 2) lang = '1'; else lang = '0';
return 'http://i' + (coord.x%4 + (coord.y%4)*4) + '.wikimapia.org/?x=' + coord.x + '&y=' + coord.y + '&zoom=' + zoom + '&lng=' + lang;
},
tileSize: new google.maps.Size(256, 256),
name: 'Wikimapia',
maxZoom: 18
}));
map.mapTypes.set('OSM0h', new google.maps.ImageMapType({
alt: 'wikimapia.org',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['0', '1', '2', '3'];
// return 'http://mt' + CDN[Math.floor(Math.random()*4)] + '.google.com/vt/lyrs=t@128,r@169000000&src=apiv3&z=' + zoom + '&x=' + coord.x + '&y=' + coord.y + '&hl=' + lang;
if (i18n.code == 2) lang = 'ru'; else lang = 'en';
return 'http://khm' + CDN[Math.floor(Math.random()*4)] + '.google.com/kh/v=118&z=' + zoom + '&x=' + coord.x + '&y=' + coord.y + '&hl=' + lang;
},
tileSize: new google.maps.Size(256, 256),
name: 'Wikimapia Hybrid',
maxZoom: 18
}));
map.mapTypes.set('OSM1', new google.maps.ImageMapType({
alt: 'osm.org',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c'];
return 'http://' + CDN[Math.floor(Math.random()*3)] + '.tile.openstreetmap.org/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'OpenStreetMap',
maxZoom: 18
}));
map.mapTypes.set('OSM2', new google.maps.ImageMapType({
alt: 'thunderforest.com',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c'];
return 'http://' + CDN[Math.floor(Math.random()*3)] + '.tile3.opencyclemap.org/landscape/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'Landscape Map',
maxZoom: 18
}));
map.mapTypes.set('OSM3', new google.maps.ImageMapType({
alt: 'mapquest.com',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['1', '2', '3', '4'];
return 'http://mtile0' + CDN[Math.floor(Math.random()*4)] + '.mqcdn.com/tiles/1.0.0/vx/map/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'MapQuest',
maxZoom: 18
}));
map.mapTypes.set('OSM3h', new google.maps.ImageMapType({
alt: 'mapquest.com',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['1', '2', '3', '4'];
return 'http://mtile0' + CDN[Math.floor(Math.random()*4)] + '.mqcdn.com/tiles/1.0.0/vx/sat/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'MapQuest Hybrid',
maxZoom: 12
}));
map.mapTypes.set('OSM4', new google.maps.ImageMapType({
alt: 'maps.cloudmade.com',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c'];
return 'http://' + CDN[Math.floor(Math.random()*3)] + '.tile.cloudmade.com/fa327a1372b64fe79e3a5d0838a87005/1/256/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'CloudMade',
maxZoom: 18
}));
map.mapTypes.set('OSM4f', new google.maps.ImageMapType({
alt: 'maps.cloudmade.com',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c'];
return 'http://' + CDN[Math.floor(Math.random()*3)] + '.tile.cloudmade.com/fa327a1372b64fe79e3a5d0838a87005/53777/256/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'CloudMade Fresh',
maxZoom: 18
}));
function eqt(z, x, y) {
NUM_CHAR = ['0', '1', '2', '3'];
var tn = Array(), num;
for (var i = z - 1; i >= 0; i--)
{
num = (x % 2) | ((y % 2) << 1);
tn[i] = NUM_CHAR[num];
x = x >> 1;
y = y >> 1;
}
return tn.join('');
}
map.mapTypes.set('OSM5', new google.maps.ImageMapType({
alt: 'www.bing.com/maps/',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['0', '1', '2', '3'];
return 'http://r' + CDN[Math.floor(Math.random()*4)] + '.ortho.tiles.virtualearth.net/tiles/r' + eqt(zoom, coord.x, coord.y) + '.png?g=858&lbl=l1';
},
tileSize: new google.maps.Size(256, 256),
name: 'Bing',
minZoom: 1,
maxZoom: 19
}));
map.mapTypes.set('OSM5h', new google.maps.ImageMapType({
alt: 'www.bing.com/maps/',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['0', '1', '2', '3'];
return 'http://h' + CDN[Math.floor(Math.random()*4)] + '.ortho.tiles.virtualearth.net/tiles/h' + eqt(zoom, coord.x, coord.y) + '.png?g=858&lbl=l1';
},
tileSize: new google.maps.Size(256, 256),
name: 'Bing Hybrid',
minZoom: 1,
maxZoom: 19
}));
map.mapTypes.set('OSM6', new google.maps.ImageMapType({
alt: 'MapBox Streets',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c'];
return 'http://' + CDN[Math.floor(Math.random()*3)] + '.tiles.mapbox.com/v3/examples.map-vyofok3q/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'MapBox Streets',
maxZoom: 17
}));
map.mapTypes.set('RD1', new google.maps.ImageMapType({
alt: 'Pirate Map',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c'];
return 'http://' + CDN[Math.floor(Math.random()*3)] + '.tiles.mapbox.com/v3/aj.Sketchy2/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'Pirate Map',
maxZoom: 6
}));
map.mapTypes.set('RD2', new google.maps.ImageMapType({
alt: 'Population Fire',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c'];
return 'http://' + CDN[Math.floor(Math.random()*3)] + '.tiles.mapbox.com/v3/aj.population-fire/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'Population Fire',
maxZoom: 6
}));
map.mapTypes.set('RD3', new google.maps.ImageMapType({
alt: 'Contour Map',
isPng: true,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c'];
return 'http://' + CDN[Math.floor(Math.random()*3)] + '.tiles.mapbox.com/v3/herwig.map-olatzdh8/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
name: 'Contour Map',
maxZoom: 17
}));
map.mapTypes.set('RD4', new google.maps.ImageMapType({
alt: 'Watercolor',
isPng: false,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c', 'd'];
return 'http://' + CDN[Math.floor(Math.random()*4)] + '.tile.stamen.com/watercolor/' + zoom + '/' + coord.x + '/' + coord.y + '.jpg';
},
tileSize: new google.maps.Size(256, 256),
name: 'Watercolor',
minZoom: 1,
maxZoom: 18
}));
map.mapTypes.set('RD5', new google.maps.ImageMapType({
alt: 'OSM Coverage',
isPng: false,
getTileUrl: function(coord, zoom) {
CDN = ['a', 'b', 'c', 'd'];
return 'http://' + CDN[Math.floor(Math.random()*4)] + '.tiles.mapbox.com/v3/saman.map-nzxr8zw8/' + zoom + '/' + coord.x + '/' + coord.y + '.jpg';
},
tileSize: new google.maps.Size(256, 256),
name: 'OSM Coverage',
maxZoom: 6,
minZoom: 3
}));
/*
map.mapTypes.set('OSMx', new google.maps.ImageMapType({
alt: 'yandex.ru',
isPng: false,
getTileUrl: function(coord, zoom) {
CDN = ['1', '2', '3', '4'];
return 'http://vec0' + CDN[Math.floor(Math.random()*4)] + '.maps.yandex.net/tiles?l=map&v=2.24.0&x=' + coord.x + '&y=' + coord.y + '&z=' + zoom;
},
tileSize: new google.maps.Size(256, 256),
name: 'Yandex Map [RU]',
maxZoom: 17
}));
*/
}
function toggleOverlay()
{
if (map.getMapTypeId() == 'OSM0h')
{
var mapoverlay = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
if (i18n.code == 2) lang = '1'; else lang = '0';
return 'http://i' + (coord.x%4 + (coord.y%4)*4) + '.wikimapia.org/?type=hybrid&x=' + coord.x + '&y=' + coord.y + '&zoom=' + zoom + '&lng=' + lang;
},
tileSize: new google.maps.Size(256, 256),
isPng: true,
maxZoom: 20,
name: 'Satellite Overlay',
alt: ''
});
map.overlayMapTypes.setAt(0, mapoverlay);
} else
if (map.getMapTypeId() == 'OSM3h')
{
var mapoverlay = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
CDN = ['1', '2', '3', '4'];
return 'http://mtile0' + CDN[Math.floor(Math.random()*4)] + '.mqcdn.com/tiles/1.0.0/vx/hyb/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
isPng: true,
maxZoom: 20,
name: 'Labels Overlay',
alt: 'Labels Overlay'
});
map.overlayMapTypes.setAt(0, mapoverlay);
} else
{
map.overlayMapTypes.setAt(0, null);
}
}
$(function(){
if (getParam('tracert') == 1)
{
$('#terminal').attr('title', i18n.tracert + ' [' + getParam('hostName1') + ']');
var btns = {};
btns[i18n.tracert_btn1] = function() { doCallback(getParam('ipAddress1'), true) };
btns[i18n.tracert_btn2] = function() { doCallback(getParam('ipAddress1'), false) };
$('#terminal').dialog({
autoOpen: false,
draggable: true,
resizable: true,
closeOnEscape: false,
position: ['right',30],
maxWidth: 1225,
maxHeight: 400,
minWidth: 660,
minHeight: 200,
buttons: btns
});
$('.ui-dialog-titlebar-close').hide();
setTimeout(function(){
$('#terminal').dialog('widget').css({"position": "absolute", "width": "700px", "height": "auto", "top": "55px", "right": "30px"}).fadeTo(500, 0.9);
}, 750);
lastMarker = null;
buttons = $('.ui-dialog-buttonset button');
msg = document.createElement('div');
scanForPlugin();
if (pluginInstalled == false || pluginEnabled == false)
{
buttons.hide();
$(msg).html('' + i18n.tracert_plugin + '');
$('#wrapContent').hide();
$('#terminal').dialog('option', {resizable: false});
$('.ui-dialog-buttonset').append(msg);
} else if (pluginVersion != '1.0.2.0')
{
buttons.hide();
$(msg).html('' + i18n.tracert_pluginver + '');
$('#wrapContent').hide();
$('#terminal').dialog('option', {resizable: false});
$('.ui-dialog-buttonset').append(msg);
}
}
if (getParam('lat2') == '' || getParam('long2') == '' || (getParam('lat2') == '0' & getParam('long2') == '0'))
var dopath = false; else var dopath = true;
var latlng1 = new google.maps.LatLng(getParam('lat1'), getParam('long1'));
if (dopath) var latlng2 = new google.maps.LatLng(getParam('lat2'), getParam('long2'));
mapTypeIds = [];
for(var type in google.maps.MapTypeId) {
mapTypeIds.push(google.maps.MapTypeId[type]);
}
mapTypeIds.push('OSM0');
mapTypeIds.push('OSM0h');
mapTypeIds.push('OSM1');
mapTypeIds.push('OSM2');
mapTypeIds.push('OSM3');
mapTypeIds.push('OSM3h');
mapTypeIds.push('OSM4');
mapTypeIds.push('OSM4f');
mapTypeIds.push('OSM5');
mapTypeIds.push('OSM5h');
mapTypeIds.push('OSM6');
if (widget.preferences.gd4ip_unusualmaps == '1')
{
mapTypeIds.push('RD1');
mapTypeIds.push('RD2');
mapTypeIds.push('RD3');
mapTypeIds.push('RD4');
mapTypeIds.push('RD5');
}
switch (widget.preferences.gd4ip_defmap) {
case '0': var mapDefType = google.maps.MapTypeId.ROADMAP; break;
case '1': var mapDefType = google.maps.MapTypeId.TERRAIN; break;
case '2': var mapDefType = google.maps.MapTypeId.HYBRID; break;
case '3': var mapDefType = 'OSM0'; break;
case '4': var mapDefType = 'OSM0h'; break;
case '5': var mapDefType = 'OSM1'; break;
case '6': var mapDefType = 'OSM2'; break;
case '7': var mapDefType = 'OSM3'; break;
case '8': var mapDefType = 'OSM3h'; break;
case '9': var mapDefType = 'OSM4'; break;
case '10': var mapDefType = 'OSM4f'; break;
case '11': var mapDefType = 'OSM5'; break;
case '12': var mapDefType = 'OSM5h'; break;
case '13': var mapDefType = 'OSM6'; break;
default: var mapDefType = google.maps.MapTypeId.HYBRID;
}
var myOptions = {
scaleControl: true,
zoom: 4,
center: latlng1,
mapTypeId: mapDefType,
mapTypeControlOptions: { mapTypeIds: mapTypeIds }
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
MapSetTypes();
google.maps.event.addListener(map, "maptypeid_changed", toggleOverlay);
toggleOverlay();
var contentString1 = ''+getParam('table1')+'
'
;
var contentString2 = ''+getParam('table2')+'
'
;
var infowindow1 = new google.maps.InfoWindow({
content: contentString1,
zIndex: 2
});
var infowindow2 = new google.maps.InfoWindow({
content: contentString2,
zIndex: 1
});
var marker1 = 'marker1.png';
serverMarker = new google.maps.Marker({
position: latlng1,
icon: marker1,
map: map,
title: getParam('countryName1') + ' - ' + getParam('ipAddress1')
});
if (dopath)
{
var marker2 = 'marker2.png';
myMarker = new google.maps.Marker({
position: latlng2,
icon: marker2,
map: map,
title: getParam('countryName2') + ' - ' + getParam('ipAddress2')
});
linePath = new google.maps.Polyline({
geodesic: true,
map: map,
strokeColor: '#7CD430',
strokeOpacity: 0.5,
strokeWeight: 4
});
var tmp = linePath.getPath();
tmp.push(latlng2)
tmp.push(latlng1)
var dst = google.maps.geometry.spherical.computeDistanceBetween(latlng2, latlng1);
function roundNum(num, dec) {
return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
}
var infowindow0 = new google.maps.InfoWindow({
content: '
'
+ i18n.title_distance + roundNum(dst/1000, 2),
zIndex: 10
});
google.maps.event.addListener(linePath, 'mouseover', function() {
infowindow0.open(map);
});
google.maps.event.addListener(linePath, 'mousemove', function(event) {
infowindow0.setPosition(event.latLng);
});
google.maps.event.addListener(linePath, 'mouseout', function() {
infowindow0.close();
});
}
google.maps.event.addListener(serverMarker, 'click', function() {
infowindow1.open(map, serverMarker);
});
google.maps.event.addListener(myMarker, 'click', function() {
infowindow2.open(map, myMarker);
});
});