News for hackers. Stuff that matters.
Re:I ported LaTeX to Javascript by csense on Saturday January 19, 2013 @07:13PM (#5085392)
EDIT: I managed to find the answer to this question myself.

I want to generate a bunch of bytes programmatically, then have the user click on a button, and allow the user to save a file containing the generated bytes. This should run entirely client-side, with no talking to the server (except for static loading of the HTML page, JS files, images, css, etc). I've been wanting to do this since I wrote my first Java applet way back in the 1990's, and haven't been able to find a way; it's a personal long-standing unscratched itch for me.

Apparently with HTML5 it's possible to do this, since this project does it! I wasn't able to find where in the code the downloading happens, and I'm not sure what this concept is called, which makes searching difficult. Thanks!

EDIT: Browsing commits instead of the source tree was fruitful [1]. What I'm looking for is called Data URI [2]. The inverse operation -- programmatically processing uploads on the client side -- can be achieved with the File API [3]. Now I need a few days to think about what startups will become possible with these capabilities!

[1] https://github.com/manuels/texlive.js/commit/b7b7eef27846473...

[2] http://en.wikipedia.org/wiki/Data_URI_scheme

[3] https://developer.mozilla.org/en-US/docs/Using_files_from_we...

Re:I ported LaTeX to Javascript by Sephr on Saturday January 19, 2013 @10:57PM (#5085947)
data: URIs are deprecated for generating content. Use object URLs and Blobs (https://developer.mozilla.org/en-US/docs/DOM/Blob). If you want to force saving the file to a disk use <a download="[filename]">
Re:I ported LaTeX to Javascript by gmac on Sunday January 20, 2013 @11:37AM (#5087312)
Although, annoyingly, data: URIs are your only option in Safari (including the latest version), and they also happen to crash the PDF viewer. Safari does have createObjectURL, but then doesn't understand the URL it creates!

Just as annoyingly, IE10 has createObjectURL too, but only allows the created URLs to be used for <img>, <audio> and <video>. To save a blob, you have to use something ms-prefixed instead, and this doesn't allow inline PDF viewing.

Re:I ported LaTeX to Javascript by rb12345 on Monday January 21, 2013 @08:12AM (#5091302)
I suppose that pdf.js could be used for inline PDF viewing, but at the moment the Firefox 18.0 version idles at ~20% CPU.
Re:I ported LaTeX to Javascript by no_more_death on Saturday January 19, 2013 @11:59PM (#5086049)
Yeah. Interestingly I got all the way to the download with Chrome 25 Beta (for Android) but then it couldn't handle the data URI.