/** * -------------- * © 2008 - 2010 * ------- * THIS CODE IS NOT FREE, IT IS INTELLECTUAL PROPTERTY AND NOT! RELEASED INTO * THE PUBLIC DOMAIN. YOU MAY NOT COPY ANYTHING, NOT EVEN PARTS OF THIS FILE, WITHOUT PERMISSION. * ------- * Any intelligent fool can make things bigger, more complex, and more violent. * It takes a touch of genius -- and a lot of courage -- to move in the opposite direction * -------------- */ //document.write('
test
'); // fetch url vars // dev parameter really set wigth php to, this is for consi stancy var log = false; var highload = false; // ifs that cancels out logic and functionality on site, to reduce cpu load var dev = gup('dev'); var all = gup('all'); var showmenu = gup('showmenu'); var showad = gup('showad'); var clean = gup('clean'); var language = gup('language'); var radarinfo = gup('radarinfo'); var gad = gup('gad'); // get ad var blackinfo = gup('blackinfo'); // get ad var currentlyPlaneInfoShownInWinodowHex = ""; // keeps track of if data is present in window, to prevent doublecclick on planes // GLOBAL VARS var lastUpdate = ""; var planeAmount = ""; var nowTime = ""; var clockinterval = "" ; var defaultOpacity = ".5"; var thePlaneSize = "0"; // defaults to regular "small" size 1 = big, 0 = small var rdrArray = []; // keeps track of current radars sending planes var glFetchTimer = 0 ; // tracks globaly var glFetchTimerLimit = 10; // seconds between loads at minimum (in theory same as min drawing interval) var theStr = ""; var map; // the map var side_bar_html = ""; var gmarkers = []; var weatherMarkersArray = []; var htmls = []; var i = 0; // var all; // for adding all flights var flights; // for adding all flights var bounds; // var s; // var global_totalNodesInLastFetch = ""; // for reloading on mapchange state... ifs var currentZoomLevel = "6" ; var savedSwLat = ""; var savedSwLng = ""; var savedNeLat = ""; var savedNeLng = ""; var activePlane = ""; var oldMarkerObject = ""; // onklick saves the current var activeTrailHex = ""; // active hex, determines current trail var activeLastLng = ""; // the last trail lat present on current map var activeLastLat = ""; // the last trail lng present on current map var activeLastAlt = ""; var winoffset = 4; // sets the offset in ver level for the small bar var opacity = .4; var idleIntervalTimer = ""; // user changable global variables var infotext = 0;// overlays text, set via chkbox onmap var urlLink = 1; var addAirportData = 1; var drawingInterval = 12000; var loadingInterval = 3600000; // 60 minutes var inactivityTimeout = 900; // value in seconds //var pageReload = 600000; var theSetReLoadInterval; // changed by radiobuttons, holds interval id var theSetReDrawInterval; // changed by radiobuttons, holds interval id var lastUpdated = ""; var idleSecs = ""; // new Insertion.After('map', '
'); // GLOBAL ARRAYS var oldPlaneInfoArray = new Array(); var arlanda = new Array(); var pointArr = new Array(); var myArray = new Array(); var thedata = new Array(); var d0 = new Array(); var d1 = new Array(); var allPlacesStr = new Array(); var polyArr = new Array(); var tinyIcon = new GIcon(); var activePlaneData = new Array; var weatherDataArray = new Array; //var currentlyActivePlane = new Array(); // callsign and marker of currently active plane var callsignOverlayTracker = new Array(); // keeps track of overlays present, only callsigns var overlayTrackerEventhandlers = new Array(); // eventhandlers for planes var overlayTracker2 = new Array(); // keeps track of overlays present on map, primary use for removal clearoverlay().. only holds airplanes. MD now with callsign and overlay // var addedPointsToMapLastUpdate = new Array(); // markers that was addeed last load - and still is unchanged // var addedPointsToMapLastUpdateThatIsToBeCleared = new Array(); // markers that was added last load - that has to be removed var airportOverlayTracker = new Array(); // keeps track of airport overlays present on map var radarOverlayTracker = new Array(); var lineOverlayTracker = new Array(); // keeps track of polygone overlays present on map var adsVisible=1; var languageArr = new Array(); var idletimer = ""; function trackIdle(){ // initial set var movedTime = new Date(); lastUpdated = movedTime.getTime(); // start clock idleIntervalTimer = setInterval(function x(){ var d = new Date(); nowTimest = d.getTime(); idleSecs = Number(idleSecs) + Number(1); // halt map here if(idleSecs > inactivityTimeout){ //console.log(idleSecs + ' - ' + inactivityTimeout); turnOffMap("You have been inactive for 15 minutes. Page has suspended automatic updating! " + '

'); } }, 1000); // drawing inteval // start observer Event.observe($('map'), 'mousemove', updateIdleTimer); function updateIdleTimer(){ //var movedTime = new Date(); // lastUpdated = movedTime.getTime(); idleSecs = 0; } } function turnOffMap(message){ clearInterval(idleIntervalTimer); clearInterval(theSetReDrawInterval); clearInterval(theSetReLoadInterval); headline = "ALERT!" ; message = message + '
Click here to reload page »'; niceAlert(headline, message); fullsizeIt('blurredbg'); // fullsize blur $('blurredbg').style.display="block" // show blur } // ----------- // changes the links/ads div position // ----------- function moveIt(id){ if(adsVisible==1){ var xVal = 443; adsVisible=0; }else{ var xVal = -443; adsVisible=1; } new Effect.Move( $("adswindow-inner2") , { x: xVal, y: 0, mode: 'relative' }); } // ----------- // x = 0x // ----------- function fixDateZeroShit(nr){ if(Number(nr)<10){return nr = "0"+String(nr);}else{return nr;}; } // ----------- // as name // returns the present name in div // ----------- function nowTimeUpd(){ dateObj = new Date(); var now = dateObj.getTime(); var minutes = fixDateZeroShit(dateObj.getMinutes()); var hours = fixDateZeroShit(dateObj.getHours()); var seconds = fixDateZeroShit(dateObj.getSeconds()); return nowTime = hours + ':' + minutes + ':' + seconds; //$("now").innerHTML = '' + WORD_clock + ': ' + hours + ':' + minutes + ':' + seconds; } // ----------- // displays time when the page is updated // or more correctly, when the functios run // ----------- function updateTime(usefade){ dateObj = new Date(); var now = dateObj.getTime(); var minutes = fixDateZeroShit(dateObj.getMinutes()); var hours = fixDateZeroShit(dateObj.getHours()); var seconds = fixDateZeroShit(dateObj.getSeconds()); lastUpdate = hours + ':' + minutes + ':' + seconds; } //----------- //displays time when the page is updated //or more correctly, when the function is run //----------- function globalTimer(){ // var glFetchTimer = 0; // tracks globaly // var glFetchTimerLimit = 10; // seconds between loads at minimum (in theory same as min drawing interval) var nowMs = new Date().valueOf(); //console.log( glFetchTimer); //console.log(nowMs); // ok to update if( (glFetchTimer + (glFetchTimerLimit*1000)) < nowMs ){ glFetchTimer = nowMs; // console.log("true/update"); return true; }else{ //console.log("do nothing"); return false; } //console.log(tet); // return true; } // ----------- // saves Cookie data, name-valuepair // ----------- function cookieStoreData(name, value, expiredays){ if(expiredays!=""){ var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie = name + '=' + value + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); }else{ document.cookie = + name + '=' + value ; } } String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }; // ----------- // gets Cookie data // ----------- function get_cookie(Name) { var search = Name + "="; var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search); // if cookie exists if (offset != -1) { offset += search.length; // set index of beginning of value end = document.cookie.indexOf(";", offset); // set index of end of cookie value if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)); } } return trim(returnvalue); } function retrieveAngleFromHeading(hdg, spd){ // gets correct image i=5; j=15; k=10; while (i<=360){ if( ( hdg > i ) && ( hdg <= j ) ){ var planeImageName = k; } i = i + 10; j = j + 10; k = k + 10; } // fix no hdg if( (hdg > 355) || (hdg <= 5) || (hdg == 0) ){ planeImageName="noll"} if( (hdg == "0") && (spd == "0") ) { planeImageName = "00"; } return planeImageName; } // ----------- // create the marker and set up the event window // ----------- function createMarker(point, name, html, hdg, callsign, latt, langg, spd, hex, type, ts, reg, alt, rdr, squawk) { var planeImageName = retrieveAngleFromHeading(hdg, spd); var innerArray = new Array(); if(thePlaneSize=="0"){ var sizefolder = "smaller/"; var wh = "21"; } if(thePlaneSize=="1") { var sizefolder = ""; var wh = "30"; } if(thePlaneSize=="5") { var sizefolder = "size0/"; var wh = "13"; } var planeImageInactive = "http://static.flight24.com/_flightradar24/images/directions/smallerplanes/" + sizefolder + planeImageName + ".png"; var planeImageActive = "http://static.flight24.com/_flightradar24/images/directions/smallerplanes/"+sizefolder+"active/" + planeImageName + ".png"; //overlayTracker2.push(innerArray); // sets correct image if( (callsign!=activePlane) || (callsign == "")){ tinyIcon.image = planeImageInactive; }else{ tinyIcon.image = planeImageActive; } //tinyIcon.image = planeImageInactive; // tinyIcon.image = "http://www.flightradar24.com/images/directions/newplanetest.png"; // tinyIcon.image = "http://www.flightradar24.com/images/directions/45.png"; // tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; tinyIcon.iconSize = new GSize(wh, wh); //tinyIcon.shadowSize = new GSize(10, 10); tinyIcon.iconAnchor = new GPoint(wh/2,wh/2); //tinyIcon.infoWindowAnchor = new GPoint(0, 150); // Set up our GMarkerOptions object literal markerOptions = { title: "Callsign: " + callsign, icon:tinyIcon }; var marker = new GMarker(point, markerOptions); var innerArray = new Array(); innerArray[0] = marker; innerArray[11] = planeImageInactive; innerArray[10] = planeImageActive; /* //$hex = $row['hex']; //$callsign = $row['kalling']; // $lat = $row['lat']; // $lon = $row['lon']; // $spd = $row['spd']; // $hdg = $row['hdg']; * */ innerArray[19] = rdr.toString().strip(); innerArray[20] = hdg.toString().strip(); innerArray[21] = latt.toString().strip(); innerArray[22] = langg.toString().strip(); innerArray[23] = spd.toString().strip(); innerArray[24] = hex.toString().strip(); innerArray[25] = type.toString().strip(); innerArray[26] = ts.toString().strip(); innerArray[27] = reg.toString().strip(); innerArray[28] = alt.toString().strip(); innerArray[29] = callsign.toString().strip(); innerArray[30] = squawk.toString().strip(); overlayTracker2.push(innerArray); // === store the name so that the tooltip function can use it === // marker.tooltip = '
'+name+'
'; //MOUSEOVER var mouseOutEventListenerObject = GEvent.addListener(marker, "mouseover", function() { marker.setImage(planeImageActive); }); // MOUSEOUT var mouseOverEventListenerObject = GEvent.addListener(marker, "mouseout", function() { if(callsign!=activePlane){ // dont remove highlight if active marker.setImage(planeImageInactive); } }); // MOUSECLICK var mouseClickEventListenerObject = GEvent.addListener(marker, "click", function() { activePlane = callsign; activeTrailHex = hex; // onklick show window, if there is a callsign, else close it // print markers, the "1" variable clears markers before adding //adjustHightlightingOfPlane(hex); //activePlane = callsign; //drawMarkers(1); // shows the trail lines (polys) /* * innerArray[0] = marker; innerArray[11] = planeImageInactive; innerArray[10] = planeImageActive; innerArray[20] = hdg; innerArray[21] = latt; innerArray[22] = langg; innerArray[23] = spd; innerArray[24] = hex; * */ // prevents doubleclick on planes if(currentlyPlaneInfoShownInWinodowHex!=hex){ planeInfoAndTrail(callsign, hex); currentlyPlaneInfoShownInWinodowHex = hex; // make all yellow, then add one red overlayTracker2.each(function(s, index) { overlayTracker2[index][0].setImage(overlayTracker2[index][11]); }); marker.setImage(planeImageActive) } }); // adds a plane to map map.addOverlay(marker); // register the overlay to overlay array //registerOverlay(marker, overlayTracker); // register listeneres, to be able to remove them later registerOverlay(mouseOutEventListenerObject, overlayTrackerEventhandlers); registerOverlay(mouseOverEventListenerObject, overlayTrackerEventhandlers); registerOverlay(mouseClickEventListenerObject, overlayTrackerEventhandlers); if(activeTrailHex == hex){ addToTrailLine(hex, latt, langg); } return true; } /** * wrapper with global turnoff ability * @param val * @return */ function log(val){ if(log == true){ console.log(val); }else{ return false; } } function panIt(lat, lng, zv){ var paintt = new GLatLng(lat, lng) ; map.setCenter(map.getCenter()); //console.log(paintt); map.panTo(paintt); if(zv != ""){ map.setZoom(zv); } } // ----------- // filter-function , (wrapper) // ----------- function filterCallsign(id){ var chk = document.getElementById(id); if(chk.checked == true){ // alert("infotext = 1"); infotext = 1;// overlays text
cookieStoreData("callsign2", "on", 90); drawMarkers(1); }else{ // alert("infotext = 0"); infotext = 0;// overlays text cookieStoreData("callsign2", "off", 90); drawMarkers(1); } } // ----------- // filter-function , (wrapper) // radiobuttons triggers this function // ----------- function filterReloadTime(id, time ,ctime){ // store cookie cookieStoreData("reloadtime", time, ctime); // sets golobal (hardly nececcary) //pageReload = time; // resets interval to new value clearInterval(theSetReLoadInterval); // remove interval // sets new interval (and adds to same variable as on init), and resets global setinterval object theSetReLoadInterval = setInterval("reload()", time); // set new interval } //----------- //filter-function , (wrapper) //radiobuttons triggers this function //----------- function filterPlaneSize(id, size , ctime){ /* size: * 0 = big * 1 = small */ // store cookie cookieStoreData("planesize", size, ctime); // global var to correct size thePlaneSize = size; // redraw all planes drawMarkers(1); } /** * grabs url parameters * @param name * @return */ /* function gup( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return "0"; else return results[1]; } */ // ----------- // filter-function , (wrapper) // radiobuttons triggers this function // ----------- function filterDrawingTime(id, time ,ctime){ // store cookie cookieStoreData("drawtime", time, ctime); // sets golobal (hardly nececcary) //pageReload = time; // resets interval to new value clearInterval(theSetReDrawInterval); // remove interval // sets new interval (and adds to same variable as on init), and resets global setinterval object theSetReDrawInterval = setInterval("drawMarkers(1)", time); // set new interval } //----------- //filter-function , (wrapper) //----------- function filterWeather(id){ //console.log($(id).checked); if($(id).checked == true){ // alert("infotext = 1"); cookieStoreData("weatherlayer", "on", 90); weather(1, setupWeatherMarkers, woeids); }else{ // alert("infotext = 0"); cookieStoreData("weatherlayer", "off", 90); clearMarkersInOverlayArr(weatherMarkersArray);// clears from map, not from array, if second arg not 1 } } // ----------- // filter-function , (wrapper) // ----------- function filterAirports(id){ //console.log($(id).checked); if($(id).checked == true){ // alert("infotext = 1"); cookieStoreData("airports2", "on", 90); onlyAddMarkersToMap(airportOverlayTracker); }else{ // alert("infotext = 0"); cookieStoreData("airports2", "off", 90); clearMarkersInOverlayArr(airportOverlayTracker);// clears from map, not from array, if second arg not 1 } } //----------- //filter-function , (wrapper) //----------- function filterRadars(id){ //console.log($(id).checked); if($(id).checked == true){ // alert("infotext = 1"); cookieStoreData("radars", "on", 90); onlyAddMarkersToMap(radarOverlayTracker); }else{ // alert("infotext = 0"); cookieStoreData("radars", "off", 90); clearMarkersInOverlayArr(radarOverlayTracker);// clears from map, not from array, if second arg not 1 } } // ----------- // removes lines from map // ----------- function removeLines(){ if(lineOverlayTracker.length > 0){ clearMarkersInOverlayArr(lineOverlayTracker);// clears from map, not from array, if second arg not 1 } } // ----------- // filter-function , (wrapper) // ----------- function filterPresentUrl(){ var urldiv = document.getElementById("urlinput2"); // the div var chk = document.getElementById("urlchk"); // the checkbox if(chk.checked == 0){ urldiv.style.display="none"; cookieStoreData("presenturl", "0", 90); } if(chk.checked == 1){ urldiv.style.display="block"; cookieStoreData("presenturl", "1", 90); } } // ----------- // filter-function , (wrapper) // ----------- function filterLinkbannerschk(){ var theDiv = $('adswindow-inner2'); // the div var chkBox = document.getElementById("linkbannerschk"); // the checkbox if(chkBox.checked == 0){ theDiv.style.display = "none"; cookieStoreData("linkbanners", "0", 2); } if(chkBox.checked == 1){ cookieStoreData("linkbanners", "1", 2); theDiv.style.display = "block"; } } // ----------- // returns colors for the poly lines, feel free to add more if needed // ----------- function returnColor(meters){ if( ( Number(meters) > 13000 ) ){color="#ff0000";return color;}; if( ( Number(meters) > 12500 ) ){color="#ff00e4";return color;}; if( ( Number(meters) > 12000 ) ){color="#d800ff";return color;}; if( ( Number(meters) > 11500 ) ){color="#ae00ff";return color;}; if( ( Number(meters) > 11000 ) ){color="#9600ff";return color;}; if( ( Number(meters) > 10500 ) ){color="#7800ff";return color;}; if( ( Number(meters) > 10000 ) ){color="#6000ff";return color;}; if( ( Number(meters) > 9500 ) ){color="#4e00ff";return color;}; if( ( Number(meters) > 9000 ) ){color="#3600ff";return color;}; if( ( Number(meters) > 8500 ) ){color="#2400ff";return color;}; if( ( Number(meters) > 8500 ) ){color="#1200ff";return color;}; if( ( Number(meters) > 7500 ) ){color="#0000ff";return color;}; if( ( Number(meters) > 7000 ) ){color="#001eff";return color;}; if( ( Number(meters) > 6500 ) ){color="#0030ff";return color;}; if( ( Number(meters) > 6000 ) ){color="#0054ff";return color;}; if( ( Number(meters) > 5500 ) ){color="#0078ff";return color;}; if( ( Number(meters) > 5000 ) ){color="#0096ff";return color;}; if( ( Number(meters) > 4500 ) ){color="#00a8ff";return color;}; if( ( Number(meters) > 4000 ) ){color="#00c0ff";return color;}; if( ( Number(meters) > 3500 ) ){color="#00eaff";return color;}; if( ( Number(meters) > 3000 ) ){color="#00ffe4";return color;}; if( ( Number(meters) > 2500 ) ){color="#00ffd2";return color;}; if( ( Number(meters) > 2000 ) ){color="#00ff9c";return color;}; if( ( Number(meters) > 1500 ) ){color="#00ff72";return color;}; if( ( Number(meters) > 1200 ) ){color="#00ff36";return color;}; if( ( Number(meters) > 1000 ) ){color="#00ff0c";return color;}; if( ( Number(meters) > 800 ) ){color="#1eff00";return color;}; if( ( Number(meters) > 600 ) ){color="#42ff00";return color;}; if( ( Number(meters) > 400 ) ){color="#ccff00";return color;}; if( ( Number(meters) > 300 ) ){color="#f0ff00";return color;}; if( ( Number(meters) > 200 ) ){color="#ffea00";return color;}; if( ( Number(meters) > 100 ) ){color="#ffe062";return color;}; if( ( Number(meters) < 100 ) ){color="#ffffff";return color;}; } // ----------- // trim func // ----------- String.prototype.trim = function(){ return this.replace("/^\s+/,''").replace("/\s+$/,''");}; function returnMarkerData(hex){ //console.log("returnMarkerData() starts... "); for (index=0;index
(' + kmph + ' km/h / ' + mph + ' mph)' ; //var hex = mda[24]; var type = mda[25]; var ts = mda[26]; var alt = mda[28]; var meters = Math.round((alt*0.3048*1)/1); var alt = mda[28]; var squawk = mda[30]; if(squawk=="" || squawk==" "){squawk=="n/a";} switch(squawk){ case 7500: squawk = 'Unlawful Interference - reported through squawk emergency code 7500 ! (i.e. Aircraft hijacking)'; break; case 7600: squawk = 'Lost Communications! - reported through squawk emergency code 7600! '; break; case 7700: squawk = 'General Emergency! - reported through squawk emergency code 7700! '; break; } // from ajax var callsignLinked = dataArr[0]; var planeImg = dataArr[1]; //console.log(planeImg); var reg = dataArr[4]; var typelong = dataArr[5]; var ICAOTypeCode = dataArr[6]; var regOwners = dataArr[7]; var startgoalLi = dataArr[15]; var comment = dataArr[16]; var regLinked = dataArr[17]; var cashe = dataArr[18]; var flightNr = dataArr[19]; if(callsign=="00000000" || callsign == "" || callsign == "@@@@@@@@"){ var callError = " (error)" ; //var callsignToFlight24 = callsign; }else{ var callError = ""; //var callsignToFlight24 = ''+callsign+''; }; if(flightNr==""){ var flightNrToFlight24 = flightNr; }else{ var flightNrToFlight24 = ''+flightNr+''; }; // Create html var data = '
'+callsign+'
' + planeImg + "" ; //var page = "planeinfo2.php?id=" + Math.floor(Math.random()*5000+1) ; $('rightcontentdivinnner').update(data); } } /* // ----------- // function overlays the poly trails // ajax data get // registers to lineOverlayTracker array all present polys // ----------- function printLine(callsign, hex){ lineOverlayTracker = []; lineOverlayTracker.length = 0; hex = hex.trim(); var url = "airplane-line.xml?" + new Date().getTime() + "&callsign=" + callsign + "&hex=" + hex; GDownloadUrl(url, function(data, responseCode){ var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); colorArr = []; for (var i = 0; i < markers.length-1; i++) { alt = markers[i].getAttribute("alt"); meters = Math.round(alt*0.3048*1)/1; color = returnColor(meters); lat = markers[i].getAttribute("lat"); lat2 = markers[i+1].getAttribute("lat"); lng = markers[i].getAttribute("lng"); lng2 = markers[i+1].getAttribute("lng"); var polyOptions = {geodesic:true}; // set for updating of lines activeLastLng = lng2; activeLastLat = lat2; activeLastAlt = alt; //polyArr[i] = new GLatLng( lat, lng ); //polyArr = new GLatLng( lat, lng ); if(lng2!=""){ var polyline = new GPolyline([ new GLatLng(lat, lng), new GLatLng(lat2, lng2) ], color, 2, 1, polyOptions); map.addOverlay(polyline); } registerOverlay(polyline, lineOverlayTracker); } // alert(colorArr); }); } */ function roundABit(nr ){ return Math.round(nr*1000)/1000 } //----------- //function overlays the poly trails //ajax data get //registers to lineOverlayTracker array all present polys //----------- function printLine2(lineArr){ lineOverlayTracker = []; lineOverlayTracker.length = 0; for (var i = 0; i < lineArr.length-1; i++) { alt = lineArr[i][2]; meters = Math.round(alt*0.3048*1)/1; color = returnColor(meters); lat = lineArr[i][0]; lat2 = lineArr[i+1][0]; lng = lineArr[i][1]; lng2 = lineArr[i+1][1]; var polyOptions = {geodesic:true}; // set for updating of lines activeLastLng = lng2; activeLastLat = lat2; activeLastAlt = alt; //polyArr[i] = new GLatLng( lat, lng ); //polyArr = new GLatLng( lat, lng ); if(lng2!=""){ var polyline = new GPolyline([ new GLatLng(lat, lng), new GLatLng(lat2, lng2) ], color, 2, 1, polyOptions); map.addOverlay(polyline); registerOverlay(polyline, lineOverlayTracker); } /* var options:PolylineOptions = new PolylineOptions({ strokeStyle: { thickness: 3, color: color, alpha: 0.5, pixelHinting: true } }); var polyline = new GPolyline(polyArr, colorArr, 2, 1, polyOptions); map.addOverlay(polyline); */ } // alert(colorArr); // d /* var options:PolylineOptions = new PolylineOptions({ strokeStyle: { thickness: 3, color: 0x123456, alpha: 0.5, pixelHinting: true } }); var polyOptions = {geodesic:true}; var polyline = new GPolyline(polyArr, colorArr, 2, 1, polyOptions); // d */ } function roundABit(nr ){ return Math.round(nr*1000)/1000 } // ----------- // not working so far..... NIU // adds a line.. // only one poly per load // ----------- function addToTrailLine(hex, lat, lng){ // only print if all valuse present if( (activeLastLng!="") && (activeLastLat!="") && (lat!="") && (lng !="") && (alt!="") ){ hex = hex.trim(); colorArr = []; meters = Math.round(activeLastAlt*0.3048*1)/1; color = returnColor(meters); var polyOptions = {geodesic:true}; var polyline = new GPolyline([ new GLatLng(activeLastLat, activeLastLng), new GLatLng(lat2, lng2) ], color, 2, 1, polyOptions); map.addOverlay(polyline); registerOverlay(polyline, lineOverlayTracker); } } // ----------- // displays filter div // uses script ac ulous, and prototype // ----------- function showfilters(id){ var element = $(id); // first check to close if other is open //if($('filterwindow-inner').style.display != "none"){Effect.BlindDown('filterwindow-inner', { duration: 0.5 });} //if($('infowindow-explain').style.display != "none"){Effect.BlindDown('infowindow-explain', { duration: 0.5 });} if(element.style.display == "none"){ Effect.BlindDown(id, { duration: 0.5 }); }else{ Effect.BlindUp(id, { duration: 0.5 }); } //var element = document.getElementById(id); } function updatetimed(){ if($('amountonmap')!=null){ var amount = overlayTracker2.length; if(infotext){amount = amount ;}; $('amountonmap').innerHTML = 'Showing ' + amount + ' planes of ' + global_totalNodesInLastFetch + ' covered (' + Math.round((amount/global_totalNodesInLastFetch)*100) + '%)'; //$('now').innerHTML = WORD_clock +': ' + nowTimeUpd(); //$('lastupdate').innerHTML = WORD_updated+': ' + lastUpdate; } } function changeUpdateIntervalOnZoomLevel(){ var amount = overlayTracker2.length; if(amount > 200){ // resets interval to new value clearInterval(theSetReDrawInterval); // remove interval // sets new interval (and adds to same variable as on init), and resets global setinterval object theSetReDrawInterval = setInterval("drawMarkers(1)", 30000); // set new interval return true; } if(amount <= 200 && amount > 5){ // resets interval to new value clearInterval(theSetReDrawInterval); // remove interval // sets new interval (and adds to same variable as on init), and resets global setinterval object theSetReDrawInterval = setInterval("drawMarkers(1)", 12000); // set new interval return true; } if(amount <= 5){ // resets interval to new value clearInterval(theSetReDrawInterval); // remove interval // sets new interval (and adds to same variable as on init), and resets global setinterval object theSetReDrawInterval = setInterval("drawMarkers(1)", 7000); // set new interval return true; } return false; } // ----------- // closes infowin. the little [x] // ----------- function onCloseInfoWin(){ Effect.BlindUp('infowindow-general', { duration: 0.3 }); removeLines(); // removes trail-polys // redraw to remove marked plane on redraw activePlane = ""; drawMarkers(1); } // ----------- // This function displays the tooltip ====== // it can be called from an icon mousover or a side_bar mouseover // ----------- function showTooltip(marker) { tooltip.innerHTML = marker.tooltip; var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom()); var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom()); var anchor=marker.getIcon().iconAnchor; var width=marker.getIcon().iconSize.width; var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y)); pos.apply(tooltip); tooltip.style.visibility="visible"; } // ===== This function is invoked when the mouse goes over an entry in the side_bar ===== // It launches the tooltip on the icon function mymouseover(i) { showTooltip(gmarkers[i]) } // ===== This function is invoked when the mouse leaves an entry in the side_bar ===== // It hides the tooltip function mymouseout() { tooltip.style.visibility="hidden"; } // This function picks up the side_bar click and opens the corresponding info window function myclick(i) { gmarkers[i].openInfoWindowHtml(htmls[i]); } // ----------- // splits the history xml data, returns array containing values // ----------- function splitHistoryString(theStr){ thedata = new Array(); brokenstring=""; if(theStr!=""){ brokenstring = theStr.split(","); // split data }else{ return 0; } thedata.hex = brokenstring[0].strip(); thedata.rdr = brokenstring[1].strip(); thedata.callsign = brokenstring[2].strip(); thedata.alt = brokenstring[3].strip(); thedata.lat = brokenstring[4].strip(); thedata.lng = brokenstring[5].strip(); thedata.spd = brokenstring[6].strip(); thedata.hdg = brokenstring[7].strip(); thedata.reg = brokenstring[8].strip(); thedata.squawk = brokenstring[9].strip(); thedata.ts = brokenstring[10].strip(); thedata.type = brokenstring[11].strip(); return thedata; } //----------- //adds //uses ajax to retrieve data //registers to array //----------- function addRadarMarker(name, lat, lng, rad){ var blueIcon = new GIcon(); //blueIcon.image = "http://www.flightradar24.com/images/markers/red-pushpin.png"; blueIcon.image = "http://static.flight24.com/_flightradar24/images/markers/blackdot.png"; //blueIcon.shadow = "http://www.flightradar24.com/images/markers/pushpin_shadow.png"; //blueIcon.title = new GTitle("test f dfsd f") ; blueIcon.iconSize = new GSize(15, 15); //blueIcon.shadowSize = new GSize(59, 32); blueIcon.iconAnchor = new GPoint(8, 8); //blueIcon.iconAnchor = new GPoint(offsetleft, offsettop); blueIcon.infoWindowAnchor = new GPoint(8, 8); //blueIcon.infoShadowAnchor = new GPoint(6, 32); var marker = new GMarker(new GLatLng(lat, lng), {title: name+' radar', icon: blueIcon }); GEvent.addListener(marker, "click", function() { loadMenuRadarClicked(name); }); // var html = '
'+ '
' + airportName + ', ' + airportIata + '
'+ '

' + airportFact + '

' + '
'; /* GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); */ //map.addOverlay(marker); // adds to map... dosnt add here, adds separatly var marker2 = doDrawCircle(0.1, rad, lat, lng ); registerOverlay(marker2, radarOverlayTracker); registerOverlay(marker, radarOverlayTracker); // adds to airports overlayTracker array } // ----------- // adds the airport markers // uses ajax to retrieve data // registers to airportOverlayTracker array // ----------- function addAirportMarker(airportName, airportCity, airportIata, airportIcao, airportFact, airportLon, airportLat){ var blueIcon = new GIcon(); blueIcon.image = "http://static.flight24.com/_flightradar24/images/markers/bluecross.png"; //blueIcon.shadow = "http://www.flightradar24.com/images/markers/pushpin_shadow.png"; blueIcon.iconSize = new GSize(16, 15); //blueIcon.shadowSize = new GSize(59, 32); blueIcon.iconAnchor = new GPoint(8, 8); //blueIcon.iconAnchor = new GPoint(offsetleft, offsettop); blueIcon.infoWindowAnchor = new GPoint(8, 8); //blueIcon.infoShadowAnchor = new GPoint(6, 32); // blueIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png"; // blueIcon.printImage = "coldmarkerie.gif"; // blueIcon.mozPrintImage = "coldmarkerff.gif"; var marker = new GMarker(new GLatLng(airportLon, airportLat), {title: airportName+' Airport ('+airportIata+')', icon: blueIcon }); var html = '
'+ '
' + airportName + ', ' + airportIata + '
'+ '

' + airportFact + '

' + '
'; /* GEvent.addListener(marker, "click", function() { //alert("sdf"); //marker.openInfoWindowHtml(html); }); */ /* //MOUSEOVER var mouseOutEventListenerObject = GEvent.addListener(marker, "mouseover", function() { //marker.openInfoWindowHtml(html); //var imgUrl = "http://www.flightradar24.com/images/directions/smallerplanes/" + sizefolder + "active/" + planeImageName + ".png"; //marker.setImage(planeImageActive); }); // MOUSEOUT var mouseOverEventListenerObject = GEvent.addListener(marker, "mouseout", function() { // marker.openInfoWindowHtml(html); //if(callsign!=activePlane){ // dont remove highlight if active //var imgUrl = "http://www.flightradar24.com/images/directions/smallerplanes/" + sizefolder + planeImageName + ".png"; // marker.setImage(planeImageInactive); //} }); */ //map.addOverlay(marker); // adds to map... dosnt add here, adds separatly registerOverlay(marker, airportOverlayTracker); // adds to airports overlayTracker array } // ----------- // unpdates current users on page, db and page // ----------- function updateUserDatabaseEntry(ip){ /* new Ajax.Updater('usersonlineData','ajaxcall_update_users.php', { method:'post', parameters: {ip : ipVar} }); */ //$('usersonline').innerHTML = amount + ' besökare på sidan' } /** * same function as loadmenu() but for planes not hooked on id */ function loadMenuPlaneKlicked(planeId){ clearInterval(clockinterval); $('rightcontentdivinnner').innerHTML = 'Loading...'; var page = "planeinfo2.php?id=" + Math.floor(Math.random()*5000+1) ; new Ajax.Updater('rightcontentdivinnner', '_ajax/'+page, { method:'GET', parameters : {id : planeId, language : language} }); } /** * same function as loadmenu() but for radars not hooked on id */ function loadMenuRadarClicked(name){ clearInterval(clockinterval); $('rightcontentdivinnner').innerHTML = 'Loading...'; var page = "radarinfo.php"; new Ajax.Updater('rightcontentdivinnner', '_ajax/'+page, { method:'GET', parameters : {name : name } }); } function genericJsonRetriever(url, functionToProcess, hash, param2){ var evaledJson = ""; //if(idx=="" || filex==""){return false;}; //var url = "url"; new Ajax.Request(url, { method: 'get', requestHeaders: {Accept: 'application/json'}, parameters: hash, onSuccess: functionToProcess, onCreate: function(){}, onLoading: function(){}, onComplete: function(transport){}, onFailure: function() { //alert('error!'); }// }); } /* * @param id * @return */ function markMenuTab(id){ //console.log("markMenuTab"); // remove all classnames if($('menu0').hasClassName('active')){$('menu0').removeClassName('active');} /* if($('menu1').hasClassName('active')){$('menu1').removeClassName('active');} */ if($('menu2').hasClassName('active')){$('menu2').removeClassName('active');} if($('menu3').hasClassName('active')){$('menu3').removeClassName('active');} if($('menu4').hasClassName('active')){$('menu4').removeClassName('active');} if($('menu5').hasClassName('active')){$('menu5').removeClassName('active');} if($('menu6').hasClassName('active')){$('menu6').removeClassName('active');} if(id!=""){ // passsed no args, defocus menu // add classname if(id=="menu6" ){ $('menu6').removeClassName('yellowify'); $('menu6').addClassName('active'); } $(id).addClassName("active"); } } /** * on filtermenu click * @param event * @return */ function activateFilters(){ // remove active color on tab if so if(gup('fa')=="1"){ $('menu6').style.backgroundColor = ""; $('menu6').style.color = ""; } var CValAirports = (get_cookie('airports2') == "on" ) ? "checked" : ""; var CValCallsign = (get_cookie('callsign2') == "on" ) ? "checked" : ""; var CValWeather = (get_cookie('weatherlayer') == "on" ) ? "checked" : ""; var ps1="";var ps2="";var ps3=""; if( get_cookie('planesize') == "1" ){ ps1 = " checked "; } if( get_cookie('planesize') == "0" ){ ps2 = " checked "; } if( get_cookie('planesize') == "5" ){ ps3 = " checked "; } if(ps1=="" && ps2=="" && ps3==""){ ps2 = " checked "; } ; // filters Markup var xhtml = '
' + '
Filters / Adjustments

Some adjustmends first, below several filters.

' + '
'+ '
'+ '

(shows weatherconditions on the map)

' + 'Aircraft icon size:
'+ '
' + '
' + ' ' + '
' + '

Shows airplane callsign on map (Varning! might slow down web-reader, google crome browser recommended for this...)

' + '
' + '
' + '
Filters
' + '
'+ '

Here you can filter the aircrafts that are shown on the map. After applied filter, only the aircrafts matching your criteria will be shown.

'; // xhtml+= '
' + '

Write full or part (beginning) of callsign or hex.

' + ' Airplane -filter' + '
'+ '
' + ' ' + '
' + '
'; // altitude filter xhtml+= '
' + ' Height -filter' + '
'+ ' ' + '
' + ' ' + '
' + ' ' + '
' + '
'; // speed filter xhtml+= '
' + ' Speed -filter' + '
'+ ' ' + '
' + ' ' + '
' + ' ' + '
' + '
'; // radar filter var unikeRadarArray = rdrArray.uniq().sort(); var ropt = ""; ropt+=''; // if(gup('airplfil')!=""){ $('airplfil').value = gup('airplfil'); } var choosenRadar = gup('radarname'); var selected = ""; unikeRadarArray.each(function(n) { if(n==choosenRadar){ selected = " SELECTED ";}else{selected="";} ropt+=''; }); xhtml+= '
' + '

Displays only aircrafts from specific radar reciever.

' + ' Radar -filter' + '
'+ '
' + ' ' + '
' + '
'; xhtml+= ' ' ; xhtml+= ' ' ; xhtml+= '
' + '
'; $('rightcontentdivinnner').innerHTML = xhtml; // set filter initial values from current URL if(gup('heightmin')!=""){ $('heightmin').value = gup('heightmin'); } if(gup('heightmax')!=""){ $('heightmax').value = gup('heightmax'); } if(gup('heightmaxunit')=="ft"){ $('maxftopt').selected = true; } if(gup('heightmaxunit')=="m"){ $('maxmopt').selected = true; } if(gup('heightminunit')=="ft"){ $('minftopt').selected = true; } if(gup('heightminunit')=="m"){ $('minmopt').selected = true; } if(gup('speedmax')!=""){ $('speedmax').value = gup('speedmax'); } if(gup('speedmaxunit')=="knots"){ $('maxknotopt').selected = true; } if(gup('speedmaxunit')=="kmph"){ $('maxkmopt').selected = true; } if(gup('speedmaxunit')=="mph"){ $('maxmphopt').selected = true; } if(gup('speedmin')!=""){ $('speedmin').value = gup('speedmin'); } if(gup('speedminunit')=="knots"){ $('minknotopt').selected = true; } if(gup('speedminunit')=="kmph"){ $('minkmopt').selected = true; } if(gup('speedminunit')=="mph"){ $('minmphopt').selected = true; } if(gup('airplfil')!=""){ $('airplfil').value = gup('airplfil'); } if(gup('airplfiltype')=="callsign"){ $('airplfilcallopt').selected = true; } if(gup('airplfiltype')=="hex"){ $('airplfilhexopt').selected = true; } var airplfil = gup(''); var airplfiltype = gup(''); } /* handles filter apply clicks */ function filter(callingBtnId){ var urlHeightMin = ""; var urlHeightMax = ""; var urlheightMaxunit = ""; var urlheightMinunit = ""; var urlSpeedMin = ""; var urlSpeedMax = ""; var urlspeedMaxunit = ""; var urlspeedMinunit = ""; var rdrChoosen = ""; var url = ""; //var element = event.element(); var doredirect = false; // heightfilter var heightMax = $('heightmax').value; var heightMin = $('heightmin').value; var heightMinunit = $('heightminunit').value; var heightMaxunit = $('heightmaxunit').value; if( IsNumeric(heightMin) && heightMin != "" ){ urlHeightMin = '&heightmin='+heightMin; doredirect = true; }else{ urlHeightMin = ""; } if( IsNumeric(heightMax) && heightMax != "" ){ urlHeightMax = '&heightmax='+heightMax; doredirect = true; }else{ urlHeightMax = ""; } var heightminunitValInex = document.filterform.heightminunit.selectedIndex; var heightminunitValText = document.filterform.heightminunit.options[heightminunitValInex].text; var heightmaxunitValInex = document.filterform.heightmaxunit.selectedIndex; var heightmaxunitValText = document.filterform.heightmaxunit.options[heightmaxunitValInex].text; var urlheightMaxunit = '&heightmaxunit='+heightmaxunitValText; var urlheightMinunit = '&heightminunit='+heightminunitValText; //rdr -filter var rdrValInex = document.filterform.radarname.selectedIndex; var rdrValText = document.filterform.radarname.options[rdrValInex].text; if( rdrValText != "" ){ rdrChoosen = '&radarname='+rdrValText; doredirect = true; }else{ rdrChoosen = ""; } // speedfilter var speedMax = $('speedmax').value; var speedMin = $('speedmin').value; var speedMinunit = $('speedminunit').value; var speedMaxunit = $('speedmaxunit').value; if( IsNumeric(speedMin) && speedMin != "" ){ var urlSpeedMin = '&speedmin='+speedMin; doredirect = true; }else{ var urlSpeedMin = ""; } if( IsNumeric(speedMax) && speedMax != "" ){ var urlSpeedMax = '&speedmax='+speedMax; doredirect = true; }else{ var urlSpeedMax = ""; } var speedminunitValInex = document.filterform.speedminunit.selectedIndex; var speedminunitValText = document.filterform.speedminunit.options[speedminunitValInex].text; var speedmaxunitValInex = document.filterform.speedmaxunit.selectedIndex; var speedmaxunitValText = document.filterform.speedmaxunit.options[speedmaxunitValInex].text; var urlspeedMaxunit = '&speedmaxunit='+speedmaxunitValText; var urlspeedMinunit = '&speedminunit='+speedminunitValText; // planefilter (callsign, hex etc.) /* '
' + ' ' + */ var pfilterValue = $('airplfil').value; var pfilterType = $('airplfiltype').value; if( pfilterValue != "" ){ var urlPfilter = '&airplfil='+pfilterValue+'&airplfiltype='+pfilterType; doredirect = true; }else{ var urlPfilter = ""; } if(doredirect){ var url = "http://www.flightradar24.com/index.php?fa=1"; url+= urlHeightMin+urlHeightMax+urlheightMaxunit+urlheightMinunit; url+= urlSpeedMin+urlSpeedMax+urlspeedMaxunit+urlspeedMinunit; url+= urlPfilter + rdrChoosen; redirect(url); } } /** * * @param event * @return */ function IsNumeric(sText){ var ValidChars = "0123456789"; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } //----------- // updates menu with ajax //----------- function loadmenu(event){ var element = event.element(); switch(element.id){ // case 'menu1' : var page = "adjustments.php"; markMenuTab(element.id); break; case 'menu2' : var page = "about.php";markMenuTab(element.id); break; case 'menu3' : var page = "activeradars.php";markMenuTab(element.id); break; case 'menu4' : var page = "activeplanes.php"; markMenuTab(element.id); break; case 'menu5' : chatWindowOpen(); markMenuTab(element.id);return true; break; case 'menu6' : activateFilters(); markMenuTab(element.id);return true; break; } $('rightcontentdivinnner').innerHTML = 'Loading...'; // var code = ""; if(element.id != "menu0"){ new Ajax.Updater('rightcontentdivinnner', '_ajax/'+page, { method:'get', parameters : { language : language} } ); // fixes sorting of the list if(element.id == "menu4"){ setTimeout(sortables_init,500) } clearInterval(clockinterval); }else{ // firstpage markMenuTab(element.id); clearInterval(clockinterval); addFistpageInfoToFirtstTab(); // adds divs to bee filled with times, amounts, etc... showPresentPosition(); } currentlyPlaneInfoShownInWinodowHex = ""; // if menu item clicked, potentially active planedata will be removed } /** * returns bool */ function getRand (truePercentage){ truePercentage = truePercentage / 10; if(Math.floor(Math.random()*11)<=truePercentage){ return true; }else{ return false; } } function addFistpageInfoToFirtstTab(){ clearInterval(clockinterval); var charterbanner = '
gå till charter.se
'; var flygresorbanner = '
gå till flygresor.se
'; // randomize the swedish banner if(getRand(50)){ var swedishBannerLink = charterbanner + flygresorbanner; }else{ var swedishBannerLink = flygresorbanner + charterbanner; } // banner image switch(countryCode){ case "sv" : var bannerImg = swedishBannerLink; break; default : var bannerImg = '
go to flight24.com
'; } // introtext var introtext = '
Flightradar24.com

Flightradar24.com shows live airtraffic in the airspace above Europe.

InformationClick here to get more information about how Flightradar24.com works and how to contribute.

Questions Please visit our forum to ask questions and to get answers.

iPhone and iPad Download Flightradar24 to your iPhone or iPad in App Store
Flightradar24 Free or Flightradar24 Pro

Twitter Follow us on Twitter

Follow us on Facebook

'; $('rightcontentdivinnner').innerHTML = introtext + '
' + '
' + '

' + //'

' + //'

'+lastUpdate+'

' + '

' + ' Users online: ≈' + userCount + '

' + '
' + '
' + WORD_maplinktitle + ':
' + '' + '
' + '
' + bannerImg; clockinterval = setInterval( updatetimed , 1000); // times this } function markPlane(){ alert('test'); } // ----------- // draws markers (planes, text, other) // ----------- function drawMarkers(clear){ changeUpdateIntervalOnZoomLevel(); // changes the updateinterval, this could be elsewhere if more convinient glFetchTimer = new Date().valueOf();; // on new fetch, this is reset, is used in setTimeout of this function // to fetch only markers within viewport var bounds = map.getBounds(); // roundabit() rounds to 3 decimals var swLat = (roundABit(bounds.getSouthWest().lat() )); var swLng = (roundABit(bounds.getSouthWest().lng() )); var neLat = roundABit(bounds.getNorthEast().lat() ); var neLng = roundABit(bounds.getNorthEast().lng() ); var boundsStr = (swLat + ',' + swLng + ',' + neLat + ',' + neLng); updateTime(); // only the clock.. var markers; //var tIme = new Date().getTime(); var boundVar = "&bounds="+boundsStr; boundVar = ""; // filepath, secure for cache with time. (planes). // var url = "data_static.xml?" + new Date().getTime(); // var url = "_xml/plane_data3.php?" + tIme + "&all=0" + boundVar; var d = new Date(); var dtime = (d.getHours() + ':' + d.getMinutes()); var url = "_xml/plane_data3.php?time=" + dtime ; // MARKERS AND TEXT ITERATION GDownloadUrl(url, function(data, responseCode) { var xml = GXml.parse(data); if(responseCode != 200) { return false;} var markers = xml.documentElement.getElementsByTagName("marker"); map.checkResize(); // map is wrong size otherwise, and dont show all markers if(markers.length < 1 || markers.length == 0 || markers.length == null ) { return false;}; // if no markers in ajax response, dont run function global_totalNodesInLastFetch = 0; global_totalNodesInLastFetch = markers.length; // clears markers, before adding new if(clear){ clearMarkersInOverlayArr(callsignOverlayTracker, 1); // clears all, then adds new clearMarkersInOverlayArrMd(overlayTracker2,1); clearListenersInOverlayArr(overlayTrackerEventhandlers, 1); } // var shouldBeInOverlayArray2Array = new Array(); // keeps track of the markers that should be on map, and so on rdrArray = []; // loop planes and (and the info div) for (var i = 0; i < markers.length; i++) { // gets the history tag content (all content is in this tag to save xml space) var history = markers[i].getAttribute("history"); // split the history tag, to obtain the latest tag, 1 is latest 0 not existant... (xml file fault) allPlaneNodes = history.split("newpoly"); // split data latestPlaneData = allPlaneNodes[1]; // split to data var pData = splitHistoryString(latestPlaneData); // START FILTERS ***** // altitude if( gup('heightmaxunit')=='m'){ var fixedAltMax = 3.2808399 * parseInt(gup('heightmax') ); }else{ var fixedAltMax = gup('heightmax'); }; if( gup('heightminunit')=='m'){ var fixedAltMin = 3.2808399 * parseInt(gup('heightmin') ); }else{ var fixedAltMin = gup('heightmin'); }; if( ( gup('heightmax')=="") || ( parseInt(pData.alt) <= fixedAltMax ) ) { var f1 = true; }else{ var f1 = false; }; if( ( gup('heightmin')=="") || ( parseInt(pData.alt) >= fixedAltMin ) ) { var f2 = true; }else{ var f2 = false; }; // speed switch(gup('speedmaxunit')){ case "kmph" : var fixedSpdMax = parseInt(gup('speedmax')) / 1.852; break; case "mph" : var fixedSpdMax = parseInt(gup('speedmax')) / 1.150779; break; default: var fixedSpdMax = parseInt(gup('speedmax')); } switch(gup('speedminunit')){ case "kmph" : var fixedSpdMin = (parseInt(gup('speedmin'))) / 1.852; break; case "mph" : var fixedSpdMin = (parseInt(gup('speedmin'))) / 1.150779; break; default: var fixedSpdMin = parseInt(gup('speedmin')); } if( ( gup('speedmax')=="") || ( parseInt(pData.spd) <= fixedSpdMax.round() ) ) { var f3 = true; }else{ var f3 = false; }; if( ( gup('speedmin')=="") || ( parseInt(pData.spd) >= fixedSpdMin.round() ) ) { var f4 = true; }else{ var f4 = false; }; // hex etc var f5 = filterOnCallEtc(pData); // bool, in function to make more readable, returns false if not "hit" // radar if( ( gup('radarname')=='' ) || ( gup('radarname') == pData.rdr) ) { var f6 = true; }else{ var f6 = false; }; // END FILTERS ***** var point = new GLatLng(pData.lat,pData.lng); var html = ""; // bubble html var label = ""; // dont add if plane is outside map bounds var boundsz = map.getBounds(); if ( (boundsz.contains(point) == true ) && f1 && f2 && f3 && f4 && f5 && f6){ if(infotext==1){ addACustomMarker(point, pData.callsign, '' ); } var marker = createMarker(point,label,html,pData.hdg,pData.callsign,pData.lat,pData.lng,thedata.spd, pData.hex,pData.type, pData.ts, pData.reg, pData.alt, pData.rdr, pData.squawk); // creates marker } // end bounds check // if plane is shown in info if(currentlyPlaneInfoShownInWinodowHex==pData.hex){ updateInfowinParams(pData.hdg, pData.lat,pData.lng,thedata.spd,pData.alt,pData.rdr) } rdrArray[i] = pData.rdr; // array used in filter } // end of for }); // ends GDownloadUrl } function filterOnCallEtc(theData){ var fType = gup('airplfiltype'); var fFil = gup('airplfil'); if(fFil!=""){ // do filter switch(fType){ case 'hex' : if((theData.hex.toLowerCase()).startsWith(fFil.toLowerCase())){return true;}else{return false;} case 'callsign' : if((theData.callsign.toLowerCase()).startsWith(fFil.toLowerCase())){return true;}else{return false;} //case 'reg' : if((theData.reg.toLowerCase()).startsWith(fFil.toLowerCase())){return true;}else{return false;} } }else{ return true; } } /* * just updates the infowin on plane at planeupdate (redraw) if the data and plane is present * */ function updateInfowinParams( hdg, lat, lng, spd, alt, rdr){ if($('planeinfoul')!=null){ // preventing bug? mayhap var kmph = Math.round((spd*1.852*1)/1); var mph = Math.round(spd*1.15077945); var spdx = spd + ' knots
(' + kmph + ' km/h / ' + mph + ' mph)
' ; $('info_lat').innerHTML = lat; $('info_lon').innerHTML = lng; $('info_alt').innerHTML = alt; $('info_spd').innerHTML = spdx; $('info_track').innerHTML = hdg; $('info_rdr').innerHTML = rdr; $('info_meters').innerHTML = Math.round((alt*0.3048*1)/1); new Effect.Highlight('info_lat', { startcolor: '#ffff99', endcolor: '#ffffff' }); new Effect.Highlight('info_lon', { startcolor: '#ffff99', endcolor: '#ffffff' }); new Effect.Highlight('info_alt', { startcolor: '#ffff99', endcolor: '#ffffff' }); new Effect.Highlight('info_spd', { startcolor: '#ffff99', endcolor: '#ffffff' }); new Effect.Highlight('info_track', { startcolor: '#ffff99', endcolor: '#ffffff' }); new Effect.Highlight('info_rdr', { startcolor: '#ffff99', endcolor: '#ffffff' }); new Effect.Highlight('info_meters', { startcolor: '#ffff99', endcolor: '#ffffff' }); } } //----------- //remove the markers in "arr" from the map //better than removing all overlays, since this makes it possible to save some items, like airports //----------- function clearListenersInOverlayArr(arr, emptyTheArr){ var beforeRemove = arr.length; //console.log(beforeRemove); for (var index = 0; index < arr.length; ++index) { var item = arr[index]; GEvent.removeListener(item); } // if we want to empty the arr, (as with airplane markers) if(emptyTheArr==1){ // arr = []; arr.length = 0; } // $('debug').innerHTML = 'after remove: ' + arr.length + '
beforeRemove: ' + beforeRemove + '
linesoverlay: ' + lineOverlayTracker.length; } // ----------- // remove the markers in "arr" from the map // better than removing all overlays, since this makes it possible to save some items, like airports // ----------- function clearMarkersInOverlayArr(arr, emptyTheArr){ var beforeRemove = arr.length; for (var index = 0; index < arr.length; ++index) { var item = arr[index]; map.removeOverlay(item); } // if we want to empty the arr, (as with airplane markers) if(emptyTheArr==1){ // arr = []; arr.length = 0; } // $('debug').innerHTML = 'after remove: ' + arr.length + '
beforeRemove: ' + beforeRemove + '
linesoverlay: ' + lineOverlayTracker.length; } //----------- //remove the markers in "arr" from the map //better than removing all overlays, since this makes it possible to save some items, like airports //----------- function clearMarkersInOverlayArrMd(arr, emptyTheArr){ var beforeRemove = arr.length; for (var index = 0; index < arr.length; ++index) { var item = arr[index]; map.removeOverlay(item[0]); } // if we want to empty the arr, (as with airplane markers) if(emptyTheArr==1){ // arr = []; arr.length = 0; } // $('debug').innerHTML = 'after remove: ' + arr.length + '
beforeRemove: ' + beforeRemove + '
linesoverlay: ' + lineOverlayTracker.length; } // ----------- // saves overlay in global array, to use for removal // ----------- function registerOverlay(overlay, array){ return array.push(overlay); } // ----------- // takes array of markers // adds them to map // -> for instace if static markers has been removed, and should be added again from present array // ----------- function onlyAddMarkersToMap(markerArray){ for (var i = 0; i < markerArray.length; i++) { map.addOverlay(markerArray[i]); } } // ----------- // returns url parameter // ----------- function gup( 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 results[1]; } } // ----------- // replace chars // ----------- function replaceOneChar(s,c,n){ s = String(s); var re = new RegExp('^(.{'+ --n +'}).(.*)$',''); return s.replace(re,'$1'+c+'$2'); }; /** * builds a copy of current url, for reload/redirect * @return */ function buildUrl(languageCode){ var urladd = ""; if(dev!=""){urladd = urladd + "&dev="+dev;}; if(all!=""){urladd = urladd + "&all="+all;}; if(showmenu!=""){urladd = urladd + "&showmenu="+showmenu;}; if(showad!=""){urladd = urladd + "&showad="+showad;}; // if(language!="" && languageCode==""){urladd = urladd + "&language="+language;}; //if(languageCode!=""){urladd = urladd + "&language="+languageCode;} if(gad!=""){urladd = urladd + "&gad="+gad;} if(blackinfo!=""){urladd = urladd + "&blackinfo="+blackinfo;} return "http://www.flightradar24.com/?" + urladd; } function changeLanguage(lng){ window.location = buildUrl(lng); } var resetFilters = function(){ window.location = "http://www.flightradar24.com/"; } function redirect(url){ window.location = url; } // ----------- // handles reload // ----------- function reload(){ /* //gets map precent center bounds = map.getCenter(); zoom = map.getZoom(); // to nice values latitude = bounds.lat(); longitude = bounds.lng(); latStr = replaceOneChar(latitude,'-',3) ; lngStr = replaceOneChar(longitude,'-',3) ; */ // add variables from current state window.location = buildUrl(); } // ----------- // stripps chars // ----------- function stringFilter(s, words) { filteredValues = words; // Characters stripped out var i; var returnString = ""; for (i = 0; i < s.length; i++) { // Search through string and append to unfiltered values to returnString. var c = s.charAt(i); if (filteredValues.indexOf(c) == -1) returnString += c; } return returnString; } // ----------- // adds custom markers to map // used to show callsign // ----------- function addACustomMarker(latlng, infoText, img){ // create offset here, not to cover plane //var latlng = new GLatLng(lat, lng); var icon = new GIcon(); // icon.image = 'http://gmaps-samples.googlecode.com/svn/trunk/markers/circular/greencirclemarker.png'; icon.image = img; icon.iconSize = new GSize(32, 32); icon.iconAnchor = new GPoint(16, 16); icon.infoWindowAnchor = new GPoint(25, 15); opts = { "icon": icon, "clickable": false, "title": infoText, "labelText": infoText, "labelOffset": new GSize(5, -20) }; var marker = new LabeledMarker(latlng, opts); /* GEvent.addListener(marker, "click", function() { // marker.openInfoWindowHtml("I'm a Labeled Marker!"); }); */ map.addOverlay(marker); // adds to map registerOverlay(marker, callsignOverlayTracker); // adds to overlayarray (for removal usage) } // ----------- // shows the present position in the urlfield // ----------- function showPresentPosition(){ /* * * m : - * d : . * * */ // create variables retrieved from map data var blat = String(map.getCenter().lat()); var blng = String(map.getCenter().lng()); // blng = blng.replace('.','d') ; // blat = blat.replace('.','d') ; blng = blng.replace('-','m') ; blat = blat.replace('-','m') ; blat = blat.split("."); blng = blng.split("."); blat = blat[0]+'d'+blat[1].truncate(2, ''); blng = blng[0]+'d'+blng[1].truncate(2, ''); // create variebles from current url var heightMax = gup('heightmax'); var heightMin = gup('heightmin'); var heightMinunit = gup('heightminunit'); var heightMaxunit = gup('heightmaxunit'); var speedMax = gup('speedmax'); var speedMin = gup('speedmin'); var speedMinunit = gup('speedminunit'); var speedMaxunit = gup('speedmaxunit'); var airplfil = gup('airplfil'); var airplfiltype = gup('airplfiltype'); var fa = ""; if( IsNumeric(heightMin) && heightMin != "" ){ var urlHeightMin = '&heightmin='+heightMin; var urlheightMinunit = '&heightminunit='+heightMinunit; fa = '&fa=1'; }else{ var urlHeightMin = ""; var urlheightMinunit = ""; } if( IsNumeric(heightMax) && heightMax != "" ){ var urlHeightMax = '&heightmax='+heightMax; var urlheightMaxunit = '&heightmaxunit='+heightMaxunit; fa = '&fa=1'; }else{ var urlHeightMax = ""; var urlheightMaxunit = ""; } if( IsNumeric(speedMin) && speedMin != "" ){ var urlspeedMin = '&speedmin='+speedMin; var urlspeedMinunit = '&speedminunit='+speedMinunit; fa = '&fa=1'; }else{ var urlspeedMin = ""; var urlspeedMinunit = ""; } if( IsNumeric(speedMax) && speedMax != "" ){ var urlspeedMax = '&speedmax='+speedMax; var urlspeedMaxunit = '&speedmaxunit='+speedMaxunit; fa = '&fa=1'; }else{ var urlspeedMax = ""; var urlspeedMaxunit = ""; } // radarname var radarname = gup('radarname'); if( radarname != "" ){ var radarnameUrl = '&radarname='+radarname; }else{ var radarnameUrl = ""; } // end radarname var airplfil = gup('airplfil'); var airplfiltype = gup('airplfiltype'); //presentUrl+= "airplfil"=SAS&"airplfiltype"=callsign; if( airplfil != "" ){ var airplfilUrl = '&airplfil='+airplfil; var airplfiltypeUrl = '&airplfiltype='+airplfiltype; fa = '&fa=1'; }else{ var airplfilUrl = ""; var airplfiltypeUrl = ""; } var presentUrl = "http://www.flightradar24.com/?lat=" + blat + "&lng=" + blng + "&zoom=" + map.getZoom(); presentUrl+= urlHeightMin+urlheightMinunit+urlHeightMax+urlheightMaxunit; presentUrl+= urlspeedMin+urlspeedMinunit+urlspeedMax+urlspeedMaxunit; presentUrl+= airplfilUrl + airplfiltypeUrl; presentUrl+= fa; presentUrl+= radarnameUrl; if($("tring") != null ){ $("tring").value = presentUrl; }; } //----------- //adds airport overlays, dosnt register them to overlay array //----------- function addRadars(){ // conditional add of airport data (returned in xml file) // get airport xml var airpurl = "/_xml/radars_xml.php?" + new Date().getTime(); // readfile GDownloadUrl(airpurl, function(airpdata, responseCode) { var airpxml = GXml.parse(airpdata); // parse xml var aMarkers = airpxml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < aMarkers.length; i++) { // get data on each node var name = aMarkers[i].getAttribute("n"); // var airportCity = aMarkers[i].getAttribute("city"); // var urltoflygresor = aMarkers[i].getAttribute("urltoflygresor"); // var airportIata = aMarkers[i].getAttribute("iata"); // var airportIcao = aMarkers[i].getAttribute("icao"); // var airportFact = aMarkers[i].getAttribute("fact"); var lat = aMarkers[i].getAttribute("x"); var lng = aMarkers[i].getAttribute("y"); var rad = aMarkers[i].getAttribute("r"); //airportFact = airportFact + '

' + WORD_search_flight_to + " " + airportName + ' '; //airportFact = airportFact + '
' + WORD_search_flight_from + " " + airportName + " " + '

'; // add node data to array, in function since it bugged otherwise addRadarMarker(name, lat, lng, rad); }; } ); return 1; }; // ----------- // adds airport overlays, dosnt register them to overlay array // ----------- function addAirports(){ // conditional add of airport data (returned in xml file) // get airport xml var airpurl = "/_xml/airports_xml.php?" + new Date().getTime(); // readfile GDownloadUrl(airpurl, function(airpdata, responseCode) { var airpxml = GXml.parse(airpdata); // parse xml var aMarkers = airpxml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < aMarkers.length; i++) { // get data on each node var airportName = aMarkers[i].getAttribute("name"); var airportCity = aMarkers[i].getAttribute("city"); var urltoflygresor = aMarkers[i].getAttribute("urltoflygresor"); var airportIata = aMarkers[i].getAttribute("iata"); var airportIcao = aMarkers[i].getAttribute("icao"); var airportFact = aMarkers[i].getAttribute("fact"); var airportLon = aMarkers[i].getAttribute("lon"); var airportLat = aMarkers[i].getAttribute("lat"); airportFact = airportFact + '

' + WORD_search_flight_to + " " + airportName + ' '; airportFact = airportFact + '
' + WORD_search_flight_from + " " + airportName + " " + '

'; // add node data to map, in function since it bugged otherwise addAirportMarker(airportName, airportCity, airportIata, airportIcao, airportFact, airportLon, airportLat); }; } ); return 1; }; // ----------- // creates the cookie for airport... timed function // ----------- function airportTimedCookieAdd(){ onlyAddMarkersToMap(airportOverlayTracker); }; /** * * @return */ function adsense(){ /* var publisherID = 'ca-pub-9249909244961130'; var adsManagerOptions = { maxAdsOnMap : 2, style: 'adunit', // The channel field is optional - replace this field with a channel number // of your own for Google AdSense tracking channel: '6504835281' }; adsManager = new GAdsManager(map, publisherID, adsManagerOptions); adsManager.enable(); */ } /** * * @param url * @return */ function fixUrl(url){ url = url.replace('d','.'); url = url.replace('m','-'); return url; } /** * */ function generatePlaneMarkers(oReq, toArray){ // eval data var evaledJson = oReq.responseText.evalJSON(true); for (var index = 0, len = evaledJson.length; index < len; ++index) { var item = flights[index]; // a flight //console.log(item); } /* var flights = evaledJson.flights; // console.log(flights.length); // Creates tablerows // loops all flights in the evaled json array for (var index = 0, len = flights.length; index < len; ++index) { var item = flights[index]; // a flight } */ // updateUserDatabaseEntry(); // updates amount of users db and page // to fetch only markers within viewport /* var bounds = map.getBounds(); var boundsStr = bounds.toString() ; updateTime(); // only the clock.. var markers; if(all==1){ var url = "_xml/plane_data3.php?" + new Date().getTime() + "&all=1&c=" + "&bounds="+boundsStr; }else{ // filepath, secure for cache with time. (planes). //var url = "data_static.xml?" + new Date().getTime(); var url = "_xml/plane_data3.php?" + new Date().getTime() + "&all=0&c=" + "&bounds="+boundsStr; } // MARKERS AND TEXT ITERATION GDownloadUrl(url, function(data, responseCode) { var xml = GXml.parse(data); // clears markers, before adding new if(clear){ //clearMarkersInOverlayArr(addedPointsToMapLastUpdateThatIsToBeCleared, 1); // removes from overlaysarray, iterates it and clears //console.log(addedPointsToMapLastUpdateThatIsToBeCleared); //addedPointsToMapLastUpdateThatIsToBeCleared = ""; clearMarkersInOverlayArr(overlayTracker, 1); clearMarkersInOverlayArr(overlayTracker2, 1); //map.clearOverlays(); //var rect = new Rectangle( new GLatLngBounds( new GLatLng(70, -30), new GLatLng(37, 44)) ); //map.addOverlay(rect); //rect.div_.style.opacity = opacity; } var markers = xml.documentElement.getElementsByTagName("marker"); map.checkResize(); // map is wrong size otherwise, dosnt show all markers // this adds the infotext (supposedly beneth) if(infotext==1){ // loop plane marker-text for (var i = 0; i < markers.length; i++) { // alert("sdas"); // gets the history tag content (all content is in this tag to save space) var history = markers[i].getAttribute("history"); // split the history tag, to obtain the latest tag, 1 is latest 0 not existant... (xml file fault) allPlaneNodes = history.split("newpoly"); // split data // planedata (only the latest) latestPlaneData = allPlaneNodes[1]; // split to data var pData = splitHistoryString(latestPlaneData); var point = new GLatLng(pData.lat,pData.lng); // dont add if plane is outside map bounds var boundsz = map.getBounds(); if (boundsz.contains(point) == true){ // magic, only add to map if it is whithin bounds addACustomMarker(point, pData.callsign, '' ); } } // end for } // end if // var shouldBeInOverlayArray2Array = new Array(); // keeps track of the markers that should be on map, and so on // loop planes and (and the info div) for (var i = 0; i < markers.length; i++) { // gets the history tag content (all content is in this tag to save space) var history = markers[i].getAttribute("history"); // split the history tag, to obtain the latest tag, 1 is latest 0 not existant... (xml file fault) allPlaneNodes = history.split("newpoly"); // split data latestPlaneData = allPlaneNodes[1]; // split to data var pData = splitHistoryString(latestPlaneData); var point = new GLatLng(pData.lat,pData.lng); var html = ""; // bubble html var label = ""; // dont add if plane is outside map bounds var boundsz = map.getBounds(); if (boundsz.contains(point) == true){ // magic, only add to map if it is whithin bounds //console.log(checkOverlaytracker2(pData.hdg, pData.lat, pData.lng)); // only add to map if it is not already present var marker = createMarker(point,label,html,pData.hdg,pData.callsign,pData.lat,pData.lng,thedata.spd, pData.hex); // creates marker var innerArray = new Array(); innerArray[0] = point; innerArray[1] = label; innerArray[2] = html; innerArray[4] = pData.hdg; innerArray[5] = pData.callsign; innerArray[6] = pData.lat; innerArray[7] = pData.lng; innerArray[8] = thedata.spd; innerArray[9] = pData.hex; // add line here with the correct heading, using heading funktion, if planning to fix the redrawing issue att klick on plane innerArray[99] = marker; // marker innerArray[100] = 0; // active-state overlayTracker2.push(innerArray); } // end bounds check } // end of for // save present lat, lng, degr, to next reload //addedPointsToMapLastUpdate = shouldBeInOverlayArray2Array; //console.log(overlayTracker2.length); }); // ends GDownloadUrl //console.log(overlayTracker2.length ); //trackPlaneAmount(); */ } /** * used in settimeout * @return */ function drawMarkersWrapped(){ if( globalTimer() ){ drawMarkers(1); }; // first check global timer } // ----------- // MAIN function ! // initiate.. onload // ----------- function init(){ // var rrr = 'http://www.flightradar24.com/_json/plane_data.php?1263819659206&all=0&c=7d5a28107e5675d9e3f4a7ae1386c926&bounds=%28%2833.797408767572485,%20-30.585937499999996%29,%20%2863.74363097533544,%2086.30859375%29%29'; // genericJsonRetriever(url2, paintRadarPositions); // is browser capable? if (GBrowserIsCompatible()) { addAirports(); // adds airports to airport array, dosnt add to map here //addRadars(); // to array appendCloseMenuBtn(); /* // radiobutton for reload time has value if(get_cookie('reloadtime') != ""){ // get value, and assign to global variable loadingInterval = get_cookie('reloadtime'); } */ // radiobutton for planesize if(get_cookie('planesize') != ""){ thePlaneSize = get_cookie('planesize'); } // radiobutton for redrawal time has value if(get_cookie('drawtime') != ""){ // get value, and assign to global variable // drawingInterval = get_cookie('drawtime'); // drawingInterval = 40000; } // handle cookie values/adjustments var CValCallsign = get_cookie('callsign2'); // the infotext on map (callsign) from cookie if(CValCallsign == "on" ) { // is 1 in cookie, user choice .... infotext = 1; //drawMarkers(1); } //alert(CValCallsign); if(CValCallsign == "" || CValCallsign == "0" ){ infotext = 0; cookieStoreData("callsign2", "off", 90); } if(CValCallsign == "off"){ infotext = 0; } addFistpageInfoToFirtstTab(); // add firstpage info.. inserterts html and starts timer // redraw markers in x sec theSetReDrawInterval = setInterval("drawMarkersWrapped(1)", drawingInterval); // drawing inteval // reload page itself in x sec, and adds returning id to variable (that is used later) //theSetReLoadInterval = setInterval("reload()", loadingInterval); // page reload //theSetReLoadInterval = setInterval("", loadingInterval); // page reload theSetReLoadInterval = setTimeout("turnOffMap('Map has suspended, to continue viewing, reload page...')", loadingInterval); // page reload //theSetReLoadInterval = setInterval("", loadingInterval); // page reload // instantiate the mapclass map = new GMap2($("map")); var mapControl = new GMapTypeControl(); // call methods of mapobject // map.addControl(new GLargeMapControl()); map.setMapType(G_PHYSICAL_MAP); map.addMapType(G_PHYSICAL_MAP); map.setUIToDefault(); map.enableRotation(); // where appliable //map.addControl(mapControl); //drawMarkers(0); // draw planes first time GEvent.addListener(map, "moveend", function(marker, point) { // store presents to cookie cookieStoreData("lat", map.getCenter().lat(), 90); cookieStoreData("lng", map.getCenter().lng(), 90); cookieStoreData("zoom", map.getZoom() , 90); // console.log(map.getZoom()); // reload // get some values var swLat = map.getCenter().lat(); var swLng = map.getCenter().lng(); //var neLat = map.getBounds().getNorthEast().lat(); //var neLng = map.getBounds().getNorthEast().lng(); var v1 = validateLimit(savedSwLat, swLat, 0.2); var v2 = validateLimit(savedSwLng, swLng, 0.2); // var v3 = validateLimit(savedNeLat, neLat, 0.5); // var v4 = validateLimit(savedNeLng, neLng, 0.5); // redraw ifs, also draws at first load if( Number(map.getZoom()) < Number(currentZoomLevel) || ( v1==true || v2==true //|| v3==true || v4==true // the diff will be greater on first run to ) ){ drawMarkers(1); //if( globalTimer() ){ drawMarkers(1); }; // first check global timer } showPresentPosition(); // updates the urlfield // saves vals used in next move... savedSwLat = swLat; savedSwLng = swLng; //savedNeLat = neLat; //savedNeLng = neLng; currentZoomLevel = map.getZoom(); }); /* GEvent.addListener( map , "maptypechanged", function() { //var mtype = map.getCurrentMapType() ; //console.log(mtype); //cookieStoreData('maptype', , 90); }); */ // if all, set another center if(all==1){ mapLat = 55.5; }; // normalcase, default and cookie if(get_cookie('lat')!=""){ // cookievals var mapLat = get_cookie('lat'); var mapLng = get_cookie('lng'); var mapZoom = get_cookie('zoom'); }else{ // defaults mapLat = initLat; mapLng = initLng; mapZoom = initZoo; } // normalcase, default and cookie if(get_cookie('maptype')!=""){ // cookievals var mapType = get_cookie('maptype'); map.setMapType(mapType); }else{ // defaults map.setMapType(G_PHYSICAL_MAP); } // not normal, coming with url variables if(gup("lat") != ""){ latStr = fixUrl(gup("lat")); mapLat = parseFloat(latStr); } if(gup("lng") != ""){ lngStr = fixUrl(gup("lng")); mapLng = parseFloat(lngStr); } if(gup("zoom") != ""){ var mapZoom = parseInt(gup("zoom")); } // set map params up var point = new GLatLng(mapLat, mapLng); map.setCenter(point, parseInt(mapZoom)); //alert(CValCallsign); var CValLinkBanners = get_cookie('linkbanners'); var CValPresentUrl = get_cookie('presenturl'); var CValAirports = get_cookie('airports2'); var CValRightCol = get_cookie('showrightcol2'); // normalcase, default and cookie if(CValRightCol == "" || CValRightCol == " " || CValRightCol == "null"){ // not set // default is to show, so we only have to add the cookie data to reflect defaultmode cookieStoreData("showrightcol2", "on", 90); }else{ // set showrightcol(get_cookie('showrightcol2')); } if(CValPresentUrl == "off"){ // is 0 in cookie, user choice .... $('urlinput2').style.display = "none"; } //alert(CValAirports); if(CValAirports == "on" || CValAirports == "" || CValAirports == "0" ){ setTimeout("airportTimedCookieAdd()", 2000); cookieStoreData("airports2", "on", 90); } if(get_cookie('radars') == "on"){ setTimeout(function x(){ onlyAddMarkersToMap(radarOverlayTracker); //console.log(radarOverlayTracker); // console.log(radarOverlayTracker.length); }, 2000); // get value, and assign to global variable //onlyAddMarkersToMap(radarOverlayTracker); } if(get_cookie('weatherlayer') == "on"){ setTimeout(function x(){ weather(1, setupWeatherMarkers, woeids); }, 3000); } fullsizeIt('map'); // keeps map full maximizeHeight('rightcontentdivinnner', 190); // keeps adjustments rightcol max height opac(); // create opacity overlay & control map.disableScrollWheelZoom(); // might work, probably not showPresentPosition(); // set up marker mouseover tooltip div var tooltip = document.createElement("div"); document.getElementById("map").appendChild(tooltip); tooltip.style.visibility="hidden"; trackIdle(); ifUrlFilterActiveMarkThatTab(); /* var ashCloud1 = new Layer(); ashCloud1.url = 'http://www.flightradar24.com/_json/ashoverlay.json.php'; ashCloud1.fetch(); */ if(gup('ash1')=="1"){ genericJsonRetriever('http://www.flightradar24.com/_json/ashoverlay2.json.php', addAsh1, "", ""); } // not capable }else { alert("Sorry, the Google Maps API is not compatible with this browser"); } }; function centerMap(lat, lng, zlev){ map.setCenter((new GLatLng( (lat), (lng))),zlev ) //map.panTo((new GLatLng( (lat), (lng))) ); //map.setZoom(zlev); } var addAsh1 = function(oReq){ var evaledJson = oReq.responseText.evalJSON(true); var dpEncodeToGPolygonArr = []; var i = 0; for (var key in evaledJson) { if (evaledJson.hasOwnProperty(key)) { // console.log(key + " -> " + evaledJson[key]); var xxx = new GLatLng(evaledJson[key][0], evaledJson[key][1]); dpEncodeToGPolygonArr[i] = xxx; i++; // map.addOverlay(new GMarker(xxx)); } } var polylineEncoder = new PolylineEncoder(); var polyline = polylineEncoder.dpEncodeToGPolyline(dpEncodeToGPolygonArr); map.addOverlay(polyline); /* */ /* console.log(trailArr); trailArr.each(function(item) { // Your code working on item here... console.log("s"); }); */ } function importanceOrder (marker,b) { return GOverlay.getZIndex(marker.getPoint().lat()) + marker.importance*1000000; } function isset(variable){ if (variable == undefined){return false;}else{return true;}; } function weather(lvl, respFunc, woeids){ if(!isset(lvl)){var lvl = "1";} if(!isset(respFunc)){var respFunc = setupWeatherMarkers ;} //if(!isset(woeids)){var woeids = "615702,906057,12587218,887274,910100,12587254,12587260,909106,887251,884552,897794,892081,899981,898091,889077,885131,904350,900809,884983,904179";}; var url = 'http://www.flightradar24.com/weather/getdata.json.php?lvl='+lvl+'&woeids='+woeids; // var url = "http://www.flightradar24.com/_json/planeInfoAndTrail_nocache.php?1273751388378&callsign=CPA257&hex=78022B"; new Ajax.Request(url, { method:'get', requestHeaders: { Accept: 'application/json'}, onSuccess: setupWeatherMarkers }); } function addWeatherClickListener(marker, woeid){ GEvent.addListener(marker, "click", function() { // map.addOverlay(new GMarker(point)); var url = 'http://www.flightradar24.com/weather/getdata.json.php?woeids='+woeid+'&lvl=2'; new Ajax.Request(url, { method:'get', requestHeaders: { Accept: 'application/json'}, onSuccess: function (transport){ var evaledJson = transport.responseText.evalJSON(true); var easyData = '
'+evaledJson[woeid][0].city + '

'; easyData+= (evaledJson[woeid][1].wconddescription); easyData+= '
Windchill: '+evaledJson[woeid][1].windchill + '°C'; easyData+= '
Wind direction: '+evaledJson[woeid][1].winddirection + '°'; easyData+= '
Wind speed: '+evaledJson[woeid][1].windspeed + 'km/h'; easyData+= '
Air humidity: '+evaledJson[woeid][1].airhumidity + '%'; easyData+= '
Air visibility (sight): '+evaledJson[woeid][1].airvisibility*100 + 'm'; easyData+= '
Air pressure: '+evaledJson[woeid][1].airpressure + 'mb'; // easyData+= '
Barometric change: '+evaledJson[woeid][1].airrising; easyData+= '
Sunrise: '+evaledJson[woeid][1].astrsunrise; easyData+= '
Sunset: '+evaledJson[woeid][1].astrsunset; //marker.openInfoWindowHtml("test"); $('rightcontentdivinnner').update(easyData); } }); }); GEvent.addListener(marker, "mouseover", function() { // console.log("test"); //marker.setImage(planeImageActive); }); marker = ""; } function setupWeatherMarkers(transport){ var evaledJson = transport.responseText.evalJSON(true); var weatherDataArrayx = new Array(); var i = 0; var pointt = ""; var marker = ""; for (var key in evaledJson) { if (evaledJson.hasOwnProperty(key)) { // console.log(key + " -> " + evaledJson[key]); weatherDataArrayx = []; weatherDataArrayx[0] = evaledJson[key][0]['city']; weatherDataArrayx[1] = evaledJson[key][0]['country']; weatherDataArrayx[2] = evaledJson[key][0]['lat']; weatherDataArrayx[3] = evaledJson[key][0]['lng']; weatherDataArrayx[4] = evaledJson[key][0]['region']; weatherDataArrayx[5] = evaledJson[key][0]['wcondcode']; weatherDataArrayx[6] = evaledJson[key][0]['wconddate']; weatherDataArrayx[7] = evaledJson[key][0]['wcondtemp']; weatherDataArrayx[8] = evaledJson[key][0]['wcondtext']; weatherDataArrayx[9] = evaledJson[key][0]['woeid']; weatherDataArray[i] = weatherDataArrayx; i++; /* var pointx = new GLatLng(weatherDataArrayx[2], weatherDataArrayx[3]); //batch.push(new GMarker(point, { icon: icon })); map.addOverlay(new GMarker(pointx)); */ } } addWeatherMarkers(); } function addWeatherMarkers(){ var item = ""; weatherMarkersArray = []; //console.log(weatherDataArray); //weatherDataArray.each(function(item) { for (var key in weatherDataArray) { baseIcon = ""; baseIcon = new GIcon(); // baseIcon.shadow = "http://xwww.google.com/mapfiles/shadow50.png"; baseIcon.iconSize = new GSize(29, 29); //baseIcon.shadowSize = new GSize(37, 34); baseIcon.iconAnchor = new GPoint(14, 14); baseIcon.infoWindowAnchor = new GPoint(0, 0); baseIcon.image = "http://www.flightradar24.com/weather/weathericons/" + weatherDataArray[key][5] + ".png"; baseIcon.infoWindowAnchor = new GPoint(weatherDataArray[key][2], weatherDataArray[key][3]); // console.log(weatherDataArray[key][1]); var titleText = weatherDataArray[key][0] + ', ' + weatherDataArray[key][1] + '. ' +weatherDataArray[key][8] + '. ' + weatherDataArray[key][7] + '°c'; // Set up our GMarkerOptions object markerOptions = { icon:baseIcon, title:titleText, zIndexProcess:importanceOrder }; // var pointx = new ; var pointt = new GLatLng(weatherDataArray[key][2], weatherDataArray[key][3]); var marker = new GMarker(pointt, markerOptions); marker.importance = 5; // batch.push(new GMarker(point, { icon: icon })); var data = ""; addWeatherClickListener(marker, weatherDataArray[key][9]); map.addOverlay(marker); weatherMarkersArray[key] = marker; } } function removeWetherLayer(){ for (var key in weatherMarkersArray) { map.removeOverlay(weatherMarkersArray[key]); } } /** * obj */ function Weather(){ this.url = ""; this.h="" parseplanedata2 = function(oReq){ var evaledJson = oReq.responseText.evalJSON(true); var dpEncodeToGPolygonArr = []; for (var key in evaledJson) { if (evaledJson.hasOwnProperty(key)) { // console.log(key + " -> " + evaledJson[key]); var latlng = new GLatLng(evaledJson[key][0], evaledJson[key][1]); //map.addOverlay(new GMarker(latlng)); dpEncodeToGPolygonArr[key] = latlng; } } polylineEncoder = new PolylineEncoder(); polyline = polylineEncoder.dpEncodeToGPolygon(dpEncodeToGPolygonArr); /* */ /* console.log(trailArr); trailArr.each(function(item) { // Your code working on item here... console.log("s"); }); */ } this.fetch = function(h){ genericJsonRetriever(this.url, parseplanedata2, h, ""); } } function ifUrlFilterActiveMarkThatTab(){ if(gup('fa')=="1"){ //Effect.Pulsate('menu6', { pulses: 30, duration: 10 }); $('menu6').style.backgroundColor = "#f6f28d"; $('menu6').style.color = "#e31212"; //$('menu6').addClassName('yellowify'); //Effect.Highlight( 'menu6' , { startcolor: '#fff600', endcolor: '#ffffff' }); } } /** * compares values, if diff is bigger than limit, return true * @param val1 * @param val2 * @param limit * @return */ function validateLimit(val1, val2, limit){ var res = ( ( Math.abs( Math.abs(val1) - Math.abs(val2) ) ) > limit ) ? true : false; // console.log(res); return res; } function opac(){ var tilelayer = new GTileLayer(GCopyrightCollection(''), 5, 10); var mapopacity = get_cookie("mapopacity"); if(mapopacity == "" || mapopacity == "NULL"){mapopacity = defaultOpacity;}; tilelayer.opacity = mapopacity; // Default opacity value tilelayer.getTileUrl = function(tile,zoom) { return "http://static.flight24.com/_flightradar24/images/1x1000.png"; } tilelayer.isPng = function() { return true;}; // Transparency is active // Older version of IE (< 7.0) has either transparency or changeable opacity. Not both in the same time. tilelayer.getOpacity = function() { return this.opacity; } overlay = new GTileLayerOverlay( tilelayer ); map.addOverlay(overlay); map.addControl(new OpacityControl( overlay )); } function OpacityControl( overlay ) { this.overlay = overlay; } OpacityControl.prototype = new GControl(); // This function positions the slider to match the specified opacity OpacityControl.prototype.setSlider = function(pos) { var left = Math.round((58*pos)); this.slide.left = left; this.knob.style.left = left+"px"; this.knob.style.top = "0px"; // correction001 } // This function reads the slider and sets the overlay opacity level OpacityControl.prototype.setOpacity = function() { this.overlay.getTileLayer().opacity = this.slide.left/58; this.map.removeOverlay(this.overlay); this.map.addOverlay(this.overlay); cookieStoreData("mapopacity", this.slide.left/58, 90); } // This gets called by the API when addControl(new OpacityControl()) OpacityControl.prototype.initialize = function(map) { var that=this; this.map = map; // Is this MSIE, if so we need to use AlphaImageLoader var agent = navigator.userAgent.toLowerCase(); if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){this.ie = true} else {this.ie = false} // create the background graphic as a
containing an image var container = document.createElement("div"); container.style.width="70px"; container.style.height="21px"; // Handle transparent PNG files in MSIE if (this.ie) { var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://static.flight24.com/_flightradar24/images/opacity-slider.png', sizingMethod='crop');"; container.innerHTML = '
'; } else { container.innerHTML = '
'; } // create the knob as a GDraggableObject // Handle transparent PNG files in MSIE if (this.ie) { var loader = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://static.flight24.com/_flightradar24/images/opacity-slider.png', sizingMethod='crop');"; this.knob = document.createElement("div"); this.knob.style.height="21px"; this.knob.style.width="13px"; this.knob.style.overflow="hidden"; this.knob_img = document.createElement("div"); this.knob_img.style.height="21px"; this.knob_img.style.width="83px"; this.knob_img.style.filter=loader; this.knob_img.style.position="relative"; this.knob_img.style.left="-70px"; this.knob.appendChild(this.knob_img); } else { this.knob = document.createElement("div"); this.knob.style.height="21px"; this.knob.style.width="13px"; this.knob.style.backgroundImage="url(http://www.maptiler.org/img/opacity-slider.png)"; this.knob.style.backgroundPosition="-70px 0px"; } container.appendChild(this.knob); this.slide=new GDraggableObject(this.knob, {container:container}); this.slide.setDraggableCursor('pointer'); this.slide.setDraggingCursor('pointer'); this.container = container; // attach the control to the map map.getContainer().appendChild(container); // init slider this.setSlider( this.overlay.getTileLayer().opacity ); // Listen for the slider being moved and set the opacity GEvent.addListener(this.slide, "dragend", function() {that.setOpacity()}); //GEvent.addListener(this.container, "click", function( x, y ) { alert(x, y) }); return container; } // Set the default position for the control OpacityControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(301, 9)); } function reportError(){} /** * resises element to window height, minus bottom margin */ function maximizeHeight(id, bottomMargin){ //return false; x(); //Event.observe(window, 'resize', x { Event.observe(window, 'resize', function() { //console.log('test'); x(); }) function x(){ var viewport = document.viewport.getDimensions(); // Gets the viewport as an object literal var height = viewport.height; // Usable window height var height = height + document.viewport.getScrollOffsets().top ; $(id).style.height = height - bottomMargin + "px"; } } /** * SOME PROTOTYPE-D LISTENERS */ Event.observe(window, 'load', function() { // Event.observe('menu0', 'click', loadmenu ); //Event.observe('menu1', 'click', loadmenu ); Event.observe('menu2', 'click', loadmenu ); Event.observe('menu3', 'click', loadmenu ); Event.observe('menu4', 'click', loadmenu ); Event.observe('menu5', 'click', loadmenu ); Event.observe('menu6', 'click', loadmenu ); // menu observers Event.observe('gotobtn', 'click', popPanTo); // closebtn //Event.observe('expandCloseBtn1', 'click', expandCloseHeader); // expandbtn //Event.observe('stroke', 'click', expandCloseHeader); // expandPlus //Event.observe('expandPlus', 'click', expandCloseHeader); // window size change //Event.observe(window, "resize", handleResize); // //Event.observe('newhead' , "resize", handleResize); // move the time div? :P //new Draggable('timedDiv'); //new Draggable('infowindow-general'); }); /** * resises element to window size */ function fullsizeIt(id ){ x(); //Event.observe(window, 'resize', x { Event.observe(window, 'scroll', function() { x(); }) Event.observe(window, 'resize', function() { x(); }) function x(){ var viewport = document.viewport.getDimensions(); // Gets the viewport as an object literal var width = viewport.width; // Usable window width var height = viewport.height; // Usable window height var width = width + document.viewport.getScrollOffsets().left ; var height = height + document.viewport.getScrollOffsets().top ; $(id).style.height = height + "px"; $(id).style.width = width + "px"; } } function showrightcol(sh){ //console.log(sh); if(sh=="off"){ $('rightcontentdivmenu').hide(); $('rightcontentdivinnner').hide(); $('showclosebtn').removeClassName('agreenminus'); $('showclosebtn').addClassName('agreenplus'); cookieStoreData("showrightcol2", "off", 90); } if(sh=="on"){ $('rightcontentdivmenu').show(); $('rightcontentdivinnner').show(); $('showclosebtn').removeClassName('agreenplus'); $('showclosebtn').addClassName('agreenminus'); cookieStoreData("showrightcol2", "on", 90); } } /** * close close/hide menu html * @return */ function appendCloseMenuBtn(){ // insert html $('rightcontentdiv').insert({ top: '
'}); // observe Event.observe('showclosebtn', 'click', function(){ if($('rightcontentdivmenu').style.display != "none"){ // is visible, hide! showrightcol("off"); }else{ showrightcol("on"); } }); } /** * * @param opac * @param radious * @param lat * @param lng * @return */ function doDrawCircle(opac, radious, lat, lng){ //var lng = Number(lng) + Number(0.1); // adjust circle, to be in middle, strange behaviour... var container; var opacity = opac; var circle; var centerMarker; var circleUnits; var circleRadius; var zoom = 2; var centerPoint = new GLatLng(lat, lng); // var oUnitsMI = document.getElementById('unitsMI'); var oUnitsKM = "KM"; //var oRadius = radious; circleRadius = radious; circleUnits = 'KM'; if (circle) { //map.removeOverlay(circle); } if (centerMarker) { //map.setCenter(centerMarker.getLatLng()) } else { //centerMarker = new GMarker(map.getCenter(),{draggable:true}); //GEvent.addListener(centerMarker,'dragend',drawCircle) //map.addOverlay(centerMarker); } var center = map.getCenter(); var bounds = new GLatLngBounds(); var circlePoints = Array(); with (Math) { if (circleUnits == 'KM') { var d = circleRadius/6378.8; // radians } var lat1 = (PI/180)* lat; // radians var lng1 = (PI/180)* lng; // radians for (var a = 0 ; a < 361 ; a++ ) { var tc = (PI/180)*a; var y = asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc)); var dlng = atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(y)); var x = ((lng1-dlng+PI) % (2*PI)) - PI ; // MOD function var point = new GLatLng(parseFloat(y*(180/PI)),parseFloat(x*(180/PI))); circlePoints.push(point); bounds.extend(point); } if (d < 1.5678565720686044) { circle = new GPolygon(circlePoints, '#000000', 0, 1, '#000000', 0.2); } else { circle = new GPolygon(circlePoints, '#000000', 0, 1); } //map.addOverlay(circle); //map.setZoom(map.getBoundsZoomLevel(bounds)); } return circle; } /** * layer to pan to country */ function popPanTo(){ // alert("test"); middle2("pantoc"); Effect.Appear('pantoc', { duration: 0.1 }); // Event.observe('closeGeneralInfoLayer', 'click', function(event) { closeGeneralInfoLayer(); }); } function closepanto(){ Effect.Fade('pantoc', { duration: 0.2 }); } /** * shows the alertwindow * @param headline * @param message * @return */ function niceAlert(headline, message){ $('alerthead').innerHTML = '

' + headline + '

'; $('alertcontent').innerHTML = '

' + message + '

'; middle2("alertdiv"); Effect.Appear('alertdiv', { duration: 0.1 }); new Draggable('alertdiv', { }); // get enviroment params Event.observe('closebtn', 'click', function(event) { closeNiceAlertWin(); }); /* Event.observe(document, 'keypress', function(event){ if(event.keyCode == Event.KEY_TAB) { closeNiceAlertWin(); } }); */ } /** * closes the alertwindow * @return */ function closeNiceAlertWin(){ Effect.Fade('alertdiv', { duration: 0.2 }); } //--------- // //--------- function middle2(id){ // get enviroment params var vpHeight = document.viewport.getHeight(); var vpWidth = document.viewport.getWidth(); var alertWidth = $(id).getWidth(); var alertheight = $(id).getHeight(); // align correctly var lalign = ( (vpWidth/2)-(alertWidth/2) ) + document.viewport.getScrollOffsets().left + "px"; var talign = (vpHeight/2)-(alertheight/2) + document.viewport.getScrollOffsets().top + "px"; $(id).style.left = lalign; $(id).style.top = talign; } function chatWindowOpen(){ window.open("./chat/index.php", "Window1", "menubar=no,width=550,height=600,toolbar=no" ); }