From f71459307aeb7eaee72a76d3e7a0041ea5c97a8a Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 30 Dec 2017 01:16:47 +0100 Subject: [PATCH] Prepare templating mechanism for driver infobox --- index.html | 2 +- js/main.js | 6 ++++-- js/util.js | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 9447c2d..c275959 100644 --- a/index.html +++ b/index.html @@ -93,7 +93,7 @@
Rennteilnehmer
-
+
diff --git a/js/main.js b/js/main.js index 1ade6cf..d2b7a0c 100644 --- a/js/main.js +++ b/js/main.js @@ -64,9 +64,11 @@ preprocessor.load(function(data) { $(event.currentTarget).addClass("selected"); // Fetch race data var rdata = slyelement.curRaces.filter(r => r.raceInfo.raceId == raceI)[0]; - // Put information about race into info box + // Put information about race into race info box $("#race-infobox").html(renderRaceInfoBox(rdata)); // See util.js - // Hand off to diagram rendering + // Put information about drivers into driver info box + $("#driver-infobox").html(renderDriverInfoBox(rdata)); // See util.js + // Hand off to diagram rendering $("#lineGraphBox").empty(); createLineGraph("#lineGraphBox", rdata); }); diff --git a/js/util.js b/js/util.js index e62fb32..ed03079 100644 --- a/js/util.js +++ b/js/util.js @@ -163,3 +163,19 @@ function renderRaceInfoBox(race) { content += ""; return content; } + +function renderDriverInfoBox(race) { + var raceInfo = race.raceInfo; + var circuit = preprocessor.getResults().circuits[raceInfo.circuitId]; + console.log(raceInfo); + var content = ""; + + content = "

"+raceInfo.name+"

"; + content += "
"+circuit.name+" ("+circuit.location+", "+circuit.country+")
"; + content += "
"+raceInfo.date.toLocaleDateString("de-DE")+"
" + content += "
"; + content += "See Race on Wikipedia "; + content += "See Circuit on Wikipedia"; + content += "
"; + return content; +}