2015-01-07 13:02:56 +00:00
/ *
2015-08-20 20:19:21 +00:00
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ __ \ / _ _ _ _ | ( _ ) | | | \ | | | | | |
| | | | _ _ _ _ _ _ _ _ _ | | _ _ | | _ _ _ | | _ _ _ _ _ _ | \ | | _ _ _ | | _ _ _ _ _ _ _ _ _ _ _ | | _ _
| | | | '_ \ / _ \ ' _ \ | | | _ | | | / _` |/ _ \ '__| | . ` |/ _ \ __\ \ /\ / / _ \| ' _ _ | | / /
| | _ _ | | | _ ) | _ _ / | | | | | _ _ | | | | ( _ | | _ _ / | | | \ | _ _ / | _ \ V V / ( _ ) | | | <
\ _ _ _ _ / | . _ _ / \ _ _ _ | _ | | _ | \ _ _ _ _ _ | _ | _ | \ _ _ , _ | \ _ _ _ | _ | | _ | \ _ | \ _ _ _ | \ _ _ | \ _ / \ _ / \ _ _ _ / | _ | | _ | \ _ \
| |
| _ |
2015-01-07 13:02:56 +00:00
* /
var map ;
2015-01-21 13:13:42 +00:00
var autoc = "" ;
var acaff = "" ;
var cton = false ;
var tcolor = [ "000000" , "FF0000" , "00FF00" , "0000FF" , "FFFF00" , "00FFFF" , "FF00FF" , "C0C0C0" , "FFFFFF" ] ;
var ccolor = 0 ;
2015-01-07 13:02:56 +00:00
var aflist = true ;
var vallpolon = true ;
var vallpoloff = true ;
var vallmaron = true ;
var vallmaroff = true ;
2015-01-21 13:13:42 +00:00
var lside = 0 ; // 0=right 1=left
2015-01-07 13:02:56 +00:00
var infowindow = new google . maps . InfoWindow ( ) ;
2015-01-21 13:13:42 +00:00
var online = [ ] ; // ([cn,alt*1,cn+"_"+ps,colcn,afdif]);
2015-01-20 16:58:38 +00:00
var offline = [ ] ; // ([cn,alt*1,cn+"_"+ps,colcn,afdif]);
2015-01-19 18:10:00 +00:00
var receivers = [ ] ;
2015-01-21 13:13:42 +00:00
var all = 0 ;
var pathl = 30 ; // path length 5' (30points)
var unit = "m" ; // metric units
var onoff = 1 ; // 1: online, 2: offline, 3: Menu
var onoffaff = "OnLine" ;
2015-01-20 16:58:38 +00:00
var triasc = 1 ; // 1: asc 2: desc
2015-01-07 13:02:56 +00:00
var tricol = 0 ; // 0:tri sur cn 1: tri sur alti
2015-01-21 13:13:42 +00:00
var ett1 = "<CENTER><IMG style=\"z-index:50\" onclick=\"alist();\" SRC=\"" + tld + "/pict/min.png\"> <IMG style=\"z-index:50\" onclick=\"sideclick();\" SRC=\"" + tld + "/pict/dbarrow.gif\"> <A HREF=\"" + tld + "/help-fr.html\" target=\"_blank\"><IMG style=\"z-index:50\" SRC=\"" + tld + "/pict/hel.png\"></A> <span id=\"onoff\" onclick=\"onofff();\"></span></CENTER>" ;
var w = 0 ; // watchdog variable
var tmgm , tmwd ;
2015-08-20 20:19:21 +00:00
var nbreq = 0 ; // nb request launch
var wlt = 0 ; // tasks white list
var wlist = [ ] ;
2015-01-07 13:02:56 +00:00
var vasp = false ;
var vrec = false ;
var vrecl = false ;
var vstm = false ;
var vapt = false ;
var vwin = false ;
var vpre = false ;
var hnew = false ;
selrec = "" ;
2015-09-18 20:03:25 +00:00
var ftype = [ "unknown" , "Glider/MotorGlider" , "Tow Plane" , "Helicopter" , "Parachute" , "Drop Plane" , "Hangglider" , "Paraglider" , "Plane" , "Jet" , "UFO" , "Balloon" , "Airship" , "Drone" , "unknown" , "Static Object" ] ;
2015-08-20 20:19:21 +00:00
var ftypec = [ "_b" , "" , "_g" , "_r" , "_b" , "_b" , "_p" , "_p" , "_b" , "_b" , "_b" , "_b" , "_b" , "_b" , "_b" , "_b" ] ;
2015-09-18 19:59:58 +00:00
var taskFeatures = [ ] ;
2015-01-21 13:13:42 +00:00
var initialResolution = 2 * Math . PI * 6378137 / 256 ; // == 156543.0339
2015-01-07 13:02:56 +00:00
var originShift = 2 * Math . PI * 6378137 / 2.0 ; // == 20037508.34
var m2ft = { "m" : 1 , "i" : 3.2808 } ;
var am2ft = { "m" : "m" , "i" : "ft" } ;
var kh2kt = { "m" : 1 , "i" : 0.53996 } ;
var akh2kt = { "m" : "km/h" , "i" : "kt" } ;
var m2kt = { "m" : 1 , "i" : 1.94384 } ;
var am2kt = { "m" : "m/s" , "i" : "kt" } ;
2015-01-19 17:41:11 +00:00
2015-08-20 20:19:21 +00:00
var hashc = "" , hashz = "" , hashm = "" , hasho = "" , hashb = "" , hashs = "" , hashl = "" , hasht = "" , hl = " " , hashw = "" , hashu = "" , hashp = "" , hashn = "" , hashy = "" ;
// center zoom maptype offline bound autoset2ma layers tasks warning units pathlength nolist devtype
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
// close popup
2015-01-07 13:02:56 +00:00
function cp ( ) {
2015-01-20 16:58:38 +00:00
clearTimeout ( tmop ) ;
var d = document . getElementById ( 'popup' ) ;
2015-01-21 13:13:42 +00:00
d . style . display = 'none' ;
}
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
// open popup
2015-01-07 13:02:56 +00:00
function op ( maxw ) {
2015-01-20 16:58:38 +00:00
var d = document . getElementById ( 'popup' ) ;
2015-01-21 13:13:42 +00:00
d . style . display = 'block' ;
2015-01-07 13:02:56 +00:00
d . style . width = maxw + 'px' ;
d . style . height = maxw + 'px' ;
2015-01-19 18:08:16 +00:00
tmop = setTimeout ( cp , 15000 ) ;
2015-01-21 13:13:42 +00:00
}
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
function chunit ( ) { // change units
if ( document . getElementById ( 'uni' ) . checked === true ) { // units imperial
unit = 'i' ;
hashu = "&u=i" ;
} else { // units metric
unit = 'm' ;
hashu = "" ;
2015-01-20 16:58:38 +00:00
}
rehash ( ) ;
2015-01-07 13:02:56 +00:00
}
2015-01-21 13:13:42 +00:00
function chpl ( ) { // change path length
if ( document . getElementById ( 'rp1' ) . checked === true ) { // 5 minutes
pathl = 30 ;
hashp = "" ;
} else if ( document . getElementById ( 'rp2' ) . checked === true ) { // 10 minutes
pathl = 60 ;
hashp = "&p=2" ;
} else { // all points
pathl = 99999 ;
hashp = "&p=3" ;
2015-01-20 16:58:38 +00:00
}
delpon ( ) ;
delpoff ( ) ;
rehash ( ) ;
2015-01-07 13:02:56 +00:00
}
2015-08-20 20:19:21 +00:00
function devtype ( ) { // devices types selected
2015-09-18 20:03:25 +00:00
var dt = 0 ;
if ( document . getElementById ( 'ICAObox' ) . checked ) {
dt += 1 ;
2015-08-20 20:19:21 +00:00
}
2015-09-18 20:03:25 +00:00
if ( document . getElementById ( 'Flarmbox' ) . checked ) {
dt += 2 ;
2015-08-20 20:19:21 +00:00
}
2015-09-18 20:03:25 +00:00
if ( document . getElementById ( 'OGNbox' ) . checked ) {
dt += 4 ;
2015-08-20 20:19:21 +00:00
}
2015-09-18 20:03:25 +00:00
if ( dt == 7 ) hashy = "" ; // all devices
else hashy = "&y=" + dt ;
reseton ( ) ;
resetoff ( ) ;
2015-08-20 20:19:21 +00:00
rehash ( ) ;
}
2015-01-07 13:02:56 +00:00
function onofff ( ) {
2015-01-21 13:13:42 +00:00
switch ( onoff ) {
2015-01-20 16:58:38 +00:00
case 1 :
2015-01-21 13:13:42 +00:00
if ( all == 1 ) {
onoffaff = "OffLine" ;
onoff = 2 ;
2015-01-20 16:58:38 +00:00
} else {
2015-01-21 13:13:42 +00:00
onoffaff = "Menu" ;
onoff = 3 ;
2015-01-20 16:58:38 +00:00
document . getElementById ( "ett2" ) . style . display = "none" ;
document . getElementById ( "dtlist" ) . style . display = "none" ;
document . getElementById ( "menu" ) . style . display = "block" ;
}
break ;
case 2 :
2015-01-21 13:13:42 +00:00
onoffaff = "Menu" ;
onoff = 3 ;
2015-01-20 16:58:38 +00:00
document . getElementById ( "ett2" ) . style . display = "none" ;
document . getElementById ( "dtlist" ) . style . display = "none" ;
document . getElementById ( "menu" ) . style . display = "block" ;
break ;
case 3 :
2015-01-21 13:13:42 +00:00
onoffaff = "OnLine" ;
onoff = 1 ;
2015-01-20 16:58:38 +00:00
document . getElementById ( "ett2" ) . style . display = "block" ;
document . getElementById ( "dtlist" ) . style . display = "block" ;
document . getElementById ( "menu" ) . style . display = "none" ;
break ;
2015-01-21 13:13:42 +00:00
}
2015-01-20 16:58:38 +00:00
afftab ( ) ;
2015-01-07 13:02:56 +00:00
}
2015-01-21 13:13:42 +00:00
function delpon ( ) { // delete all online path
var j = - 1 ;
while ( online [ ++ j ] ) {
window [ "P_" + online [ j ] [ 2 ] ] . getPath ( ) . clear ( ) ;
window [ "M_" + online [ j ] [ 2 ] ] . set ( 'tra' , 0 ) ;
2015-01-20 16:58:38 +00:00
}
2015-01-07 13:02:56 +00:00
}
2015-01-21 13:13:42 +00:00
function delpoff ( ) { // delete all offline path
var j = - 1 ;
while ( offline [ ++ j ] ) {
window [ "P_" + offline [ j ] [ 2 ] ] . getPath ( ) . clear ( ) ;
window [ "M_" + offline [ j ] [ 2 ] ] . set ( 'tra' , 0 ) ;
2015-01-20 16:58:38 +00:00
}
2015-01-07 13:02:56 +00:00
}
function deletepath ( pol ) {
2015-01-20 16:58:38 +00:00
window [ pol ] . getPath ( ) . clear ( ) ;
2015-01-21 13:13:42 +00:00
window [ "M_" + pol . substring ( 2 ) ] . set ( 'tra' , 0 ) ;
2015-01-07 13:02:56 +00:00
}
function deleteallpath ( ) {
2015-01-21 13:13:42 +00:00
if ( onoff == 1 ) {
2015-01-20 16:58:38 +00:00
delpon ( ) ;
} else {
delpoff ( ) ;
}
2015-01-07 13:02:56 +00:00
}
function allpath ( ) {
2015-01-21 13:13:42 +00:00
var j = - 1 ;
if ( onoff == 1 ) {
if ( vallpolon === true ) vallpolon = false ;
else vallpolon = true ;
while ( online [ ++ j ] ) {
window [ "P_" + online [ j ] [ 2 ] ] . setOptions ( {
visible : vallpolon
} ) ;
2015-01-20 16:58:38 +00:00
}
} else {
2015-01-21 13:13:42 +00:00
if ( vallpoloff === true ) vallpoloff = false ;
else vallpoloff = true ;
while ( offline [ ++ j ] ) {
window [ "P_" + offline [ j ] [ 2 ] ] . setOptions ( {
visible : vallpoloff
} ) ;
2015-01-20 16:58:38 +00:00
}
}
afftab ( ) ;
2015-01-07 13:02:56 +00:00
}
function allmarker ( ) {
2015-01-21 13:13:42 +00:00
var j = - 1 ;
if ( onoff == 1 ) {
if ( vallmaron === true ) vallmaron = false ;
else vallmaron = true ;
while ( online [ ++ j ] ) {
window [ "M_" + online [ j ] [ 2 ] ] . setOptions ( {
visible : vallmaron
} ) ;
2015-01-20 16:58:38 +00:00
}
} else {
2015-01-21 13:13:42 +00:00
if ( vallmaroff === true ) vallmaroff = false ;
else vallmaroff = true ;
while ( offline [ ++ j ] ) {
window [ "M_" + offline [ j ] [ 2 ] ] . setOptions ( {
visible : vallmaroff
} ) ;
2015-01-20 16:58:38 +00:00
}
}
afftab ( ) ;
2015-01-07 13:02:56 +00:00
}
function tricn ( ) {
2015-01-21 13:13:42 +00:00
if ( tricol == 1 ) triasc = 1 ;
else if ( triasc == 1 ) triasc = 2 ;
else triasc = 1 ;
2015-01-20 16:58:38 +00:00
tricol = 0 ;
afftab ( ) ;
2015-01-07 13:02:56 +00:00
}
function trialti ( ) {
2015-01-20 16:58:38 +00:00
if ( tricol === 0 ) triasc = 1 ;
2015-01-21 13:13:42 +00:00
else if ( triasc == 1 ) triasc = 2 ;
else triasc = 1 ;
2015-01-20 16:58:38 +00:00
tricol = 1 ;
afftab ( ) ;
2015-01-07 13:02:56 +00:00
}
function focuson ( poly ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( poly ) !== null ) document . getElementById ( poly ) . className = 'yel' ;
window [ poly ] . setOptions ( {
strokeWeight : 4 ,
strokeOpacity : 1
} ) ;
2015-01-07 13:02:56 +00:00
}
function focusoff ( poly ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( poly ) !== null ) document . getElementById ( poly ) . className = 'whi' ;
window [ poly ] . setOptions ( {
strokeWeight : 2 ,
strokeOpacity : 0.75
} ) ;
2015-01-07 13:02:56 +00:00
}
function asp ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'aspbox' ) . checked ) {
vasp = true ;
2015-01-20 16:58:38 +00:00
airspaceoverlay . setOpacity ( 1 ) ;
map . overlayMapTypes . setAt ( 1 , airspaceoverlay ) ;
2015-01-21 13:13:42 +00:00
rempl ( 4 , "z" ) ;
} else {
vasp = false ;
2015-01-20 16:58:38 +00:00
airspaceoverlay . setOpacity ( 0 ) ;
map . overlayMapTypes . removeAt ( 1 ) ;
2015-01-21 13:13:42 +00:00
rempl ( 4 , " " ) ;
}
2015-01-07 13:02:56 +00:00
rehash ( ) ;
}
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
function apt ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'aptbox' ) . checked ) {
vapt = true ;
2015-01-20 16:58:38 +00:00
airportoverlay . setOpacity ( 1 ) ;
map . overlayMapTypes . setAt ( 2 , airportoverlay ) ;
2015-01-21 13:13:42 +00:00
rempl ( 5 , "a" ) ;
} else {
vapt = false ;
2015-01-20 16:58:38 +00:00
airportoverlay . setOpacity ( 0 ) ;
map . overlayMapTypes . removeAt ( 2 ) ;
2015-01-21 13:13:42 +00:00
rempl ( 5 , " " ) ;
}
2015-01-20 16:58:38 +00:00
rehash ( ) ;
2015-01-19 17:41:11 +00:00
}
2015-01-07 13:02:56 +00:00
function wind ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'winbox' ) . checked ) {
vwin = true ;
2015-01-20 16:58:38 +00:00
windoverlay . setOpacity ( 1 ) ;
map . overlayMapTypes . setAt ( 3 , windoverlay ) ;
2015-01-21 13:13:42 +00:00
if ( map . getZoom ( ) > 7 ) map . setZoom ( 7 ) ;
rempl ( 2 , "v" ) ;
} else {
vwin = false ;
2015-01-20 16:58:38 +00:00
windoverlay . setOpacity ( 0 ) ;
map . overlayMapTypes . removeAt ( 3 ) ;
2015-01-21 13:13:42 +00:00
rempl ( 2 , " " ) ;
}
2015-01-20 16:58:38 +00:00
rehash ( ) ;
2015-01-19 17:41:11 +00:00
}
2015-01-07 13:02:56 +00:00
function pres ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'prebox' ) . checked ) {
vpre = true ;
2015-01-20 16:58:38 +00:00
presoverlay . setOpacity ( 1 ) ;
map . overlayMapTypes . setAt ( 4 , presoverlay ) ;
2015-01-21 13:13:42 +00:00
if ( map . getZoom ( ) > 7 ) map . setZoom ( 7 ) ;
rempl ( 3 , "p" ) ;
} else {
vpre = false ;
2015-01-20 16:58:38 +00:00
presoverlay . setOpacity ( 0 ) ;
map . overlayMapTypes . removeAt ( 4 ) ;
2015-01-21 13:13:42 +00:00
rempl ( 3 , " " ) ;
}
2015-01-20 16:58:38 +00:00
rehash ( ) ;
2015-01-19 17:41:11 +00:00
}
2015-01-07 13:02:56 +00:00
2015-08-20 20:19:21 +00:00
function hidenew ( ) {
if ( document . getElementById ( 'hnewbox' ) . checked ) hnew = true ;
else hnew = false ;
2015-01-19 17:41:11 +00:00
}
2015-01-07 13:02:56 +00:00
2015-09-18 20:03:25 +00:00
function reseton ( ) { // delete all online markers and their path
var j = - 1 ;
while ( online [ ++ j ] ) {
window [ "M_" + online [ j ] [ 2 ] ] . setMap ( null ) ;
delete window [ "M_" + online [ j ] [ 2 ] ] ;
window [ "P_" + online [ j ] [ 2 ] ] . setMap ( null ) ;
delete window [ "P_" + online [ j ] [ 2 ] ] ;
}
2015-01-19 17:41:11 +00:00
}
2015-01-07 13:02:56 +00:00
2015-09-18 20:03:25 +00:00
function resetoff ( ) { // delete all offline markers and their path
var j = - 1 ;
while ( offline [ ++ j ] ) {
window [ "M_" + offline [ j ] [ 2 ] ] . setMap ( null ) ;
delete window [ "M_" + offline [ j ] [ 2 ] ] ;
window [ "P_" + offline [ j ] [ 2 ] ] . setMap ( null ) ;
delete window [ "P_" + offline [ j ] [ 2 ] ] ;
}
2015-01-07 13:02:56 +00:00
}
2015-08-20 20:19:21 +00:00
2015-01-07 13:02:56 +00:00
function lineoff ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'offl' ) . checked ) {
all = 0 ;
2015-08-20 20:19:21 +00:00
resetoff ( ) ;
2015-01-21 13:13:42 +00:00
hasho = "" ;
2015-01-20 16:58:38 +00:00
} else {
2015-01-21 13:13:42 +00:00
all = 1 ;
hasho = "&o=1" ;
2015-01-20 16:58:38 +00:00
}
rehash ( ) ;
2015-01-07 13:02:56 +00:00
}
function bounds ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'boundsbox' ) . checked ) {
2015-01-20 16:58:38 +00:00
bound = true ;
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'astmbox' ) . checked ) {
vstm = false ;
hashs = "" ;
2015-01-20 16:58:38 +00:00
document . getElementById ( 'astmbox' ) . checked = false ;
}
amax = parseFloat ( document . getElementById ( 'latmax' ) . value ) ;
amin = parseFloat ( document . getElementById ( 'latmin' ) . value ) ;
2015-01-21 13:13:42 +00:00
if ( amin > amax ) {
var tmp = amax ;
amax = amin ;
amin = tmp ;
}
2015-01-20 16:58:38 +00:00
omax = parseFloat ( document . getElementById ( 'lonmax' ) . value ) ;
omin = parseFloat ( document . getElementById ( 'lonmin' ) . value ) ;
2015-01-21 13:13:42 +00:00
if ( omin > omax ) {
var tmp = omax ;
omax = omin ;
omin = tmp ;
}
2015-01-20 16:58:38 +00:00
if ( amax > 85 ) amax = 85 ;
if ( amin < - 85 ) amin = - 85 ;
if ( omax > 180 ) omax = 180 ;
if ( omin < - 180 ) omin = - 180 ;
2015-01-21 13:13:42 +00:00
boundc = "&b=" + amax + "&c=" + amin + "&d=" + omax + "&e=" + omin ;
2015-01-20 16:58:38 +00:00
document . getElementById ( 'latmax' ) . value = amax ;
document . getElementById ( 'latmin' ) . value = amin ;
document . getElementById ( 'lonmax' ) . value = omax ;
document . getElementById ( 'lonmin' ) . value = omin ;
2015-08-20 20:19:21 +00:00
reseton ( ) ;
resetoff ( ) ;
2015-01-21 13:13:42 +00:00
hashb = "&b=" + amax . toFixed ( 4 ) + "," + amin . toFixed ( 4 ) + "," + omax . toFixed ( 4 ) + "," + omin . toFixed ( 4 ) ;
} else {
2015-01-20 16:58:38 +00:00
bound = false ;
if ( vstm === false ) boundc = "" ;
2015-01-21 13:13:42 +00:00
hashb = "" ;
2015-01-20 16:58:38 +00:00
}
rehash ( ) ;
2015-01-07 13:02:56 +00:00
}
function afftab ( ) {
2015-01-21 13:13:42 +00:00
var j = - 1 ;
var dlistd = "<TABLE class=\"tt\">" ;
var mar = "" ;
var pol = "" ;
var affcpt = "" ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
switch ( onoff ) {
2015-01-20 16:58:38 +00:00
case 1 :
online . sort ( ASC ) ;
2015-01-21 13:13:42 +00:00
if ( triasc == 2 ) online . reverse ( ) ;
while ( online [ ++ j ] ) {
mar = "M_" + online [ j ] [ 2 ] ;
pol = "P_" + online [ j ] [ 2 ] ;
dlistd += "<TR id=\"" + pol + "\" onmouseover=\"focuson('" + pol + "');\" onmouseout=\"focusoff('" + pol + "');\"><TD class=\"cgv\"><input onchange=\"vpolmar(this.checked ,'" + mar + "');\" type=\"checkbox\" " + isvisib ( mar ) + " ></TD><TD class=\"cgv\"><input onchange=\"vpolmar(this.checked ,'" + pol + "');\" type=\"checkbox\" " + isvisib ( pol ) + " ></TD><TD class=\"cgn\" onmousedown=\"centeron('" + mar + "');\" onmouseup=\"centeroff();\" oncontextmenu=\"event.stopPropagation(); redraw('" + pol + "'); return false;\" ondblclick=\"event.stopPropagation(); autocenter('" + mar + "');\" >" + online [ j ] [ 0 ] + "</TD><TD class=\"cgc\"><span style='background-color: " + online [ j ] [ 3 ] + "' ondblclick=\"deletepath('" + pol + "'); return false;\" oncontextmenu=\"this.style.backgroundColor=changecolor('" + mar + "'); return false;\"> </span></TD><TD onclick=\"affinfo('" + mar + "')\" class=\"cga\">" ;
if ( unit == "i" ) {
dlistd += ( online [ j ] [ 1 ] * m2ft [ unit ] ) . toFixed ( ) ;
} // { var tv=online[j][1]*m2ft[unit]; dlistd+= tv.toFixed(); }
else dlistd += online [ j ] [ 1 ] + "m" ;
dlistd += "</TD><TD class=\"cgv\"><IMG src='" + tld + "/pict/" + online [ j ] [ 4 ] + ".gif'></TD></TR>" ;
2015-01-20 16:58:38 +00:00
}
affcpt = " (" + online . length + ")" ;
break ;
case 2 :
offline . sort ( ASC ) ;
2015-01-21 13:13:42 +00:00
if ( triasc == 2 ) offline . reverse ( ) ;
while ( offline [ ++ j ] ) {
mar = "M_" + offline [ j ] [ 2 ] ;
pol = "P_" + offline [ j ] [ 2 ] ;
dlistd += "<TR id=\"" + pol + "\" onmouseover=\"focuson('" + pol + "');\" onmouseout=\"focusoff('" + pol + "');\"><TD class=\"cgv\"><input onchange=\"vpolmar(this.checked ,'" + mar + "');\" type=\"checkbox\" " + isvisib ( mar ) + " ></TD><TD class=\"cgv\"><input onchange=\"vpolmar(this.checked ,'" + pol + "');\" type=\"checkbox\" " + isvisib ( pol ) + " ></TD><TD class=\"cgn\" onmousedown=\"centeron('" + mar + "');\" onmouseup=\"centeroff();\" oncontextmenu=\"event.stopPropagation(); redraw('" + pol + "'); return false;\" ondblclick=\"event.stopPropagation(); autocenter('" + mar + "');\" >" + offline [ j ] [ 0 ] + "</TD><TD class=\"cgc\"><span style='background-color: " + offline [ j ] [ 3 ] + "' ondblclick=\"deletepath('" + pol + "'); return false;\" oncontextmenu=\"this.style.backgroundColor=changecolor('" + mar + "'); return false;\"> </span></TD><TD onclick=\"affinfo('" + mar + "')\" class=\"cga\">" ;
if ( unit == "i" ) {
dlistd += ( offline [ j ] [ 1 ] * m2ft [ unit ] ) . toFixed ( ) ;
} else dlistd += offline [ j ] [ 1 ] + "m" ;
dlistd += "</TD><TD class=\"cgv\"><IMG src='" + tld + "/pict/" + offline [ j ] [ 4 ] + ".gif'></TD></TR>" ;
2015-01-20 16:58:38 +00:00
}
affcpt = " (" + offline . length + ")" ;
break ;
case 3 :
affcpt = " " ;
break ;
2015-01-21 13:13:42 +00:00
}
dlistd += "</TABLE>" ;
2015-01-07 13:02:56 +00:00
document . getElementById ( "dtlist" ) . innerHTML = dlistd ;
2015-09-18 20:03:25 +00:00
if ( aflist === true ) document . getElementById ( "onoff" ) . innerHTML = "<B>" + onoffaff + "</B>" + affcpt ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
}
2015-01-21 13:13:42 +00:00
function ASC ( a , b ) {
a = a [ tricol ] ;
b = b [ tricol ] ;
if ( a > b )
return 1 ;
if ( a < b )
return - 1 ;
return 0 ;
}
2015-01-19 17:41:11 +00:00
2015-01-21 13:13:42 +00:00
function alist ( ) {
2015-01-19 17:50:55 +00:00
if ( aflist === true ) {
2015-01-21 13:13:42 +00:00
document . getElementById ( "ett1" ) . innerHTML = "<CENTER><IMG style=\"z-index:50\" onclick=\"alist();\" SRC=\"" + tld + "/pict/plu.png\"></CENTER>" ;
document . getElementById ( 'dlist' ) . style . width = "20px" ;
document . getElementById ( 'dlist' ) . style . height = "20px" ;
if ( lside == 1 ) document . getElementById ( 'ac' ) . style . left = "65px" ;
else document . getElementById ( 'ac' ) . style . right = "0px" ;
2015-01-07 13:02:56 +00:00
centeroff ( ) ;
aflist = false ;
2015-04-06 18:34:24 +00:00
hashn = "&n=0" ;
2015-01-21 13:13:42 +00:00
} else {
2015-01-20 16:58:38 +00:00
document . getElementById ( "ett1" ) . innerHTML = ett1 ;
2015-01-21 13:13:42 +00:00
document . getElementById ( 'dlist' ) . style . width = "180px" ;
document . getElementById ( 'dlist' ) . style . height = "90%" ;
if ( lside == 1 ) document . getElementById ( 'ac' ) . style . left = "245px" ;
else document . getElementById ( 'ac' ) . style . right = "180px" ;
2015-01-07 13:02:56 +00:00
aflist = true ;
afftab ( ) ;
2015-04-06 18:34:24 +00:00
hashn = "" ;
2015-01-21 13:13:42 +00:00
}
2015-04-06 18:34:24 +00:00
rehash ( ) ;
2015-01-07 13:02:56 +00:00
}
function sideclick ( ) {
2015-01-20 16:58:38 +00:00
if ( lside === 0 ) {
2015-01-21 13:13:42 +00:00
document . getElementById ( 'dlist' ) . className = "lleft" ;
document . getElementById ( 'ac' ) . className = "acleft" ;
document . getElementById ( 'ac' ) . style . right = "" ;
lside = 1 ;
2015-01-20 16:58:38 +00:00
} else {
2015-01-21 13:13:42 +00:00
document . getElementById ( 'dlist' ) . className = "lright" ;
document . getElementById ( 'ac' ) . className = "acright" ;
document . getElementById ( 'ac' ) . style . left = "" ;
lside = 0 ;
2015-01-20 16:58:38 +00:00
}
2015-01-07 13:02:56 +00:00
}
function autocenter ( mark ) {
2015-01-21 13:13:42 +00:00
document . getElementById ( "divInfoac" ) . innerHTML = "<B>AC</B>: " + window [ mark ] . get ( 'title' ) ;
autoc = mark ;
2015-01-20 16:58:38 +00:00
document . getElementById ( "divInfoac" ) . style . display = "block" ;
map . setCenter ( window [ mark ] . getPosition ( ) ) ;
2015-01-07 13:02:56 +00:00
}
function centeron ( mark ) {
2015-01-21 13:13:42 +00:00
cton = true ;
2015-01-20 16:58:38 +00:00
map . setCenter ( window [ mark ] . getPosition ( ) ) ;
2015-01-07 13:02:56 +00:00
}
function centeroff ( ) {
2015-01-21 13:13:42 +00:00
if ( autoc !== "" ) {
map . setCenter ( window [ autoc ] . getPosition ( ) ) ;
}
cton = false ;
2015-01-07 13:02:56 +00:00
}
function vpolmar ( chk , polmar ) {
2015-01-21 13:13:42 +00:00
window [ polmar ] . setOptions ( {
visible : chk
} ) ;
2015-01-07 13:02:56 +00:00
}
function isvisib ( pol ) {
2015-01-20 16:58:38 +00:00
if ( window [ pol ] . getVisible ( ) === true ) return "checked" ;
else return "" ;
2015-01-07 13:02:56 +00:00
}
function dec2dms ( dec ) {
2015-01-20 16:58:38 +00:00
dec = Math . abs ( dec ) ;
2015-01-07 13:02:56 +00:00
var decd = Math . floor ( dec ) ;
2015-01-21 13:13:42 +00:00
var decm = Math . floor ( ( dec - decd ) * 60 ) ;
var decs = Math . floor ( ( dec - decd - ( decm / 60 ) ) * 3600 ) ;
return "" + decd + "° " + decm + "' " + decs + "\"" ;
2015-01-07 13:02:56 +00:00
}
function changecolor ( mark ) {
2015-01-20 16:58:38 +00:00
var colactive = window [ mark ] . get ( 'icol' ) ;
2015-01-21 13:13:42 +00:00
if ( ++ colactive == 9 ) colactive = 0 ;
2015-01-20 16:58:38 +00:00
var ncol = tcolor [ colactive ] ;
2015-01-21 13:13:42 +00:00
window [ window [ mark ] . get ( 'poly' ) ] . setOptions ( {
strokeColor : '#' + ncol
} ) ;
window [ mark ] . set ( 'icol' , "" + colactive ) ;
return "#" + ncol ;
2015-01-07 13:02:56 +00:00
}
function redraw ( pol ) {
2015-01-21 13:13:42 +00:00
var p = pol . substring ( 2 ) ;
var mrk = window [ "M_" + p ] ;
var fi = mrk . get ( 'fid' ) ;
var lo = mrk . getPosition ( ) . lng ( ) . toFixed ( ) ;
2015-01-20 16:58:38 +00:00
mrk . set ( 'tra' , 1 ) ;
2015-08-20 20:19:21 +00:00
downloadUrl ( tld + '/' + cxml1 + '?id=' + p + "&l=" + lo , function ( data ) {
2015-01-20 16:58:38 +00:00
var vtrace = data . documentElement . getElementsByTagName ( "m" ) ;
var err = parseFloat ( vtrace [ 0 ] . getAttribute ( "e" ) ) ;
var idd = vtrace [ 0 ] . getAttribute ( "i" ) ;
var encodedt = vtrace [ 0 ] . getAttribute ( "r" ) ;
2015-01-21 13:13:42 +00:00
if ( err === 0 && encodedt . length > 2 ) {
window [ 'P_' + idd ] . getPath ( ) . clear ( ) ;
var ftrace = google . maps . geometry . encoding . decodePath ( encodedt ) ;
window [ 'P_' + idd ] . setPath ( ftrace ) ;
}
} ) ;
2015-01-07 13:02:56 +00:00
}
function taskbox ( ) {
2015-09-18 20:03:25 +00:00
var vtas = false ;
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'taskbox' ) . checked ) {
vtas = true ;
2015-08-20 20:19:21 +00:00
if ( wlt == 2 ) {
2015-09-18 20:03:25 +00:00
-- wlt ;
reseton ( ) ;
resetoff ( ) ;
2015-08-20 20:19:21 +00:00
}
2015-01-20 16:58:38 +00:00
} else {
2015-09-18 20:03:25 +00:00
if ( wlt == 1 ) {
++ wlt ;
reseton ( ) ;
resetoff ( ) ;
}
2015-01-20 16:58:38 +00:00
}
2015-01-21 13:13:42 +00:00
var j = - 1 ;
2015-09-18 19:59:58 +00:00
while ( taskFeatures [ ++ j ] ) {
taskFeatures [ j ] . setOptions ( {
2015-01-21 13:13:42 +00:00
visible : vtas
} ) ;
2015-01-20 16:58:38 +00:00
}
2015-01-07 13:02:56 +00:00
}
function reclbox ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'reclbox' ) . checked ) {
vrecl = true ;
rempl ( 6 , "r" ) ;
2015-01-20 16:58:38 +00:00
} else {
2015-01-21 13:13:42 +00:00
vrecl = false ;
rempl ( 6 , " " ) ;
2015-01-20 16:58:38 +00:00
}
2015-01-21 13:13:42 +00:00
var j = - 1 ;
while ( receivers [ ++ j ] ) {
window [ "R_" + receivers [ j ] [ 0 ] ] . setOptions ( {
visible : vrecl
} ) ;
2015-01-20 16:58:38 +00:00
}
rehash ( ) ;
2015-01-07 13:02:56 +00:00
}
function checkrec ( ) {
2015-01-21 13:13:42 +00:00
downloadUrl ( tld + '/' + rxml , function ( data ) {
2015-01-20 16:58:38 +00:00
var vlrec = data . documentElement . getElementsByTagName ( "m" ) ;
var err = parseFloat ( vlrec [ 0 ] . getAttribute ( "e" ) ) ;
2015-01-21 13:13:42 +00:00
if ( err === 0 && vlrec . length > 1 ) {
2015-01-20 16:58:38 +00:00
selrec = "" ;
// effacer markers
2015-01-21 13:13:42 +00:00
var j = - 1 ;
while ( receivers [ ++ j ] ) {
window [ "R_" + receivers [ j ] [ 0 ] ] . setMap ( null ) ;
delete window [ "R_" + receivers [ j ] [ 0 ] ] ;
2015-01-20 16:58:38 +00:00
}
2015-01-21 13:13:42 +00:00
receivers . length = 0 ;
for ( var i = 1 ; i < vlrec . length ; i ++ ) {
2015-01-20 16:58:38 +00:00
var re = vlrec [ i ] . getAttribute ( "a" ) ;
var rlat = parseFloat ( vlrec [ i ] . getAttribute ( "b" ) ) ;
var rlon = parseFloat ( vlrec [ i ] . getAttribute ( "c" ) ) ;
var ract = parseInt ( vlrec [ i ] . getAttribute ( "d" ) ) ;
2015-01-21 13:13:42 +00:00
var rind = 2000 * ract ;
2015-01-20 16:58:38 +00:00
selrec += "<option value='" + re + "'>" + re + "</option>" ;
2015-01-21 13:13:42 +00:00
receivers . push ( [ re , rlat , rlon ] ) ; // lat et lon stockées mais jamais utilisées ?
window [ "R_" + re ] = new google . maps . Marker ( {
position : new google . maps . LatLng ( rlat , rlon ) ,
title : "Receiver: " + re ,
map : map ,
icon : "" + tld + "/pict/rec" + ract + ".png" ,
zIndex : rind ,
visible : vrecl
} ) ;
2015-01-20 16:58:38 +00:00
}
2015-01-21 13:13:42 +00:00
setTimeout ( checkrec , 120000 ) ;
} else {
selrec = "<option value='_error_'>Error</option>" ;
2015-01-20 16:58:38 +00:00
setTimeout ( checkrec , 20000 ) ;
2015-01-21 13:13:42 +00:00
}
2015-01-20 16:58:38 +00:00
reclbox ( ) ;
2015-01-21 13:13:42 +00:00
} ) ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
}
function receiv ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'recbox' ) . checked ) {
vrec = true ;
} else {
vrec = false ;
2015-01-20 16:58:38 +00:00
}
2015-01-07 13:02:56 +00:00
}
function affinfodata ( mark ) {
2015-01-21 13:13:42 +00:00
var mrk = window [ mark ] ;
var vz = mrk . get ( 'vz' ) * m2kt [ unit ] ;
var vx = mrk . get ( 'speed' ) * kh2kt [ unit ] ;
var al = mrk . get ( 'alt' ) * m2ft [ unit ] ;
document . getElementById ( "aclt" ) . innerHTML = mrk . get ( 'tim' ) ;
document . getElementById ( "acla" ) . innerHTML = mrk . getPosition ( ) . lat ( ) . toFixed ( 6 ) ;
document . getElementById ( "aclo" ) . innerHTML = mrk . getPosition ( ) . lng ( ) . toFixed ( 6 ) ;
document . getElementById ( "acal" ) . innerHTML = al . toFixed ( ) + " " + am2ft [ unit ] ;
document . getElementById ( "acsp" ) . innerHTML = vx . toFixed ( ) + " " + akh2kt [ unit ] ;
document . getElementById ( "actr" ) . innerHTML = mrk . get ( 'track' ) ;
document . getElementById ( "acvz" ) . innerHTML = ( ( vz >= 0 ) ? "+" : "–" ) + Math . abs ( vz ) . toFixed ( 1 ) + " " + am2kt [ unit ] ;
2015-01-20 16:58:38 +00:00
var re = mrk . get ( 'rec' ) ;
2015-01-21 13:13:42 +00:00
if ( typeof ( window [ "R_" + re ] ) != 'undefined' ) {
var mre = window [ "R_" + re ] ;
var di = dist ( mrk . getPosition ( ) . lat ( ) , mrk . getPosition ( ) . lng ( ) , mre . getPosition ( ) . lat ( ) , mre . getPosition ( ) . lng ( ) ) ;
re += " (" + di . toFixed ( ) + " Km)" ;
2015-01-20 16:58:38 +00:00
} else {
re += " (?)" ;
}
document . getElementById ( "acrx" ) . innerHTML = re ;
2015-01-07 13:02:56 +00:00
}
function affinfodata2 ( mark ) {
2015-01-21 13:13:42 +00:00
var mrk = window [ mark ] ;
document . getElementById ( "acmo" ) . innerHTML = mrk . get ( 'model' ) ;
2015-01-07 13:02:56 +00:00
}
function affinfo ( mark ) {
2015-01-20 16:58:38 +00:00
affinfodata ( mark ) ;
2015-01-21 13:13:42 +00:00
var mrk = window [ mark ] ;
var rg = mrk . get ( 'reg' ) ;
var fi = mrk . get ( 'fid' ) ;
var vd = "block" ;
if ( fi == rg ) vd = "none" ;
2015-01-20 16:58:38 +00:00
document . getElementById ( "ac1" ) . style . display = vd ;
2015-01-21 13:13:42 +00:00
document . getElementById ( "accn" ) . innerHTML = mrk . get ( 'cn' ) ;
document . getElementById ( "acfi" ) . innerHTML = fi ;
document . getElementById ( "acre" ) . innerHTML = rg ;
document . getElementById ( "acty" ) . innerHTML = ftype [ mrk . get ( 'type' ) * 1 ] ;
if ( fi != "hidden" ) {
document . getElementById ( "acif" ) . innerHTML = "<A HREF='https://www.google.com/search?nfpr=1&q=\"" + rg + "\"' target='_blank' onclick=\"event.stopPropagation();\">Infos</a> <A HREF='https://www.google.com/search?nfpr=1&q=\"" + rg + "\"&tbm=isch' target='_blank' onclick=\"event.stopPropagation();\">Pictures</a>" ;
2015-08-20 20:19:21 +00:00
if ( mrk . get ( 'dinfo' ) === "" ) {
2015-01-21 13:13:42 +00:00
downloadUrl ( tld + '/' + dxml + '?i=' + mark + '&f=' + fi , function ( data ) {
var dat = data . documentElement . getElementsByTagName ( "m" ) ;
var err = parseFloat ( dat [ 0 ] . getAttribute ( "g" ) ) ;
var mrk = dat [ 0 ] . getAttribute ( "i" ) ;
if ( err === 0 ) {
window [ mrk ] . set ( 'model' , "" + dat [ 0 ] . getAttribute ( "c" ) ) ;
affinfodata2 ( mrk ) ;
document . getElementById ( "ac2" ) . style . display = "block" ;
2015-08-20 20:19:21 +00:00
window [ mrk ] . set ( 'dinfo' , "ok" ) ;
2015-01-21 13:13:42 +00:00
} else {
2015-08-20 20:19:21 +00:00
window [ mrk ] . set ( 'dinfo' , "_" ) ;
2015-01-21 13:13:42 +00:00
document . getElementById ( "ac2" ) . style . display = "none" ;
}
} ) ;
2015-01-20 16:58:38 +00:00
} else {
2015-08-20 20:19:21 +00:00
if ( mrk . get ( 'dinfo' ) != "_" ) {
2015-01-20 16:58:38 +00:00
affinfodata2 ( mark ) ;
document . getElementById ( "ac2" ) . style . display = "block" ;
} else {
document . getElementById ( "ac2" ) . style . display = "none" ;
}
}
2015-01-21 13:13:42 +00:00
} else {
2015-01-20 16:58:38 +00:00
document . getElementById ( "ac2" ) . style . display = "none" ;
2015-01-21 13:13:42 +00:00
document . getElementById ( "acif" ) . innerHTML = "" ;
document . getElementById ( "acmo" ) . innerHTML = "" ;
2015-01-20 16:58:38 +00:00
}
2015-01-21 13:13:42 +00:00
acaff = mark ;
2015-01-20 16:58:38 +00:00
document . getElementById ( "ac" ) . style . display = "block" ;
2015-01-07 13:02:56 +00:00
}
function settomap ( ) {
2015-01-21 13:13:42 +00:00
var b = map . getBounds ( ) ;
amax = b . getNorthEast ( ) . lat ( ) ;
amin = b . getSouthWest ( ) . lat ( ) ;
omax = b . getNorthEast ( ) . lng ( ) ;
omin = b . getSouthWest ( ) . lng ( ) ;
if ( amax > 85 ) amax = 85 ;
if ( amin < - 85 ) amin = - 85 ;
if ( omax > 180 ) omax = 180 ;
if ( omin < - 180 ) omin = - 180 ;
document . getElementById ( 'latmax' ) . value = amax ;
document . getElementById ( 'latmin' ) . value = amin ;
document . getElementById ( 'lonmax' ) . value = omax ;
document . getElementById ( 'lonmin' ) . value = omin ;
if ( bound === true ) bounds ( ) ;
if ( vstm === true ) {
boundc = "&b=" + amax + "&c=" + amin + "&d=" + omax + "&e=" + omin ;
hashs = "&s=1" ;
rehash ( ) ;
}
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
}
function astm ( ) {
2015-01-21 13:13:42 +00:00
if ( document . getElementById ( 'astmbox' ) . checked ) {
vstm = true ;
2015-01-20 16:58:38 +00:00
if ( document . getElementById ( 'boundsbox' ) . checked ) {
2015-01-21 13:13:42 +00:00
bound = false ;
2015-01-20 16:58:38 +00:00
document . getElementById ( 'boundsbox' ) . checked = false ;
2015-01-21 13:13:42 +00:00
hashb = "" ;
2015-01-20 16:58:38 +00:00
}
settomap ( ) ;
} else {
2015-01-21 13:13:42 +00:00
vstm = false ;
if ( bound === false ) boundc = "" ;
hashs = "" ;
2015-01-20 16:58:38 +00:00
rehash ( ) ;
}
2015-01-07 13:02:56 +00:00
}
2015-01-21 13:13:42 +00:00
function dist ( lat1 , lon1 , lat2 , lon2 ) {
2015-01-20 16:58:38 +00:00
var torad = Math . PI / 180 ;
lat1 *= torad ;
lon1 *= torad ;
lat2 *= torad ;
lon2 *= torad ;
2015-01-21 13:13:42 +00:00
var dt = Math . acos ( ( Math . sin ( lat1 ) * Math . sin ( lat2 ) ) + ( Math . cos ( lat1 ) * Math . cos ( lat2 ) * Math . cos ( lon1 - lon2 ) ) ) ;
dt *= 6366 ;
2015-01-07 13:02:56 +00:00
return dt ;
}
2015-01-21 13:13:42 +00:00
function gesmark ( ) {
2015-09-18 20:03:25 +00:00
if ( nbreq > 0 ) {
-- nbreq ;
return ;
}
++ nbreq ;
2015-08-20 20:19:21 +00:00
downloadUrl ( tld + '/' + cxml + "?a=" + all + boundc + recc + parc + tz + hashy , function ( data ) {
2015-01-21 13:13:42 +00:00
++ w ;
var planeurs = data . documentElement . getElementsByTagName ( "m" ) ;
online . length = 0 ;
offline . length = 0 ;
var colcn ;
var del = "N" ;
for ( var i = 0 ; i < planeurs . length ; i ++ ) {
// récupération des données transmises pour ce planeur
var tab = planeurs [ i ] . getAttribute ( "a" ) . split ( "," ) ;
2015-01-19 17:41:11 +00:00
2015-08-20 20:19:21 +00:00
2015-09-18 20:03:25 +00:00
var fid = tab [ 12 ] ;
if ( wlt == 1 ) {
if ( wlist . indexOf ( fid ) == - 1 ) continue ;
}
var ps = tab [ 3 ] ;
2015-01-21 13:13:42 +00:00
var lat = parseFloat ( tab [ 0 ] ) ;
var lon = parseFloat ( tab [ 1 ] ) ;
var cn = tab [ 2 ] ;
2015-08-20 20:19:21 +00:00
if ( cn == "" ) cn = "_" ;
2015-09-18 20:03:25 +00:00
2015-01-21 13:13:42 +00:00
var alt = tab [ 4 ] ;
var tim = tab [ 5 ] ;
var ddf = tab [ 6 ] ;
var track = tab [ 7 ] ;
var speed = tab [ 8 ] ;
var vz = tab [ 9 ] ;
var typ = tab [ 10 ] ;
var rec = tab [ 11 ] ;
2015-08-20 20:19:21 +00:00
var crc = tab [ 13 ] ;
2015-01-21 13:13:42 +00:00
var posi = new google . maps . LatLng ( lat , lon ) ;
2015-08-20 20:19:21 +00:00
var polyvar = "P_" + crc ;
var markvar = "M_" + crc ;
2015-01-21 13:13:42 +00:00
var visib = true ;
2015-08-20 20:19:21 +00:00
if ( typeof ( window [ polyvar ] ) == 'undefined' ) // If aircraft not already created
2015-01-20 16:58:38 +00:00
{
2015-08-20 20:19:21 +00:00
// create path color for array
2015-01-21 13:13:42 +00:00
hcol = tcolor [ ccolor ] ;
if ( hnew === true ) visib = false ;
2015-08-20 20:19:21 +00:00
// create Marker
2015-01-21 13:13:42 +00:00
var polyOptions = {
strokeColor : '#' + hcol ,
strokeOpacity : 0.75 ,
strokeWeight : 2 ,
visible : visib
} ;
window [ polyvar ] = new google . maps . Polyline ( polyOptions ) ;
window [ polyvar ] . setMap ( map ) ;
window [ polyvar ] . set ( 'nom' , "" + cn + " - " + ps ) ;
window [ polyvar ] . set ( 'poly' , "" + polyvar ) ;
window [ polyvar ] . getPath ( ) . push ( posi ) ; // ajout d'une position sur le tracé
google . maps . event . addListener ( window [ polyvar ] , "mouseover" , function ( ) {
focuson ( this . get ( 'poly' ) ) ;
var bcol = this . strokeColor ;
document . getElementById ( "divInfo" ) . innerHTML = "<span style='background-color: " + bcol + "'> </span> " + this . get ( 'nom' ) ;
} ) ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
google . maps . event . addListener ( window [ polyvar ] , "mouseout" , function ( ) {
focusoff ( this . get ( 'poly' ) ) ;
document . getElementById ( "divInfo" ) . innerHTML = " " ;
} ) ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
// création du Marker
window [ markvar ] = new google . maps . Marker ( {
position : posi ,
title : cn + " - " + ps + " @ " + alt + "m" ,
map : map ,
icon : "" + tld + "/markers/" + cn + ftypec [ typ * 1 ] + ".png" ,
visible : visib
} ) ;
window [ markvar ] . set ( 'poly' , "" + polyvar ) ;
window [ markvar ] . set ( 'mark' , "" + markvar ) ;
window [ markvar ] . set ( 'nom' , "" + cn + " - " + ps ) ;
window [ markvar ] . set ( 'cn' , "" + cn ) ;
window [ markvar ] . set ( 'reg' , "" + ps ) ;
if ( fid == "0" ) fid = "hidden" ;
window [ markvar ] . set ( 'fid' , "" + fid ) ;
window [ markvar ] . set ( 'type' , "" + typ ) ;
window [ markvar ] . set ( 'icol' , "" + ccolor ) ;
window [ markvar ] . set ( 'off' , 0 ) ;
2015-08-20 20:19:21 +00:00
window [ markvar ] . set ( 'dinfo' , "" ) ;
2015-01-21 13:13:42 +00:00
window [ markvar ] . setTitle ( "" + cn + " - " + ps + " @ " + ( alt * m2ft [ unit ] ) . toFixed ( ) + am2ft [ unit ] + " @ " + tim ) ;
window [ markvar ] . set ( 'speed' , "" + speed ) ;
window [ markvar ] . set ( 'track' , "" + track ) ;
window [ markvar ] . set ( 'vz' , "" + vz ) ;
window [ markvar ] . set ( 'tim' , "" + tim ) ;
window [ markvar ] . set ( 'rec' , "" + rec ) ;
window [ markvar ] . set ( 'alt' , "" + alt ) ;
window [ markvar ] . set ( 'tra' , 0 ) ;
google . maps . event . addListener ( window [ markvar ] , "mouseover" , function ( ) {
var bcol = window [ this . get ( 'poly' ) ] . strokeColor ;
document . getElementById ( "divInfo" ) . innerHTML = "<span style='background-color: " + bcol + "'> </span> " + this . get ( 'nom' ) ;
focuson ( this . get ( 'poly' ) ) ;
} ) ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
google . maps . event . addListener ( window [ markvar ] , "mouseout" , function ( ) {
document . getElementById ( "divInfo" ) . innerHTML = " " ;
focusoff ( this . get ( 'poly' ) ) ;
} ) ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
google . maps . event . addListener ( window [ markvar ] , "click" , function ( ) {
affinfo ( this . get ( 'mark' ) ) ;
} ) ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
google . maps . event . addListener ( window [ markvar ] , "dblclick" , function ( ) {
document . getElementById ( "divInfoac" ) . innerHTML = "<B>AC</B>: " + this . get ( 'title' ) ;
autoc = this . get ( 'mark' ) ;
document . getElementById ( "divInfoac" ) . style . display = "block" ;
map . setCenter ( this . position ) ;
} ) ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
google . maps . event . addListener ( window [ markvar ] , "rightclick" , function ( ) {
var pol = this . get ( 'poly' ) ;
redraw ( pol ) ;
} ) ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
if ( ++ ccolor == 9 ) ccolor = 0 ;
} // fin du if typeof...
var difalt = vz * 1 ;
colcn = window [ polyvar ] . strokeColor ;
2015-09-18 20:03:25 +00:00
if ( ddf < 600 ) { // if online (active during 10 last minutes)
2015-01-21 13:13:42 +00:00
if ( ddf > 120 ) afdif = "n" ;
else if ( difalt === 0 ) afdif = "z" ;
else if ( difalt < - 4 ) afdif = "mmm" ;
else if ( difalt < - 1 ) afdif = "mm" ;
else if ( difalt < 0 ) afdif = "m" ;
else if ( difalt > 4 ) afdif = "ppp" ;
else if ( difalt > 1 ) afdif = "pp" ;
else afdif = "p" ;
2015-08-20 20:19:21 +00:00
online . push ( [ cn , alt * 1 , crc , colcn , afdif ] ) ;
2015-01-21 13:13:42 +00:00
if ( window [ markvar ] . get ( 'off' ) == 1 ) {
window [ markvar ] . setOptions ( {
zIndex : 50
} ) ;
window [ markvar ] . setIcon ( "" + tld + "/markers/" + cn + ftypec [ typ * 1 ] + ".png" ) ;
window [ markvar ] . set ( 'off' , 0 ) ;
}
if ( window [ markvar ] . get ( 'tra' ) === 0 ) {
if ( window [ polyvar ] . getPath ( ) . getLength ( ) >= pathl ) window [ polyvar ] . getPath ( ) . removeAt ( 0 ) ; // remove first point of the trace
}
window [ polyvar ] . getPath ( ) . push ( posi ) ; // ajout d'une position sur le tracé
window [ markvar ] . setPosition ( posi ) ; // déplace le marker
// change l'altitude affichée
window [ markvar ] . setTitle ( "" + cn + " - " + ps + " @ " + ( alt * m2ft [ unit ] ) . toFixed ( ) + am2ft [ unit ] + " @ " + tim ) ;
window [ markvar ] . set ( 'speed' , "" + speed ) ;
window [ markvar ] . set ( 'track' , "" + track ) ;
window [ markvar ] . set ( 'vz' , "" + vz ) ;
window [ markvar ] . set ( 'tim' , "" + tim ) ;
window [ markvar ] . set ( 'rec' , "" + rec ) ;
window [ markvar ] . set ( 'alt' , "" + alt ) ;
} else {
if ( all === 0 ) {
if ( typeof ( window [ polyvar ] ) != 'undefined' ) { // si pas déjà effacé
// efface et détruit le PolyLine et le Marker
window [ polyvar ] . setMap ( null ) ;
delete window [ polyvar ] ;
window [ markvar ] . setMap ( null ) ;
delete window [ markvar ] ;
if ( autoc == markvar ) {
autoc = "" ;
document . getElementById ( "divInfoac" ) . innerHTML = " " ;
document . getElementById ( "divInfoac" ) . style . display = "none" ;
2015-01-20 16:58:38 +00:00
}
2015-01-21 13:13:42 +00:00
if ( acaff == markvar ) acaff = "" ;
}
} else {
2015-08-20 20:19:21 +00:00
offline . push ( [ cn , alt * 1 , crc , colcn , "n" ] ) ;
2015-01-21 13:13:42 +00:00
if ( window [ markvar ] . get ( 'off' ) === 0 ) {
window [ markvar ] . setOptions ( {
zIndex : 10
} ) ;
window [ markvar ] . setIcon ( "" + tld + "/markers/" + cn + "_o.png" ) ;
window [ markvar ] . set ( 'off' , 1 ) ;
}
}
}
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
if ( autoc == markvar ) {
document . getElementById ( "divInfoac" ) . innerHTML = "<B>AC</B>: " + cn + " - " + ps + " @ " + ( alt * m2ft [ unit ] ) . toFixed ( ) + am2ft [ unit ] ;
if ( cton === false ) map . setCenter ( new google . maps . LatLng ( lat , lon ) ) ;
}
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
if ( acaff == markvar ) affinfodata ( markvar ) ;
2015-01-20 16:58:38 +00:00
2015-01-19 17:41:11 +00:00
2015-01-21 13:13:42 +00:00
} // fin du for (var i = 0; i < planeurs.length; i++)
// tri et affichage du tableau
afftab ( ) ;
2015-08-20 20:19:21 +00:00
if ( -- nbreq < 0 ) {
2015-09-18 20:03:25 +00:00
nbreq = 0 ;
} else {
tmgm = setTimeout ( gesmark , 10000 ) ;
2015-08-20 20:19:21 +00:00
}
2015-01-21 13:13:42 +00:00
} ) ;
}
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
function wd ( ) {
if ( w === 0 ) {
clearTimeout ( tmgm ) ;
gesmark ( ) ;
}
2015-01-21 13:13:42 +00:00
w = 0 ;
2015-01-20 16:58:38 +00:00
tmwd = setTimeout ( wd , 30000 ) ;
2015-01-07 13:02:56 +00:00
}
function rehash ( ) {
2015-08-20 20:19:21 +00:00
window . location . hash = hashc + hashz + hashm + hasho + hashb + hashs + hashl + hashw + hashp + hashu + hashn + hashy ;
2015-01-07 13:02:56 +00:00
}
function rempl ( po , c ) {
2015-01-21 13:13:42 +00:00
var thl = hl ;
hl = thl . substring ( 0 , po ) + c + thl . substring ( po + 1 ) ;
thl = hl . replace ( / /g , '' ) ;
if ( thl === '' ) hashl = '' ;
else hashl = "&l=" + thl ;
2015-01-19 17:53:42 +00:00
}
2015-01-07 13:02:56 +00:00
2015-01-21 13:13:42 +00:00
function taskclic ( ) {
document . getElementById ( "chfile" ) . click ( ) ;
}
2015-01-07 13:02:56 +00:00
2015-09-18 19:59:58 +00:00
function loadtask ( cont ) {
var tasks = [ ] ;
try {
tasks = tasks . concat ( parseJSONTasks ( cont ) ) ;
} catch ( err ) {
tasks . push ( parseXCSoarTask ( cont ) ) ;
}
2015-01-21 13:13:42 +00:00
for ( var i = 0 ; i < tasks . length ; i ++ ) {
2015-09-18 19:59:58 +00:00
showTask ( tasks [ i ] ) ;
filterDevices ( tasks [ i ] . wlist ) ;
}
2015-09-18 20:03:25 +00:00
}
2015-09-18 19:59:58 +00:00
function parseJSONTasks ( cont ) {
var res = JSON . parse ( cont ) ;
var tasks = [ ] ;
for ( var i = 0 ; i < res . tasks . length ; i ++ ) {
var task = { } ;
task . name = res . tasks [ i ] . name ;
task . color = res . tasks [ i ] . color ;
var tp = [ ] ;
if ( typeof res . tasks [ i ] . legs != 'undefined' ) {
for ( var ii = 0 ; ii < res . tasks [ i ] . legs . length ; ii ++ ) {
if ( typeof res . tasks [ i ] . legs [ ii ] [ 1 ] == 'undefined' ) { // circle
tp [ tp . length - 1 ] . type = "circle" ;
tp [ tp . length - 1 ] . radius = res . tasks [ i ] . legs [ ii ] [ 0 ] ;
} else {
tp . push ( {
lat : res . tasks [ i ] . legs [ ii ] [ 0 ] ,
lon : res . tasks [ i ] . legs [ ii ] [ 1 ]
} ) ;
}
}
2015-08-20 20:19:21 +00:00
}
2015-09-18 19:59:58 +00:00
task . turnpoints = tp ;
if ( typeof res . tasks [ i ] . wlist != 'undefined' ) {
task . wlist = [ ] ;
for ( var ii = 0 ; ii < res . tasks [ i ] . wlist . length ; ii ++ ) {
task . wlist . push ( res . tasks [ i ] . wlist [ ii ] ) ;
2015-01-21 13:13:42 +00:00
}
}
2015-09-18 19:59:58 +00:00
tasks . push ( task ) ;
}
return tasks ;
}
2015-01-19 17:41:11 +00:00
2015-09-18 19:59:58 +00:00
function parseXCSoarTask ( cont ) {
var ltp ;
var tp = [ ] ;
var wl = [ ] ;
tp . length = 0 ;
var oParser = new DOMParser ( ) ;
var oDOM = oParser . parseFromString ( cont , "text/xml" ) ;
var points = oDOM . getElementsByTagName ( "Point" ) ;
for ( var i = 0 ; i < points . length ; i ++ ) {
var loc = points [ i ] . getElementsByTagName ( "Waypoint" ) [ 0 ] . getElementsByTagName ( "Location" ) [ 0 ] ;
var ltp = {
lat : loc . getAttribute ( "latitude" ) ,
lon : loc . getAttribute ( "longitude" )
} ;
if ( points [ i ] . getElementsByTagName ( "ObservationZone" ) [ 0 ] . getAttribute ( "type" ) == "Cylinder" ) {
ltp . type = "circle" ;
ltp . radius = parseFloat ( points [ i ] . getElementsByTagName ( "ObservationZone" ) [ 0 ] . getAttribute ( "radius" ) ) ;
}
tp . push ( ltp ) ;
}
var task = {
turnpoints : tp
} ;
return task ;
}
function showTask ( task ) {
var tc , tn , ltp ;
var tp = [ ] ;
tn = task . name || 'task ' + taskFeatures . length ;
tc = task . color || 'FF0000' ;
for ( var ii = 0 ; ii < task . turnpoints . length ; ii ++ ) {
if ( ( task . turnpoints [ ii ] . type == 'circle' ) ) {
point = new google . maps . LatLng ( task . turnpoints [ ii ] . lat , task . turnpoints [ ii ] . lon ) ;
tp . push ( point ) ;
aatCircle = new google . maps . Circle ( {
strokeColor : '#' + tc ,
strokeOpacity : 0.5 ,
strokeWeight : 2 ,
fillColor : '#' + tc ,
fillOpacity : 0.1 ,
map : map ,
center : point ,
radius : task . turnpoints [ ii ] . radius
} ) ;
taskFeatures . push ( aatCircle ) ;
} else { // Point
point = new google . maps . LatLng ( task . turnpoints [ ii ] . lat , task . turnpoints [ ii ] . lon ) ;
tp . push ( point ) ;
}
2015-08-20 20:19:21 +00:00
}
2015-09-18 19:59:58 +00:00
var flightPath = new google . maps . Polyline ( {
path : tp ,
strokeColor : '#' + tc ,
strokeOpacity : 1 ,
strokeWeight : 2 ,
map : map
} ) ;
flightPath . set ( 'nom' , '' + tn ) ;
taskFeatures . push ( flightPath ) ;
google . maps . event . addListener ( flightPath , 'mouseover' , function ( ) {
var bcol = this . strokeColor ;
document . getElementById ( 'divInfo' ) . innerHTML = '<span style=\'background-color: ' + bcol + '\'> </span> task: ' + this . get ( 'nom' ) ;
} ) ;
google . maps . event . addListener ( flightPath , 'mouseout' , function ( ) {
document . getElementById ( 'divInfo' ) . innerHTML = ' ' ;
} ) ;
document . getElementById ( 'dtaskbox' ) . innerHTML = '<INPUT type="checkbox" id="taskbox" onChange="javascript : taskbox();" checked>' ;
}
function filterDevices ( wl ) {
if ( typeof wl != 'undefined' ) {
for ( var i = 0 ; i < wl . length ; i ++ ) {
wlist . push ( wl [ i ] ) ;
}
2015-01-21 13:13:42 +00:00
}
2015-01-07 13:02:56 +00:00
2015-09-18 19:59:58 +00:00
if ( wlist . length > 0 ) {
wlt = 1 ;
reseton ( ) ;
resetoff ( ) ;
}
2015-01-07 13:02:56 +00:00
}
2015-09-18 20:03:25 +00:00
function rtask ( ) { // select a task file
2015-01-21 13:13:42 +00:00
var files = document . getElementById ( 'chfile' ) . files ;
if ( ! files . length ) {
alert ( 'Please select a file!' ) ;
return ;
2015-01-07 13:02:56 +00:00
}
2015-01-21 13:13:42 +00:00
var file = files [ 0 ] ;
var reader = new FileReader ( ) ;
reader . onloadend = function ( evt ) {
if ( evt . target . readyState == FileReader . DONE ) {
var cont = evt . target . result ;
cont = cont . trim ( ) ;
2015-09-18 19:59:58 +00:00
loadtask ( cont ) ;
2015-01-21 13:13:42 +00:00
}
} ;
reader . readAsText ( file ) ;
}
2015-01-07 13:02:56 +00:00
2015-01-21 13:13:42 +00:00
function initialize ( ) {
var has = window . location . hash . substring ( 1 ) . split ( '&' ) ; // parse the parameters
2015-01-20 16:58:38 +00:00
var parh = [ ] ;
var cent = [ ] ;
2015-09-18 20:03:25 +00:00
var gmdelay = 0 ; // to delay first call to gesmark if task file required
2015-01-21 13:13:42 +00:00
for ( var i = 0 ; i < has . length ; i ++ ) {
var x = has [ i ] . split ( '=' ) ;
parh [ x [ 0 ] ] = x [ 1 ] ;
2015-01-20 16:58:38 +00:00
}
// parameter c=lat,lon (center of the map)
if ( typeof ( parh . c ) != 'undefined' ) {
2015-01-21 13:13:42 +00:00
cent = parh . c . split ( ',' ) ;
vlat = parseFloat ( cent [ 0 ] ) ;
vlon = parseFloat ( cent [ 1 ] ) ;
hashc = "c=" + vlat . toFixed ( 5 ) + "," + vlon . toFixed ( 5 ) ;
2015-01-20 16:58:38 +00:00
}
// parameter o=1 (display offline)
if ( typeof ( parh . o ) != 'undefined' ) {
2015-01-26 17:21:48 +00:00
if ( parh . o == "1" ) {
2015-01-21 13:13:42 +00:00
all = 1 ;
hasho = "&o=1" ;
}
2015-01-20 16:58:38 +00:00
}
airspaceoverlay = new google . maps . ImageMapType ( {
2015-01-21 13:13:42 +00:00
getTileUrl : function ( tile , zoom ) {
var tx = tile . x ;
var ty = tile . y ;
var res = initialResolution / Math . pow ( 2 , zoom ) ;
ty = ( ( 1 << zoom ) - ty - 1 ) ; // TMS
var swlon = tx * 256 * res - originShift ;
var swlat = ty * 256 * res - originShift ;
var nelon = ( tx + 1 ) * 256 * res - originShift ;
var nelat = ( ty + 1 ) * 256 * res - originShift ;
var baseURL = "http://maps.openaip.net/geowebcache/service/wms?service=WMS&request=GetMap&version=1.1.1&layers=openaip_approved_airspaces_geometries&styles=&format=image/png&transparent=true&height=256&width=256&srs=EPSG:900913&bbox=" ;
var url = baseURL + swlon + "," + swlat + "," + nelon + "," + nelat ;
return url ;
} ,
maxZoom : 17 ,
minZoom : 4 ,
opacity : 0 ,
tileSize : new google . maps . Size ( 256 , 256 )
} ) ;
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
airportoverlay = new google . maps . ImageMapType ( {
2015-01-21 13:13:42 +00:00
getTileUrl : function ( tile , zoom ) {
var tx = tile . x ;
var ty = tile . y ;
var res = initialResolution / Math . pow ( 2 , zoom ) ;
ty = ( ( 1 << zoom ) - ty - 1 ) ; // TMS
var swlon = tx * 256 * res - originShift ;
var swlat = ty * 256 * res - originShift ;
var nelon = ( tx + 1 ) * 256 * res - originShift ;
var nelat = ( ty + 1 ) * 256 * res - originShift ;
var baseURL = "http://maps.openaip.net/geowebcache/service/wms?service=WMS&request=GetMap&version=1.1.1&layers=openaip_approved_airports&styles=&format=image/png&transparent=true&height=256&width=256&srs=EPSG:900913&bbox=" ;
var url = baseURL + swlon + "," + swlat + "," + nelon + "," + nelat ;
return url ;
} ,
maxZoom : 17 ,
minZoom : 6 ,
opacity : 0 ,
tileSize : new google . maps . Size ( 256 , 256 )
} ) ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
windoverlay = new google . maps . ImageMapType ( {
2015-01-21 13:13:42 +00:00
getTileUrl : function ( tile , zoom ) {
if ( zoom > 7 ) return ;
return "http://www.openportguide.org/tiles/actual/wind_vector/5/" + zoom + "/" + tile . x + "/" + tile . y + ".png" ;
} ,
maxZoom : 7 ,
opacity : 0 ,
tileSize : new google . maps . Size ( 256 , 256 )
} ) ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
presoverlay = new google . maps . ImageMapType ( {
2015-01-21 13:13:42 +00:00
getTileUrl : function ( tile , zoom ) {
if ( zoom > 7 ) return ;
return "http://www.openportguide.org/tiles/actual/surface_pressure/5/" + zoom + "/" + tile . x + "/" + tile . y + ".png" ;
} ,
maxZoom : 7 ,
opacity : 0 ,
tileSize : new google . maps . Size ( 256 , 256 )
} ) ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
var myOptions = {
2015-01-21 13:13:42 +00:00
mapTypeControlOptions : {
// mapTypeIds: ['RELIEF', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.TERRAIN, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID ]
mapTypeIds : [ google . maps . MapTypeId . ROADMAP , google . maps . MapTypeId . TERRAIN , google . maps . MapTypeId . SATELLITE , google . maps . MapTypeId . HYBRID ]
} ,
zoom : 13 ,
center : new google . maps . LatLng ( vlat , vlon ) ,
overviewMapControl : true ,
scaleControl : true ,
draggableCursor : 'default' ,
draggingCursor : 'default'
//mapTypeId: google.maps.MapTypeId.TERRAIN
2015-01-19 17:53:42 +00:00
} ;
2015-01-07 13:02:56 +00:00
map = new google . maps . Map ( document . getElementById ( "map_canvas" ) , myOptions ) ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
//map.mapTypes.set('RELIEF' , RELIEF);
2015-01-20 16:58:38 +00:00
var mid = 'TERRAIN' ;
2015-01-21 13:13:42 +00:00
var tmid = {
"r" : "ROADMAP" ,
"t" : "TERRAIN" ,
"s" : "SATELLITE" ,
"h" : "HYBRID"
} ;
2015-01-19 17:41:11 +00:00
2015-01-20 16:58:38 +00:00
// parameter m= map type
if ( typeof ( parh . m ) != 'undefined' ) {
mid = tmid [ parh . m ] ;
2015-01-21 13:13:42 +00:00
hashm = "&m=" + parh . m ;
2015-01-20 16:58:38 +00:00
}
2015-01-19 17:41:11 +00:00
2015-01-20 16:58:38 +00:00
map . setMapTypeId ( google . maps . MapTypeId [ mid ] ) ;
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
google . maps . event . addListener ( map , 'maptypeid_changed' , function ( ) {
2015-01-21 13:13:42 +00:00
hashm = "&m=" + map . getMapTypeId ( ) . substr ( 0 , 1 ) ;
rehash ( ) ;
} ) ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
google . maps . event . addListener ( map , 'click' , function ( ) {
2015-01-21 13:13:42 +00:00
infowindow . close ( ) ;
} ) ;
2015-01-07 13:02:56 +00:00
google . maps . event . addListener ( map , 'bounds_changed' , function ( ) {
2015-01-21 13:13:42 +00:00
if ( vstm === true ) settomap ( ) ;
} ) ;
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
google . maps . event . addListener ( map , 'zoom_changed' , function ( ) {
2015-01-21 13:13:42 +00:00
hashz = "&z=" + map . getZoom ( ) ;
rehash ( ) ;
} ) ;
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
google . maps . event . addListener ( map , 'center_changed' , function ( ) {
2015-01-21 13:13:42 +00:00
var nc = map . getCenter ( ) ;
hashc = "c=" + nc . lat ( ) . toFixed ( 5 ) + "," + nc . lng ( ) . toFixed ( 5 ) ;
rehash ( ) ;
} ) ;
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
// parameter z= zoom level
if ( typeof ( parh . z ) != 'undefined' ) map . setZoom ( parseInt ( parh . z ) ) ;
else {
var southWest = new google . maps . LatLng ( vlatmin , vlonmin ) ;
var northEast = new google . maps . LatLng ( vlatmax , vlonmax ) ;
2015-01-21 13:13:42 +00:00
var bounds = new google . maps . LatLngBounds ( southWest , northEast ) ;
2015-01-20 16:58:38 +00:00
map . fitBounds ( bounds ) ;
2015-01-07 13:02:56 +00:00
}
2015-01-19 17:41:11 +00:00
2015-01-21 13:13:42 +00:00
var divinfoCont = document . createElement ( 'DIV' ) ; // contener glider info when overmouse
2015-01-07 13:02:56 +00:00
divinfoCont . style . paddingTop = "7px" ;
divinfoCont . style . paddingRight = "3px" ;
2015-01-21 13:13:42 +00:00
var divinfoContac = document . createElement ( 'DIV' ) ; // contener autocenter
2015-01-07 13:02:56 +00:00
divinfoContac . style . paddingTop = "7px" ;
divinfoContac . style . paddingRight = "3px" ;
2015-01-21 13:13:42 +00:00
var divinfoContpb = document . createElement ( 'DIV' ) ; // contener poweredby
2015-01-07 13:02:56 +00:00
divinfoContpb . style . paddingTop = "7px" ;
divinfoContpb . style . paddingRight = "3px" ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
var divInfo = document . createElement ( "div" ) ;
divInfo . id = "divInfo" ;
divInfo . className = "divInfoclass" ;
divInfo . style . width = "170px" ;
divInfo . style . float = "left" ;
divInfo . style . display = "block" ;
2015-01-21 13:13:42 +00:00
divInfo . appendChild ( document . createTextNode ( "..." ) ) ;
2015-01-07 13:02:56 +00:00
var divInfoac = document . createElement ( "div" ) ;
divInfoac . id = "divInfoac" ;
divInfoac . className = "divInfoclass" ;
divInfoac . style . width = "170px" ;
divInfoac . style . cursor = 'pointer' ;
divInfoac . style . float = "left" ;
divInfoac . style . display = "none" ;
2015-01-21 13:13:42 +00:00
divInfoac . appendChild ( document . createTextNode ( "..." ) ) ;
2015-01-07 13:02:56 +00:00
var divInfopb = document . createElement ( "div" ) ;
divInfopb . id = "divInfopb" ;
//divInfopb.className = "divInfoclass";
//divInfopb.style.width = "170px";
divInfopb . style . backgroundColor = '#F5F5F5' ;
divInfopb . style . opacity = 0.7 ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
divInfopb . style . cursor = 'pointer' ;
divInfopb . style . float = "left" ;
divInfopb . style . display = "block" ;
2015-01-21 13:13:42 +00:00
divInfopb . innerHTML = " Powered By <A HREF=\"http://glidernet.org\" target=\"_blank\"><B>GliderNet.Org</B></A> " ;
2015-01-19 17:41:11 +00:00
2015-01-07 13:02:56 +00:00
// divInfopb.appendChild ( document.createTextNode("Powered By <B>GliderNet.Org</B>"));
2015-01-21 13:13:42 +00:00
divinfoCont . appendChild ( divInfo ) ;
divinfoContac . appendChild ( divInfoac ) ;
divinfoContpb . appendChild ( divInfopb ) ;
2015-01-07 13:02:56 +00:00
divinfoCont . index = 1 ;
map . controls [ google . maps . ControlPosition . TOP _CENTER ] . push ( divinfoCont ) ;
map . controls [ google . maps . ControlPosition . TOP _LEFT ] . push ( divinfoContac ) ;
map . controls [ google . maps . ControlPosition . TOP _RIGHT ] . push ( divinfoContpb ) ;
google . maps . event . addDomListener ( divInfoac , 'click' , function ( ) {
2015-01-21 13:13:42 +00:00
document . getElementById ( "divInfoac" ) . innerHTML = " " ;
autoc = "" ;
2015-01-07 13:02:56 +00:00
document . getElementById ( "divInfoac" ) . style . display = "none" ;
} ) ;
2015-01-20 16:58:38 +00:00
// affiche l'altitude du terrain quand clic-droit
elevator = new google . maps . ElevationService ( ) ;
2015-01-21 13:13:42 +00:00
google . maps . event . addListener ( map , 'rightclick' , function ( event ) {
var locations = [ ] ;
var clickedLocation = event . latLng ;
locations . push ( clickedLocation ) ;
var latc = clickedLocation . lat ( ) ;
var alat = ( latc >= 0 ? "N" : "S" ) + " " + dec2dms ( latc ) ;
var lonc = clickedLocation . lng ( ) ;
var alon = ( lonc >= 0 ? "E" : "W" ) + " " + dec2dms ( lonc ) ;
var positionalRequest = {
'locations' : locations
} ;
elevator . getElevationForLocations ( positionalRequest , function ( results , status ) {
if ( status == google . maps . ElevationStatus . OK ) {
if ( results [ 0 ] ) {
var te = Math . round ( results [ 0 ] . elevation ) ;
infowindow . setContent ( 'Elevation:' + ( te * m2ft [ unit ] ) . toFixed ( ) + am2ft [ unit ] + '<BR>Lat: ' + alat + '<BR>Lon: ' + alon ) ;
infowindow . setPosition ( clickedLocation ) ;
infowindow . open ( map ) ;
} else {
alert ( 'No results found' ) ;
}
} else {
alert ( 'Elevation service failed due to: ' + status ) ;
}
} ) ;
} ) ;
2015-01-07 13:02:56 +00:00
2015-01-20 16:58:38 +00:00
document . getElementById ( "ett1" ) . innerHTML = ett1 ;
2015-01-21 13:13:42 +00:00
document . getElementById ( "ett2" ) . innerHTML = "<TABLE class=\"tt\"><TR width=\"12\"><TH class=\"cgv\" ondblclick=\"allmarker();\"><IMG src='" + tld + "/pict/ico.png'></TH><TH class=\"cgv\" ondblclick=\"allpath();\"><IMG src='" + tld + "/pict/tra.gif'></TH><TH class=\"cgn\" onclick=\"tricn();\">CN</TH><TH class=\"cgc\" ondblclick=\"deleteallpath();\"><IMG border =\"0\" src='" + tld + "/pict/a.gif'></TH><TH class=\"cga\" onclick=\"trialti();\">Alti.</TH><TH class=\"cgz\">Vz</TH></TR></table>" ;
2015-03-07 20:38:37 +00:00
document . getElementById ( "ac" ) . innerHTML = "<span style=\"color: #333; font-weight: bold; font-size: 1.1em; line-height: 1.3em;\"> ..::Aircraft::..</span><BR><span class=\"act\">CN: </span><span id=\"accn\" class=\"aca\"></span><BR><DIV id=\"ac1\"><span class=\"act\">Regist.: </span><span id=\"acre\" class=\"aca\"></span><BR></DIV><span class=\"act\">Device Id: </span><span id=\"acfi\" class=\"aca\"></span><BR><span class=\"act\">Type: </span><span id=\"acty\" class=\"aca\"></span><BR><DIV id=\"ac2\"><span class=\"act\">Model: </span><span id=\"acmo\" class=\"aca\"></span></DIV><span class=\"act\">Last time: </span><span id=\"aclt\" class=\"aca\"></span><BR><span class=\"act\">Latitude: </span><span id=\"acla\" class=\"aca\"></span><BR><span class=\"act\">Longitude: </span><span id=\"aclo\" class=\"aca\"></span><BR><span class=\"act\">Altitude: </span><span id=\"acal\" class=\"aca\"></span><BR><span class=\"act\">G.Speed: </span><span id=\"acsp\" class=\"aca\"></span><BR><span class=\"act\">Track: </span><span id=\"actr\" class=\"aca\"></span><span class=\"aca\"> °</span><BR><span class=\"act\">Vz: </span><span id=\"acvz\" class=\"aca\"></span><BR><span class=\"act\">Receiver: </span><span id=\"acrx\" class=\"aca\"></span><BR><span id=\"acif\" class=\"aca\"></span>" ;
2015-01-20 16:58:38 +00:00
document . getElementById ( "dtable" ) . innerHTML = "<DIV id=\"menu\" style=\"display:none;\"></DIV><DIV id=\"dtlist\" style=\"display:block\"></DIV>" ;
2015-08-28 19:44:58 +00:00
document . getElementById ( "menu" ) . innerHTML = "<TABLE class=\"tt\"><TR><TD><INPUT type=\"checkbox\" id=\"hnewbox\" onChange='javascript : hidenew();'> Hide new gliders<BR><INPUT type=\"checkbox\" id=\"offl\" onChange='javascript : lineoff();'" + ( ( all === 0 ) ? " checked" : "" ) + "> Ignore Offline<HR><INPUT type=\"checkbox\" id=\"boundsbox\" onChange='javascript : bounds();'" + ( ( bound === true ) ? " checked" : "" ) + "> Bounds<BR><TABLE cellspacing=\"0\" cellpading=\"0\"><TR align=\"center\"><TD colspan=\"2\"><INPUT type=\"text\" id=\"latmax\" name=\"latmax\" size=\"7\" value=\"" + amax + "\"></TD></TR><TR align=\"center\"><TD><INPUT type=\"text\" id=\"lonmin\" name=\"lonmin\" size=\"7\" value=\"" + omin + "\"></TD><TD><INPUT type=\"text\" id=\"lonmax\" name=\"lonmax\" size=\"7\" value=\"" + omax + "\"></TD></TR><TR align=\"center\"><TD colspan=\"2\"><INPUT type=\"text\" id=\"latmin\" name=\"latmin\" size=\"7\" value=\"" + amin + "\"></TD></TR></TABLE><BR> <INPUT type=\"button\" onclick=\"settomap()\" value=\"Set to map\"><BR><INPUT type=\"checkbox\" id=\"astmbox\" onChange='javascript : astm();'> Auto Set to map<HR>..:: Devices ::..<BR><INPUT type=\"checkbox\" id=\"ICAObox\" onChange=\"javascript : devtype();\"> ICAO<BR><INPUT type=\"checkbox\" id=\"Flarmbox\" onChange=\"javascript : devtype();\"> Flarm<BR><INPUT type=\"checkbox\" id=\"OGNbox\" onChange=\"javascript : devtype();\"> OGN Trackers<HR>..:: Layers ::..<BR><INPUT type=\"checkbox\" id=\"winbox\" onChange=\"javascript : wind();\"> Wind <BR><INPUT type=\"checkbox\" id=\"prebox\" onChange=\"javascript : pres();\"> Pressure <BR><INPUT type=\"checkbox\" id=\"aspbox\" onChange=\"javascript : asp();\"> AirSpaces <A HREF=\"http://www.openaip.net\" target=\"_blank\" style=\"font-size:10px;\">( openaip.net )</A><BR><INPUT type=\"checkbox\" id=\"aptbox\" onChange=\"javascript : apt();\"> Airports <A HREF=\"http://www.openaip.net\" target=\"_blank\" style=\"font-size:10px;\">( openaip.net )</A><BR><INPUT type=\"checkbox\" id=\"reclbox\" onChange=\"javascript : reclbox();\"> Receivers<BR><span id=\"dtaskbox\"><INPUT type=\"checkbox\" disabled></span> <span onclick=\"taskclic();\">Tasks</span><BR> <DIV style=\"display:none\"><input type=\"file\" id=\"chfile\" onchange=\"rtask()\" /></DIV><HR>..::Units::..<BR><input type=\"radio\" name=\"units\" id=\"unm\" value=\"m\" onclick=\"chunit()\" checked>Met. <input type=\"radio\" name=\"units\" id=\"uni\" value=\"i\" onclick=\"chunit()\">Imp.<HR>..::Path length::..<BR><input type=\"radio\" name=\"pl\" id=\"rp1\" value=\"1\" checked onclick=\"chpl()\">5' <input type=\"radio\" name=\"pl\" id=\"rp2\" value=\"2\" onclick=\"chpl()\">10' <input type=\"radio\" name=\"pl\" id=\"rp3\" value=\"3\" onclick=\"chpl()\">All<HR><CENTER>Join the<BR><A HREF=\"http://ddb.glidernet.org\" target=\"_blank\">OGN DataBase</A></CENTER><HR><CENTER><A HREF=\"https://github.com/glidernet/ogn-live\" target=\"_blank\">Sources</A></CENTER></TD></TR></TABLE>" ;
2015-01-20 16:58:38 +00:00
// parameter b=lat1,lon1,lat2,lon2 bounds
if ( typeof ( parh . b ) != 'undefined' ) {
2015-01-21 13:13:42 +00:00
cent = parh . b . split ( ',' ) ;
2015-01-20 16:58:38 +00:00
document . getElementById ( 'latmax' ) . value = parseFloat ( cent [ 0 ] ) ;
document . getElementById ( 'latmin' ) . value = parseFloat ( cent [ 1 ] ) ;
document . getElementById ( 'lonmax' ) . value = parseFloat ( cent [ 2 ] ) ;
document . getElementById ( 'lonmin' ) . value = parseFloat ( cent [ 3 ] ) ;
2015-01-21 13:13:42 +00:00
boundc = "&b=" + cent [ 0 ] + "&c=" + cent [ 1 ] + "&d=" + cent [ 2 ] + "&e=" + cent [ 3 ] ;
document . getElementById ( 'boundsbox' ) . checked = true ;
2015-01-20 16:58:38 +00:00
bound = true ;
2015-01-21 13:13:42 +00:00
hashb = "&b=" + cent [ 0 ] + "," + cent [ 1 ] + "," + cent [ 2 ] + "," + cent [ 3 ] ;
2015-01-20 16:58:38 +00:00
}
// parameter l= active layers
if ( typeof ( parh . l ) != 'undefined' ) {
for ( var i = 0 ; i < parh . l . length ; i ++ ) {
2015-01-21 13:13:42 +00:00
switch ( parh . l [ i ] ) {
case 'v' : // wind
document . getElementById ( 'winbox' ) . checked = true ;
wind ( ) ;
break ;
case 'p' : // pressure
document . getElementById ( 'prebox' ) . checked = true ;
pres ( ) ;
break ;
case 'z' : // airspace
document . getElementById ( 'aspbox' ) . checked = true ;
asp ( ) ;
break ;
case 'a' : // airport
document . getElementById ( 'aptbox' ) . checked = true ;
apt ( ) ;
break ;
case 'r' : // receivers
document . getElementById ( 'reclbox' ) . checked = true ;
break ;
2015-01-20 16:58:38 +00:00
}
}
}
if ( typeof ( parh . t ) != 'undefined' ) {
2015-09-18 20:03:25 +00:00
gmdelay = 1 ;
var xhr = new XMLHttpRequest ( ) ;
2015-01-21 13:13:42 +00:00
xhr . open ( "GET" , parh . t , true ) ;
xhr . onreadystatechange = function ( ) {
2015-01-20 16:58:38 +00:00
if ( xhr . readyState === 4 ) {
var status = xhr . status ;
if ( ( status >= 200 && status < 300 ) || status === 304 ) {
2015-09-18 19:59:58 +00:00
loadtask ( xhr . responseText ) ;
2015-01-20 16:58:38 +00:00
} else {
2015-01-21 13:13:42 +00:00
alert ( "Task Request unsuccessful" + status ) ;
2015-01-20 16:58:38 +00:00
}
}
2015-08-20 20:19:21 +00:00
gesmark ( ) ;
2015-01-21 13:13:42 +00:00
} ;
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
xhr . send ( null ) ;
2015-01-20 16:58:38 +00:00
}
// parameter w=0 (Don't display the warning)
2015-01-21 13:13:42 +00:00
var warn = 1 ;
2015-01-20 16:58:38 +00:00
if ( typeof ( parh . w ) != 'undefined' ) {
2015-01-26 17:21:48 +00:00
if ( parh . w == "0" ) {
2015-01-21 13:13:42 +00:00
warn = 0 ;
hashw = "&w=0" ;
}
2015-01-20 16:58:38 +00:00
}
2015-09-18 20:03:25 +00:00
// parameter n=0 (Hide the panel)
2015-04-06 18:34:24 +00:00
if ( typeof ( parh . n ) != 'undefined' ) {
if ( parh . n == "0" ) {
alist ( ) ;
}
}
2015-01-21 13:13:42 +00:00
if ( warn == 1 ) {
2015-08-20 20:19:21 +00:00
document . getElementById ( "popup" ) . innerHTML = "<img class=\"pr\" alt=\"close\" src=\"" + tld + "/pict/close.png\"><H1>Warning!</H1><BR><P style=\"text-align:justify;\"><B>The data on this site can be ambiguous in certain situations and the displayed position of an aircraft or glider can be displaced relative to the actual position.<BR>Before raising an alert please contact us so we can interpret the data correctly.</B><BR><BR><B>If you want your devices to be identified, join the <A HREF=\"http://ddb.glidernet.org\" target=\"_blank\">OGN DataBase</A>.</B></P>" ;
2015-01-20 16:58:38 +00:00
op ( 300 ) ;
}
// parameter s=1 auto set bounds to the map
if ( typeof ( parh . s ) != 'undefined' ) {
2015-01-26 17:21:48 +00:00
if ( parh . s == "1" ) {
2015-01-21 13:13:42 +00:00
document . getElementById ( 'astmbox' ) . checked = true ;
vstm = true ;
hashs = "&s=1" ;
2015-01-20 16:58:38 +00:00
}
}
// parameter u=i units imperial ou metric (default))
if ( typeof ( parh . u ) != 'undefined' ) {
2015-01-21 13:13:42 +00:00
if ( parh . u == "i" ) {
document . getElementById ( 'uni' ) . checked = true ;
unit = "i" ;
2015-08-20 20:19:21 +00:00
hashu = "&u=i" ;
2015-01-20 16:58:38 +00:00
}
}
// parameter p=1,2 or 3 path length 5", 10" or all points
if ( typeof ( parh . p ) != 'undefined' ) {
2015-01-26 17:21:48 +00:00
if ( parh . p == "2" ) { // 10 minutes
2015-01-21 13:13:42 +00:00
pathl = 60 ;
document . getElementById ( 'rp2' ) . checked = true ;
hashp = "&p=2" ;
2015-01-26 17:21:48 +00:00
} else if ( parh . p == "3" ) { // all points
2015-01-21 13:13:42 +00:00
pathl = 99999 ;
document . getElementById ( 'rp3' ) . checked = true ;
hashp = "&p=3" ;
2015-01-20 16:58:38 +00:00
}
}
2015-08-20 20:19:21 +00:00
// parameter device type d=1 ICAO ,2 Flarm or 3 OGN tracker
if ( typeof ( parh . y ) != 'undefined' ) {
2015-09-18 20:03:25 +00:00
if ( ( parh . y & 1 ) == 1 ) {
document . getElementById ( 'ICAObox' ) . checked = true ;
}
if ( ( parh . y & 2 ) == 2 ) {
document . getElementById ( 'Flarmbox' ) . checked = true ;
}
if ( ( parh . y & 4 ) == 4 ) {
document . getElementById ( 'OGNbox' ) . checked = true ;
}
devtype ( ) ;
2015-08-20 20:19:21 +00:00
} else {
2015-09-18 20:03:25 +00:00
document . getElementById ( 'ICAObox' ) . checked = true ;
document . getElementById ( 'Flarmbox' ) . checked = true ;
document . getElementById ( 'OGNbox' ) . checked = true ;
2015-08-20 20:19:21 +00:00
}
2015-01-20 16:58:38 +00:00
2015-01-21 13:13:42 +00:00
tz = "&z=" + ( tz / - 60 ) ; // the javascript gettimezone function return negative value in minutes then /-60 to have correct hours
2015-01-20 16:58:38 +00:00
rehash ( ) ;
checkrec ( ) ;
tmwd = setTimeout ( wd , 30000 ) ;
2015-08-20 20:19:21 +00:00
if ( gmdelay == 0 ) gesmark ( ) ;
2015-01-21 13:13:42 +00:00
}