Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
OutRed
GitHub Repository: OutRed/artclass
Path: blob/main/static/emulatorjs/EmulatorJS-main/emujs_data/loader.js
595 views
1
(async function() {
2
let VERSION = 31.6;
3
if ((window.location && ['localhost', '127.0.0.1'].includes(location.hostname)) ||
4
'undefined' != typeof EJS_DEBUG_XX && true === EJS_DEBUG_XX) {
5
fetch('https://raw.githack.com/EmulatorJS/EmulatorJS/main/data/version.json').then(response => {
6
if (response.ok) {
7
response.text().then(body => {
8
let version = JSON.parse(body);
9
if (VERSION < version.current_version) {
10
console.log('Using emulatorjs version ' + VERSION + ' but the newest version is ' + version.current_version + '\nopen https://github.com/EmulatorJS/EmulatorJS to update');
11
}
12
})
13
}
14
})
15
}
16
function loadStyle(file) {
17
return new Promise(function(resolve, reject) {
18
let css = document.createElement('link');
19
css.rel = 'stylesheet';
20
css.href = function() {
21
if ('undefined' != typeof EJS_paths && typeof EJS_paths[file] == 'string') {
22
return EJS_paths[file];
23
} else if ('undefined' != typeof EJS_pathtodata) {
24
if (!EJS_pathtodata.endsWith('/')) EJS_pathtodata+='/';
25
return EJS_pathtodata+file+'?v='+VERSION;
26
} else {
27
return file+'?v='+VERSION;
28
}
29
}();
30
css.onload = resolve;
31
document.head.appendChild(css);
32
})
33
}
34
function loadScript(file) {
35
return new Promise(function (resolve, reject) {
36
let script = document.createElement('script');
37
script.src = function() {
38
if ('undefined' != typeof EJS_paths && typeof EJS_paths[file] == 'string') {
39
return EJS_paths[file];
40
} else if ('undefined' != typeof EJS_pathtodata) {
41
if (!EJS_pathtodata.endsWith('/')) EJS_pathtodata+='/';
42
return EJS_pathtodata+file+'?v='+VERSION;
43
} else {
44
return file+'?v='+VERSION;
45
}
46
}();
47
script.onload = resolve;
48
document.head.appendChild(script);
49
})
50
}
51
const isIpad = /Macintosh/i.test(navigator.userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 1;
52
if (('undefined' != typeof EJS_DEBUG_XX && true === EJS_DEBUG_XX) ||
53
/(iPad|iPhone|iPod)/gi.test(navigator.userAgent) || isIpad) {
54
await loadStyle('emu-css.css');
55
await loadScript('emu-main.js');
56
await loadScript('emulator.js');
57
} else {
58
await loadStyle('emu-css.min.css');
59
await loadScript('emulator.min.js');
60
}
61
let config = {};
62
config.gameUrl = EJS_gameUrl;
63
'undefined' != typeof EJS_mameCore && (config.mameCore = EJS_mameCore);
64
'undefined' != typeof EJS_biosUrl && (config.biosUrl = EJS_biosUrl);
65
'undefined' != typeof EJS_gameParentUrl && (config.gameParentUrl = EJS_gameParentUrl);
66
'undefined' != typeof EJS_gamePatchUrl && (config.gamePatchUrl = EJS_gamePatchUrl);
67
'undefined' != typeof EJS_AdUrl && (config.adUrl = EJS_AdUrl);
68
'undefined' != typeof EJS_paths && (config.paths = EJS_paths);
69
'undefined' != typeof EJS_gameID && (config.gameId = EJS_gameID);
70
'undefined' != typeof EJS_netplayUrl && (config.netplayUrl = EJS_netplayUrl);
71
'undefined' != typeof EJS_startOnLoaded && (config.startOnLoad = EJS_startOnLoaded);
72
'undefined' != typeof EJS_core && (config.system = EJS_core);
73
'undefined' != typeof EJS_oldCores && (config.oldCores = EJS_oldCores);
74
'undefined' != typeof EJS_loadStateURL && (config.loadStateOnStart = EJS_loadStateURL);
75
'undefined' != typeof EJS_defaultOptions && (config.defaultMenuOptions = EJS_defaultOptions);
76
'undefined' != typeof EJS_language && (config.lang = EJS_language);
77
'undefined' != typeof EJS_noAutoCloseAd && (config.noAutoAdClose = EJS_noAutoCloseAd);
78
'undefined' != typeof EJS_VirtualGamepadSettings && (config.VirtualGamepadSettings = EJS_VirtualGamepadSettings);
79
'undefined' != typeof EJS_Buttons && (config.buttons = EJS_Buttons);
80
'undefined' != typeof EJS_Settings && (config.settings = EJS_Settings);
81
'undefined' != typeof EJS_CacheLimit && (config.cacheLimit = EJS_CacheLimit);
82
config.onsavestate = null;
83
config.onloadstate = null;
84
'undefined' != typeof EJS_onSaveState && (config.onsavestate = EJS_onSaveState);
85
'undefined' != typeof EJS_onLoadState && (config.onloadstate = EJS_onLoadState);
86
'undefined' != typeof EJS_lightgun && (config.lightgun = EJS_lightgun);
87
'undefined' != typeof EJS_gameName && (config.gameName = EJS_gameName);
88
'undefined' != typeof EJS_pathtodata && (config.dataPath = EJS_pathtodata);
89
'undefined' != typeof EJS_mouse && (config.mouse = EJS_mouse);
90
'undefined' != typeof EJS_multitap && (config.multitap = EJS_multitap);
91
'undefined' != typeof EJS_playerName && (config.playerName = EJS_playerName);
92
'undefined' != typeof EJS_cheats && (config.cheats = EJS_cheats);
93
'undefined' != typeof EJS_color && (config.color = EJS_color);
94
window.EJS_emulator = await new EJS(EJS_player, config);
95
'undefined' != typeof EJS_onGameStart && EJS_emulator.on('start-game', EJS_onGameStart);
96
})();
97
98