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:

svgEditor.loadFromString('<svg>...</svg>');

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.

<script type="text/javascript">
  svgEditor.loadFromString('<svg>...</svg>');
</script>

What now? Is this a variable “inside” the iframe? Is this something I need to initialize by calling a function? Which one?

​#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