-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1 lines (1 loc) · 3.77 KB
/
index.html
1
<!doctypehtml><html lang=en-us><head><meta charset=utf-8><meta content="text/html; charset=utf-8"http-equiv=Content-Type><title>NES Header Information</title><style>html{font-family:sans-serif}.emscripten{padding-right:0;margin-left:auto;margin-right:auto;display:block}textarea.emscripten{font-family:monospace;width:80%}div.emscripten{text-align:center}.rom{background-color:#b1c7ea;padding:5px 10px;border-radius:5px;border:1px ridge #000;font-size:.8rem;height:auto}.rom:hover{background-color:#2d5ba3;color:#fff}.rom:active{background-color:#0d3f8f;color:#fff}.rom:disabled{background-color:#cacaca;color:#000}#dropzone{position:fixed;left:0;top:0;z-index:666;width:100%;height:100%;background-color:#0080c0;opacity:.5;display:none}</style></head><body><div style=margin:8px><label class=rom for=file>Open ROM</label><input accept=.nes id=file onchange=onChange(event) style=width:0;opacity:0 type=file><span id=romname></span></div><pre id=rominfo style=font-family:monospace,monospace;margin:8px>Drag and drop a ROM</pre><div class=emscripten id=status>Downloading...</div><div class=emscripten><progress hidden id=progress max=100 value=0></progress></div><script>var statusElement=document.getElementById("status"),progressElement=document.getElementById("progress"),Module={preRun:[],postRun:[],print:function(){var e=document.getElementById("output");return e&&(e.value=""),function(t){arguments.length>1&&(t=Array.prototype.slice.call(arguments).join(" ")),console.log(t),e&&(e.value+=t+"\n",e.scrollTop=e.scrollHeight)}}(),setStatus:function(e){if(Module.setStatus.last||(Module.setStatus.last={time:Date.now(),text:""}),e!==Module.setStatus.last.text){var t=e.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/),s=Date.now();t&&s-Module.setStatus.last.time<30||(Module.setStatus.last.time=s,Module.setStatus.last.text=e,t?(e=t[1],progressElement.value=100*parseInt(t[2]),progressElement.max=100*parseInt(t[4]),progressElement.hidden=!1):(progressElement.value=null,progressElement.max=null,progressElement.hidden=!0),statusElement.innerHTML=e)}},totalDependencies:0,monitorRunDependencies:function(e){this.totalDependencies=Math.max(this.totalDependencies,e),Module.setStatus(e?"Preparing... ("+(this.totalDependencies-e)+"/"+this.totalDependencies+")":"All downloads complete.")}};Module.setStatus("Downloading..."),window.onerror=function(){Module.setStatus("Exception thrown, see JavaScript console"),Module.setStatus=function(e){e&&Module.printErr("[post-exception status] "+e)}}</script><script async src=index.js></script><div id=dropzone></div><script>"use strict";const romNameElement=document.getElementById("romname"),romInfoElement=document.getElementById("rominfo");function onChange(e){handleFiles(e.target.files)}function handleFiles(e){let n=e[0],t=new FileReader;t.onload=function(e){romNameElement.textContent=n.name,romInfoElement.textContent="";let t=new Uint8Array(e.target.result);if(t.byteLength<16)return void(romInfoElement.textContent="Error: file size is too small");if(78!==t[0]||69!==t[1]||83!==t[2]||26!==t[3])return void(romInfoElement.textContent="Error: file is not an iNES ROM image");let o=Module._malloc(t.byteLength);Module.HEAPU8.set(t,o),Module.ccall("PrintNESInfo",null,["number","number"],[o,t.byteLength]),Module._free(o)},t.readAsArrayBuffer(n)}const dropzone=document.getElementById("dropzone");function dragover(e){e.stopPropagation(),e.preventDefault(),"dropzone"!==e.target.id&&(dropzone.style.display="block")}function dragleave(e){e.stopPropagation(),e.preventDefault(),"dropzone"===e.target.id&&(dropzone.style.display="none")}function drop(e){e.stopPropagation(),e.preventDefault(),dropzone.style.display="none",handleFiles(e.dataTransfer.files)}window.addEventListener("dragover",dragover,!1),dropzone.addEventListener("dragleave",dragleave,!1),dropzone.addEventListener("drop",drop,!1)</script></body></html>