From 7656042d560e1da8020258499c4f9ecf51271c6b Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Mon, 17 Apr 2017 19:10:25 +0000
Subject: [PATCH] Fix clearing tram info for unknown vehicles in schedule table

---
 index.js  |    3 ++-
 common.js |    6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/common.js b/common.js
index 37368a1..6d3f6f9 100644
--- a/common.js
+++ b/common.js
@@ -33,10 +33,10 @@
 
 // Webservice-related functions
 function parseVehicle(vehicleId) {
-	if(!vehicleId) return;
+	if(!vehicleId) return false;
 	if(vehicleId.substr(0, 15) != '635218529567218') {
 		console.log('Unknown vehicle, vehicleId=' + vehicleId);
-		return;
+		return false;
 	}
 	
 	var id = parseInt(vehicleId.substr(15)) - 736;
@@ -122,7 +122,7 @@
 		low = 1;
 	} else {
 		console.log('Unknown vehicle, vehicleId=' + vehicleId + ', id=' + id);
-		return;
+		return false;
 	}
 	
 	return {
diff --git a/index.js b/index.js
index dbcbf83..a26a7a1 100644
--- a/index.js
+++ b/index.js
@@ -27,6 +27,7 @@
 var route_line = document.getElementById('route-line');
 var route_table = document.getElementById('route-table');
 var route_vehicle = document.getElementById('route-vehicle');
+var route_vehicle_info;
 
 var refresh_button = document.getElementById('refresh');
 var refresh_text = document.getElementById('refresh-text');
@@ -245,7 +246,7 @@
 	if(!tripId) tripId = route_id;
 	if(!tripId) return;
 	
-	if(!vehicleInfo) vehicleInfo = route_vehicle_info;
+	if(vehicleInfo === undefined) vehicleInfo = route_vehicle_info;
 	
 	console.log('loadRoute(' + tripId + ')');
 	route_id = tripId;

--
Gitblit v1.9.1