mattgodbolt / Miracle

JavaScript Sega Master System Emulator
http://xania.org/miracle/miracle.html
GNU General Public License v3.0
117 stars 30 forks source link

SMS files fail to load from the browser #5

Closed mattgodbolt closed 2 years ago

mattgodbolt commented 9 years ago

the file browser is basically completely broken

gernotk commented 9 years ago

For a quick workaround, just add this bookmarklet to your collection:

javascript:jQuery(%22%23file_upload%22).change(function(e){var%20file=e.target.files[0],fileName=file.name,fileReader=new%20FileReader;fileReader.onload=function(){miracle_reset(),loadRom(fileName,fileReader.result),hideRomChooser(),start()},fileReader.readAsBinaryString(file)});

This will enable you to select, load and run ROMs on your hardrive using the HTML5 FileReader-API in supporting browsers,

gernotk commented 9 years ago

The code above in a more readable form:

$('#file_upload').change(function (e) {
  var file = e.target.files[0],
      fileName = file.name,
      fileReader = new FileReader();

  fileReader.onload = function() {
    miracle_reset();
    loadRom(fileName, fileReader.result);
    hideRomChooser();
    start();
  };

  fileReader.readAsBinaryString(file);
});
mattgodbolt commented 9 years ago

Thanks! I should really fix the underlying issue (I'd be happy to accept a pull request too) :)

On Thu, Aug 20, 2015 at 1:31 AM, Gernot Kieseritzky < notifications@github.com> wrote:

The code above in a more readable form:

$('#file_upload').change(function (e) { var file = e.target.files[0], fileName = file.name, fileReader = new FileReader();

fileReader.onload = function() { miracle_reset(); loadRom(fileName, fileReader.result); hideRomChooser(); start(); };

fileReader.readAsBinaryString(file); });

— Reply to this email directly or view it on GitHub https://github.com/mattgodbolt/Miracle/issues/5#issuecomment-132906151.

Matt