Skip to content

Commit

Permalink
refactor code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jan 4, 2024
1 parent f819f73 commit c82d0b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
18 changes: 10 additions & 8 deletions app/views/user/perfStat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,7 @@ object perfStat:
)(viewTheGames())
)
),
ratingChart.isDefined option div(cls := "rating-history-container")(
div(cls := "rating-history-container")(
div(cls := "time-selector-buttons"),
(spinner),
div(cls := "chart-container")(canvas(cls := "rating-history")),
div(id := "time-range-slider")
)
),
ratingChart.isDefined option ratingHistoryContainer,
div(cls := "box__pad perf-stat__content")(
glicko(user, perfType, user.perfs(perfType), percentile),
counter(stat.count),
Expand All @@ -73,6 +66,15 @@ object perfStat:
)
)

def ratingHistoryContainer = div(cls := "rating-history-container")(
div(cls := "rating-history-container")(
div(cls := "time-selector-buttons"),
spinner,
div(cls := "chart-container")(canvas(cls := "rating-history")),
div(id := "time-range-slider")
)
)

private def decimal(v: Double) = lila.common.Maths.roundDownAt(v, 2)

private def glicko(u: User, perfType: PerfType, perf: Perf, percentile: Option[Double])(using
Expand Down
7 changes: 1 addition & 6 deletions app/views/user/show/header.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,7 @@ object header:
val hideTroll = u.marks.troll && !ctx.is(u)
div(id := "us_profile")(
if info.ratingChart.isDefined && (!u.lame || ctx.is(u) || isGranted(_.UserModView)) then
div(cls := "rating-history-container")(
div(cls := "time-selector-buttons"),
(spinner),
div(cls := "chart-container")(canvas(cls := "rating-history")),
div(id := "time-range-slider")
)
views.html.user.perfStat.ratingHistoryContainer
else (ctx.is(u) && u.count.game < 10) option newPlayer(u),
div(cls := "profile-side")(
div(cls := "user-infos")(
Expand Down

0 comments on commit c82d0b6

Please sign in to comment.