Add ability to load a map file manually

This commit is contained in:
2025-06-16 22:41:30 -07:00
parent 591edb4165
commit 9769b26ddb
5 changed files with 22 additions and 1 deletions

View File

@@ -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);
});