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");