Web Dev Solutions

Catalin Mititiuc

From a3bf726e40fe4ed529bdefa83c977af4b72791a9 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Tue, 30 Apr 2024 21:10:11 -0700 Subject: Allow placing a counter that doesn't already exist --- src/modules/record_sheet.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/modules/record_sheet.js') diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js index 736ffb2..6909249 100644 --- a/src/modules/record_sheet.js +++ b/src/modules/record_sheet.js @@ -94,12 +94,17 @@ export function getSelected() { } export function select(data) { - const selector = - `#record-sheet .soldier-record[data-number="${data.number}"][data-allegiance="${data.allegiance}"]` - unSelect(); + + if (!data) { + return; + } + + const { allegiance: al, number: n } = data, + selector = `.soldier-record[data-number="${n}"][data-allegiance="${al}"]`; + document.querySelector(selector).classList.add('selected'); - document.getElementById('toggle-prone-counter').checked = data.prone; + document.querySelector('#toggle-prone-counter').checked = data.prone; } export function endMove() { -- cgit v1.2.3