load game data from file; dedupe getElement calls

This commit is contained in:
Max Bradbury 2020-07-19 13:17:50 +01:00
parent 9e71b72536
commit 578b46ca34
1 changed files with 9 additions and 1 deletions

View File

@ -29,6 +29,8 @@ async function run() {
pageButton.addEventListener('touchend', pagination);
}
const gameDataInput = document.getElementById("game-data");
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
@ -36,7 +38,7 @@ async function run() {
}
function clear_game() {
document.getElementById("game-data").innerHTML = "";
gameDataInput.innerHTML = "";
}
let new_game_button = document.getElementById("new");
@ -61,6 +63,12 @@ async function run() {
}
}
document.getElementById("game").addEventListener("change", function() {
readFile(this, function (e) {
gameDataInput.innerHTML = e.target.result;
}, "text");
});
const preview = document.getElementById("preview");
preview.style.display = "none";