Web Dev Solutions

Catalin Mititiuc

From 98e4fd58d8c222652f3a5bd1d8a76f7618824e17 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Wed, 22 May 2024 09:12:47 -0700 Subject: Use observable for end move and prone flag --- src/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index 298f961..53cbf2e 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ import * as panzoom from './modules/pan-zoom.js'; import * as gameboard from './modules/gameboard.js'; import * as recordSheet from './modules/record_sheet.js'; import * as mapSelectDialog from './modules/map_select_dialog.js'; +import { Observable } from './modules/observable.js'; globalThis.svgns = 'http://www.w3.org/2000/svg'; @@ -131,7 +132,7 @@ document.querySelectorAll('.end-turn').forEach(el => clearMoveEndedIndicators(opponentRecords); gameboard.clearFiringArcs(opponent); - gameboard.select(firstOpponentRecord); + Observable.notify('select', firstOpponentRecord); }) ); @@ -157,12 +158,11 @@ gameboard.setDistanceCallback((count = '-') => { distanceOutput.style.display = count === '-' ? 'none' : 'block'; }); -gameboard.setProneFlagCallback(checked => proneToggle.checked = checked); +Observable.subscribe('proneflag', checked => proneToggle.checked = checked); -document.querySelectorAll('.end-move').forEach(el => el.addEventListener('click', () => { - recordSheet.endMove(); - gameboard.endMove(); -})); +document.querySelectorAll('.end-move').forEach(el => + el.addEventListener('click', () => Observable.notify('endmove')) +); document.querySelector('#fullscreen').addEventListener('click', () => { if (!document.fullscreenElement) { -- cgit v1.2.3