From 3878852a8491247b3da8b9b25a2ceff6123b7994 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 30 Dec 2017 02:04:15 +0100 Subject: [PATCH] Add more data to driver table --- js/util.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/js/util.js b/js/util.js index e2fd3be..9163399 100644 --- a/js/util.js +++ b/js/util.js @@ -167,15 +167,27 @@ function renderRaceInfoBox(race) { function renderDriverInfoBox(race) { var raceInfo = race.raceInfo; var drivers = race.drivers; - console.log(raceInfo); - var content = ""; + // Assign results to drivers + for(var ri in race.results) { + var driverResult = race.results[ri]; + for(var di in drivers) { + var driver = drivers[di]; + // :-( + if(driverResult.driverId == driver.driverId) { + Object.assign(drivers[di], driverResult); + } + } + } + + var content = ""; // Table header content += ""; content += ""; content += ""; - content += ""; + content += ""; content += ""; + content += ""; content += ""; content += ""; content += ""; @@ -188,10 +200,16 @@ function renderDriverInfoBox(race) { content += ""; for(var di in drivers) { var driver = drivers[di]; + // Replace NaN with something proper + if(isNaN(driver.position)) { + driver.position = "-/-"; + } + console.log(driver); content += ""; - content += ""; + content += ""; content += ""; + content += ""; content += ""; content += ""; content += "";
#RankCodePointsForenameSurnameNationality
"+driver.number+""+driver.rank+""+driver.code+""+driver.points+""+driver.forename+""+driver.surname+""+driver.nationality+"