Files
puzzle-scoreboard/app/views/contests/_selectors.html.slim
sto cd032e3456
Some checks failed
CI / scan_ruby (push) Failing after 15s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 14s
CI / test (push) Successful in 42s
Show offline participants on public scoreboard + filter
2025-11-06 10:40:47 +01:00

45 lines
1.8 KiB
Plaintext

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();
})