load game data from file; dedupe getElement calls
This commit is contained in:
parent
9e71b72536
commit
578b46ca34
10
script.js
10
script.js
|
@ -29,6 +29,8 @@ async function run() {
|
||||||
pageButton.addEventListener('touchend', pagination);
|
pageButton.addEventListener('touchend', pagination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gameDataInput = document.getElementById("game-data");
|
||||||
|
|
||||||
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
|
||||||
|
@ -36,7 +38,7 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear_game() {
|
function clear_game() {
|
||||||
document.getElementById("game-data").innerHTML = "";
|
gameDataInput.innerHTML = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_game_button = document.getElementById("new");
|
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");
|
const preview = document.getElementById("preview");
|
||||||
preview.style.display = "none";
|
preview.style.display = "none";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue