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) {
|
async function displayOptions(data) {
|
||||||
for (service in data) {
|
for (service in data) {
|
||||||
const serviceData = data[service]
|
if (data[service]) {
|
||||||
const lastStop = serviceData['stops'][(serviceData['stops'].length - 1)]
|
const serviceData = data[service]
|
||||||
log(`displayOptions: data[${service}] = ${serviceData}`, 'dbug')
|
const lastStop = serviceData?.stops[(serviceData['stops'].length - 1)]
|
||||||
let button = `
|
log(`displayOptions: data[${service}] = ${serviceData}`, 'dbug')
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
document.getElementById('train_options').style = 'display:block;'
|
||||||
|
return data
|
||||||
}
|
}
|
||||||
document.getElementById('train_options').style = 'display:block;'
|
|
||||||
return data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function displayOne(object) {
|
async function displayOne(object) {
|
||||||
|
Reference in New Issue
Block a user