Auto refresh feature on public scoreboards
All checks were successful
CI / scan_ruby (push) Successful in 19s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 38s

#12
#13
This commit is contained in:
sto
2025-12-08 17:11:47 +01:00
parent 1fc05bea63
commit ee250b96ad
8 changed files with 89 additions and 56 deletions

View File

@@ -1,15 +1,3 @@
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
@@ -17,29 +5,29 @@ javascript:
option value=-1
= t("contests.scoreboard.all_categories")
- @contest.categories.each do |category|
option value=category.id
= category.name
- if @category == category.id.to_s
option value=category.id selected=true
= category.name
- else
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();
document.getElementById('categories').addEventListener('change', (e) => {
addParam('category', e.target.value);
})
- if @contest.offline_form && @contest.puzzles.length < 2
.row
.col
input type="checkbox" id="offline" style="padding: 5px;"
- if @hide_offline
input type="checkbox" id="offline" style="padding: 5px;" checked=true
- else
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();
document.getElementById('offline').addEventListener('change', (e) => {
console.log('changed');
if (e.target.checked) addParam('hide_offline', e.target.checked);
else removeParam('hide_offline');
})