2010-05-10 Javascript

I still haven’t learnt Javascript. Right now I’m trying to integrate svg-edit and Oddmuse. This requires some Javascript voodoo that escapes me.

svg-edit

Oddmuse

If you upload a SVGĀ file to http://www.emacswiki.org/test/SVG_Test, you’ll be able to look at it. I’m using an iframe to do that.

http://www.emacswiki.org/test/SVG_Test

If you then click on *Edit this page* and then on *Edit image in the browser*, you’ll get the SVGĀ editor.

What I’m lacking is loading and saving the image!

If you look around the svg-edit project’s pages, you’ll note example code like the following:

What I don’t understand is where this code runs and how svgEditor is set.

If I simply add the following to the top of the page, inside the header, then Firebug will tell me that the svgEditor object does not exist.

What now? Is this a variable ā€œinsideā€ the iframe? Is this something I need to initialize by calling a function? Which one?

*Update*: Perhaps I’m running into some cross-site scripting protection. The site runs on www.emacswiki.org, the SVG editor runs on svg-edit.googlecode.com. Using Firebug, I run `document.getElementsByName('svgEditor')[0].getSVGDocument().setUserData('fd')` and get an error message. ⚠

​#Javascript ​#SVG ​#Wikis

Comments

(Please contact me if you want to remove your comment.)

⁂

This site is great!

– Kate 2010-05-13 10:38 UTC

---

It looks like you’re not including the javascript library that provides the SVG editing functions.

– Harald 2010-05-13 12:32 UTC

Harald

---

Hah, I’m seeing the light. Copying the script over to localhost has fixed this. I’ve come a long way. Now I need MIME encoding in Javascript, and probably a cool Save dialog – or a little rewrite.

– Alex Schroeder 2010-05-13 20:41 UTC

Alex Schroeder

---

EditSVG

test.svg

Comments on SVG Editor Extension

Alex Schroeder