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