Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-08-05 16:56:46 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-08-05 16:56:46 -0700
commit7c2b441c7cea59631f6fb0588271b0fb5f10a79a (patch)
treeafe393547b0123ffef1f9b1a890c3ab98c4ef693 /src/index.js
parentf35d716bd38d03285fa511f6794af5d93e88f4dc (diff)
WIP: view squad record sheets
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/index.js b/src/index.js
index 62c1128..decc0f8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -145,8 +145,7 @@ async function load() {
document.querySelectorAll('.end-turn').forEach(el =>
el.addEventListener('click', ({ target: { dataset: { allegiance: opponent }}}) => {
const dataSelector = `[data-allegiance="${opponent}"]`,
- opponentRecords = Array.from(document.querySelectorAll(`.soldier-record${dataSelector}:not(.inactive)`)),
- firstOpponentRecord = opponentRecords.sort((el1, el2) => el1.dataset.number > el2.dataset.number).at(0);
+ opponentRecords = Array.from(document.querySelectorAll(`.soldier-record${dataSelector}:not(.inactive)`));
el.setAttribute('disabled', '');
updateTurnCounter();
@@ -155,9 +154,9 @@ document.querySelectorAll('.end-turn').forEach(el =>
gameboard.clearFiringArcs(opponent);
- if (firstOpponentRecord) {
- Observable.notify('select', firstOpponentRecord);
- firstOpponentRecord.scrollIntoView({ behavior: 'smooth' });
+ if (opponentRecords.length > 0) {
+ Observable.notify('select', opponentRecords.at(0));
+ //firstOpponentRecord.scrollIntoView({ behavior: 'smooth' });
}
})
);
@@ -260,25 +259,6 @@ document.querySelector('#toggle-grid-vis input').addEventListener('change', func
svg.querySelector('#dots').style.display = this.checked ? 'inline' : 'none';
});
-document.querySelectorAll('#record-sheet [data-allegiance]').forEach(el => {
- const squadNumbers = el.querySelectorAll(`.squad-number`);
- const recordContainer = el.querySelector('.records');
-
- squadNumbers.forEach(sn =>
- sn.addEventListener('click', function() {
- if (!this.classList.contains('selected')) {
- recordContainer.dataset.viewSquadNumber = this.dataset.number;
- console.log();
- squadNumbers.forEach(sn =>
- sn.classList[sn.dataset.number === this.dataset.number ? 'add' : 'remove']('selected')
- );
-
- if (el.querySelector('.soldier-record.selected')) Observable.notify('select');
- }
- })
- );
-});
-
document.querySelectorAll('.view-squad').forEach(b => b.addEventListener('click', e => {
const currentSquad = b.closest('.records-header').querySelector('.squad-number text');
const currentSquadContainer = b.closest('[id$="-record"]').querySelector(`.records > .squad-${currentSquad.textContent}`);