From baddeb90347f909c58866a86ddacca731974fd78 Mon Sep 17 00:00:00 2001 From: Dynomity Date: Fri, 21 Aug 2015 18:38:38 -0600 Subject: [PATCH] cleaning up code and plane table --- public_html/config.js | 3 +++ public_html/gmap.html | 4 +++- public_html/script.js | 40 +++++++++++++++------------------------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/public_html/config.js b/public_html/config.js index 27a9e09..57efb12 100644 --- a/public_html/config.js +++ b/public_html/config.js @@ -98,3 +98,6 @@ ShowClocks = true; // Controls page title, righthand pane when nothing is selected PageName = "DUMP1090"; + +// Path to country flags subfolder +flag_dir = "flags-tiny"; diff --git a/public_html/gmap.html b/public_html/gmap.html index a8fc7ae..ec899e2 100644 --- a/public_html/gmap.html +++ b/public_html/gmap.html @@ -144,7 +144,7 @@ Position: n/a - Country: n/a + Country: n/an/a @@ -156,6 +156,7 @@ + @@ -168,6 +169,7 @@ + diff --git a/public_html/script.js b/public_html/script.js index 57d7a3d..33118d2 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -71,29 +71,25 @@ function processReceiverUpdate(data) { plane.tr = PlaneRowTemplate.cloneNode(true); // Lookup ICAO country flag - var img = document.createElement('img'); var hexa = +("0x" + hex); for (var i = 0; i < ICAO_Codes.length; i++) { if ( hexa >= ICAO_Codes[i].start && hexa <= ICAO_Codes[i].end) { - img.src = escapeHtml(ICAO_Codes[i].icon_fn); - img.style.margin = "1px 2px"; - img.style.cssFloat = "right"; - img.title = ICAO_Codes[i].Country; - plane.Country = ICAO_Codes[i].Country; - plane.Flag = img; + plane.Country = ICAO_Codes[i].Country; + plane.Flag = '
'; } } // end of flag lookup + if (hex[0] === '~') { // Non-ICAO address plane.tr.cells[0].textContent = hex.substring(1); $(plane.tr).css('font-style', 'italic'); - } else { - plane.tr.cells[0].textContent = hex; - //append the flag - plane.tr.cells[0].appendChild(plane.Flag); + plane.tr.cells[1].textContent = (""); + } else { + plane.tr.cells[0].textContent = (hex); + plane.tr.cells[1].innerHTML = (plane.Flag); } plane.tr.addEventListener('click', selectPlaneByHex.bind(undefined,hex,false)); @@ -680,14 +676,14 @@ function refreshTableInfo() { } // ICAO doesn't change - tableplane.tr.cells[1].textContent = (tableplane.flight !== null ? tableplane.flight : ""); - tableplane.tr.cells[2].textContent = (tableplane.squawk !== null ? tableplane.squawk : ""); - tableplane.tr.cells[3].textContent = format_altitude_brief(tableplane.altitude, tableplane.vert_rate); - tableplane.tr.cells[4].textContent = format_speed_brief(tableplane.speed); - tableplane.tr.cells[5].textContent = format_distance_brief(tableplane.sitedist); - tableplane.tr.cells[6].textContent = format_track_brief(tableplane.track); - tableplane.tr.cells[7].textContent = tableplane.messages; - tableplane.tr.cells[8].textContent = tableplane.seen.toFixed(0); + tableplane.tr.cells[2].textContent = (tableplane.flight !== null ? tableplane.flight : ""); + tableplane.tr.cells[3].textContent = (tableplane.squawk !== null ? tableplane.squawk : ""); + tableplane.tr.cells[4].textContent = format_altitude_brief(tableplane.altitude, tableplane.vert_rate); + tableplane.tr.cells[5].textContent = format_speed_brief(tableplane.speed); + tableplane.tr.cells[6].textContent = format_distance_brief(tableplane.sitedist); + tableplane.tr.cells[7].textContent = format_track_brief(tableplane.track); + tableplane.tr.cells[8].textContent = tableplane.messages; + tableplane.tr.cells[9].textContent = tableplane.seen.toFixed(0); tableplane.tr.className = classes; @@ -866,9 +862,3 @@ function drawCircle(marker, distance) { }); circle.bindTo('center', marker, 'position'); } - -function escapeHtml(str) { - var div = document.createElement('div'); - div.appendChild(document.createTextNode('flags-tiny/' + str)); - return div.innerHTML; -};
ICAOCountry Flight Squawk Altitude