Try and fix but broke it. Deprecated earlier than planned
This commit is contained in:
parent
b11ce6922d
commit
c1ad8c7244
@ -34,9 +34,11 @@ async function parse(data) {
|
||||
}
|
||||
|
||||
async function displayOptions(data) {
|
||||
if (data.length){
|
||||
for (service in data) {
|
||||
if (data[service]) {
|
||||
const serviceData = data[service]
|
||||
if (serviceData?.stops) {
|
||||
const lastStop = serviceData?.stops[(serviceData['stops'].length - 1)]
|
||||
log(`displayOptions: data[${service}] = ${serviceData}`, 'dbug')
|
||||
let button = `
|
||||
@ -53,13 +55,13 @@ async function displayOptions(data) {
|
||||
document.getElementById('train_options').style = 'display:block;'
|
||||
return data
|
||||
}
|
||||
}
|
||||
}}}
|
||||
|
||||
async function displayOne(object) {
|
||||
// Display a single service
|
||||
const dataTableHead = `
|
||||
<p id='data_headcode'>${object['headcode']}</p>
|
||||
<p id='data_piscode'>PIS Code: ${object['pis']}</p>
|
||||
<p id='data_headcode'>${object?.headcode}</p>
|
||||
<p id='data_piscode'>PIS Code: ${object?.pis}</p>
|
||||
<table id='data_table'>
|
||||
<tr>
|
||||
<th>Location</th>
|
||||
@ -70,20 +72,22 @@ async function displayOne(object) {
|
||||
const dataTableClose = `
|
||||
</table>`
|
||||
let publicStops = []
|
||||
for (const stop of object['stops']) {
|
||||
if (stop['isPublic']) {
|
||||
publicStops.push(stop)
|
||||
}
|
||||
}
|
||||
console.log(publicStops)
|
||||
stopRows = ''
|
||||
for (const stop of publicStops) {
|
||||
stopRows += await createPublicStopTableRow(stop)
|
||||
}
|
||||
// If there are no public stops, show non-public locations
|
||||
if (!publicStops.length) {
|
||||
let stopRows = ''
|
||||
if (object?.stops) {
|
||||
for (const stop of object['stops']) {
|
||||
stopRows += await createPublicStopTableRow(stop, 'wtt')
|
||||
if (stop['isPublic']) {
|
||||
publicStops.push(stop)
|
||||
}
|
||||
}
|
||||
console.log(publicStops)
|
||||
for (const stop of publicStops) {
|
||||
stopRows += await createPublicStopTableRow(stop)
|
||||
}
|
||||
// If there are no public stops, show non-public locations
|
||||
if (!publicStops?.length) {
|
||||
for (const stop of object['stops']) {
|
||||
stopRows += await createPublicStopTableRow(stop, 'wtt')
|
||||
}
|
||||
}
|
||||
}
|
||||
const displayBox = document.getElementById('train_data')
|
||||
|
Reference in New Issue
Block a user