mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
Add loadMapFromUrl
This commit is contained in:
parent
f5c507a94b
commit
13ad4f941c
3 changed files with 41 additions and 2 deletions
18
src/loadMapFromUrl.js
Normal file
18
src/loadMapFromUrl.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function makeFileFromUrl(mapLink, callback) {
|
||||
fetch(mapLink, {
|
||||
method: 'GET',
|
||||
mode: 'cors',
|
||||
})
|
||||
.then(response => response.blob())
|
||||
.then(blob => callback(blob));
|
||||
}
|
||||
|
||||
function loadMapFromUrl(uploadFile) {
|
||||
const url = new URL(location.href);
|
||||
const mapLink = url.searchParams.get('maplink');
|
||||
if (mapLink) {
|
||||
makeFileFromUrl(decodeURIComponent(mapLink), uploadFile);
|
||||
}
|
||||
}
|
||||
|
||||
window.loadMapFromUrl = loadMapFromUrl;
|
||||
Loading…
Add table
Add a link
Reference in a new issue