index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-15 18:08:24 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-15 18:08:24 -0700 |
commit | 021b8d3a9a25b751180781b000696841da83e0b1 (patch) | |
tree | b67f6b727ed90a2fe3e7030195bbf720d7ba7e7b /src/index.js | |
parent | bd31e3e4a64775d3e2ea2efeb5b2122e384b30e3 (diff) |
Apply styles and map script to manually loaded files
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/index.js b/src/index.js index 1a7a6c7..3710843 100644 --- a/src/index.js +++ b/src/index.js @@ -65,16 +65,35 @@ function clearMoveEndedIndicators(records) { } function load() { - URL.revokeObjectURL(this.data); const svg = this.contentDocument.querySelector('svg'), - startLocs = svg.querySelector('.start-locations'); + startLocs = svg.querySelector('.start-locations'), + scriptEl = this.contentDocument.querySelector('script'); + + const linkEl = document.createElement('link'); + linkEl.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); + linkEl.setAttribute('rel', 'stylesheet'); + linkEl.setAttribute('href', 'http://localhost:8080/assets/css/map.css'); + linkEl.setAttribute('type', 'text/css'); + linkEl.onload = function (e) { + console.log('map.css loaded'); + + if (scriptEl) { + scriptEl.onload = function () { + console.log('map.js loaded'); + gameboard.start(svg); + recordSheet.start(startLocs, gameboard.getUnits(), gameboard.unSelect, gameboard.select); + }; + scriptEl.setAttribute('href', 'http://localhost:8080/map.js'); + } + }; + svg.prepend(linkEl); this.style.opacity = 1; mapPlaceholder.style.opacity = 0; + URL.revokeObjectURL(this.data); panzoom.start(svg); - gameboard.start(svg); - recordSheet.start(startLocs, gameboard.getUnits(), gameboard.unSelect, gameboard.select); + recordSheet.clear(); } document.querySelectorAll('.end-turn').forEach(el => |