From 218a38496d8907175346b81ce8a4afbe2943d1fd Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Mon, 17 Apr 2017 19:04:42 +0000
Subject: [PATCH] Fix problem with departures not loading when unknown vehicle is present on list

---
 index.js |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 1f9621b..dbcbf83 100644
--- a/index.js
+++ b/index.js
@@ -184,7 +184,7 @@
 			var dir_cell = addCellWithText(tr, data.old[i].direction);
 			var vehicle = parseVehicle(data.old[i].vehicleId);
 			dir_cell.appendChild(displayVehicle(vehicle));
-			addCellWithText(tr, vehicle.num).className = 'vehicleData';
+			addCellWithText(tr, (vehicle ? vehicle.num : '')).className = 'vehicleData';
 			var status = parseStatus(data.old[i]);
 			addCellWithText(tr, status);
 			addCellWithText(tr, '');
@@ -202,7 +202,7 @@
 			var dir_cell = addCellWithText(tr, data.actual[i].direction);
 			var vehicle = parseVehicle(data.actual[i].vehicleId);
 			dir_cell.appendChild(displayVehicle(vehicle));
-			addCellWithText(tr, vehicle.num).className = 'vehicleData';
+			addCellWithText(tr, (vehicle ? vehicle.num : '')).className = 'vehicleData';
 			var status = parseStatus(data.actual[i]);
 			var status_cell = addCellWithText(tr, status);
 			var delay = parseDelay(data.actual[i]);
@@ -267,7 +267,9 @@
 		deleteChildren(route_vehicle);
 		if(vehicleInfo) {
 			var span = displayVehicle(vehicleInfo);
-			setText(route_vehicle, span.title);
+			if(span) {
+				setText(route_vehicle, span.title);
+			}
 			route_vehicle.insertBefore(span, route_vehicle.firstChild);
 		}
 		

--
Gitblit v1.9.1