2023-06-20 19:17:02 +00:00
|
|
|
(async function() {
|
|
|
|
const folderPath = (path) => path.substring(0, path.length - path.split('/').pop().length);
|
|
|
|
const scriptPath = folderPath((new URL(document.currentScript.src)).pathname);
|
|
|
|
if (!scriptPath.endsWith('/')) scriptPath+='/';
|
|
|
|
//console.log(scriptPath);
|
|
|
|
function loadScript(file) {
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
let script = document.createElement('script');
|
|
|
|
script.src = function() {
|
|
|
|
if ('undefined' != typeof EJS_paths && typeof EJS_paths[file] == 'string') {
|
|
|
|
return EJS_paths[file];
|
|
|
|
} else {
|
|
|
|
return scriptPath+file;
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
script.onload = resolve;
|
|
|
|
document.head.appendChild(script);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
function loadStyle(file) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
let css = document.createElement('link');
|
|
|
|
css.rel = 'stylesheet';
|
|
|
|
css.href = function() {
|
|
|
|
if ('undefined' != typeof EJS_paths && typeof EJS_paths[file] == 'string') {
|
|
|
|
return EJS_paths[file];
|
|
|
|
} else {
|
|
|
|
return scriptPath+file;
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
css.onload = resolve;
|
|
|
|
document.head.appendChild(css);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (('undefined' != typeof EJS_DEBUG_XX && true === EJS_DEBUG_XX) || true) {
|
|
|
|
await loadScript('emulator.js');
|
2023-06-24 17:42:10 +00:00
|
|
|
await loadScript('nipplejs.js');
|
2023-06-25 03:18:12 +00:00
|
|
|
await loadScript('gamepad.js');
|
2023-06-22 16:00:13 +00:00
|
|
|
await loadScript('GameManager.js');
|
2023-06-20 19:17:02 +00:00
|
|
|
await loadStyle('css/main.css');
|
|
|
|
}
|
|
|
|
const config = {};
|
|
|
|
config.gameUrl = EJS_gameUrl;
|
|
|
|
config.dataPath = scriptPath;
|
2023-06-20 21:17:49 +00:00
|
|
|
'undefined' != typeof EJS_core && (config.system = EJS_core);
|
2023-06-20 19:17:02 +00:00
|
|
|
|
|
|
|
new EmulatorJS(EJS_player, config);
|
|
|
|
|
|
|
|
})();
|