From 75a0c37ea5e5a9fa395690984c373536e8efccfa Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Sat, 27 Apr 2024 13:10:43 -0700
Subject: Some cleanup
---
src/modules/recordSheet.js | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 src/modules/recordSheet.js
(limited to 'src/modules/recordSheet.js')
diff --git a/src/modules/recordSheet.js b/src/modules/recordSheet.js
new file mode 100644
index 0000000..99af18f
--- /dev/null
+++ b/src/modules/recordSheet.js
@@ -0,0 +1,32 @@
+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();
+}
--
cgit v1.2.3