From cc6f6751958bfddff56e5e1f048f844a13acb85c Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 22 Dec 2017 13:57:42 +0100 Subject: [PATCH] optimized loading of the race data --- js/main.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/js/main.js b/js/main.js index ef1a9fa..d1d1454 100644 --- a/js/main.js +++ b/js/main.js @@ -6,6 +6,7 @@ var slyelement = { obj: {}, + curRaces: {}, el: '.frame', options: { horizontal: 1, @@ -44,19 +45,19 @@ preprocessor.load(function(data) { // Someone chose a year yearSelector.change(function(event) { var selectedYear = $(event.target).val(); - var races = processor.getRacesByYear(selectedYear); + slyelement.curRaces = processor.getRacesByYear(selectedYear); $("#courseSelection").empty(); - for(var race in races) { - $("#courseSelection").append("
  • " + races[race].raceInfo.name +" " + races[race].raceInfo.date + "
  • "); + for(var race in slyelement.curRaces) { + var raceD = slyelement.curRaces[race]; + $("#courseSelection").append("
  • " + raceD.raceInfo.name +" " + raceD.raceInfo.date + "
  • "); } $("#courseSelection li").click(function(event) { - var race = event.target.attributes.data.value; + var raceI = event.target.attributes.data.value; + var rdata = slyelement.curRaces.filter(r => r.raceInfo.raceId == raceI)[0]; $("#lineGraphBox").empty(); - createLineGraph("#lineGraphBox", processor.getRace(race)); + createLineGraph("#lineGraphBox", rdata); }); - slyelement.obj.reload(); - var raceData = races[0]; - + slyelement.obj.reload(); }); $(window).resize(function(e) {