Skip to content

Commit 0e7e819

Browse files
updated vehicle follow logic; fix vehicle colors
1 parent ef6863a commit 0e7e819

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

js/app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ $(window).ready(function() {
150150
e.find('.data').hide();
151151

152152
listScroll.refresh();
153+
154+
// disable following only we are collapsing the followed vehicle
155+
if(follow_vehicle == parseInt(e.attr('class').match(/vehicle(\d+)/)[1])) {
156+
followVehicle(parseInt(e.attr('class').match(/vehicle(\d+)/)[1]));
157+
}
153158
} else {
154159
// expand data for selected vehicle
155160
e.addClass('active');
@@ -267,7 +272,11 @@ $(window).ready(function() {
267272
$("#locate-me,.chasecar").show();
268273
$("#locate-me").click(function() {
269274
if(map && currentPosition) {
275+
// disable following of vehicles
276+
stopFollow();
277+
// open map
270278
$('.nav .home').click();
279+
// pan map to our current location
271280
map.panTo(new google.maps.LatLng(currentPosition.lat, currentPosition.lon));
272281
} else {
273282
alert("No position available");

js/mobile.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/tracker.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function load() {
5252
});
5353

5454
nite.init(map);
55-
setInterval(function() { nite.refresh(); }, 300000); // 5min
55+
setInterval(function() { nite.refresh(); }, 60000); // 1min
5656

5757
// we need a dummy overlay to access getProjection()
5858
overlay = new google.maps.OverlayView();
@@ -224,14 +224,23 @@ function updateZoom() {
224224
}
225225

226226

227+
function stopFollow() {
228+
if(follow_vehicle != -1) {
229+
vehicles[follow_vehicle].follow = false;
230+
follow_vehicle = -1;
231+
}
232+
}
233+
227234
function followVehicle(index) {
228235
if(follow_vehicle != -1) vehicles[follow_vehicle].follow = false;
229236

230-
panTo(index);
231-
232-
if(follow_vehicle != index) {
237+
if(follow_vehicle == index) {
238+
vehicles[follow_vehicle].follow = false;
239+
follow_vehicle = -1;
240+
} else if(follow_vehicle != index) {
233241
follow_vehicle = index;
234242
vehicles[follow_vehicle].follow = true;
243+
panTo(index);
235244
}
236245
}
237246

@@ -608,7 +617,7 @@ function addPosition(position) {
608617
line: [],
609618
polyline: new google.maps.Polyline({
610619
map: map,
611-
strokeColor: balloon_colors[color_index],
620+
strokeColor: balloon_colors[c],
612621
strokeOpacity: 0.8,
613622
strokeWeight: 3,
614623
clickable: false,
@@ -620,7 +629,7 @@ function addPosition(position) {
620629
alt_data: new Array(),
621630
path_enabled: vehicle_type == "balloon" && position.vehicle.toLowerCase().indexOf("iss") == -1,
622631
follow: false,
623-
color_index: color_index};
632+
color_index: c};
624633
vehicles.push(vehicle_info);
625634
}
626635

0 commit comments

Comments
 (0)