demo: Small cleanups

This commit is contained in:
relrelb 2021-07-09 11:40:02 +03:00 committed by relrelb
parent df47c53f5c
commit a33066f666
1 changed files with 8 additions and 11 deletions

View File

@ -21,8 +21,11 @@ const sampleFileInputContainer = document.getElementById(
);
const localFileInput = document.getElementById("local-file");
const sampleFileInput = document.getElementById("sample-swfs");
const animOptGroup = document.getElementById("anim-optgroup");
const gamesOptGroup = document.getElementById("games-optgroup");
// prettier-ignore
const optionGroups = {
"Animation": document.getElementById("anim-optgroup"),
"Game": document.getElementById("games-optgroup"),
};
// Default config used by the player.
const config = {
@ -66,7 +69,8 @@ async function loadFile(file) {
return;
}
hideSample();
load({ data: await new Response(file).arrayBuffer(), ...config });
const data = await new Response(file).arrayBuffer();
load({ data, ...config });
}
function loadSample() {
@ -123,14 +127,7 @@ window.addEventListener("load", () => {
option.textContent = swfData.title;
option.value = swfData.location;
option.swfData = swfData;
switch (swfData.type) {
case "Animation":
animOptGroup.append(option);
break;
case "Game":
gamesOptGroup.append(option);
break;
}
optionGroups[swfData.type].append(option);
}
sampleFileInputContainer.classList.remove("hidden");