handle null headsign

This commit is contained in:
2026-07-08 14:09:40 -06:00
parent bb1be8a143
commit 9354988f93
2 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -300,6 +300,6 @@
</div>
</div>
<script type="module" src="/js/main.js?v=6"></script>
<script type="module" src="/js/main.js?v=7"></script>
</body>
</html>
+13 -2
View File
@@ -166,10 +166,21 @@ function renderVehicleIcon(vehicle) {
}
function vehiclePopupContent(vehicle) {
return `<b>${routeDesignator(vehicle.route)}</b> to <b>${vehicle.headsign?.replace(
let content = `<b>${routeDesignator(vehicle.route)}</b>`
if (vehicle.headsign) {
content += ` to <b>${vehicle.headsign.replace(
/^to /i,
""
)}</b>${vehicle.nearest_station ? `<br />@ ${vehicle.nearest_station?.name}` : ""}<br /><br /><small>vehicle #: ${vehicle.id}</small>`
)}</b>`
}
if (vehicle.nearest_station) {
content += `<br />@ ${vehicle.nearest_station.name}`
}
content += `<br /><br /><small>vehicle #: ${vehicle.id}</small>`
return content
}
function renderVehicle(vehicle) {