Show offline participants on public scoreboard + filter
This commit is contained in:
45
app/views/contests/_selectors.html.slim
Normal file
45
app/views/contests/_selectors.html.slim
Normal file
@@ -0,0 +1,45 @@
|
||||
javascript:
|
||||
function updateParams() {
|
||||
categorySelectEl = document.getElementById('categories');
|
||||
offlineInputEl = document.getElementById('offline');
|
||||
if (categorySelectEl && !offlineInputEl) {
|
||||
window.location.replace(`/public/#{@contest.slug}?category=${categorySelectEl.value}`);
|
||||
} else if (!categorySelectEl) {
|
||||
window.location.replace(`/public/#{@contest.slug}?hide_offline=${offlineInputEl.checked}`);
|
||||
} else {
|
||||
window.location.replace(`/public/#{@contest.slug}?category=${categorySelectEl.value}&hide_offline=${offlineInputEl.checked}`);
|
||||
}
|
||||
}
|
||||
- if @contest.categories.size > 0
|
||||
.row
|
||||
.col
|
||||
select.mb-2 id="categories" style="padding: 5px"
|
||||
option value=-1
|
||||
= t("contests.scoreboard.all_categories")
|
||||
- @contest.categories.each do |category|
|
||||
option value=category.id
|
||||
= category.name
|
||||
javascript:
|
||||
categorySelectEl = document.getElementById('categories');
|
||||
urlParams = new URLSearchParams(window.location.search);
|
||||
selectedCategory = urlParams.get('category');
|
||||
Array.from(categorySelectEl.children).forEach((option) => {
|
||||
if (option.value == selectedCategory) option.selected = true;
|
||||
});
|
||||
categorySelectEl.addEventListener('change', (e) => {
|
||||
updateParams();
|
||||
})
|
||||
- if @contest.offline_form
|
||||
.row
|
||||
.col
|
||||
input type="checkbox" id="offline" style="padding: 5px;"
|
||||
label for="offline"
|
||||
.ms-2
|
||||
= t("contests.scoreboard.hide_offline")
|
||||
javascript:
|
||||
offlineInputEl = document.getElementById('offline');
|
||||
urlParams = new URLSearchParams(window.location.search);
|
||||
offlineInputEl.checked = urlParams.get('hide_offline') == "true";
|
||||
offlineInputEl.addEventListener('change', (e) => {
|
||||
updateParams();
|
||||
})
|
||||
Reference in New Issue
Block a user