world-ecoregion/map-generator/static/script.js

30 lines
748 B
JavaScript
Raw Normal View History

const mapSettings = document.getElementById('map-settings');
//const board = document.getElementById('board');
const map = document.getElementById('map');
const spinner = document.getElementById('spinner');
2019-04-22 07:57:20 +00:00
function generate() {
spinner.classList.remove('d-none');
const formData = new FormData(mapSettings)
if (!formData.get('seed')) {
formData.set('seed', (new Date()).getTime() % 1e5);
}
const queryString = new URLSearchParams(formData).toString()
map.src = '/map?' + queryString;
map.classList.add('d-none');
}
mapSettings.addEventListener('submit', (e) => {
e.preventDefault();
2019-04-22 07:57:20 +00:00
generate()
});
2019-04-22 07:57:20 +00:00
generate()
map.addEventListener('load', () => {
spinner.classList.add('d-none');
map.classList.remove('d-none');
});