+
+
+
+ + +
+
+
+ +
-

Hallo!

+

Hallo F1-Fan!

- Mit Bootstrap sieht alles per Default ein wenig hübscher aus.
- Eingerückt wird mit 2 Leerzeichen pro Einrückungsebene.
- Charset ist UTF-8.
- TODO + Hier ist noch viel zutun ...

@@ -89,4 +92,4 @@ - \ No newline at end of file + diff --git a/js/main.js b/js/main.js index 71b0ea0..68e24f4 100644 --- a/js/main.js +++ b/js/main.js @@ -5,7 +5,12 @@ */ preprocessor.load(function(data) { + // Some sample code for a year selector - TODO: Improve a lot and move somewhere else + var yearSelector = $("#seasonByYearSelector"); + var seasons = preprocessor.getResults().seasons; + for(var year in seasons) yearSelector.append(""); - createTestPieChart("#testchartbox", queries.getDriversByNationality()); + // No more test chart + //createTestPieChart("#testchartbox", queries.getDriversByNationality()); }); From 1c91eab49aca179bce72bd836b5ba42b2e3e4540 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 8 Dec 2017 13:50:59 +0100 Subject: [PATCH 2/2] Added queries to get race information. Added processor function to get all races of an given year --- js/processor.js | 9 ++++++++- js/queries.js | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/js/processor.js b/js/processor.js index d05e4ff..d08fbe8 100644 --- a/js/processor.js +++ b/js/processor.js @@ -8,7 +8,8 @@ var processor = { lapTimes: null, pitStops: null, qualifying: null, - results: null + results: null, + raceInfo: null }; race.drivers = queries.getDriversByRaceId(raceId); @@ -16,7 +17,13 @@ var processor = { race.qualifying = queries.getQualifingDataByRaceId(raceId); race.pitStops = queries.getPitStopsByRaceId(raceId); race.results = queries.getResultsByRaceId(raceId); + race.raceInfo = queries.getRaceById(raceId); return race; }, + + getRacesByYear: function(year) { + var races = queries.getRacesByYear(year); + return races.map(race => processor.getRace(race.raceId)); + } }; diff --git a/js/queries.js b/js/queries.js index fd13bfe..c7e97c8 100644 --- a/js/queries.js +++ b/js/queries.js @@ -109,6 +109,26 @@ var queries = { return myMap; }, + getRaceById: function(raceId){ + var rawData = preprocessor.getResults(); + return rawData.races[raceId]; + }, + + getRacesByYear: function(year){ + var rawData = preprocessor.getResults(); + + var races = []; + for(var key in rawData.races){ + if(rawData.races[key].year == year){ + races.push(rawData.races[key]); + } + } + races.sort((o1,o2) => o1["round"] - o2["round"]); + + return races; + + }, + getQualifingDataByRaceId: function(raceId) { var rawData = preprocessor.getResults();