From 8a1836418ed78b0517e2da50c35e12ffaf2763ca Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 22 Apr 2023 22:19:37 +0100 Subject: [PATCH] Add more logic that may or may not work --- js/pis.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/pis.js b/js/pis.js index 4486d7c..6c46e5c 100644 --- a/js/pis.js +++ b/js/pis.js @@ -26,7 +26,21 @@ async function displayData(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? - log(`displayData: ${JSON.stringify(json)}`) + const div = document.getElementById('result-box') + const tableHtml = ` + + + + +
CodeStations
` + div.insertAdjacentHTML("beforeend", tableHtml) + const table = document.getElementById('result-table') + const data = JSON.parse(json) + for(var i = 0; i < data.length; i++) { + let row = `${data[i][code]} + ${data[i][stops]}` + table.insertAdjacentHTML("beforeend", row) + } } async function noData() {