Try and fix but broke it. Deprecated earlier than planned

This commit is contained in:
Fred Boniface 2023-07-11 23:49:53 +01:00
parent b11ce6922d
commit c1ad8c7244
2 changed files with 21 additions and 17 deletions

View File

@ -34,9 +34,11 @@ async function parse(data) {
} }
async function displayOptions(data) { async function displayOptions(data) {
if (data.length){
for (service in data) { for (service in data) {
if (data[service]) { if (data[service]) {
const serviceData = data[service] const serviceData = data[service]
if (serviceData?.stops) {
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 = `
@ -53,13 +55,13 @@ 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
const dataTableHead = ` const dataTableHead = `
<p id='data_headcode'>${object['headcode']}</p> <p id='data_headcode'>${object?.headcode}</p>
<p id='data_piscode'>PIS Code: ${object['pis']}</p> <p id='data_piscode'>PIS Code: ${object?.pis}</p>
<table id='data_table'> <table id='data_table'>
<tr> <tr>
<th>Location</th> <th>Location</th>
@ -70,22 +72,24 @@ async function displayOne(object) {
const dataTableClose = ` const dataTableClose = `
</table>` </table>`
let publicStops = [] let publicStops = []
let stopRows = ''
if (object?.stops) {
for (const stop of object['stops']) { for (const stop of object['stops']) {
if (stop['isPublic']) { if (stop['isPublic']) {
publicStops.push(stop) publicStops.push(stop)
} }
} }
console.log(publicStops) console.log(publicStops)
stopRows = ''
for (const stop of publicStops) { for (const stop of publicStops) {
stopRows += await createPublicStopTableRow(stop) stopRows += await createPublicStopTableRow(stop)
} }
// If there are no public stops, show non-public locations // If there are no public stops, show non-public locations
if (!publicStops.length) { if (!publicStops?.length) {
for (const stop of object['stops']) { for (const stop of object['stops']) {
stopRows += await createPublicStopTableRow(stop, 'wtt') stopRows += await createPublicStopTableRow(stop, 'wtt')
} }
} }
}
const displayBox = document.getElementById('train_data') const displayBox = document.getElementById('train_data')
displayBox.innerHTML = '' displayBox.innerHTML = ''
displayBox.insertAdjacentHTML('beforeend', dataTableHead + stopRows + dataTableClose) displayBox.insertAdjacentHTML('beforeend', dataTableHead + stopRows + dataTableClose)

2
sw.js
View File

@ -1,6 +1,6 @@
/* Service Worker */ /* Service Worker */
const swVersion = '2023.6.7-1' const swVersion = '2023.6.7-990'
const cacheName = `owlboard-${swVersion}` const cacheName = `owlboard-${swVersion}`
const cacheIDs = [cacheName] const cacheIDs = [cacheName]
let staticCache = [ let staticCache = [