How to make a user be able to download a FlatAssembler project file?


#1

Hey, guys!
So, I’ve made a web-app that converts arithmetic expressions to i486-compatible assembly. It uses a syntax that can be compiled using FlatAssembler. You can (hopefully) see it here:
http://flatassembler.000webhostapp.com/compiler.html
So, I was wondering, is it possible to make the user be able to download a customized FlatAssembler project file, one that includes the compiler output (which is produced by the client-side JavaScript), as well as the declarations of the variables used in the arithmetic expression and the routines for their input from keyboard? I don’t know any PHP right now, so please provide detailed instructions (or, better yet, link to them).

P.S. I hope that what I am doesn’t break the copyright laws, does it? FlatAssembler is available free for download and its source (which I haven’t really studied) is available under the BSD license.


#2

Just google “Stream files to user browser using PHP”


#3

OK, well, the first problem I need to solve is how to send that assembly code produced by JavaScript to the server. It’s not at all obvious how.
If I send the “innerHTML” to it, it will get the nearly-imparsable SGML code with the syntax-highlighting information it doesn’t even need.
If I send the “textContent” to it, the whitespace characters won’t be correctly preserved (as they are shown on the screen), and they are important in the FlatAssembler syntax (the new-line characters are used to end the directives).
The “innerText” property might do the trick in some browsers, but using it is a recipe for causing incompatibility with various browsers, right?
And even if I manage to prepare the text to be sent to the server, what’s next? Make an AJAX, and then try to download a file by calling the “window.open” in the event handler? As far as I know, no modern browser would allow me to do this with the default security settings.
I hope you see the problems I am facing now.


#4

you might be best off posting your issue at stackoverflow.com while there are some knowledgeable members here there will be hundreds more over there and you may get assistance quicker with regards to it being a coding issue or problem that needs solved out with our hosting


#5

This isn’t really a coding question for stackoverflow.com, this is a recommendation question.

Nevertheless, I’ve figured out how to do it myself. It works in all browsers I’ve tested it on (including Internet Explorer 6) except Opera 12 (and there it doesn’t even show the error it’s supposed to show if the browser doesn’t correctly implement the JavaScript directives I was using, but it sends corrupted data to the server).


#6

Done some JavaScript trickery to make it work in Opera.
Well, that’s the problem with JavaScript. It’s an easy programming language in that, for example, although I have studied quite a few programming languages, I can’t imagine making a program that converts arithmetic expressions to assembly or a PacMan game in any language except JavaScript. However, if you make your program work on your machine, that doesn’t mean it will work on some nearly-identical machine. It’s just not well-standardized, and the standards quite often aren’t implemented properly by various devices that are used to browse the Internet.

Anyway, is there a way to code against the Internet Explorer 6 and the Android Stock Browser attempting to render assembly code (.ASM files) as if it was HTML?


#7

I’ve figured out how to fix that in the Android Stock Browser. People who use Internet Explorer these days hopefully know what they are doing :-).