pis #2

Merged
fred.boniface merged 76 commits from pis into main 2023-05-06 21:53:45 +01:00
Showing only changes of commit 833517b2dd - Show all commits

View File

@ -9,7 +9,7 @@ async function findByOrigDest() {
if (json == false) {
await noData()
} else {
await displayData(json)
await insertData(json)
}
document.getElementById('crs-box').style = 'display:none'
document.getElementById('result-box').style = 'display:block'
@ -22,7 +22,7 @@ async function fetchOrigDest() {
return {origin: orig, destination: dest}
}
async function displayData(json) {
async function insertData(json) {
// Receives the JSON Respose ([{},{}]) containing one or more possible
// PIS codes. Display the code and the stops with a method of scrolling between them.
// Maybe as a table or a carousel?
@ -36,7 +36,8 @@ async function displayData(json) {
div.insertAdjacentHTML("beforeend", tableHtml)
const table = document.getElementById('result-table')
const data = JSON.parse(json)
for(var i = 0; i < data.length; i++) {
for(var i = 0; i < data.length; i++) { // Break into separate function. Need to
// iterate over stops.
let row = `<tr><td class="code">${data[i][code]}</td>
<td class="stops">${data[i][stops]}</td></tr>`
table.insertAdjacentHTML("beforeend", row)