'add another image' button functionality
This commit is contained in:
parent
9383ac76fd
commit
e7641255e5
|
@ -31,7 +31,7 @@ html(lang="en-gb")
|
||||||
textarea#output
|
textarea#output
|
||||||
br
|
br
|
||||||
button#download download
|
button#download download
|
||||||
button.pagination.prev add another image
|
button.pagination.prev#add add another image
|
||||||
button.pagination.start#reset start again
|
button.pagination.start#reset start again
|
||||||
script(type="module")
|
script(type="module")
|
||||||
include script.js
|
include script.js
|
||||||
|
|
12
script.js
12
script.js
|
@ -3,6 +3,8 @@ import init, {load_default_game_data, add_tiles} from './pkg/bitsy_tiles.js';
|
||||||
async function run() {
|
async function run() {
|
||||||
await init();
|
await init();
|
||||||
|
|
||||||
|
const output = document.getElementById("output");
|
||||||
|
|
||||||
// hide all pages except start page
|
// hide all pages except start page
|
||||||
for (let page of document.getElementsByClassName('page')) {
|
for (let page of document.getElementsByClassName('page')) {
|
||||||
page.style.display = "none";
|
page.style.display = "none";
|
||||||
|
@ -103,6 +105,16 @@ async function run() {
|
||||||
importButton.addEventListener("click", addTiles);
|
importButton.addEventListener("click", addTiles);
|
||||||
importButton.addEventListener("touchend", 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() {
|
function reset() {
|
||||||
gameDataInput.innerHTML = '';
|
gameDataInput.innerHTML = '';
|
||||||
preview.removeAttribute("src");
|
preview.removeAttribute("src");
|
||||||
|
|
Loading…
Reference in New Issue