Skip to content

Commit

Permalink
Add option to toggle all servers in leaderboard page
Browse files Browse the repository at this point in the history
  • Loading branch information
Simyon264 committed Aug 23, 2024
1 parent 895e77b commit 18a225c
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions ReplayBrowser/Pages/Leaderboard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ else
Toggle server selection
</button>

<div class="collapse" id="serverSelectionCollapse">
<div class="collapse" id="serverSelectionCollapse" style="margin-bottom: 6px">
<div style="flex-direction: column; display: flex">
@{
var urls = Configuration.GetSection("ReplayUrls").Get<StorageUrl[]>()!;
Expand All @@ -77,19 +77,20 @@ else
var selectedServers = selectedServersQuery.Split(',');
foreach (var storage in urls)
{
// Server selection
<input
type="checkbox"
class="server-checkbox"
id="@storage.FallBackServerName.Replace(' ', '_')"
name="@storage.FallBackServerName.Replace(' ', '_')"
value="@storage.FallBackServerName"
checked="@selectedServers.Contains(storage.FallBackServerName)"
>
<label for="@storage.FallBackServerName.Replace(' ', '_')">@storage.FallBackServerName (@storage.FallBackServerId)</label>
// Server selection
<input
type="checkbox"
class="server-checkbox"
id="@storage.FallBackServerName.Replace(' ', '_')"
name="@storage.FallBackServerName.Replace(' ', '_')"
value="@storage.FallBackServerName"
checked="@selectedServers.Contains(storage.FallBackServerName)"
>
<label for="@storage.FallBackServerName.Replace(' ', '_')">@storage.FallBackServerName (@storage.FallBackServerId)</label>
}
}
</div>
<button class="btn btn-secondary" type="button" onclick="toggle()">Toggle all</button>
</div>
<button class="btn btn-outline-success" type="button" onclick="search()">Filter</button>
</div>
Expand Down Expand Up @@ -159,6 +160,15 @@ else
<script>
const allServersCount = document.getElementsByClassName("server-checkbox").length;
function toggle() {
let checkboxes = document.getElementsByClassName("server-checkbox");
let checked = Array.from(checkboxes).filter(x => x.checked).length;
let allChecked = checked === allServersCount;
for (let checkbox of checkboxes) {
checkbox.checked = !allChecked;
}
}
function changeTimeRange(timeRange) {
var uri = new URL(window.location.href);
uri.searchParams.set("timeRange", timeRange);
Expand Down

0 comments on commit 18a225c

Please sign in to comment.