@@ -3,7 +3,7 @@ import { Participant, Match, MatchResults, ParticipantResult, ViewerData } from
3
3
import { splitBy , getRanking , rankingHeader } from "./helpers" ;
4
4
5
5
type ConnectionType = 'square' | 'straight' | false ;
6
- type Placement = 'before' | 'after' ;
6
+ type Placement = 'none' | ' before' | 'after' ;
7
7
8
8
interface Connection {
9
9
connectPrevious ?: ConnectionType ,
@@ -12,21 +12,21 @@ interface Connection {
12
12
13
13
interface Config {
14
14
/**
15
- * Where the position of a participant is placed.
15
+ * Where the position of a participant is placed relative to its name .
16
16
* - If `before`, the position is prepended before the team name. "#1 Team"
17
17
* - If `after`, the position is appended after the team name, in parentheses. "Team (#1)"
18
18
*/
19
- participantPositionPlacement : Placement ,
19
+ participantOriginPlacement : Placement ,
20
20
21
21
/**
22
- * Whether to show the position of a participant wherever possible.
22
+ * Whether to show the origin of a slot ( wherever possible) .
23
23
*/
24
- showParticipantPosition : boolean ,
24
+ showSlotsOrigin : boolean ,
25
25
26
26
/**
27
- * Whether to show the position of a participant in the lower bracket of an elimination stage.
27
+ * Whether to show the origin of a slot ( in the lower bracket of an elimination stage) .
28
28
*/
29
- showLowerBracketParticipantPosition : boolean ,
29
+ showLowerBracketSlotsOrigin : boolean ,
30
30
}
31
31
32
32
class BracketsViewer {
@@ -43,9 +43,9 @@ class BracketsViewer {
43
43
}
44
44
45
45
this . config = {
46
- participantPositionPlacement : config && config . participantPositionPlacement || 'before' ,
47
- showParticipantPosition : config && config . showParticipantPosition || true ,
48
- showLowerBracketParticipantPosition : config && config . showLowerBracketParticipantPosition || false ,
46
+ participantOriginPlacement : config && config . participantOriginPlacement || 'before' ,
47
+ showSlotsOrigin : config && config . showSlotsOrigin || true ,
48
+ showLowerBracketSlotsOrigin : config && config . showLowerBracketSlotsOrigin || false ,
49
49
} ;
50
50
51
51
switch ( data . stage . type ) {
@@ -252,10 +252,12 @@ class BracketsViewer {
252
252
} else {
253
253
const participant = this . participants . find ( participant => participant . id === team . id ) ;
254
254
255
- nameDOM . text ( participant === undefined ? 'TBD' : participant . name ) ;
256
- resultDOM . text ( team . score === undefined ? '-' : team . score ) ;
255
+ if ( participant ) {
256
+ nameDOM . text ( participant . name ) ;
257
+ this . renderTeamOrigin ( nameDOM , team , lowerBracket ) ;
258
+ }
257
259
258
- this . renderTeamPosition ( nameDOM , team , lowerBracket ) ;
260
+ resultDOM . text ( team . score === undefined ? '-' : team . score ) ;
259
261
260
262
if ( team . result && team . result === 'win' ) {
261
263
nameDOM . addClass ( 'win' ) ;
@@ -290,18 +292,19 @@ class BracketsViewer {
290
292
return teamDOM ;
291
293
}
292
294
293
- private renderTeamPosition ( name : JQuery , team : ParticipantResult , lowerBracket : boolean ) {
295
+ private renderTeamOrigin ( name : JQuery , team : ParticipantResult , lowerBracket : boolean ) {
294
296
if ( team . position === undefined ) return ;
295
- if ( ! this . config . showParticipantPosition ) return ;
296
- if ( ! this . config . showLowerBracketParticipantPosition && lowerBracket ) return ;
297
+ if ( this . config . participantOriginPlacement === 'none' ) return ;
298
+ if ( ! this . config . showSlotsOrigin ) return ;
299
+ if ( ! this . config . showLowerBracketSlotsOrigin && lowerBracket ) return ;
297
300
298
301
// 'P' for position (where the participant comes from) and '#' for actual seeding.
299
302
const text = lowerBracket ? `P${ team . position } ` : `#${ team . position } ` ;
300
303
301
- this . addPosition ( name , text , this . config . participantPositionPlacement ) ;
304
+ this . addTeamOrigin ( name , text , this . config . participantOriginPlacement ) ;
302
305
}
303
306
304
- private addPosition ( name : JQuery , text : string , placement : Placement , ) {
307
+ private addTeamOrigin ( name : JQuery , text : string , placement : Placement ) {
305
308
if ( placement === 'before' )
306
309
name . prepend ( $ ( '<span>' ) . text ( `${ text } ` ) ) ;
307
310
else
0 commit comments