Only re-create the graph if the target race id has changed

This commit is contained in:
Marcel 2017-12-29 17:17:21 +01:00
parent 508e224883
commit 1099a1ef23
1 changed files with 3 additions and 0 deletions

View File

@ -7,6 +7,7 @@
var slyelement = { var slyelement = {
obj: {}, obj: {},
curRaces: {}, curRaces: {},
curRaceId: 0,
el: '.frame', el: '.frame',
options: { options: {
horizontal: 1, horizontal: 1,
@ -62,6 +63,8 @@ preprocessor.load(function(data) {
"</li>"); "</li>");
$("#courseSelection li").click(function(event) { $("#courseSelection li").click(function(event) {
var raceI = event.currentTarget.attributes.data.value; var raceI = event.currentTarget.attributes.data.value;
if(slyelement.curRaceId == raceI){ return; }
slyelement.curRaceId = raceI;
var rdata = slyelement.curRaces.filter(r => r.raceInfo.raceId == raceI)[0]; var rdata = slyelement.curRaces.filter(r => r.raceInfo.raceId == raceI)[0];
$("#lineGraphBox").empty(); $("#lineGraphBox").empty();
createLineGraph("#lineGraphBox", rdata); createLineGraph("#lineGraphBox", rdata);