Skip to content

Commit 39a3923

Browse files
Merge 'beta'; pred.alt graph yaxis scaling +twaeks
fd8d2dd - always first fetch predictions after clean_refresh() 1bfe441 - scale y-axis based on pred.alt as well
2 parents 8df85a4 + fd8d2dd commit 39a3923

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

js/tracker.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ var plot_options = {
8686
mode: "x"
8787
},
8888
yaxes: [
89-
{show: false, min: 0 },
90-
{show: false, min: 0 },
89+
{show: false, min: 0, max: 0},
90+
{show: false, min: 0, max: 0},
9191
{show: false, min: 0 },
9292
{show: false, min: 0 },
9393
{show: false, min: 0 },
@@ -1048,7 +1048,15 @@ function redrawPrediction(vcallsign) {
10481048
for(var i = 0, ii = data.length; i < ii; i++) {
10491049
latlng = new google.maps.LatLng(data[i].lat, data[i].lon);
10501050
line.push(latlng);
1051-
graph_data.push([parseInt(data[i].time)*1000, parseInt(data[i].alt)]);
1051+
1052+
// pred.alt for graph
1053+
var alt = parseInt(data[i].alt);
1054+
graph_data.push([parseInt(data[i].time)*1000, alt]);
1055+
// adjust y-range
1056+
if(alt > vehicle.graph_yaxes[0].max) {
1057+
vehicle.graph_yaxes[0].max = alt;
1058+
vehicle.graph_yaxes[1].max = vehicle.graph_yaxes[0].max;
1059+
}
10521060

10531061
if(parseFloat(data[i].alt) > max_alt) {
10541062
max_alt = parseFloat(data[i].alt);
@@ -2259,6 +2267,8 @@ function refresh() {
22592267
complete: function(request, textStatus) {
22602268
clearTimeout(periodical);
22612269
periodical = setTimeout(refresh, timer_seconds * 1000);
2270+
2271+
if(periodical_predictions === null) refreshPredictions();
22622272
}
22632273
});
22642274
}
@@ -2453,7 +2463,8 @@ function initHabitat() {
24532463
}
24542464

24552465

2456-
var periodical, periodical_receivers, periodical_predictions;
2466+
var periodical, periodical_receivers;
2467+
var periodical_predictions = null;
24572468
var timer_seconds = 15;
24582469

24592470
function startAjax() {
@@ -2467,9 +2478,6 @@ function startAjax() {
24672478

24682479
//periodical_listeners = setInterval(refreshReceivers, 60 * 1000);
24692480
refreshReceivers();
2470-
2471-
//periodical_predictions = setInterval(refreshPredictions, 2 * timer_seconds * 1000);
2472-
refreshPredictions();
24732481
}
24742482

24752483
function stopAjax() {
@@ -2478,6 +2486,7 @@ function stopAjax() {
24782486
if(ajax_positions) ajax_positions.abort();
24792487

24802488
clearTimeout(periodical_predictions);
2489+
periodical_predictions = null;
24812490
if(ajax_predictions) ajax_predictions.abort();
24822491
}
24832492

0 commit comments

Comments
 (0)