EmulatorJS/data/emulator.min.js

1 line
452 KiB
JavaScript
Raw Normal View History

var EJS=function(o){window.EJS_MODULES=o;var n={},i=[];function a(e){if(n[e])return n[e].exports;i.push(e);var t=n[e]={i:e,l:!1,exports:{}};return o[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}return window.getUsedModules=function(){return i.sort(function(e,t){return t<e?1:-1})},window.getUnusedModules=function(){for(var e=[],t=getUsedModules(),n=0;n<o.length;n++)null===o[n]||t.includes(n)||e.push(n);return e},Array.isArray,a.m=o,a.c=n,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)a.d(n,o,function(e){return t[e]}.bind(null,o));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=162)}([function(e){e.exports=function(e,t,n){console.warn(e),e&&e.response&&0===e.response.status?t.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;"><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors">'+n.localization("CORS Error")+"</a></strong>":t.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">'+n.localization("Network Error")+"</strong>"}},null,null,null,null,null,function(e){e.exports=class{gamepads;timeout;listeners;constructor(){if(!navigator.getGamepads&&!navigator.webkitGetGamepads)throw new Error("Get gamepads not found!");if(!window.setTimeout)throw new Error("setTimeout was not found!");this.gamepads=[],this.listeners={},this.timeout=null,this.loop()}terminate(){window.clearTimeout(this.timeout)}getGamepads(){return navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[]}loop(){this.updateGamepadState(),this.timeout=setTimeout(this.loop.bind(this),10)}updateGamepadState(){const o=this.getGamepads();o.forEach((a,n)=>{if(a){let t=!1;this.gamepads.forEach((i,e)=>{i.index===a.index&&(t=!0,i.axes.forEach((e,t)=>{if(a.axes[t]!==e){const e=function(){switch(t){case 0:return"LEFT_STICK_X";case 1:return"LEFT_STICK_Y";case 2:return"RIGHT_STICK_X";case 3:return"RIGHT_STICK_Y";default:return null}}();e&&this.dispatchEvent("axischanged",{axis:e,value:a.axes[t],index:a.index,gamepadIndex:a.index})}}),a.buttons.forEach((e,t)=>{let n=1===i.buttons[t],o=("object"==typeof i.buttons[t]&&(n=i.buttons[t].pressed),1===e);"object"==typeof e&&(o=e.pressed),n!==o&&(o?this.dispatchEvent("buttondown",{index:t,gamepadIndex:a.index}):this.dispatchEvent("buttonup",{index:t,gamepadIndex:a.index}))}),this.gamepads[e]=o[n])}),t||(this.gamepads.push(o[n]),this.dispatchEvent("connected",{gamepadIndex:a.index}))}});for(let n=0;n<this.gamepads.length;n++)if(this.gamepads[n]){let t=!1;for(let e=0;e<o.length;e++)if(o[e]&&this.gamepads[n].index===o[e].index){t=!0;break}t||(this.dispatchEvent("disconnected",{gamepadIndex:this.gamepads[n].index}),this.gamepads.splice(n,1),n--)}}dispatchEvent(e,t){"function"==typeof this.listeners[e]&&((t=t||{}).type=e,this.listeners[e](t))}on(e,t){this.listeners[e.toLowerCase()]=t}}},null,null,null,null,function(e,t,n){function o(o,i){let e;try{e=new URL(o)}catch(e){}return e&&["http:","https:"].includes(e.protocol)||!e?new Promise(function(t,e){let n=new XMLHttpRequest;i.onProgress&&n.addEventListener("progress",i.onProgress),n.onload=function(){if(n.readyState===n.DONE){let e=n.response;try{e=JSON.parse(e)}catch(e){}t({data:e,headers:{"content-length":n.getResponseHeader("content-length"),"content-type":n.getResponseHeader("content-type"),"last-modified":n.getResponseHeader("last-modified")}})}},n.responseType=i.type,n.onerror=e,n.open(i.method,o,!0),n.send()}):new Promise(async function(t,n){if("HEAD"===i.method)t({headers:{}});else{le