Web Dev Solutions

Catalin Mititiuc

From 187faec2dfb7959c536d6847a61be912cff9275e Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Wed, 29 May 2024 18:02:18 -0700 Subject: Try to simplify trooper counter --- src/modules/record_sheet.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/modules/record_sheet.js') diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js index 2865309..33a21fe 100644 --- a/src/modules/record_sheet.js +++ b/src/modules/record_sheet.js @@ -81,12 +81,13 @@ function createWeaponIcon(type) { function createRecord(unit) { const { dataset: { allegiance, number, squad }} = unit, primaryWeapon = unit.querySelector('.primary-weapon'), - pw = primaryWeapon?.getAttribute('href').replace('#', '') || 'rifle', + pw = primaryWeapon.getAttributeNS(null, 'href').split('#').pop() || 'rifle', div = document.createElement('div', { is: 'soldier-record-block' }), spans = Array(6).fill('span').map(t => document.createElement(t)), [tn, sn, pwt, pwd, pwrs, pwrl] = spans; - div.setAttribute('class', 'soldier-record'); + div.classList.add('soldier-record'); + if (unit.classList.contains('selected')) div.classList.add('selected'); div.dataset.number = number; div.dataset.allegiance = allegiance; -- cgit v1.2.3