fix game data buttons/inputs

This commit is contained in:
Max Bradbury 2020-07-19 20:51:56 +01:00
parent 81ed60f6f0
commit 7e5085516e
1 changed files with 25 additions and 3 deletions

View File

@ -29,12 +29,13 @@ async function run() {
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() {
load_default_game_data();
// 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() {
@ -65,10 +66,22 @@ async function run() {
document.getElementById("game").addEventListener("change", function() {
readFile(this, function (e) {
gameDataInput.innerHTML = e.target.result;
gameDataInput.value = e.target.result;
checkGameData();
}, "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");
preview.style.display = "none";
@ -89,6 +102,15 @@ async function run() {
const importButton = document.getElementById("import");
importButton.addEventListener("click", addTiles);
importButton.addEventListener("touchend", addTiles);
function reset() {
gameDataInput.innerHTML = '';
preview.removeAttribute("src");
}
let resetButton = document.getElementById("reset");
resetButton.addEventListener("click", reset);
}
run();