iwa-panda2

Manage Weather Data by International Weather Agency (Version 2)
Log | Files | Refs | README

commit 7b5cfca4b85c543189c6de7ea9511be61c315acd
parent 3f52ddae4a7441bd9016f9708cb69aba6378387b
Author: Johs <[email protected]>
Date:   Mon, 12 Jun 2023 14:48:29 +0200

tables update

Diffstat:
Mjs/panda.js | 27+++++++++++++++++++++------
Mviews/dashboard.html | 4+++-
2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/js/panda.js b/js/panda.js @@ -10,12 +10,27 @@ fetch(`http://localhost:8080/api/${token}`) windchills.sort(jsonSorter('windchill')); let slicedArray = windchills.slice(0, 5); - let weatherList = document.getElementById('weather-list'); - slicedArray.forEach(item => { - let listItem = document.createElement('li'); - listItem.textContent = item['windchill'] + " degrees Celsius, Location: " + item['location']; - weatherList.appendChild(listItem); - }) + // let weatherList = document.getElementById('weather-list'); + // slicedArray.forEach(item => { + // let listItem = document.createElement('li'); + // listItem.textContent = item['windchill'] + " degrees Celsius, Location: " + item['location']; + // weatherList.appendChild(listItem); + // }) + let weatherlist = document.querySelector('.table'); + for (i=0; i<5; i++) { + let newRow = weatherlist.insertRow() + let newCellRank = newRow.insertCell(); + let newTextRank = document.createTextNode(i+1 + '.'); + newCellRank.appendChild(newTextRank); + + let newCellZoo = newRow.insertCell(); + let newTextZoo = document.createTextNode(slicedArray[0].location); + newCellZoo.appendChild(newTextZoo); + + let newCellChill = newRow.insertCell(); + let newTextChill = document.createTextNode(slicedArray[0].windchill); + newCellChill.appendChild(newTextChill); + } }); diff --git a/views/dashboard.html b/views/dashboard.html @@ -30,7 +30,9 @@ <div class="content-title"> <h2>Top 5 - Zoo's</h2> </div> - <ol id="weather-list"></ol> + <table class="table"> + + </table> </div> </div>