index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <Catalin.Mititiuc@gmail.com> | 2024-03-24 16:42:49 -0700 |
---|---|---|
committer | Catalin Mititiuc <Catalin.Mititiuc@gmail.com> | 2024-03-24 16:42:49 -0700 |
commit | b5143808d2d907102346413e70aa28641effcacc (patch) | |
tree | 9a758058ea6634a16b180a4e39f85fe7f4ac2482 /index.js | |
parent | 1935310fbf26769938a6e9a4008623c7b44fc5a8 (diff) |
WIP: template work
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -1,3 +1,42 @@ +class SoldierRecordBlock extends HTMLDivElement { + constructor() { + super(); + + let template = document.getElementById('soldier-record-block'); + let templateContent = template.content; + + const shadowRoot = this.attachShadow({ mode: "open" }); + shadowRoot.appendChild(templateContent.cloneNode(true)); + + customElements.define( + 'damage-block', + class extends HTMLSpanElement { + constructor() { + super(); + + let template = document.getElementById('damage-block'); + let templateContent = template.content; + + const shadowRoot = this.attachShadow({ mode: "open" }); + shadowRoot.appendChild(templateContent.cloneNode(true)); + } + }, + { extends: 'span' } + ); + + this.shadowRoot + .querySelector('input[type="number"]') + .addEventListener('click', e => e.stopPropagation()) + ; + } +} + +customElements.define( + 'soldier-record-block', + SoldierRecordBlock, + { extends: 'div'} +); + function isEven(n) { return n % 2 === 0; } @@ -274,6 +313,8 @@ document.querySelectorAll('.soldier-record').forEach(el => }) ); +document.querySelectorAll('#record-sheet .damage').forEach(el => el.addEventListener('click', e => e.stopPropagation())); + document.querySelectorAll('.set-firing-arc').forEach(el => el.addEventListener('click', e => { let selectedSoldier = document.querySelector('.soldier-record.selected'); |