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