Attempt fix null services
This commit is contained in:
parent
1313c41889
commit
b11ce6922d
@ -35,16 +35,17 @@ async function parse(data) {
|
|||||||
|
|
||||||
async function displayOptions(data) {
|
async function displayOptions(data) {
|
||||||
for (service in data) {
|
for (service in data) {
|
||||||
|
if (data[service]) {
|
||||||
const serviceData = data[service]
|
const serviceData = data[service]
|
||||||
const lastStop = serviceData['stops'][(serviceData['stops'].length - 1)]
|
const lastStop = serviceData?.stops[(serviceData['stops'].length - 1)]
|
||||||
log(`displayOptions: data[${service}] = ${serviceData}`, 'dbug')
|
log(`displayOptions: data[${service}] = ${serviceData}`, 'dbug')
|
||||||
let button = `
|
let button = `
|
||||||
<button class='service_button' onclick='displayOne(data[${service}])'>
|
<button class='service_button' onclick='displayOne(data[${service}])'>
|
||||||
<span class='service_toc'>${serviceData?.operator || 'GW'}</span>
|
<span class='service_toc'>${serviceData?.operator || 'GW'}</span>
|
||||||
<span class='service_origin_time'>${serviceData['stops'][0]['wttDeparture']}</span>
|
<span class='service_origin_time'>${serviceData?.stops[0]['wttDeparture']}</span>
|
||||||
<span class='service_origin_tiploc'>${serviceData['stops'][0]['tiploc']}</span>
|
<span class='service_origin_tiploc'>${serviceData?.stops[0]['tiploc']}</span>
|
||||||
to
|
to
|
||||||
<span class='service_dest_tiploc'>${lastStop['tiploc']}</span>
|
<span class='service_dest_tiploc'>${lastStop?.tiploc}</span>
|
||||||
</button>
|
</button>
|
||||||
`
|
`
|
||||||
document.getElementById('train_options').insertAdjacentHTML('beforeend', button)
|
document.getElementById('train_options').insertAdjacentHTML('beforeend', button)
|
||||||
@ -52,6 +53,7 @@ async function displayOptions(data) {
|
|||||||
document.getElementById('train_options').style = 'display:block;'
|
document.getElementById('train_options').style = 'display:block;'
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function displayOne(object) {
|
async function displayOne(object) {
|
||||||
// Display a single service
|
// Display a single service
|
||||||
|
Reference in New Issue
Block a user