got first / second time working in color
This commit is contained in:
parent
59b15ac310
commit
ff4d5695a3
@ -38,7 +38,9 @@
|
||||
<!--<span class="timecell seconds">{{getPenaltySum(raceindex, team.idteam)}}</span>-->
|
||||
<app-timespan [theNumber]="getPenaltySum(raceindex, team.idteam)" [theUnit]="'s'"></app-timespan>
|
||||
</div>
|
||||
<div class="totalcell" [ngStyle]="{'grid-column':3, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
||||
<div class="totalcell" [ngStyle]="{'grid-column':3, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}"
|
||||
[class]="'timerank'+getTimeRank(raceindex, team.idteam)"
|
||||
>
|
||||
<app-timespan [theNumber]="getRaceTime(raceindex, team.idteam) | minutes" [theUnit]="'m'"></app-timespan>
|
||||
<app-timespan [theNumber]="getRaceTimeSeconds(raceindex, team.idteam)" [theUnit]="'s'"></app-timespan>
|
||||
</div>
|
||||
|
||||
@ -40,6 +40,11 @@
|
||||
.resultcell {
|
||||
font-size: 120%;
|
||||
}
|
||||
.best {
|
||||
background-color: forestgreen;
|
||||
.timerank0 {
|
||||
color: #1dd21d;
|
||||
font-weight: bolder;
|
||||
}
|
||||
.timerank1 {
|
||||
color :darkorange;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ export class PouleComponent implements OnInit {
|
||||
|
||||
protected teams: any[] = [];
|
||||
protected times: any[] = [];
|
||||
protected teamtotaltimes: {};
|
||||
|
||||
protected maxRaces = 0;
|
||||
private timesIndexed: {};
|
||||
@ -56,7 +57,8 @@ export class PouleComponent implements OnInit {
|
||||
console.log('loading data.');
|
||||
|
||||
// fetch the poule data
|
||||
this.championshipService.getTeamsInPoule(this.topmenuService.championship$.value, this.topmenuService.tier$.value, this.topmenuService.poule$.value)
|
||||
this.championshipService.getTeamsInPoule(this.topmenuService.championship$.value, this.topmenuService.tier$.value,
|
||||
this.topmenuService.poule$.value)
|
||||
.subscribe(val => {
|
||||
this.teams = val;
|
||||
|
||||
@ -69,11 +71,13 @@ export class PouleComponent implements OnInit {
|
||||
});
|
||||
this.maxRaces = maxRaces;
|
||||
});
|
||||
this.championshipService.getTimesInPoule(this.topmenuService.championship$.value, this.topmenuService.tier$.value, this.topmenuService.poule$.value).subscribe(val => {
|
||||
this.championshipService.getTimesInPoule(this.topmenuService.championship$.value, this.topmenuService.tier$.value,
|
||||
this.topmenuService.poule$.value).subscribe(val => {
|
||||
this.times = val;
|
||||
|
||||
// preprocess this array -> map idteam on the laptime array so we can index it using 0..n-1
|
||||
this.timesIndexed = {};
|
||||
this.teamtotaltimes = {};
|
||||
this.maxLaps = 0;
|
||||
this.times.forEach(t => {
|
||||
if (!this.timesIndexed[t.idteam]) {
|
||||
@ -84,10 +88,35 @@ export class PouleComponent implements OnInit {
|
||||
this.maxLaps = t.laptimesms.length;
|
||||
}
|
||||
|
||||
// get the list of times, sorted, for each team
|
||||
if (!this.teamtotaltimes[t.idteam]) {
|
||||
this.teamtotaltimes[t.idteam] = [];
|
||||
}
|
||||
const sum = t.laptimesms.reduce((prev, next) => {
|
||||
return prev + next;
|
||||
});
|
||||
this.teamtotaltimes[t.idteam].push(+(sum + (t.penaltysum * 1000)));
|
||||
|
||||
// calculate the best two
|
||||
this.bestTwo[t.idteam] = this.getBestTwo(t.idteam);
|
||||
});
|
||||
|
||||
console.log('totaltimes');
|
||||
console.log(this.teamtotaltimes);
|
||||
Object.keys(this.teamtotaltimes).forEach(key => {
|
||||
this.teamtotaltimes[key].sort((a, b) => {
|
||||
if (a < b) {
|
||||
return -1;
|
||||
} else if (a === b) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -160,6 +189,10 @@ export class PouleComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
getPenalisedRaceTime(raceNr: number, idTeam: number): number {
|
||||
return this.getRaceTime(raceNr, idTeam) + (this.getPenaltySum(raceNr, idTeam) * 1000);
|
||||
}
|
||||
|
||||
getRaceTime(raceNr: number, idTeam: number): number {
|
||||
const time = this.getLapTimes(raceNr, idTeam);
|
||||
if (!time) {
|
||||
@ -201,4 +234,15 @@ export class PouleComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
getTimeRank(raceindex, idteam: any) {
|
||||
if (!this.teamtotaltimes) {
|
||||
return -1;
|
||||
}
|
||||
let penalisedRaceTime = this.getPenalisedRaceTime(raceindex, idteam);
|
||||
let indexOf = this.teamtotaltimes[idteam].indexOf(penalisedRaceTime);
|
||||
console.log(penalisedRaceTime + ' ' + indexOf);
|
||||
console.log(this.teamtotaltimes[idteam]);
|
||||
console.log(this.timesIndexed[idteam]);
|
||||
return indexOf;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user