index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/map.js')
-rw-r--r-- | src/map.js | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1,18 +1,21 @@ const svgns = "http://www.w3.org/2000/svg"; +const dataset = document.currentScript.dataset; const svg = document.querySelector('svg'); -const cellTemplate = svg.querySelector('#hex'); const gb = svg.querySelector('.gameboard'); const bg = svg.querySelector('#background'); const imageMaps = svg.querySelector('#image-maps'); -const grid = gb.querySelector('.grid'); -const dataset = document.currentScript.dataset; + if ('cols' in dataset && 'rows' in dataset) { + const cellTemplate = svg.querySelector('#hex'); + const grid = gb.querySelector('.grid'); + createCells(grid, dataset, cellTemplate.id); - setElAttrs(bg, calcComputedBboxFor(imageMaps)); - svg.setAttribute('viewBox', formatForViewBox(calcComputedBboxFor(gb))); } +setElAttrs(bg, calcComputedBboxFor(imageMaps)); +svg.setAttribute('viewBox', formatForViewBox(calcComputedBboxFor(gb))); + function setElAttrs(el, attrs) { for (key in attrs) { el.setAttributeNS(null, key, attrs[key]); |