|
|
|
@ -14,6 +14,7 @@ struct HtmlOptions { |
|
|
|
let withTeamIndex: Bool |
|
|
|
let withTeamIndex: Bool |
|
|
|
let withScore: Bool |
|
|
|
let withScore: Bool |
|
|
|
let withPlannedDate: Bool |
|
|
|
let withPlannedDate: Bool |
|
|
|
|
|
|
|
let includeLoserBracket: Bool |
|
|
|
|
|
|
|
|
|
|
|
// Default initializer with all options defaulting to true |
|
|
|
// Default initializer with all options defaulting to true |
|
|
|
init( |
|
|
|
init( |
|
|
|
@ -21,13 +22,15 @@ struct HtmlOptions { |
|
|
|
withRank: Bool = true, |
|
|
|
withRank: Bool = true, |
|
|
|
withTeamIndex: Bool = true, |
|
|
|
withTeamIndex: Bool = true, |
|
|
|
withScore: Bool = true, |
|
|
|
withScore: Bool = true, |
|
|
|
withPlannedDate: Bool = true |
|
|
|
withPlannedDate: Bool = true, |
|
|
|
|
|
|
|
includeLoserBracket: Bool = false |
|
|
|
) { |
|
|
|
) { |
|
|
|
self.headName = headName |
|
|
|
self.headName = headName |
|
|
|
self.withRank = withRank |
|
|
|
self.withRank = withRank |
|
|
|
self.withTeamIndex = withTeamIndex |
|
|
|
self.withTeamIndex = withTeamIndex |
|
|
|
self.withScore = withScore |
|
|
|
self.withScore = withScore |
|
|
|
self.withPlannedDate = withPlannedDate |
|
|
|
self.withPlannedDate = withPlannedDate |
|
|
|
|
|
|
|
self.includeLoserBracket = includeLoserBracket |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -308,6 +311,13 @@ enum HtmlService { |
|
|
|
var brackets = "" |
|
|
|
var brackets = "" |
|
|
|
for round in tournament.rounds() { |
|
|
|
for round in tournament.rounds() { |
|
|
|
brackets = brackets.appending(HtmlService.bracket(round: round).html(options: options)) |
|
|
|
brackets = brackets.appending(HtmlService.bracket(round: round).html(options: options)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if options.includeLoserBracket { |
|
|
|
|
|
|
|
if round.index == 1 { |
|
|
|
|
|
|
|
let sub = HtmlService.loserBracket(upperRound: round, hideTitle: true).html(options: options) |
|
|
|
|
|
|
|
template = template.appending(sub) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var winnerName = "" |
|
|
|
var winnerName = "" |
|
|
|
@ -326,6 +336,16 @@ enum HtmlService { |
|
|
|
brackets = brackets.appending(winner) |
|
|
|
brackets = brackets.appending(winner) |
|
|
|
|
|
|
|
|
|
|
|
template = template.replacingOccurrences(of: "{{brackets}}", with: brackets) |
|
|
|
template = template.replacingOccurrences(of: "{{brackets}}", with: brackets) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if options.includeLoserBracket { |
|
|
|
|
|
|
|
for round in tournament.rounds() { |
|
|
|
|
|
|
|
if round.index > 1 { |
|
|
|
|
|
|
|
let sub = HtmlService.loserBracket(upperRound: round, hideTitle: true).html(options: options) |
|
|
|
|
|
|
|
template = template.appending(sub) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return template |
|
|
|
return template |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|