Pairing tab in progress

This commit is contained in:
Claude Brisson
2023-12-19 04:02:18 +01:00
parent 47ceb8dbe7
commit fdcdd9c1a9
7 changed files with 123 additions and 16 deletions

View File

@@ -65,6 +65,7 @@
#if($tour)
const tour_id = ${tour.id};
const tour_rounds = ${tour.rounds};
let activeRound = 1;
#end
#set($datepickerLocale = $translate.datepickerLocale($request.lang, $request.loc))
const datepickerLocale = '$datepickerLocale';
@@ -100,6 +101,20 @@
onLoad(() => {
if (!window.location.hash && window.location.search) {
window.location.hash = '#information'
}
if (window.location.hash) {
let step = window.location.hash.substring(1);
let suffix = /^(.)+-(\d+)$/.exec(step);
if (suffix) {
step = suffix[1];
activeRound = parseInt(suffix[2]);
$('.active-round').forEach(e => e.innerHTML = `${activeRound}`);
}
chooseStep(step);
}
$('.step').on('click', e => {
let tab = e.target.closest('.step');
if (tab.classList.contains('active')) return;
@@ -125,10 +140,28 @@
}
});
// prev/next round buttons
if (activeRound === 1) {
$('.prev-round').addClass('disabled');
}
if (activeRound === tour_rounds) {
$('.next-round').addClass('disabled');
}
$('.prev-round').on('click', e => {
let base = window.location.href.replace(/-\d+$/g, '');
window.location.href = `#${base}-${activeRound - 1}`;
window.location.reload();
});
$('.next-round').on('click', e => {
let base = window.location.href.replace(/-\d+$/g, '');
window.location.href = `#${base}-${activeRound + 1}`;
window.location.reload();
});
});
// ]]#
#include('/js/tour-information.inc.js')
#include('/js/tour-registration.inc.js')
#include('/js/tour-pairing.inc.js')
</script>
<div id="invalid_character" class="hidden">Invalid character</div>
<script type="text/javascript" src="/lib/datepicker-1.3.4/datepicker-full.min.js"></script>