Skip to content

Commit 8a89cc8

Browse files
Merge branch 'beta', pred.alt + query mode fixes
fcfa587 - fix pred.alt. not showing on clipped graphs 5bf3d63 - invalid qm and empty query reset qmode
2 parents 09955b2 + fcfa587 commit 8a89cc8

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

js/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function load_hash(no_refresh) {
121121
break;
122122
case "qm":
123123
def.mode = v.replace(/_/g, ' ');
124+
if(modeList.indexOf(def.mode) == -1) def.mode = (is_mobile) ? modeDefaultMobile : modeDefault;
124125
break;
125126
case "q":
126127
def.query = v;
@@ -1011,11 +1012,14 @@ $(window).ready(function() {
10111012

10121013
if(text === wvar.query) return;
10131014

1015+
// when running an empty search, it's probably best to reset the query mode
1016+
10141017
wvar.query = text;
10151018
stopFollow();
10161019
zoomed_in = false;
10171020
wvar.zoom = true;
10181021

1022+
if(text === "") { wvar.mode = null; }
10191023
clean_refresh(wvar.mode, true);
10201024
});
10211025
});

js/gmaps_extentions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ google.maps.DropDownControl.prototype.setVisible = function(isVisible) {
175175
this.div_.style.display = (isVisible) ? 'block' : 'none';
176176
};
177177

178+
google.maps.DropDownControl.prototype.select = function(text) {
179+
this.header.innerHTML = (this.options.headerPrefix || "") + text;
180+
};
181+
178182
// simple status control
179183

180184
google.maps.StatusTextControl = function(options) {

js/tracker.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,12 @@ function clean_refresh(text, force) {
331331
if(ajax_inprogress) return false;
332332

333333
stopAjax();
334+
335+
// reset mode if, invalid mode is specified
336+
if(modeList.indexOf(text) == -1) text = (is_mobile) ? modeDefaultMobile : modeDefault;
337+
334338
wvar.mode = text;
339+
tmpC.select(text);
335340

336341
position_id = 0;
337342

@@ -1916,20 +1921,22 @@ function updateGraph(vcallsign, reset_selection) {
19161921
updateTimebox(new Date());
19171922
}
19181923

1919-
if(vcallsign === null) return;
1924+
if(vcallsign === null || !vehicles.hasOwnProperty(vcallsign)) return;
19201925

19211926
var series = vehicles[vcallsign].graph_data;
19221927

19231928
// if we are drawing the plot for the fisrt time
19241929
// and the dataset is too large, we set an initial selection of the last 7 days
19251930
if(!plot_options.hasOwnProperty('xaxis')) {
19261931
if(series.length && series[0].data.length > 4001) {
1927-
var end = series[0].data.length - 1;
1932+
var last = series[0].data.length - 1;
1933+
var end_a = series[0].data[last][0];
1934+
var end_b = (series[1].data.length) ? series[1].data[series[1].data.length - 1][0] : 0;
19281935

19291936
plot_options.xaxis = {
19301937
superzoom: 1,
1931-
min: series[0].data[end-4000][0],
1932-
max: series[0].data[end][0],
1938+
min: series[0].data[last-4000][0],
1939+
max: Math.max(end_a, end_b),
19331940
};
19341941

19351942
}
@@ -2638,7 +2645,9 @@ function update(response) {
26382645
end: function(ctx) {
26392646

26402647
// update graph is current vehicles is followed
2641-
if(follow_vehicle !== null && vehicles[follow_vehicle].graph_data_updated) updateGraph(follow_vehicle, false);
2648+
if(follow_vehicle !== null &&
2649+
vehicles.hasOwnProperty(follow_vehicle) &&
2650+
vehicles[follow_vehicle].graph_data_updated) updateGraph(follow_vehicle, false);
26422651

26432652
// store in localStorage
26442653
offline.set('positions', ctx.lastPositions);

0 commit comments

Comments
 (0)