Skip to content

Commit b988600

Browse files
committed
support for displaying old sonde
1 parent dddbf5a commit b988600

File tree

2 files changed

+122
-27
lines changed

2 files changed

+122
-27
lines changed

css/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ header .search form input[type='submit'] {
441441
border: 1px solid #ccc;
442442
cursor: pointer;
443443
z-index: 5;
444+
text-align: center;
444445
}
445446

446447
#main .row .data .vbutton.active {

js/tracker.js

Lines changed: 121 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,6 @@ function clean_refresh(text, force, history_step) {
334334
history_step = !!history_step;
335335

336336
if(text == wvar.mode && !force) return false;
337-
if(ajax_inprogress) return false;
338-
339337
stopAjax();
340338

341339
// reset mode if, invalid mode is specified
@@ -813,7 +811,6 @@ function updateAltitude(vcallsign) {
813811
} else if(position.gps_alt > 55000) {
814812
position.gps_alt = 55000;
815813
}
816-
vehicle.marker.setAltitude(pixel_altitude);
817814
}
818815

819816
function updateZoom() {
@@ -1224,11 +1221,11 @@ function updateVehicleInfo(vcallsign, newPosition) {
12241221
//'<span>' + vcallsign + ' <i class="icon-target"></i></span>' +
12251222
'<canvas class="graph"></canvas>' +
12261223
'<i class="arrow"></i></div>' +
1227-
'<div class="data">' +
1224+
'<div class="data" style="min-height:' + (vehicle.image_src_size[1]+95) + 'px">' +
12281225
'<img class="'+((vehicle.vehicle_type=="car")?'car':'')+'" src="'+image+'" />' +
1229-
'<span class="vbutton path '+((vehicle.polyline_visible) ? 'active' : '')+'" data-vcallsign="'+vcallsign+'"' +
1230-
' style="top:'+(vehicle.image_src_size[1]+55)+'px">Path</span>' +
1231-
'<span class="sbutton" onclick="shareVehicle(\'' + vcallsign + '\')">Share</span>' +
1226+
'<span class="vbutton path '+((vehicle.polyline_visible) ? 'active' : '')+'" data-vcallsign="'+vcallsign+'"' + ' style="top:'+(vehicle.image_src_size[1]+55)+'px">Path</span>' +
1227+
((vehicle.vehicle_type!="car") ? '<span class="sbutton" onclick="shareVehicle(\'' + vcallsign + '\')" style="top:'+(vehicle.image_src_size[1]+85)+'px">Share</span>' : '') +
1228+
((vehicle.vehicle_type!="car") ? '<span class="sbutton" onclick="window.open(\'https://sondehub.org/card/' + vcallsign + '\')" style="top:'+(vehicle.image_src_size[1]+115)+'px">Card</span>' : '') +
12321229
((vcallsign in hysplit) ? '<span class="vbutton hysplit '+((hysplit[vcallsign].getMap()) ? 'active' : '')+'"' +
12331230
' data-vcallsign="'+vcallsign+'" style="top:'+(vehicle.image_src_size[1]+55+21+10)+'px">HYSPLIT</span>' : '') +
12341231
((vcallsign.substr(0, 6) in ssdv) ? '<a class="vbutton active" href="//ssdv.habhub.org/' + vcallsign.substr(0, 6) + '"' +
@@ -1642,7 +1639,6 @@ function mapInfoBox_handle_path_fetch(id,vehicle) {
16421639
var callsign_list = []
16431640
for(var rxcall in data.callsign){
16441641
if(data.callsign.hasOwnProperty(rxcall)) {
1645-
_new_call += "<b>Received via:&nbsp;</b> ";
16461642
_new_call = rxcall;
16471643
if(data.callsign[rxcall].hasOwnProperty('snr')){
16481644
if(data.callsign[rxcall].snr){
@@ -1945,11 +1941,6 @@ function addPosition(position) {
19451941
}
19461942
if (!wvar.nyan) {this.setIcon(img);};
19471943
};
1948-
marker.setAltitude = function(alt) {
1949-
//var pos = overlay.getProjection().fromLatLngToDivPixel(this.shadow.getLatLng());
1950-
//pos.y -= alt;
1951-
//this.setLatLng(overlay.getProjection().fromDivPixelToLatLng(pos));
1952-
};
19531944

19541945
// Add landing marker if the payload provides a predicted landing position.
19551946
if (position.data.hasOwnProperty('pred_lat') && position.data.hasOwnProperty('pred_lon')){
@@ -2588,8 +2579,10 @@ function graphAddPosition(vcallsign, new_data) {
25882579

25892580
var ajax_positions = null;
25902581
var ajax_positions_single = null;
2582+
var ajax_positions_old = null;
25912583
var ajax_inprogress = false;
25922584
var ajax_inprogress_single = false;
2585+
var ajax_inprogress_old = "none";
25932586

25942587
function refresh() {
25952588
if(ajax_inprogress) {
@@ -2598,6 +2591,10 @@ function refresh() {
25982591
return;
25992592
}
26002593

2594+
if (ajax_inprogress_old == wvar.query) {
2595+
return;
2596+
}
2597+
26012598
ajax_inprogress = true;
26022599

26032600
$("#stText").text("checking |");
@@ -2620,7 +2617,17 @@ function refresh() {
26202617
success: function(response, textStatus) {
26212618
$("#stText").text("loading |");
26222619
response.fetch_timestamp = Date.now();
2623-
update(response);
2620+
if (wvar.query != null) {
2621+
if (JSON.stringify(response).indexOf(wvar.query) == -1) {
2622+
//check using new API
2623+
ajax_inprogress = false;
2624+
refreshSingleOld(wvar.query);
2625+
} else {
2626+
update(response);
2627+
}
2628+
} else {
2629+
update(response);
2630+
}
26242631
$("#stText").text("");
26252632
$("#stTimer").attr("data-timestamp", response.fetch_timestamp);
26262633
},
@@ -2633,6 +2640,8 @@ function refresh() {
26332640
$("#stText").text("no connection |");
26342641
$("#stTimer").attr("data-timestamp", data.fetch_timestamp);
26352642
}
2643+
2644+
ajax_inprogress = false;
26362645
},
26372646
complete: function(request, textStatus) {
26382647
document.getElementById("timeperiod").disabled = false;
@@ -2657,6 +2666,9 @@ function refreshSingle(serial, first) {
26572666
}
26582667
return;
26592668
}
2669+
if (serial == ajax_inprogress_old) {
2670+
return;
2671+
}
26602672

26612673
if (first === undefined) {
26622674
first = false;
@@ -2689,7 +2701,82 @@ function refreshSingle(serial, first) {
26892701
periodical_focus = setTimeout(refreshSingle, timer_seconds_focus * 1000, serial);
26902702
}
26912703
});
2692-
}
2704+
}
2705+
2706+
function refreshSingleOld(serial) {
2707+
2708+
if(serial == ajax_inprogress_old) {
2709+
return;
2710+
}
2711+
2712+
var data_url = "https://api.v2.sondehub.org/sonde/" + encodeURIComponent(serial);
2713+
2714+
ajax_inprogress_old = serial;
2715+
2716+
ajax_positions_old = $.ajax({
2717+
type: "GET",
2718+
url: data_url,
2719+
dataType: "json",
2720+
success: function(data, textStatus) {
2721+
var response = {};
2722+
response.positions = {};
2723+
var dataTemp = [];
2724+
for (var i = data.length - 1; i >= 0; i--) {
2725+
if (data[i].hasOwnProperty('subtype')) {
2726+
if (data[i].subtype != "SondehubV1") {
2727+
var dataTempEntry = {};
2728+
var station = data[i].uploader_callsign
2729+
dataTempEntry.callsign = {};
2730+
dataTempEntry.callsign[station] = {};
2731+
dataTempEntry.callsign[station].snr = data[i].snr;
2732+
dataTempEntry.callsign[station].rssi = data[i].rssi;
2733+
dataTempEntry.gps_alt = data[i].alt;
2734+
dataTempEntry.gps_heading = data[i].heading;
2735+
dataTempEntry.gps_lat = data[i].lat;
2736+
dataTempEntry.gps_lon = data[i].lon;
2737+
dataTempEntry.gps_time = data[i].datetime;
2738+
dataTempEntry.server_time = data[i].datetime;
2739+
dataTempEntry.vehicle = data[i].serial;
2740+
dataTempEntry.position_id = data[i].serial + "-" + data[i].datetime;
2741+
dataTempEntry.data = {};
2742+
if (data[i].batt) {
2743+
dataTempEntry.data.batt = data[i].batt;
2744+
}
2745+
if (data[i].burst_timer) {
2746+
dataTempEntry.data.burst_timer = data[i].burst_timer;
2747+
}
2748+
if (data[i].frequency) {
2749+
dataTempEntry.data.burst_timer = data[i].frequency;
2750+
}
2751+
if (data[i].humidity) {
2752+
dataTempEntry.data.humidity = data[i].humidity;
2753+
}
2754+
if (data[i].manufacturer) {
2755+
dataTempEntry.data.manufacturer = data[i].manufacturer;
2756+
}
2757+
if (data[i].sats) {
2758+
dataTempEntry.data.sats = data[i].sats;
2759+
}
2760+
if (data[i].temp) {
2761+
dataTempEntry.data.temperature_external = data[i].temp;
2762+
}
2763+
if (data[i].type) {
2764+
dataTempEntry.data.type = data[i].type;
2765+
dataTempEntry.type = data[i].type;
2766+
}
2767+
if (data[i].pressure) {
2768+
dataTempEntry.data.pressure = data[i].pressure;
2769+
}
2770+
dataTemp.push(dataTempEntry)
2771+
}
2772+
}
2773+
}
2774+
response.positions.position = dataTemp;
2775+
response.fetch_timestamp = Date.now();
2776+
update(response, "old");
2777+
}
2778+
});
2779+
}
26932780

26942781
function refreshReceivers() {
26952782
// if options to hide receivers is selected do nothing
@@ -2978,6 +3065,9 @@ function stopAjax() {
29783065
if(ajax_positions) ajax_positions.abort();
29793066

29803067
clearTimeout(periodical_focus);
3068+
if(ajax_positions_single) ajax_positions_single.abort();
3069+
3070+
if(ajax_positions_old) ajax_positions_old.abort();
29813071

29823072
clearTimeout(periodical_predictions);
29833073
periodical_predictions = null;
@@ -3339,16 +3429,18 @@ function update(response, flag) {
33393429
!response.positions.position ||
33403430
!response.positions.position.length) {
33413431

3342-
// if no vehicles are found, this will remove the spinner and put a friendly message
3343-
$("#main .empty").html("<span>No vehicles :(</span>");
3432+
if (flag != "old") {
3433+
// if no vehicles are found, this will remove the spinner and put a friendly message
3434+
$("#main .empty").html("<span>No vehicles :(</span>");
33443435

3345-
if (flag === undefined) {
3346-
ajax_inprogress = false;
3347-
} else {
3348-
ajax_inprogress_single = false;
3349-
}
3436+
if (flag === undefined) {
3437+
ajax_inprogress = false;
3438+
} else {
3439+
ajax_inprogress_single = false;
3440+
}
33503441

3351-
return;
3442+
return;
3443+
}
33523444
}
33533445

33543446
ssdv = (!response.ssdv) ? {} : response.ssdv;
@@ -3444,10 +3536,12 @@ function update(response, flag) {
34443536

34453537
if(periodical_predictions === null) refreshPredictions();
34463538

3447-
if (flag === undefined) {
3448-
ajax_inprogress = false;
3449-
} else {
3450-
ajax_inprogress_single = false;
3539+
if (flag != "old") {
3540+
if (flag === undefined) {
3541+
ajax_inprogress = false;
3542+
} else {
3543+
ajax_inprogress_single = false;
3544+
}
34513545
}
34523546
}
34533547
};

0 commit comments

Comments
 (0)