EmulatorJS/index.html

160 lines
7.1 KiB
HTML
Raw Normal View History

2022-02-18 18:43:44 +00:00
<html>
2022-02-23 03:45:45 +00:00
<head>
<title>Emulatorjs | Select Game Rom</title>
<link rel="icon" type="image/png" href="docs/Emulatorjs Logo.png">
</head>
2022-02-20 21:51:44 +00:00
<body>
2022-02-23 03:45:45 +00:00
<style>
body{
background: #c4bdff;
2022-02-23 17:04:46 +00:00
margin: 0;
padding: 0;
2022-02-23 03:45:45 +00:00
}
.form{
position: absolute;
top: 450px;
left: 50%;
margin-top: -150px;
margin-left: -250px;
width: 500px;
height: 200px;
border: 4px dashed #111;
}
.form p{
width: 100%;
height: 100%;
text-align: center;
line-height: 170px;
color: #111;
font-family: Arial;
}
.form input{
position: absolute;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
outline: none;
opacity: 0;
}
.eimg{
width: 250px;
2022-02-23 17:04:46 +00:00
}
#uploadf, #uploadf1{
display: block;
2022-02-23 03:45:45 +00:00
}
</style>
2022-02-20 21:51:44 +00:00
<script>
window.addEventListener('load', function() {
document.getElementById('file').onchange = async function(e) {
var ce = function(e) {return document.createElement(e);};
var br = function(e) {e.appendChild(ce('br'))};
var gameUrl = URL.createObjectURL(new Blob([e.target.files[0]]))
var extension = e.target.files[0].name.split('.').pop()
var gameName = e.target.files[0].name.replaceAll("'", "\\'")
var gameName = gameName.substr(0, gameName.length - extension.length - 1)
2022-02-23 17:04:46 +00:00
e.target.remove();
document.getElementById('uploadf').style.display = "none"; document.getElementById('uploadf1').style.display = "none";
2022-02-20 21:51:44 +00:00
if (['fds', 'nes', 'unif', 'unf'].includes(extension)) {
var core = 'nes';
} else if (['z64'].includes(extension)) {
var core = 'n64';
} else if (['smc', 'fig', 'sfc', 'gd3', 'gd7', 'dx2', 'bsx', 'swc'].includes(extension)) {
var core = 'snes';
} else if (['nds'].includes(extension)) {
var core = 'nds';
} else if (['gba'].includes(extension)) {
var core = 'gba';
} else if (['gb'].includes(extension)) {
var core = 'gb';
} else {
var core = await function() {
return new Promise(function(resolve, reject) {
var cores = {"NES / Nintendo Entertainment System / Famicon": "nes",
"SNES / Super Nintendo Entertainment System": "snes",
"Nintendo 64": "n64",
"Nintendo Game Boy": "gb",
"Nintendo Game Boy Advance": "gba",
"Nintendo DS": "nds",
"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"};
var a = ce('div');
a.style = 'padding: 50px;';
var p = ce('h2');
p.innerHTML = 'Unable to auto-detect system. Please select the desired system.';
a.appendChild(p);
br(a);
for (var k in cores) {
var input = ce('input');
input.type = 'radio';
input.id = 'game-' + cores[k];
input.name = 'game';
input.value = cores[k];
a.appendChild(input);
var label = ce('label');
label.for = 'game-' + cores[k];
label.innerHTML = k;
a.appendChild(label);
br(a);
};
br(a);
var submit = ce('input');
submit.type = 'submit';
submit.value = 'Load Game';
submit.onclick = function(e) {
var q = false;
var radios = document.getElementsByName('game');
for (var i=0; i<radios.length; i++) {
if (radios[i].checked) {
var q = radios[i].value;
break;
};
};
if (! q) {
return;
};
while(document.body.firstChild) {
document.body.removeChild(document.body.firstChild);
};
resolve(q);
};
a.appendChild(submit);
document.body.appendChild(a);
});
}();
};
var a = document.createElement('div');
2022-02-23 17:08:16 +00:00
a.style = "width:65%;height:100%;max-width:100%";
2022-02-20 21:51:44 +00:00
var b = document.createElement('div');
b.id = 'game';
a.appendChild(b);
2022-02-23 17:04:46 +00:00
document.getElementById("cont").appendChild(a);
2022-02-20 21:51:44 +00:00
var script = document.createElement('script');
2022-02-23 17:04:46 +00:00
script.innerHTML = "EJS_player = '#game'; EJS_gameName = '" + gameName + "'; EJS_biosUrl = ''; EJS_gameUrl = '" + gameUrl + "'; EJS_core = '" + core + "'; EJS_pathtodata = 'data/';";
2022-02-20 21:51:44 +00:00
document.body.appendChild(script);
var script = document.createElement('script');
script.src = 'data/loader.js';
document.body.appendChild(script);
}
})
</script>
2022-02-23 17:04:46 +00:00
<center id="cont">
<img id="uploadf1" class="eimg" src="docs/Emulatorjs Logo.png">
2022-02-23 03:45:45 +00:00
</center>
2022-02-23 17:04:46 +00:00
<div id="uploadf" class="form">
2022-02-23 03:45:45 +00:00
<input type="file" id="file">
<b><p>Select Game Rom: Drag your files here or click in this area.</p></b>
</div>
2022-02-20 21:51:44 +00:00
</body>
2022-02-18 18:43:44 +00:00
</html>