Skip to content

Commit bf81c5b

Browse files
committed
Implement dropNLastRounds
1 parent dd46ae2 commit bf81c5b

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type Options = {
6262
liveMatchBorderColor: string,
6363
liveMatchBgColor: string,
6464
distanceBetweenScorePairs: number,
65-
hideNLastRounds: number,
65+
dropNLastRounds: number,
6666

6767
onMatchClick: (match: Partial<Match>) => void,
6868

lib/draw/get_round_titles.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const get_default_round_name = (rounds_count, round_index) => {
88
return `1/${Math.pow(2, rounds_count - round_index - 1)}`
99
}
1010

11-
export const get_round_titles = (all_data, get_option) => {
12-
return all_data.rounds.map((r, i) => {
11+
export const get_round_titles = (all_data, renderableRoundsCount, get_option) => {
12+
return all_data.rounds.slice(0, renderableRoundsCount).map((r, i) => {
1313
const wrapper = document.createElement('div')
1414
wrapper.className = 'round-title'
1515

lib/draw/render_content.mjs

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ export const render_content = (all_data, shell, get_option) => {
4343

4444
tryAddLackingRounds(all_data, get_option)
4545

46-
shell.round_titles_wrapper.append(...get_round_titles(all_data, get_option))
46+
const renderableRoundsCount = all_data.rounds.length - get_option('dropNLastRounds')
47+
48+
shell.round_titles_wrapper.append(...get_round_titles(all_data, renderableRoundsCount, get_option))
4749

4850
shell.matches_positioner.innerHTML = ''
4951

5052
const round_elements = []
51-
all_data.rounds.forEach((_, round_index) => {
53+
all_data.rounds.slice(0, renderableRoundsCount).forEach((_, round_index) => {
5254

5355
const round_el = get_round_element(all_data, round_index, get_option)
5456

lib/options/options_meta.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const GENERAL_OPTIONS = {
4242
default_value: false
4343
},
4444

45-
hideNLastRounds: {
45+
dropNLastRounds: {
4646
type: 'number',
4747
default_value: 0
4848
}

0 commit comments

Comments
 (0)