Don't throw error when no squads to view

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 22:41:33 -07:00
parent f70527bebb
commit 56bbbd9361

View File

@ -263,14 +263,13 @@ document.querySelectorAll('.view-squad').forEach(b => b.addEventListener('click'
const currentSquad = b.closest('.records-header').querySelector('.squad-number text'); const currentSquad = b.closest('.records-header').querySelector('.squad-number text');
const currentSquadContainer = b.closest('[id$="-record"]').querySelector(`.records > .squad-${currentSquad.textContent}`); const currentSquadContainer = b.closest('[id$="-record"]').querySelector(`.records > .squad-${currentSquad.textContent}`);
if (currentSquadContainer) {
if (b.value === 'next') { if (b.value === 'next') {
//const toSquad = currentSquadContainer.nextElementSibling || b.closest('[id$="-record"]').querySelector('.records > :first-child');
const toSquad = currentSquadContainer.nextElementSibling; const toSquad = currentSquadContainer.nextElementSibling;
if (!toSquad) return; if (!toSquad) return;
currentSquad.textContent = +toSquad.className.match(/\d+/); currentSquad.textContent = +toSquad.className.match(/\d+/);
currentSquadContainer.addEventListener('transitionend', e => { currentSquadContainer.addEventListener('transitionend', e => {
console.log('transitionend', 'current', currentSquadContainer, 'next', toSquad);
currentSquadContainer.style.display = 'none'; currentSquadContainer.style.display = 'none';
toSquad.style.display = 'block'; toSquad.style.display = 'block';
b.closest('[id$="-record"]').querySelector('.records').scrollTo(0, 0); b.closest('[id$="-record"]').querySelector('.records').scrollTo(0, 0);
@ -292,6 +291,7 @@ document.querySelectorAll('.view-squad').forEach(b => b.addEventListener('click'
currentSquadContainer.style.transform = 'translateX(100%)'; currentSquadContainer.style.transform = 'translateX(100%)';
} }
}
})); }));
contentVisToggleEl.addEventListener('input', toggleContentVis); contentVisToggleEl.addEventListener('input', toggleContentVis);