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 12:55:40 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-15 12:55:40 -0700 |
commit | bd31e3e4a64775d3e2ea2efeb5b2122e384b30e3 (patch) | |
tree | abf17daa0636791891405eda7ad96797debaf6fe /src | |
parent | 98f8464aeb4bdfa5ede0eda71f5285587c0ab76d (diff) |
Add ability to load a map file manually
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/index.js b/src/index.js index 3efa5a7..1a7a6c7 100644 --- a/src/index.js +++ b/src/index.js @@ -12,6 +12,7 @@ const mapPlaceholder = document.querySelector('.map-placeholder'), // fileName = localStorage.getItem('map') || (env === 'test' ? 'test_map' : 'map1'), fileName = localStorage.getItem('map') || 'map1', map = `assets/images/${fileName}.svg`, + fileInputEl = document.querySelector('input[type="file"]'), toggleContentVis = (function () { document.querySelectorAll('#content div').forEach(div => { @@ -64,6 +65,7 @@ function clearMoveEndedIndicators(records) { } function load() { + URL.revokeObjectURL(this.data); const svg = this.contentDocument.querySelector('svg'), startLocs = svg.querySelector('.start-locations'); @@ -156,3 +158,12 @@ document.querySelector('#download-save').addEventListener('click', e => { element.click(); // document.body.removeChild(element); }); + +document.querySelector('#upload-save').addEventListener('click', () => { + fileInputEl.click(); +}); + +document.querySelector('input[type="file"]').addEventListener('change', e => { + const [file] = fileInputEl.files; + document.querySelector('object').data = URL.createObjectURL(file); +}); |