Skip to content

Commit

Permalink
query by registration when DB info is loaded
Browse files Browse the repository at this point in the history
(even if we had already queried by hex)
  • Loading branch information
wiedehopf committed Mar 14, 2021
1 parent be80c25 commit 88aa5a8
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2091,20 +2091,27 @@ function refreshPhoto(selected) {
displaySil();
return;
}
if (selected.psAPIresponse) {
displayPhoto();
return;
}
const ts = new Date().getTime();
if (selected.psAPIresponseTS && selected.psAPIresponseTS - ts < 10000)
return;

let urlTail;
let param;
if (selected.registration != null) {
urlTail = 'reg/' + selected.registration;
param = 'reg';
} else {
urlTail = 'hex/' + selected.icao.toUpperCase();
param = 'hex';
}

const ts = new Date().getTime();
if (param == selected.psAPIparam) {
if (selected.psAPIresponse) {
displayPhoto();
return;
}
if (selected.psAPIresponseTS && selected.psAPIresponseTS - ts < 10000)
return;
}

selected.psAPIparam = param;
setPhotoHtml("<p>Loading image...</p>");
$('#copyrightInfo').html("<span></span>");
//console.log(ts/1000 + 'sending psAPI request');
Expand Down

0 comments on commit 88aa5a8

Please sign in to comment.