2019-04-22 05:19:31 +00:00
|
|
|
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');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-04-22 05:19:31 +00:00
|
|
|
mapSettings.addEventListener('submit', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2019-04-22 07:57:20 +00:00
|
|
|
generate()
|
2019-04-22 05:19:31 +00:00
|
|
|
});
|
|
|
|
|
2019-04-22 07:57:20 +00:00
|
|
|
generate()
|
|
|
|
|
2019-04-22 05:19:31 +00:00
|
|
|
map.addEventListener('load', () => {
|
|
|
|
spinner.classList.add('d-none');
|
|
|
|
map.classList.remove('d-none');
|
|
|
|
});
|