'add another image' button functionality

This commit is contained in:
Max Bradbury 2020-07-19 22:01:51 +01:00
parent 9383ac76fd
commit e7641255e5
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

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