index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-08-02 14:44:51 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-08-02 14:51:31 -0700 |
commit | eb3c919f7d5562e0732349f8382534c618bef448 (patch) | |
tree | f6a16356d6d70ba66aa6db76afcdbdefa2c8eea0 | |
parent | a042537c8eeff2e45bcc5d678e2657f4f542ec93 (diff) |
Deselect when view changes to another squad
-rw-r--r-- | src/index.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/index.js b/src/index.js index cc4dd6d..e6a8802 100644 --- a/src/index.js +++ b/src/index.js @@ -266,10 +266,15 @@ document.querySelectorAll('#record-sheet [data-allegiance]').forEach(el => { squadNumbers.forEach(sn => sn.addEventListener('click', function() { - recordContainer.dataset.viewSquadNumber = this.dataset.number; - squadNumbers.forEach(sn => - sn.classList[sn.dataset.number === this.dataset.number ? 'add' : 'remove']('selected') - ); + 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'); + } }) ); }); |