Skip to content

Commit 450c940

Browse files
committed
Added abbreviations in lang
1 parent e3a2b78 commit 450c940

File tree

4 files changed

+68
-59
lines changed

4 files changed

+68
-59
lines changed

src/dom.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ParticipantResult } from "brackets-model";
22
import { rankingHeader } from "./helpers";
3+
import { abbreviations } from "./lang";
34
import { Connection, FinalType, Placement, Ranking } from "./types";
45

56
/**
@@ -187,7 +188,7 @@ export function setupWin(participantContainer: HTMLElement, resultContainer: HTM
187188
participantContainer.classList.add('win');
188189

189190
if (participant.score === undefined)
190-
resultContainer.innerText = 'W';
191+
resultContainer.innerText = abbreviations.win;
191192
}
192193
}
193194

@@ -203,9 +204,9 @@ export function setupLoss(participantContainer: HTMLElement, resultContainer: HT
203204
participantContainer.classList.add('loss');
204205

205206
if (participant.forfeit)
206-
resultContainer.innerText = 'F'; // Forfeit.
207+
resultContainer.innerText = abbreviations.forfeit;
207208
else if (participant.score === undefined)
208-
resultContainer.innerText = 'L';
209+
resultContainer.innerText = abbreviations.loss;
209210
}
210211
}
211212

src/helpers.ts

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Match, ParticipantResult } from "brackets-model";
2-
import { RankingHeader, Ranking, RankingFormula, RankingHeaders, RankingItem, RankingMap } from "./types";
2+
import { headers } from "./lang";
3+
import { RankingHeader, Ranking, RankingFormula, RankingItem, RankingMap } from "./types";
34

45
/**
56
* Splits an array based on values of a given key of the objects of the array.
@@ -29,56 +30,6 @@ export function isMajorRound(roundNumber: number): boolean {
2930
return roundNumber === 1 || roundNumber % 2 === 0;
3031
}
3132

32-
/**
33-
* Headers of the ranking.
34-
*/
35-
const headers: RankingHeaders = {
36-
'rank': {
37-
text: '#',
38-
tooltip: 'Rank',
39-
},
40-
'id': {
41-
text: 'Name',
42-
tooltip: 'Name',
43-
},
44-
'played': {
45-
text: 'P',
46-
tooltip: 'Played',
47-
},
48-
'wins': {
49-
text: 'W',
50-
tooltip: 'Wins',
51-
},
52-
'draws': {
53-
text: 'D',
54-
tooltip: 'Draws',
55-
},
56-
'losses': {
57-
text: 'L',
58-
tooltip: 'Losses',
59-
},
60-
'forfeits': {
61-
text: 'F',
62-
tooltip: 'Forfeits',
63-
},
64-
'scoreFor': {
65-
text: 'SF',
66-
tooltip: 'Score For',
67-
},
68-
'scoreAgainst': {
69-
text: 'SA',
70-
tooltip: 'Score Against',
71-
},
72-
'scoreDifference': {
73-
text: '+/-',
74-
tooltip: 'Score Difference',
75-
},
76-
'points': {
77-
text: 'Pts',
78-
tooltip: 'Points',
79-
},
80-
}
81-
8233
/**
8334
* Returns the header for a ranking property.
8435
*

src/lang.ts

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Status } from "brackets-model";
22
import { isMajorRound } from "./helpers";
3-
import { FinalType, OriginHint } from "./types";
3+
import { FinalType, OriginHint, RankingHeaders } from "./types";
44

55
/**
66
* Returns an origin hint function based on rounds information.
@@ -159,4 +159,63 @@ export function getLoserBracketRoundName(roundNumber: number): string {
159159
return `LB Round ${roundNumber}`;
160160
}
161161

162-
// TODO: add letters as traduction (W, L, D, F and all ranking headers)
162+
/**
163+
* Abbreviations used in the viewer.
164+
*/
165+
export const abbreviations = {
166+
win: 'W',
167+
loss: 'L',
168+
forfeit: 'F',
169+
position: 'P',
170+
seed: '#',
171+
}
172+
173+
/**
174+
* Headers of the ranking.
175+
*/
176+
export const headers: RankingHeaders = {
177+
rank: {
178+
text: '#',
179+
tooltip: 'Rank',
180+
},
181+
id: {
182+
text: 'Name',
183+
tooltip: 'Name',
184+
},
185+
played: {
186+
text: 'P',
187+
tooltip: 'Played',
188+
},
189+
wins: {
190+
text: abbreviations.win,
191+
tooltip: 'Wins',
192+
},
193+
draws: {
194+
text: 'D',
195+
tooltip: 'Draws',
196+
},
197+
losses: {
198+
text: abbreviations.loss,
199+
tooltip: 'Losses',
200+
},
201+
forfeits: {
202+
text: abbreviations.forfeit,
203+
tooltip: 'Forfeits',
204+
},
205+
scoreFor: {
206+
text: 'SF',
207+
tooltip: 'Score For',
208+
},
209+
scoreAgainst: {
210+
text: 'SA',
211+
tooltip: 'Score Against',
212+
},
213+
scoreDifference: {
214+
text: '+/-',
215+
tooltip: 'Score Difference',
216+
},
217+
points: {
218+
text: 'Pts',
219+
tooltip: 'Points',
220+
},
221+
}

src/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,7 @@ export class BracketsViewer {
366366
if (!this.config.showSlotsOrigin) return;
367367
if (!this.config.showLowerBracketSlotsOrigin && inLowerBracket) return;
368368

369-
// 'P' for position (where the participant comes from) and '#' for actual seeding.
370-
const origin = inLowerBracket ? `P${participant.position}` : `#${participant.position}`;
371-
369+
const origin = (inLowerBracket ? lang.abbreviations.position : lang.abbreviations.seed) + participant.position;
372370
dom.addTeamOrigin(nameContainer, origin, this.config.participantOriginPlacement);
373371
}
374372

0 commit comments

Comments
 (0)