hudbrog / gCodeViewer

a visual web based gcode analyzer
Other
421 stars 150 forks source link

Loading GCODE file from URL #11

Closed hackwin closed 11 years ago

hackwin commented 11 years ago

Any ideas on how to load the GCODE from a URL?

hudbrog commented 11 years ago

Sorry, modern browser security prevents cross site requests, so there is no way to implement loading from url without server side. I have no plans on making that viewer server dependent.

hackwin commented 11 years ago

Thanks for replying. I needed to load the file from within the same domain. AJAX worked fine

On 10/7/2013 10:55 PM, Alex Ustyantsev wrote:

Sorry, modern browser security prevents cross site requests, so there is no way to implement loading from url without server side. I have no plans on making that viewer server dependent.

— Reply to this email directly or view it on GitHub https://github.com/hudbrog/gCodeViewer/issues/11#issuecomment-25861641.

Humphreybas commented 10 years ago

Could you share your code snippet how to load gcode from an URL? Many thanks in advance!

hackwin commented 10 years ago

Lines 187 to 209 contain the added code: http://ideone.com/5oTp9e

You can run it from the browser javascript console using: GCODE.gCodeReader.loadUrl("http://localhost/gCodeViewer/model.gcode");

Humphreybas commented 10 years ago

Thanks a lot! Unfortunately it's not working. Are you still using it? And on what commit of gCodeViewer?

I will give some extra info below in case you wouldn't mind reading it and have a quick solution, but with no means I expect you to invest time in it and fix my issues of course.

The latest commit gives me a "gcode.match is not function" error in detectSlicer and a js syntax error on the gcode file itself (as if the browser tries to interpret it as a javascript?). After adding "gcodeResponse = String(gcodeResponse);" to the loadUrl function the gcode.match error is replaced by other errors like: "TypeError: Argument 1 of SVGMatrix.translate is not a finite floating-point value" I switched to the commit which is close to your original post (Oct 8 2013 so I took: a797c52a3b35ead10d8dba8e2fd9da5bbf328b35) but that didn't fix it either.

hackwin commented 10 years ago

Here's a copy of the code I used: http://jbcse.com/downloads/gCodeViewer.zip

http://i.imgur.com/rFpgwRj.png

Here's a demo page: http://jbcse.com/projects/gCodeViewer-from-URL/

Enter into the console: GCODE.gCodeReader.loadUrl("thin-wall.gcode");

Humphreybas commented 10 years ago

Thanks mate, stupid of me I didn't check Chrome, works like a charm there, but not in FF, so it was a browser issue. Thanks for your help, I will use it in chrome until I gain super javascript powers.