[solved] Issues with Scripting on SVG

Discuss SVG code, accessible via the XML Editor.
JZA
Posts: 39
Joined: Sun Mar 25, 2012 7:09 am
Location: Cancun
Contact:

[solved] Issues with Scripting on SVG

Postby JZA » Fri Jul 19, 2013 3:34 pm

I am trying to make a calendar on SVG, where the graphic display the remaining days to an event. I have a sample on how to insert the JS into an SVG, however when I try to port the code to a better designed SVG I get a blank result. I use

Code: Select all

getElementID("<tag">).appendNode(daysleft);

I put the ElementID on the

Code: Select all

<text>
Node (ln. 173) but nothing comes up. Please check the code, working svg:
http://pastebin.mozilla.org/2648490
Target SVG:
http://pastebin.mozilla.org/2649264
Last edited by JZA on Sat Jul 20, 2013 6:02 pm, edited 1 time in total.

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Issues with Scripting on SVG

Postby hulf2012 » Sat Jul 20, 2013 2:06 am

Hello
The pastebin.mozilla links shows nothing. Do you already solved your problem?

I think it should be:

Code: Select all

    getElementID("<tag>").appendNode(daysleft);

Maybe a typing error. mmm getElementByID or getElementID? I don't remember right now.

A general idea is: In Inkscape, save your graphics as a plain svg, then in any text editor include the javacript. Also some web browsers doesn't support all the SVG specification.

Also, the elementID is an attribute of the element. And element is path, g (for group) , text , etc. something like:

Code: Select all

<text id="text123" style="font ... " x=100 y=100> A sample text  </text>
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.

JZA
Posts: 39
Joined: Sun Mar 25, 2012 7:09 am
Location: Cancun
Contact:

Re: Issues with Scripting on SVG

Postby JZA » Sat Jul 20, 2013 1:16 pm

Sorry I put it for a day, I switch to live for a month
http://pastebin.mozilla.org/2658398

Working SVG
http://pastebin.mozilla.org/2658402

It clearly worked on the first time, it should work on the second.

JZA
Posts: 39
Joined: Sun Mar 25, 2012 7:09 am
Location: Cancun
Contact:

Re: Issues with Scripting on SVG

Postby JZA » Sat Jul 20, 2013 2:25 pm

Ok was able to work with a friend. Final code's here:

http://pastebin.mozilla.org/2658558

Image

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Issues with Scripting on SVG

Postby hulf2012 » Sat Jul 20, 2013 4:50 pm

Hello:
Sigh ... I also found the same solution, but ... too late. Just change the X- position of your text and change the font size in the style.
In Inkscape, using the XML editor your "datetime" text appeared out of the page.
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.


Return to “SVG / XML Code”