Web Dev Solutions

Catalin Mititiuc

export function unSelect() { const selected = getSelected(); if (selected) { selected.classList.remove('selected'); } document.getElementById('toggle-prone-counter').checked = false; } export function getSelected() { return document.querySelector('.soldier-record.selected'); } export function select(data) { const selector = `#record-sheet .soldier-record[data-number="${data.number}"][data-allegiance="${data.allegiance}"]` unSelect(); document.querySelector(selector).classList.add('selected'); document.getElementById('toggle-prone-counter').checked = data.prone; } export function endMove() { const selected = getSelected(); if (selected) { selected.classList.toggle('movement-ended'); } unSelect(); }