From e7641255e5ebfde1b2fedbbf0b3ba3a031b66c2b Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sun, 19 Jul 2020 22:01:51 +0100 Subject: [PATCH] 'add another image' button functionality --- index.pug | 2 +- script.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/index.pug b/index.pug index fd23db2..adffd5d 100644 --- a/index.pug +++ b/index.pug @@ -31,7 +31,7 @@ html(lang="en-gb") textarea#output br button#download download - button.pagination.prev add another image + button.pagination.prev#add add another image button.pagination.start#reset start again script(type="module") include script.js diff --git a/script.js b/script.js index 2e9ceb1..2529994 100644 --- a/script.js +++ b/script.js @@ -3,6 +3,8 @@ import init, {load_default_game_data, add_tiles} from './pkg/bitsy_tiles.js'; async function run() { await init(); + const output = document.getElementById("output"); + // hide all pages except start page for (let page of document.getElementsByClassName('page')) { page.style.display = "none"; @@ -103,6 +105,16 @@ async function run() { importButton.addEventListener("click", addTiles); importButton.addEventListener("touchend", addTiles); + function addImage() { + gameDataInput.value = output.value; + output.value = ""; + } + + const addImageButton = document.getElementById("add"); + + addImageButton.addEventListener("click", addImage); + addImageButton.addEventListener("touchend", addImage); + function reset() { gameDataInput.innerHTML = ''; preview.removeAttribute("src");