diff --git a/js/train-detail.js b/js/train-detail.js index e60dd33..1ae46dd 100644 --- a/js/train-detail.js +++ b/js/train-detail.js @@ -30,6 +30,7 @@ async function parse(data) { displayOne(data[0]) } displayOptions(data) + document.getElementById('train_data').style = 'display:block;' } async function displayOptions(data) { @@ -38,10 +39,13 @@ async function displayOptions(data) { async function displayOne(object) { // Display a single service immediately - const dataHead = ` + const dataTableHead = `

${object['headcode']}

-

${object['pis']}

+

PIS Code: ${object['pis']}

+ ` + const dataTableClose = ` +
` let publicStops = [] for (const stop of object['stops']) { if (stop['isPublic']) { @@ -51,18 +55,29 @@ async function displayOne(object) { console.log(publicStops) stopRows = '' for (const stop of publicStops) { - stopRows += await createStopTableRow(stop) + stopRows += await createPublicStopTableRow(stop) } const displayBox = document.getElementById('train_data') - displayBox.insertAdjacentHTML('beforeend', dataHead + stopRows) + displayBox.insertAdjacentHTML('beforeend', dataTableHead + stopRows + dataTableClose) } -async function createStopTableRow(stop) { +async function createPublicStopTableRow(stop) { + let data_tiploc = stop['tiploc'], public_arr = stop['publicArrival'], + public_dep = stop['publicDeparture'] + if (typeof data_tiploc === 'undefined') { + data_tiploc = '' + } + if (typeof public_arr === 'undefined') { + public_arr = '-' + } + if (typeof public_dep === 'undefined') { + public_dep = '-' + } return ` - ${stop['tiploc']} - ${stop['publicArrival']} - ${stop['publicDeparture']} + ${data_tiploc} + ${public_arr} + ${public_dep} ` } \ No newline at end of file diff --git a/styles/train-detail.css b/styles/train-detail.css new file mode 100644 index 0000000..187e18b --- /dev/null +++ b/styles/train-detail.css @@ -0,0 +1,16 @@ +#data_headcode { + color: var(--second-text-color); + font-size: 25px; + font-weight:bolder; +} + +#data_piscode { + color: var(--second-text-color); +} + +#data_table { + color: var(--second-text-color); + width: 200px; + margin: auto; +} + \ No newline at end of file diff --git a/train-detail.html b/train-detail.html index 77bfd58..fd98282 100644 --- a/train-detail.html +++ b/train-detail.html @@ -12,6 +12,7 @@ +