var user = new L.FeatureGroup(); var geojsonLayer; var atcLayer; var polarLayer; var santaLayer; var notamLayer; waypoints = ''; //initialize the layer group for the aircrft markers layer_data = L.layerGroup(); // Show airports on map function airportPopup (feature, layer) { var output = ''; output += '
'; output += '
'; if (typeof feature.properties.image_thumb != 'undefined' && feature.properties.image_thumb != '') { output += ''; } output += '
'; output += '
'; output += '
'; output += '
'+feature.properties.name+'
'; output += '
'; output += '
'; output += '
'; output += ''+feature.properties.icao+''; output += '
'; output += '
'; output += '
'; output += '
'; output += '
'; output += '
'; output += 'City'; output += feature.properties.city; output += '
'; if (feature.properties.altitude != "" || feature.properties.altitude != 0) { output += '
'; output += 'Altitude'; output += Math.round(feature.properties.altitude*3,2809)+' feet - '+feature.properties.altitude+' m'; output += '
'; } output += '
'; output += 'Country'; output += feature.properties.country; output += '
'; if (feature.properties.homepage != "") { output += '
'; output += 'Links'; output += 'Homepage'; output += '
'; } output += '
'; output += ''; layer.bindPopup(output); }; function update_airportsLayer() { if (typeof airportsLayer != 'undefined') { if (map.hasLayer(airportsLayer) == true) { map.removeLayer(airportsLayer); } } if (map.getZoom() > 7) { var bbox = map.getBounds().toBBoxString(); airportsLayer = new L.GeoJSON.AJAX("/live-tracking-3d/airport-geojson.php?coord="+bbox,{ pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: feature.properties.icon, iconSize: [16, 18] //popupAnchor: [0, -28] }) }).on('click', function() { $(".showdetails").load("airport-data.php?"+Math.random()+"&airport_icao="+feature.properties.icao); }); } }).addTo(map); } }; $( document ).ready(function() { var zoom = map.getZoom(); map.on('moveend', function() { if (map.getZoom() > 7) { update_airportsLayer(); if ($("#airspace").hasClass("active")) { map.removeLayer(airspaceLayer); update_airspaceLayer(); } if ($("#waypoints").hasClass("active")) { map.removeLayer(waypointsLayer); update_waypointsLayer(); } } else { update_airportsLayer(); if ($("#airspace").hasClass("active")) { map.removeLayer(airspaceLayer); } if ($("#waypoints").hasClass("active")) { map.removeLayer(waypointsLayer); } } if ($("#notam").hasClass("active")) { map.removeLayer(notamLayer); update_notamLayer(); } }); map.on('zoomend', function() { if ((map.getZoom() > 7 && zoom < 7) || (map.getZoom() < 7 && zoom > 7)) { zoom = map.getZoom(); getLiveData(1); } }); //update_waypointsLayer(); update_airportsLayer(); function info_update (props) { $("#ibxaircraft").html('

Aircrafts detected

' + '' + props + ''); } $(".showdetails").on("click",".close",function(){ $(".showdetails").empty(); $("#aircraft_ident").attr('class',''); getLiveData(1); return false; }) //var sidebar = L.control.sidebar('sidebar').addTo(map); $("#aircraft_ident").attr('class',''); var MapTrack = getCookie('MapTrack'); if (MapTrack != '') { $("#aircraft_ident").attr('class',MapTrack); $(".showdetails").load("/live-tracking-3d/aircraft-data.php?"+Math.random()+"&flightaware_id="+MapTrack); delCookie('MapTrack'); } function getLiveData(click) { var bbox = map.getBounds().toBBoxString(); layer_data_p = L.layerGroup(); $.ajax({ dataType: "json", // url: "live/geojson?"+Math.random(), url: "/live-tracking-3d/live/geojson?"+Math.random()+"&coord="+bbox+"&history="+document.getElementById('aircraft_ident').className, success: function(data) { map.removeLayer(layer_data); layer_data = L.layerGroup(); var live_data = L.geoJson(data, { pointToLayer: function (feature, latLng) { var markerLabel = ""; var callsign = feature.properties.c; var departure_airport_code = feature.properties.dac; var arrival_airport_code = feature.properties.aac; var flightaware_id = feature.properties.fi; var aircraft_shadow = feature.properties.as; var squawk = feature.properties.sq; var altitude = feature.properties.a; var heading = feature.properties.h; var type = feature.properties.t; if (callsign != ""){ markerLabel += callsign; } if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; } info_update(feature.properties.fc); if (document.getElementById('aircraft_ident').className == callsign || document.getElementById('aircraft_ident').className == flightaware_id) { var iconURLpath = '/live-tracking-3d/getImages.php?color=FF0000&filename='+aircraft_shadow; var iconURLShadowpath = '/live-tracking-3d/getImages.php?color=8D93B9&filename='+aircraft_shadow; } else if ( squawk == "7700" || squawk == "7600" || squawk == "7500" ) { var iconURLpath = '/live-tracking-3d/getImages.php?color=FF8C00&filename='+aircraft_shadow; var iconURLShadowpath = '/live-tracking-3d/getImages.php?color=8D93B9&filename='+aircraft_shadow; } else { var iconURLpath = '/live-tracking-3d/getImages.php?color=1a3151&filename='+aircraft_shadow; var iconURLShadowpath = '/live-tracking-3d/getImages.php?color=8D93B9&filename='+aircraft_shadow; } if (map.getZoom() > 7) { var movingtime = Math.round(50000+feature.properties.sqt*1000); return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ rotationAngle: heading, autostart: true, iconAngle: heading, title: markerLabel, alt: callsign, icon: L.icon({ iconUrl: iconURLpath, iconSize: [30, 30], iconAnchor: [15, 30] /* shadowUrl: iconURLShadowpath, shadowSize: [30,30], shadowAnchor: [16,30] */ }) }) .on('click', function() { $("#aircraft_ident").attr('class',flightaware_id); $(".showdetails").load("/live-tracking-3d/aircraft-data.php?"+Math.random()+"&flightaware_id="+flightaware_id); getLiveData(1); }); } else { var movingtime = Math.round(50000+feature.properties.sqt*1000); return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ rotationAngle: heading, autostart: true, iconAngle: heading, title: markerLabel, alt: callsign, icon: L.icon({ iconUrl: iconURLpath, iconSize: [15, 15], iconAnchor: [7, 15] /* shadowUrl: iconURLShadowpath, shadowSize: [15,15], shadowAnchor: [8,15] */ }) }) .on('click', function() { $("#aircraft_ident").attr('class',flightaware_id); $(".showdetails").load("/live-tracking-3d/aircraft-data.php?"+Math.random()+"&flightaware_id="+flightaware_id); getLiveData(1); }); } }, onEachFeature: function (feature, layer) { var altitude = feature.properties.a; var type = feature.properties.t; var callsign = feature.properties.c; var output = ''; //individual aircraft if (feature.minimal == "false" && type == "aircraft"){ output += '
'; if (typeof feature.properties.image_source_website != 'undefined') { if (typeof feature.properties.image_copyright != 'undefined') { output += '
'+feature.properties.registration+' '+feature.properties.aircraft_name+'Image © '+ feature.properties.image_copyright+'
'; } else { output += '
'+feature.properties.registration+' '+feature.properties.aircraft_name+'
'; } } else { if (typeof feature.properties.image_copyright != 'undefined') { output += '
'+feature.properties.registration+' '+feature.properties.aircraft_name+'Image © '+ feature.properties.image_copyright+'
'; } else { output += '
'+feature.properties.registration+' '+feature.properties.aircraft_name+'
'; } } output += '
'; output += '
'; output += ''; output += '
'+feature.properties.airline_name+'
'; output += '
'; output += '
'; output += '
'; output += ''+feature.properties.departure_airport_code+''+feature.properties.departure_airport; if (typeof feature.properties.departure_airport_time != 'undefined') { output += '
'+feature.properties.departure_airport_time+''; } output += '
'; output += ''; output += '
'; output += ''+feature.properties.arrival_airport_code+''+feature.properties.arrival_airport; if (typeof feature.properties.arrival_airport_time != 'undefined') { output += '
'+feature.properties.arrival_airport_time+''; } output += '
'; output += '
'; if (typeof feature.properties.route_stop != 'undefined') { output += 'Route stop: '+feature.properties.route_stop; } output += '
'; output += '
'; output += '
'; output += '
'; output += '
'; output += ''+feature.properties.departure_airport_code+''+feature.properties.departure_airport; output += '
'; output += ''; output += '
'; output += ''+feature.properties.arrival_airport_code+''+feature.properties.arrival_airport; output += '
'; output += '
'; output += '
'; output += 'Aircraft'; if (feature.properties.aircraft_wiki != 'undefined') { output += ''; output += feature.properties.aircraft_name; output += ''; } else { output += feature.properties.aircraft_name; } output += '
'; if (feature.properties.altitude != "" || feature.properties.altitude != 0) { output += '
'; output += 'Altitude'; output += feature.properties.altitude+'00 feet - '+Math.round(feature.properties.altitude*30.48)+' m (FL'+feature.properties.altitude+')'; output += '
'; } if (feature.properties.registration != "") { output += '
'; output += 'Registration'; output += ''+feature.properties.registration+''; output += '
'; } output += '
'; output += 'Speed'; output += feature.properties.ground_speed+' knots - '+Math.round(feature.properties.ground_speed*1.852)+' km/h'; output += '
'; output += '
'; output += 'Coordinates'; output += feature.properties.latitude+", "+feature.properties.longitude; output += '
'; output += '
'; output += 'Heading'; output += feature.properties.heading; output += '
'; if (typeof feature.properties.pilot_name != 'undefined') { output += '
'; output += 'Pilot'; if (typeof feature.properties.pilot_id != 'undefined') { output += feature.properties.pilot_name+" ("+feature.properties.pilot_id+")"; } else { output += feature.properties.pilot_name; } output += '
'; } output += '
'; if (typeof feature.properties.waypoints != 'undefined') { output += '
Route'; output += feature.properties.waypoints; output += '
'; } if (typeof feature.properties.acars != 'undefined') { output += '
Latest ACARS message'; output += feature.properties.acars; output += '
'; } if (typeof feature.properties.squawk != 'undefined') { output += '
'; output += 'Squawk: '; output += feature.properties.squawk; if (typeof feature.properties.squawk_usage != 'undefined') { output += ' - '+feature.properties.squawk_usage; } output += '
'; } output += ''; layer.bindPopup(output); layer_data.addLayer(layer); } else { layer_data.addLayer(layer); } if (type == "route"){ var style = { "color": "#c74343", "weight": 2, "opacity": 0.5 }; layer.setStyle(style); layer_data.addLayer(layer); } if (type == "routedest"){ var styled = { "color": "#945add", "weight": 2, "opacity": 1.0, "dashArray": "6" }; layer.setStyle(styled); layer_data.addLayer(layer); } //aircraft history position as a line if (type == "history"){ if (document.getElementById('aircraft_ident').className == callsign) { if (map.getZoom() > 7) { var style = { "color": getAltitudeColor(altitude), "weight": 3, "opacity": 1 }; layer.setStyle(style); layer_data.addLayer(layer); } else { var style = { "color": getAltitudeColor(altitude), "weight": 2, "opacity": 1 }; layer.setStyle(style); layer_data.addLayer(layer); } } else { if (map.getZoom() > 7) { var style = { "color": getAltitudeColor(altitude), "weight": 3, "opacity": 0.6 }; layer.setStyle(style); layer_data.addLayer(layer); } else { var style = { "color": getAltitudeColor(altitude), "weight": 2, "opacity": 0.6 }; layer.setStyle(style); layer_data.addLayer(layer); } } } } }); layer_data.addTo(map); //re-create the bootstrap tooltips on the marker //showBootstrapTooltip(); } }); // getLiveData(0); } //load the function on startup getLiveData(0); //then load it again every 30 seconds reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},30000); var currentdate = new Date(); var currentyear = new Date().getFullYear(); var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0)); var enddate = new Date(Date.UTC(currentyear,11,25,2,0,0,0)); if (currentdate.getTime() > begindate.getTime() && currentdate.getTime() < enddate.getTime()) { update_santaLayer(false); } //adds the bootstrap hover to the map buttons $('.button').tooltip({ placement: 'right' }); }); function atcPopup (feature, layer) { var output = ''; output += '
'; output += '
'+feature.properties.ident+'
'; output += ' '+feature.properties.info+'
'; output += '
'; layer.bindPopup(output); }; function update_atcLayer() { var bbox = map.getBounds().toBBoxString(); atcLayer = new L.GeoJSON.AJAX("/live-tracking-3d/atc-geojson.php?coord="+bbox,{ onEachFeature: atcPopup, pointToLayer: function (feature, latlng) { if (feature.properties.atc_range > 0) { var atccolor = feature.properties.atccolor; return L.circle(latlng, feature.properties.atc_range*1, { fillColor: atccolor, color: atccolor, weight: 1, opacity: 0.3, fillOpacity: 0.3 }); } else { if (feature.properties.type == 'Delivery') { return L.marker(latlng, {icon: L.icon({ iconUrl: '/live-tracking-3d/images/atc_del.png', iconSize: [15, 15], iconAnchor: [7, 7] }) }); } else if (feature.properties.type == 'Ground') { return L.marker(latlng, {icon: L.icon({ iconUrl: '/live-tracking-3d/images/atc_gnd.png', iconSize: [20, 20], iconAnchor: [10, 10] }) }); } else if (feature.properties.type == 'Tower') { return L.marker(latlng, {icon: L.icon({ iconUrl: '/live-tracking-3d/images/atc_twr.png', iconSize: [25, 25], iconAnchor: [12, 12] }) }); } else if (feature.properties.type == 'Approach') { return L.marker(latlng, {icon: L.icon({ iconUrl: '/live-tracking-3d/images/atc_app.png', iconSize: [30, 30], iconAnchor: [15, 15] }) }); } else if (feature.properties.type == 'Departure') { return L.marker(latlng, {icon: L.icon({ iconUrl: '/live-tracking-3d/images/atc_dep.png', iconSize: [35, 35], iconAnchor: [17, 17] }) }); } else if (feature.properties.type == 'Control Radar or Centre') { return L.marker(latlng, {icon: L.icon({ iconUrl: '/live-tracking-3d/images/atc_ctr.png', iconSize: [40, 40], iconAnchor: [20, 20] }) }); } else { return L.marker(latlng, {icon: L.icon({ iconUrl: '/live-tracking-3d/images/atc.png', iconSize: [30, 30], iconAnchor: [15, 30] }) }); } } } }).addTo(map); }; function update_polarLayer() { polarLayer = new L.GeoJSON.AJAX("/live-tracking-3d/polar-geojson.php",{ style: function(feature) { return feature.properties.style } }).addTo(map); }; function update_santaLayer(nows) { if (nows) var url = "/live-tracking-3d/live-santa-geojson.php?now"; else var url = "/live-tracking-3d/live-santa-geojson.php"; var santageoJSON = new L.GeoJSON.AJAX(url,{ onEachFeature: function(feature,layer) { var playbackOptions = { orientIcons: true, clickCallback: function() { $(".showdetails").load("/live-tracking-3d/space-data.php?"+Math.random()+"&sat=santaclaus"); }, marker: function(){ return { icon: L.icon({ iconUrl: '/live-tracking-3d/images/santa.png', iconSize: [60, 60], iconAnchor: [30, 30] }) } } }; var santaplayback = new L.Playback(map,feature,null,playbackOptions); santaplayback.start(); var now = new Date(); if (nows == false) santaplayback.setCursor(now.getTime()); } }); }; function showNotam() { if (!$("#notam").hasClass("active")) { //loads the function to load the waypoints update_notamLayer(); //add the active class $("#notam").addClass("active"); } else { //remove the waypoints layer map.removeLayer(notamLayer); //remove the active class $("#notam").removeClass("active"); } } function notamscope(selectObj) { var idx = selectObj.selectedIndex; var scope = selectObj.options[idx].value; document.cookie = 'notamscope='+scope+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' if ($("#notam").hasClass("active")) { map.removeLayer(notamLayer); update_notamLayer(); } } function iconColor(color) { document.cookie = 'IconColor='+color.substring(1)+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' window.location.reload(); } function iconColorAltitude(val) { document.cookie = 'IconColorAltitude='+val.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' window.location.reload(); } function airportDisplayZoom(zoom) { document.cookie = 'AirportZoom='+zoom+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' window.location.reload(); } function clickFlightPopup(cb) { document.cookie = 'flightpopup='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' window.location.reload(); } function clickFlightPath(cb) { document.cookie = 'flightpath='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' window.location.reload(); } function clickFlightRoute(cb) { document.cookie = 'MapRoute='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' window.location.reload(); } function clickFlightRemainingRoute(cb) { document.cookie = 'MapRemainingRoute='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' window.location.reload(); } function clickFlightEstimation(cb) { document.cookie = 'flightestimation='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' window.location.reload(); } function clickSanta(cb) { if (cb.checked) { update_santaLayer(true); } else { // FIXME : Need to use leafletplayback stop() for example window.location.reload(); } } function archivePause() { clearInterval(reloadPage); console.log('Pause'); } function archivePlay() { reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},10000); console.log('Play'); } function notamPopup (feature, layer) { var output = ''; output += '
'; output += ' '+feature.properties.ref+' '+feature.properties.title+'
'; output += ' '+feature.properties.text+'
'; output += ' '+feature.properties.latitude+'/'+feature.properties.longitude+' '+feature.properties.radiusnm+'NM/'+feature.properties.radiusm+'m
'; output += '
'; layer.bindPopup(output); }; function update_notamLayer() { var bbox = map.getBounds().toBBoxString(); if (getCookie('notamscope') == '' || getCookie('notamscope') == 'All') { url = "/live-tracking-3d/notam-geojson.php?coord="+bbox; } else { url = "/live-tracking-3d/notam-geojson.php?coord="+bbox+"&scope="+getCookie(notamscope); } //notamLayer = new L.GeoJSON.AJAX("/live-tracking-3d/notam-geojson.php?coord="+bbox,{ notamLayer = new L.GeoJSON.AJAX(url,{ // onEachFeature: notamPopup, pointToLayer: function (feature, latlng) { var circle = L.circle(latlng, feature.properties.radius, { fillColor: feature.properties.color, color: feature.properties.color, weight: 1, opacity: 0.3, fillOpacity: 0.3 }).on('click', function() { $(".showdetails").load("notam-data.php?"+Math.random()+"¬am="+encodeURI(feature.properties.ref)); }); return circle; } }).addTo(map); }; function update_waypointsLayer() { var bbox = map.getBounds().toBBoxString(); var lineStyle = { "color": "#ff7800", "weight": 1, "opacity": 0.65 }; waypointsLayer = new L.GeoJSON.AJAX("/live-tracking-3d/waypoints-geojson.php?coord="+bbox,{ onEachFeature: waypointsPopup, pointToLayer: function (feature, latlng) { return L.marker(latlng, {icon: L.icon({ iconUrl: feature.properties.icon, iconSize: [12, 13], iconAnchor: [2, 13] //popupAnchor: [0, -28] }) }); }, style: lineStyle }).addTo(map); }; function showWaypoints() { if (!$("#waypoints").hasClass("active")) { //loads the function to load the waypoints update_waypointsLayer(); //add the active class $("#waypoints").addClass("active"); } else { //remove the waypoints layer map.removeLayer(waypointsLayer); //remove the active class $("#waypoints").removeClass("active"); } } function waypointsPopup (feature, layer) { var output = ''; output += '
'; if (typeof feature.properties.segment_name != 'undefined') { output += ' Segment name: '+feature.properties.segment_name+'
'; output += ' From: '+feature.properties.name_begin+' To : '+feature.properties.name_end+'
'; } if (typeof feature.properties.ident != 'undefined') { output += ' Ident: '+feature.properties.ident+'
'; } if (typeof feature.properties.alt != 'undefined') { output += ' Altitude: '+feature.properties.alt*100+' feet - '; output += Math.round(feature.properties.alt*30,48)+' m (FL'+feature.properties.alt+')
'; } if (typeof feature.properties.base != 'undefined') { output += ' Base Altitude: '+feature.properties.base*100+' feet - '; output += Math.round(feature.properties.base*30,48)+' m (FL'+feature.properties.base+')
'; output += ' Top Altitude: '+feature.properties.top*100+' feet - '; output += Math.round(feature.properties.top*30,48)+' m (FL'+feature.properties.top+')
'; } // output += ' Control : '+feature.properties.control+'
 Usage : '+feature.properties.usage; output += '
'; layer.bindPopup(output); }; function showAirspace() { if (!$("#airspace").hasClass("active")) { //loads the function to load the waypoints update_airspaceLayer(); //add the active class $("#airspace").addClass("active"); } else { //remove the waypoints layer map.removeLayer(airspaceLayer); //remove the active class $("#airspace").removeClass("active"); } } function airspacePopup (feature, layer) { var output = ''; output += '
'; if (typeof feature.properties.title != 'undefined') { output += ' Title: '+feature.properties.title+'
'; } if (typeof feature.properties.type != 'undefined') { output += ' Type: '+feature.properties.type+'
'; } if (typeof feature.properties.tops != 'undefined') { output += ' Tops: '+feature.properties.tops+'
'; } if (typeof feature.properties.base != 'undefined') { output += ' Base: '+feature.properties.base+'
'; } output += '
'; layer.bindPopup(output); }; function update_airspaceLayer() { var bbox = map.getBounds().toBBoxString(); airspaceLayer = new L.GeoJSON.AJAX("/live-tracking-3d/airspace-geojson.php?coord="+bbox,{ onEachFeature: airspacePopup, pointToLayer: function (feature, latlng) { /* return L.marker(latlng, {icon: L.icon({ // iconUrl: feature.properties.icon, iconSize: [12, 13], iconAnchor: [2, 13] // //popupAnchor: [0, -28] }) }); */ }, style: function(feature) { return { "color": feature.properties.color, "weight": 1, "opacity": 0.2 }; /* if (feature.properties.type == 'RESTRICTED') { return { "color": '#cf2626', "weight": 1, "opacity": 0.2 }; } else if (feature.properties.type == 'CLASS D') { return { "color": '#1a74b3', "weight": 1, "opacity": 0.2 }; } else if (feature.properties.type == 'CLASS B') { return { "color": '#1a74b3', "weight": 1, "opacity": 0.2 }; } else if (feature.properties.type == 'GSEC') { return { "color": '#1b5acf', "weight": 1, "opacity": 0.2 }; } else if (feature.properties.type == 'CLASS C') { return { "color": '#9b6c9d', "weight": 1, "opacity": 0.3 }; } else if (feature.properties.type == 'PROHIBITED') { return { "color": '#1b5acf', "weight": 1, "opacity": 0.2 }; } else if (feature.properties.type == 'DANGER') { return { "color": '#781212', "weight": 1, "opacity": 0.55 }; } else if (feature.properties.type == 'OTHER' || feature.properties.type == 'CLASS A') { return { "color": '#ffffff', "weight": 1, "opacity": 0.55 }; } else { return { "color": '#afffff', "weight": 1, "opacity": 0.55 }; } */ } }).addTo(map); }; function getAltitudeColor(x) { return x < 10 ? '#ea0000': x < 30 ? '#ea3a00': x < 60 ? '#ea6500': x < 80 ? '#ea8500': x < 100 ? '#eab800': x < 120 ? '#eae300': x < 140 ? '#d3ea00': x < 160 ? '#b0ea00': x < 180 ? '#9cea00': x < 200 ? '#8cea00': x < 220 ? '#46ea00': x < 240 ? '#00ea4a': x < 260 ? '#00eac7': x < 280 ? '#00cfea': x < 300 ? '#009cea': x < 320 ? '#0065ea': x < 340 ? '#001bea': x < 360 ? '#3e00ea': x < 380 ? '#6900ea': x < 400 ? '#a400ea': x < 500 ? '#cb00ea': x < 600 ? '#ea00db': '#3e00ea' ; // return '#' + ('00000' + (x*2347 | 0).toString(16)).substr(-6); };