fix game data buttons/inputs
This commit is contained in:
parent
81ed60f6f0
commit
7e5085516e
28
script.js
28
script.js
|
@ -29,12 +29,13 @@ async function run() {
|
||||||
pageButton.addEventListener('touchend', pagination);
|
pageButton.addEventListener('touchend', pagination);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gameDataInput = document.getElementById("game-data");
|
const gameDataInput = document.getElementById("game-data");
|
||||||
|
const buttonGameDataProceed = document.getElementById("game-data-next");
|
||||||
|
|
||||||
function new_game() {
|
function new_game() {
|
||||||
load_default_game_data();
|
load_default_game_data();
|
||||||
// we don't need to look at the default game data, so skip ahead to the image page
|
// we don't need to look at the default game data, so skip ahead to the image page
|
||||||
document.getElementById("game-data-next").click();
|
buttonGameDataProceed.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear_game() {
|
function clear_game() {
|
||||||
|
@ -65,10 +66,22 @@ async function run() {
|
||||||
|
|
||||||
document.getElementById("game").addEventListener("change", function() {
|
document.getElementById("game").addEventListener("change", function() {
|
||||||
readFile(this, function (e) {
|
readFile(this, function (e) {
|
||||||
gameDataInput.innerHTML = e.target.result;
|
gameDataInput.value = e.target.result;
|
||||||
|
checkGameData();
|
||||||
}, "text");
|
}, "text");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function checkGameData() {
|
||||||
|
if (gameDataInput.value.length > 0) {
|
||||||
|
buttonGameDataProceed.removeAttribute("disabled");
|
||||||
|
} else {
|
||||||
|
buttonGameDataProceed.setAttribute("disabled", "disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameDataInput.addEventListener("change", checkGameData);
|
||||||
|
gameDataInput.addEventListener("keyup", checkGameData);
|
||||||
|
|
||||||
const preview = document.getElementById("preview");
|
const preview = document.getElementById("preview");
|
||||||
preview.style.display = "none";
|
preview.style.display = "none";
|
||||||
|
|
||||||
|
@ -89,6 +102,15 @@ async function run() {
|
||||||
const importButton = document.getElementById("import");
|
const importButton = document.getElementById("import");
|
||||||
importButton.addEventListener("click", addTiles);
|
importButton.addEventListener("click", addTiles);
|
||||||
importButton.addEventListener("touchend", addTiles);
|
importButton.addEventListener("touchend", addTiles);
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
gameDataInput.innerHTML = '';
|
||||||
|
preview.removeAttribute("src");
|
||||||
|
}
|
||||||
|
|
||||||
|
let resetButton = document.getElementById("reset");
|
||||||
|
|
||||||
|
resetButton.addEventListener("click", reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
Loading…
Reference in New Issue