Revert index.html

This commit is contained in:
Ethan O'Brien 2024-01-23 23:53:55 -06:00
parent 7cf0c2d484
commit 00cfa38bdb
2 changed files with 89 additions and 5 deletions

Binary file not shown.

View file

@ -104,7 +104,88 @@
<input type = file id = input>
Drag ROM file or click here
</div>
<script>
input.onchange = async () => {
const url = new Blob([input.files[0]])
const parts = input.files[0].name.split(".")
const core = await (async (ext) => {
if (["fds", "nes", "unif", "unf"].includes(ext))
return "nes"
if (["smc", "fig", "sfc", "gd3", "gd7", "dx2", "bsx", "swc"].includes(ext))
return "snes"
if (["z64", "n64"].includes(ext))
return "n64"
if (["pce"].includes(ext))
return "pce"
if (["ngp", "ngc"].includes(ext))
return "ngp"
if (["ws", "wsc"].includes(ext))
return "ws"
if (["col", "cv"].includes(ext))
return "coleco"
if (["d64"].includes(ext))
return "vice_x64"
if (["nds", "gba", "gb", "z64", "n64"].includes(ext))
return ext
return await new Promise(resolve => {
const cores = {
"Nintendo 64": "n64",
"Nintendo Game Boy": "gb",
"Nintendo Game Boy Advance": "gba",
"Nintendo DS": "nds",
"Nintendo Entertainment System": "nes",
"Super Nintendo Entertainment System": "snes",
"PlayStation": "psx",
"Virtual Boy": "vb",
"Sega Mega Drive": "segaMD",
"Sega Master System": "segaMS",
"Sega CD": "segaCD",
"Atari Lynx": "lynx",
"Sega 32X": "sega32x",
"Atari Jaguar": "jaguar",
"Sega Game Gear": "segaGG",
"Sega Saturn": "segaSaturn",
"Atari 7800": "atari7800",
"Atari 2600": "atari2600",
"NEC TurboGrafx-16/SuperGrafx/PC Engine": "pce",
"NEC PC-FX": "pcfx",
"SNK NeoGeo Pocket (Color)": "ngp",
"Bandai WonderSwan (Color)": "ws",
"ColecoVision": "coleco",
"Commodore 64": "vice_x64"
}
const button = document.createElement("button")
const select = document.createElement("select")
for (const type in cores) {
const option = document.createElement("option")
option.value = cores[type]
option.textContent = type
select.appendChild(option)
}
button.onclick = () => resolve(select[select.selectedIndex].value)
button.textContent = "Load game"
box.innerHTML = ""
box.appendChild(select)
box.appendChild(button)
})
})(parts.pop())
const div = document.createElement("div")
const sub = document.createElement("div")
const script = document.createElement("script")
@ -112,22 +193,25 @@
sub.id = "game"
div.id = "display"
const topp = document.getElementById("top");
topp.remove();
const top = document.getElementById("top");
top.remove();
box.remove()
div.appendChild(sub)
document.body.appendChild(div)
window.EJS_player = "#game";
window.EJS_gameName = parts.shift();
window.EJS_biosUrl = "";
window.EJS_gameUrl = "BtnTest.gba";
window.EJS_core = "gba";
window.EJS_gameUrl = url;
window.EJS_core = core;
window.EJS_pathtodata = "data/";
window.EJS_startOnLoaded = true;
window.EJS_DEBUG_XX = true;
script.src = "data/loader.js";
document.body.appendChild(script);
}
box.ondragover = () => box.setAttribute("drag", true);
box.ondragleave = () => box.removeAttribute("drag");
</script>
</body>
</html>