index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
-rw-r--r-- | src/index.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/index.js b/src/index.js index a8b766a..3a8a48e 100644 --- a/src/index.js +++ b/src/index.js @@ -9,7 +9,8 @@ const mapPlaceholder = document.querySelector('.map-placeholder'), proneToggle = document.getElementById('toggle-prone-counter'), object = document.querySelector('object'); -object.addEventListener('load', function () { +object.addEventListener('load', function (e) { + console.log('object load listener', e); mapPlaceholder.remove(); this.style.opacity = 1; @@ -89,20 +90,24 @@ document.getElementById('toggle-prone-counter').addEventListener('input', functi object.data = `${localStorage.getItem('map') || 'map1'}.svg`; -document - .querySelector('#content input[type="checkbox"].visible') - .addEventListener('input', function () { - const divs = document.querySelectorAll('#content div'); - - divs.forEach(d => { - if (this.checked) { - d.style.display = d.id == 'record-sheet' ? 'flex' : 'block'; - } else { - d.style.display = 'none'; - } - }); +const contentVisToggleEl = document.querySelector('#content input[type="checkbox"].visible'); +contentVisToggleEl.checked = (localStorage.getItem('content-visibility') !== 'false'); + +const toggleContentVis = (function () { + document.querySelectorAll('#content div').forEach(div => { + if (this.checked) { + div.style.display = div.id == 'record-sheet' ? 'flex' : 'block'; + } else { + div.style.display = 'none'; + } }); + localStorage.setItem('content-visibility', this.checked); +}).bind(contentVisToggleEl); + +toggleContentVis(); +contentVisToggleEl.addEventListener('input', toggleContentVis); + const showButton = document.getElementById('show-dialog'), mapDialog = document.getElementById('map-dialog'), selectEl = mapDialog.querySelector('select'), |