Fix logic around pis reset

This commit is contained in:
Fred Boniface 2023-04-25 00:16:24 +01:00
parent 0596b23355
commit a1a99698d3

View File

@ -33,9 +33,7 @@ async function insertData(json) {
<th class="stops">Stations</th> <th class="stops">Stations</th>
</tr>` </tr>`
let results = 0 let results = 0
for(var i = 0; i < json.length; i++) { // Break into separate function. Need to for(var i = 0; i < json.length; i++) { // Hopefully can style output with CSS
// iterate over stops and print them in the
// format: `AVN, PRI, SHH... etc.`
tableData += `<tr><td class="code">${json[i]['code']}</td> tableData += `<tr><td class="code">${json[i]['code']}</td>
<td class="stops">${json[i]['stops']}</td></tr>` <td class="stops">${json[i]['stops']}</td></tr>`
results++ results++
@ -48,7 +46,7 @@ async function insertData(json) {
} }
async function noData() { async function noData() {
const msg = '<p>No results found</p>' const msg = '<p id="result-table">No results found</p>'
document.getElementById('result-box').insertAdjacentHTML("beforeend", msg) document.getElementById('result-box').insertAdjacentHTML("beforeend", msg)
} }
@ -56,6 +54,6 @@ async function reset() {
document.getElementById('origin').value = "" document.getElementById('origin').value = ""
document.getElementById('destination').value = "" document.getElementById('destination').value = ""
document.getElementById('result-box').style = 'display:none' document.getElementById('result-box').style = 'display:none'
document.getElementById('result-box').innerHTML = '' // This removes the <span> results-count. I need to remove the <table> ONLY. document.getElementById('result-table').remove()
document.getElementById('crs-box').style = 'display:block' document.getElementById('crs-box').style = 'display:block'
} }