Added span for flag icon in selected

This commit is contained in:
Dynomity 2015-08-19 22:00:57 -06:00
parent 1a5e6e2187
commit 1babb5b55c
2 changed files with 13 additions and 22 deletions

View file

@ -115,7 +115,7 @@
<a href="http://www.airframes.org/" onclick="document.getElementById('horrible_hack').submit.call(document.getElementById('airframes_post')); return false;"> <a href="http://www.airframes.org/" onclick="document.getElementById('horrible_hack').submit.call(document.getElementById('airframes_post')); return false;">
<span id="selected_icao"></span> <span id="selected_icao"></span>
</a> </a>
<span id="selected_icaoflag"></span>
<span id="selected_registration"></span> <span id="selected_registration"></span>
<span id="selected_icaotype"></span> <span id="selected_icaotype"></span>
<span id="selected_emergency"></span> <span id="selected_emergency"></span>

View file

@ -69,6 +69,7 @@ function processReceiverUpdate(data) {
} else { } else {
plane = new PlaneObject(hex); plane = new PlaneObject(hex);
plane.tr = PlaneRowTemplate.cloneNode(true); plane.tr = PlaneRowTemplate.cloneNode(true);
// Lookup ICAO country flag // Lookup ICAO country flag
var img = document.createElement('img'); var img = document.createElement('img');
var hexa = +("0x" + hex); var hexa = +("0x" + hex);
@ -79,6 +80,8 @@ function processReceiverUpdate(data) {
img.style.margin = "1px 2px"; img.style.margin = "1px 2px";
img.style.cssFloat = "right"; img.style.cssFloat = "right";
img.title = ICAO_Codes[i].Country; img.title = ICAO_Codes[i].Country;
plane.Country = ICAO_Codes[i].Country;
plane.Flag = img;
} }
} }
// end of flag lookup // end of flag lookup
@ -90,7 +93,7 @@ function processReceiverUpdate(data) {
} else { } else {
plane.tr.cells[0].textContent = hex; plane.tr.cells[0].textContent = hex;
//append the flag //append the flag
plane.tr.cells[0].appendChild(img); plane.tr.cells[0].appendChild(plane.Flag);
} }
plane.tr.addEventListener('click', selectPlaneByHex.bind(undefined,hex,false)); plane.tr.addEventListener('click', selectPlaneByHex.bind(undefined,hex,false));
@ -610,28 +613,16 @@ function refreshSelected() {
$('#selected_seen').text(selected.seen.toFixed(1) + 's'); $('#selected_seen').text(selected.seen.toFixed(1) + 's');
} }
// add the country and flag // add the country and flag to the selected section
var flagtag = document.createElement('img'); $('#selected_country').text(selected.Country);
var icao_dec, i = 0; // the following is not working to add the flag. Note the property has tags for table.
var CountryName = null; // flagtag.style.margin = "0px 10px";
// flagtag.style.cssFloat = "none";
//
// document.getElementById('selected_icao').appendChild(selected.Flag);
// Convert the hex to integer //$('#selected_icaoflag').attr(selected.Flag);
icao_dec = parseInt(selected.icao,16);
// Look up the country of registration from icao address in array
for (i = 0; i < Icao_Codes.length; i++) {
if (icao_dec > Icao_Codes[i][0] && icao_dec < Icao_Codes[i][1]) {
CountryName = Icao_Codes[i][2];
CountryName = CountryName.replace(/_/g, ' ');
$('#selected_country').text(CountryName);
flagtag.src = escapeHtml(Icao_Codes[i][2]);
flagtag.title = Icao_Codes[i][2];
flagtag.style.margin = "0px 10px";
flagtag.style.cssFloat = "none";
}
}
document.getElementById('selected_icao').appendChild(flagtag);
if (selected.position === null) { if (selected.position === null) {
$('#selected_position').text('n/a'); $('#selected_position').text('n/a');