Web Dev Solutions

Catalin Mititiuc

From 5afa53ef7aa1ecf50d2ba2eaebb4df0b4337a8a9 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Sat, 6 Apr 2024 15:09:09 -0700 Subject: Add turn counter and inning indicator --- index.html | 6 ++++++ index.js | 17 ++++++++++++++++- style.css | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 1b0e219..a317b49 100644 --- a/index.html +++ b/index.html @@ -242,6 +242,12 @@
Prone: + Turn: + + 0 + + +
diff --git a/index.js b/index.js index e52bf71..ee2d3ad 100644 --- a/index.js +++ b/index.js @@ -915,7 +915,22 @@ document.querySelectorAll('.end-move').forEach(el => el.addEventListener('click' document.querySelectorAll('.end-turn').forEach(el => el.addEventListener('click', ({ target: { dataset: { allegiance }}}) => { let dataSelector = `[data-troop-allegiance="${allegiance}"]`, - records = Array.from(qA(`.soldier-record${dataSelector}`)); + records = Array.from(qA(`.soldier-record${dataSelector}`)), + turnCounter = document.getElementById('turn-count'), + { textContent: count, dataset: { update }} = turnCounter; + + el.setAttribute('disabled', ''); + + document + .querySelector(`button.end-turn:not([data-allegiance="${allegiance}"])`) + .removeAttribute('disabled'); + + if (update == '1') { + turnCounter.children.namedItem('count').textContent++ + turnCounter.dataset.update = '0'; + } else { + turnCounter.dataset.update = '1'; + } qA(`#firing-arcs ${dataSelector}`).forEach(el => el.remove()); diff --git a/style.css b/style.css index 4d288b9..a6387c4 100644 --- a/style.css +++ b/style.css @@ -400,6 +400,14 @@ img.logo { display: block; } +#turn-count[data-update="0"] span.inning-bottom { + display: none; +} + +#turn-count[data-update="1"] span.inning-top { + display: none; +} + @media (width >= 1800px) { #record-sheet { flex-direction: row; -- cgit v1.2.3