@@ -3,7 +3,7 @@ import { Participant, Match, MatchResults, ParticipantResult, StageType } from '
3
3
import { splitBy , getRanking , getOriginAbbreviation } from './helpers' ;
4
4
import * as dom from './dom' ;
5
5
import * as lang from './lang' ;
6
- import { Config , Connection , FinalType , MatchLocation , OriginHint , RankingItem , RoundName , ViewerData } from './types' ;
6
+ import { Config , Connection , FinalType , MatchLocation , OriginHint , ParticipantContainers , RankingItem , RoundName , ViewerData } from './types' ;
7
7
8
8
export class BracketsViewer {
9
9
@@ -305,49 +305,47 @@ export class BracketsViewer {
305
305
* @param roundNumber Number of the round.
306
306
*/
307
307
private createTeam ( participant : ParticipantResult | null , originHint : OriginHint , matchLocation : MatchLocation , roundNumber ?: number ) : HTMLElement {
308
- const participantContainer = dom . createParticipantContainer ( ) ;
309
- const nameContainer = dom . createNameContainer ( ) ;
310
- const resultContainer = dom . createResultContainer ( ) ;
308
+ const containers : ParticipantContainers = {
309
+ participant : dom . createParticipantContainer ( ) ,
310
+ name : dom . createNameContainer ( ) ,
311
+ result : dom . createResultContainer ( ) ,
312
+ }
311
313
312
314
if ( participant === null )
313
- nameContainer . innerText = 'BYE' ;
315
+ containers . name . innerText = 'BYE' ;
314
316
else
315
- this . renderParticipant ( participantContainer , nameContainer , resultContainer , participant , originHint , matchLocation , roundNumber ) ;
317
+ this . renderParticipant ( containers , participant , originHint , matchLocation , roundNumber ) ;
316
318
317
- participantContainer . append ( nameContainer , resultContainer ) ;
319
+ containers . participant . append ( containers . name , containers . result ) ;
318
320
319
321
if ( participant && participant . id !== null )
320
- this . setupMouseHover ( participant . id , participantContainer ) ;
322
+ this . setupMouseHover ( participant . id , containers . participant ) ;
321
323
322
- return participantContainer ;
324
+ return containers . participant ;
323
325
}
324
326
325
- // TODO: group containers into an object
326
-
327
327
/**
328
328
* Renders a participant.
329
329
*
330
- * @param participantContainer The participant container.
331
- * @param nameContainer The name container.
332
- * @param resultContainer The result container.
330
+ * @param containers Containers for the participant.
333
331
* @param participant The participant result.
334
332
* @param originHint Origin hint for the match.
335
333
* @param matchLocation Location of the match.
336
334
* @param roundNumber Number of the round.
337
335
*/
338
- private renderParticipant ( participantContainer : HTMLElement , nameContainer : HTMLElement , resultContainer : HTMLElement , participant : ParticipantResult , originHint : OriginHint , matchLocation : MatchLocation , roundNumber ?: number ) : void {
336
+ private renderParticipant ( containers : ParticipantContainers , participant : ParticipantResult , originHint : OriginHint , matchLocation : MatchLocation , roundNumber ?: number ) : void {
339
337
const found = this . participants . find ( item => item . id === participant . id ) ;
340
338
341
339
if ( found ) {
342
- nameContainer . innerText = found . name ;
343
- this . renderTeamOrigin ( nameContainer , participant , matchLocation , roundNumber ) ;
340
+ containers . name . innerText = found . name ;
341
+ this . renderTeamOrigin ( containers . name , participant , matchLocation , roundNumber ) ;
344
342
} else
345
- this . renderHint ( nameContainer , participant , originHint , matchLocation ) ;
343
+ this . renderHint ( containers . name , participant , originHint , matchLocation ) ;
346
344
347
- resultContainer . innerText = `${ participant . score || '-' } ` ;
345
+ containers . result . innerText = `${ participant . score || '-' } ` ;
348
346
349
- dom . setupWin ( participantContainer , resultContainer , participant ) ;
350
- dom . setupLoss ( participantContainer , resultContainer , participant ) ;
347
+ dom . setupWin ( containers . participant , containers . result , participant ) ;
348
+ dom . setupLoss ( containers . participant , containers . result , participant ) ;
351
349
}
352
350
353
351
/**
0 commit comments