From eb8e715bb5b9ce3a155511305e0458e8ca6f30b3 Mon Sep 17 00:00:00 2001 From: hasparus Date: Tue, 30 Oct 2018 12:01:07 +0100 Subject: [PATCH] Add modal for upload map link --- index.html | 4 +-- script.js | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 95 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 87a77f20..40e9780a 100644 --- a/index.html +++ b/index.html @@ -705,8 +705,8 @@ Load diff --git a/script.js b/script.js index 8aef65d9..34788a6b 100644 --- a/script.js +++ b/script.js @@ -275,7 +275,7 @@ function fantasyMap() { placePoints(); calculateVoronoi(points); - makeFileFromUrl(decodeURIComponent(mapLink)).then(blob => { + makeBlobFromUrl(decodeURIComponent(mapLink)).then(blob => { uploadFile(blob); manorsAndRegions(); // namesBase global state cleanData(); @@ -6824,7 +6824,7 @@ function fantasyMap() { uploadFile(fileToLoad); }); - function makeFileFromUrl(mapLink) { + function makeBlobFromUrl(mapLink) { return fetch(mapLink, { method: 'GET', mode: 'cors', @@ -7728,7 +7728,7 @@ function fantasyMap() { } if (id === "saveButton") {$("#saveDropdown").slideToggle();} if (id === "loadButton") {$("#loadDropdown").slideToggle();} - if (id === "loadMap") {mapToLoad.click();} + if (id === "zoomReset") {resetZoom(1000);} if (id === "zoomPlus") { scale += 1; @@ -7826,6 +7826,96 @@ function fantasyMap() { $("#saveDropdown").slideUp("fast"); }); + $('#loadDropdown > div[role="button"]').click(event => { + const id = event.target.id; + console.log(event, id); + + if (id === "loadMap") { + mapToLoad.click(); + } + if (id === "loadMapFromURL") { + const modal = document.createElement("form"); + Object.assign(modal.style, { + position: "absolute", + left: "50%", + top: "50%", + transform: "translate3d(-50%, -50%, 0)", + border: "1px solid #5e4fa2", + boxShadow: "2px 2px 5px -3px #3a2804", + padding: "auto", + background: "white" + }); + modal.className = "ui-dialog ui-widget ui-widget-content ui-front ui-dialog-buttons"; + + // + + modal.innerHTML = ` +
+ + Load Map + + +
+
+ +
+
+
+ +
+
+ `; + + modal.onsubmit = (event) => { + event.preventDefault(); + console.log("ok", event) + document.body.removeChild(modal); + } + + document.body.appendChild(modal); + } + $("#loadDropdown").slideUp("fast"); + }); + // lock / unlock option randomization $("#options i[class^='icon-lock']").click(function() { $(this).toggleClass("icon-lock icon-lock-open");