Loading ...
Sorry, an error occurred while loading the content.
 

using Javascript functions in SVG

Expand Messages
  • ivana.moric
    Hi all. I am havig trouble using JS functioned from Adobe SVG in firefox. I have the program which uses them and it works in IE with asv3.0 installed (6.0
    Message 1 of 8 , Jun 17, 2008
      Hi all. I am havig trouble using JS functioned from Adobe SVG in
      firefox. I have the program which uses them and it works in IE with
      asv3.0 installed (6.0 doesn't work at all). but when i open the same
      file in forefox, it doesnt show svg element or move it. i have tried
      switching native support off and copying NPSVG3.dll and . zip to
      plugins folder of mozilla, but that doesn't work and causes mozilla to
      crash. can anyone help me. I will put a part of used code here, i can
      put it all if necessary:

      <script type="text/ecmascript" a3:scriptImplementation="Adobe"><![CDATA[
      function init(evt){
      if (!window.svgDocument)svgDocument = evt.target.ownerDocument;
      vozilopogled=svgDocument.getElementById("pogled")
      voziloPointer=svgDocument.getElementById("pointer")
      voziloime=svgDocument.getElementById("trackime")

      getURL("Files/data.xml",loaded);
      }
      function loaded(obj){
      if(obj.success){
      var frag = parseXML(obj.content, svgDocument)
      //stvaranje instance widgeta "vozilo", te prosljedivanje ID-a kao
      argumenta.
      vozilo=new vozilo(frag.firstChild.getAttribute("id"))
      vozilo.parseData(frag.firstChild.firstChild.getData())
      }
      }
      ...
    • Samuel Dagan
      Hi Ivana, You ll find the answers in http://jwatt.org/svg/authoring/ Good luck, Samy ... to ... can ... [CDATA[ ... evt.target.ownerDocument; ... kao
      Message 2 of 8 , Jun 17, 2008
        Hi Ivana,
        You'll find the answers in http://jwatt.org/svg/authoring/
        Good luck, Samy


        --- In svg-developers@yahoogroups.com, "ivana.moric"
        <ivana.moric@...> wrote:
        >
        > Hi all. I am havig trouble using JS functioned from Adobe SVG in
        > firefox. I have the program which uses them and it works in IE with
        > asv3.0 installed (6.0 doesn't work at all). but when i open the same
        > file in forefox, it doesnt show svg element or move it. i have tried
        > switching native support off and copying NPSVG3.dll and . zip to
        > plugins folder of mozilla, but that doesn't work and causes mozilla
        to
        > crash. can anyone help me. I will put a part of used code here, i
        can
        > put it all if necessary:
        >
        > <script type="text/ecmascript" a3:scriptImplementation="Adobe"><!
        [CDATA[
        > function init(evt){
        > if (!window.svgDocument)svgDocument =
        evt.target.ownerDocument;
        > vozilopogled=svgDocument.getElementById("pogled")
        > voziloPointer=svgDocument.getElementById("pointer")
        > voziloime=svgDocument.getElementById("trackime")
        >
        > getURL("Files/data.xml",loaded);
        > }
        > function loaded(obj){
        > if(obj.success){
        > var frag = parseXML(obj.content, svgDocument)
        > //stvaranje instance widgeta "vozilo", te prosljedivanje ID-a
        kao
        > argumenta.
        > vozilo=new vozilo(frag.firstChild.getAttribute("id"))
        > vozilo.parseData(frag.firstChild.firstChild.getData())
        > }
        > }
        > ...
        >
      • ivana.moric
        ... i have read that link but i am inexpirienced in this so i don t know what and how to change. if someone would be kind enough to help me, i would be most
        Message 3 of 8 , Jun 18, 2008
          --- In svg-developers@yahoogroups.com, "Samuel Dagan" <dagan@...> wrote:
          >
          > Hi Ivana,
          > You'll find the answers in http://jwatt.org/svg/authoring/
          > Good luck, Samy
          >
          >
          > --- In svg-developers@yahoogroups.com, "ivana.moric"
          > <ivana.moric@> wrote:
          > >
          > > Hi all. I am havig trouble using JS functioned from Adobe SVG in
          > > firefox. I have the program which uses them and it works in IE with
          > > asv3.0 installed (6.0 doesn't work at all). but when i open the same
          > > file in forefox, it doesnt show svg element or move it. i have tried
          > > switching native support off and copying NPSVG3.dll and . zip to
          > > plugins folder of mozilla, but that doesn't work and causes mozilla
          > to
          > > crash. can anyone help me. I will put a part of used code here, i
          > can
          > > put it all if necessary:
          > >
          > > <script type="text/ecmascript" a3:scriptImplementation="Adobe"><!
          > [CDATA[
          > > function init(evt){
          > > if (!window.svgDocument)svgDocument =
          > evt.target.ownerDocument;
          > > vozilopogled=svgDocument.getElementById("pogled")
          > > voziloPointer=svgDocument.getElementById("pointer")
          > > voziloime=svgDocument.getElementById("trackime")
          > >
          > > getURL("Files/data.xml",loaded);
          > > }
          > > function loaded(obj){
          > > if(obj.success){
          > > var frag = parseXML(obj.content, svgDocument)
          > > //stvaranje instance widgeta "vozilo", te prosljedivanje ID-a
          > kao
          > > argumenta.
          > > vozilo=new vozilo(frag.firstChild.getAttribute("id"))
          > > vozilo.parseData(frag.firstChild.firstChild.getData())
          > > }
          > > }
          > > ...
          > >
          >

          i have read that link but i am inexpirienced in this so i don't know
          what and how to change. if someone would be kind enough to help me, i
          would be most grateful. i can send him whole cose (there is not much
          of it)
        • Samuel Dagan
          Hi Ivana, I found that most of the lines of your example are not conformed to the J.Watt s authoring guide, but if I ll correct the them, it won t help you to
          Message 4 of 8 , Jun 19, 2008
            Hi Ivana,
            I found that most of the lines of your example are not conformed to
            the J.Watt's authoring guide, but if I'll correct the them, it won't
            help you to learn anything. Instead of it I am writing below a svg
            file, written according to the rules. First run it, and try to
            understand it. Afterwards you can change few lines, run it again and
            look at the error console (in Firefox: tools, Error console). That way
            you'll have less errors and you'll be able to do easily the corrections.
            Here comes the file, cheers:

            <?xml version="1.0" encoding="UTF-8"?>
            <svg version="1.1" baseProfile="full"
            xmlns="http://www.w3.org/2000/svg"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xmlns:ev="http://www.w3.org/2001/xml-events"
            width="100%" height="100%"
            viewBox="-320 -280 630 570"
            onload="init(evt);">

            <title>Monotonic functions</title>
            <rect x="-320" y="-280" width="630" height="570"
            style="stroke:red; stroke-width:2; fill:none" />

            <script type="text/ecmascript"><![CDATA[
            if (!window) window = this;
            var obj; //object
            var dtime=50; //delta time (msec)
            var timer; //timer for animation
            var del=0.4; //step = 0.4 %
            var beg=0; //beg value "
            var end=100; //end value for "
            var val=0; //current value for "
            function init(evt){
            show();
            }
            function show(){
            if((end-val)<=del){
            val=end;
            get();
            val=beg;
            timer=setTimeout("show()", dtime);
            return;
            }
            val=val+del;
            timer=setTimeout("show()", dtime);
            get();
            }
            function get(){
            obj = document.getElementById("inc");
            obj.setAttributeNS(null,"startOffset",""+val+"%");
            obj = document.getElementById("dec");
            obj.setAttributeNS(null,"startOffset",""+val+"%");
            }
            //
            ]]>
            </script>

            <defs>
            <path style="stroke:#993300; fill:none; stroke-width:2;"
            id="cubic" d="M-300 270C-100 -270,100 270,300 -270" />
            <path style="stroke:#cc0066; fill:none; stroke-width:2;"
            id="linear" d="M-300 -270L300 270" />
            </defs>
            <use xlink:href="#cubic"/>
            <use xlink:href="#linear"/>
            <g style="font-style:italic; font-size:24pt; font-family:serif;
            font-weight:bold;stroke:none;">
            <text fill="#930" dy="30">
            <textPath id="inc" xlink:href="#cubic" startOffset="0%">
            y = x³</textPath></text>
            <text fill="#c06" dy="-10" text-anchor="end">
            <textPath id="dec" xlink:href="#linear" startOffset="0%">
            y = −9x</textPath></text>
            </g>
            </svg>



            --- In svg-developers@yahoogroups.com, "ivana.moric" <ivana.moric@...>
            wrote:
            >
            > --- In svg-developers@yahoogroups.com, "Samuel Dagan" <dagan@> wrote:
            > >
            > > Hi Ivana,
            > > You'll find the answers in http://jwatt.org/svg/authoring/
            > > Good luck, Samy
            > >
            > >
            > > --- In svg-developers@yahoogroups.com, "ivana.moric"
            > > <ivana.moric@> wrote:
            > > >
            > > > Hi all. I am havig trouble using JS functioned from Adobe SVG in
            > > > firefox. I have the program which uses them and it works in IE with
            > > > asv3.0 installed (6.0 doesn't work at all). but when i open the same
            > > > file in forefox, it doesnt show svg element or move it. i have tried
            > > > switching native support off and copying NPSVG3.dll and . zip to
            > > > plugins folder of mozilla, but that doesn't work and causes mozilla
            > > to
            > > > crash. can anyone help me. I will put a part of used code here, i
            > > can
            > > > put it all if necessary:
            > > >
            > > > <script type="text/ecmascript" a3:scriptImplementation="Adobe"><!
            > > [CDATA[
            > > > function init(evt){
            > > > if (!window.svgDocument)svgDocument =
            > > evt.target.ownerDocument;
            > > > vozilopogled=svgDocument.getElementById("pogled")
            > > > voziloPointer=svgDocument.getElementById("pointer")
            > > > voziloime=svgDocument.getElementById("trackime")
            > > >
            > > > getURL("Files/data.xml",loaded);
            > > > }
            > > > function loaded(obj){
            > > > if(obj.success){
            > > > var frag = parseXML(obj.content, svgDocument)
            > > > //stvaranje instance widgeta "vozilo", te prosljedivanje ID-a
            > > kao
            > > > argumenta.
            > > > vozilo=new vozilo(frag.firstChild.getAttribute("id"))
            > > > vozilo.parseData(frag.firstChild.firstChild.getData())
            > > > }
            > > > }
            > > > ...
            > > >
            > >
            >
            > i have read that link but i am inexpirienced in this so i don't know
            > what and how to change. if someone would be kind enough to help me, i
            > would be most grateful. i can send him whole cose (there is not much
            > of it)
            >
          • Ivana
            ... with ... the same ... tried ... mozilla ... ID-a ... errr... this is suppose to do something? cause all i get is This XML file does not appear to have any
            Message 5 of 8 , Jun 19, 2008
              --- In svg-developers@yahoogroups.com, "Samuel Dagan" <dagan@...> wrote:
              >
              > Hi Ivana,
              > I found that most of the lines of your example are not conformed to
              > the J.Watt's authoring guide, but if I'll correct the them, it won't
              > help you to learn anything. Instead of it I am writing below a svg
              > file, written according to the rules. First run it, and try to
              > understand it. Afterwards you can change few lines, run it again and
              > look at the error console (in Firefox: tools, Error console). That way
              > you'll have less errors and you'll be able to do easily the corrections.
              > Here comes the file, cheers:
              >
              > <?xml version="1.0" encoding="UTF-8"?>
              > <svg version="1.1" baseProfile="full"
              > xmlns="http://www.w3.org/2000/svg"
              > xmlns:xlink="http://www.w3.org/1999/xlink"
              > xmlns:ev="http://www.w3.org/2001/xml-events"
              > width="100%" height="100%"
              > viewBox="-320 -280 630 570"
              > onload="init(evt);">
              >
              > <title>Monotonic functions</title>
              > <rect x="-320" y="-280" width="630" height="570"
              > style="stroke:red; stroke-width:2; fill:none" />
              >
              > <script type="text/ecmascript"><![CDATA[
              > if (!window) window = this;
              > var obj; //object
              > var dtime=50; //delta time (msec)
              > var timer; //timer for animation
              > var del=0.4; //step = 0.4 %
              > var beg=0; //beg value "
              > var end=100; //end value for "
              > var val=0; //current value for "
              > function init(evt){
              > show();
              > }
              > function show(){
              > if((end-val)<=del){
              > val=end;
              > get();
              > val=beg;
              > timer=setTimeout("show()", dtime);
              > return;
              > }
              > val=val+del;
              > timer=setTimeout("show()", dtime);
              > get();
              > }
              > function get(){
              > obj = document.getElementById("inc");
              > obj.setAttributeNS(null,"startOffset",""+val+"%");
              > obj = document.getElementById("dec");
              > obj.setAttributeNS(null,"startOffset",""+val+"%");
              > }
              > //
              > ]]>
              > </script>
              >
              > <defs>
              > <path style="stroke:#993300; fill:none; stroke-width:2;"
              > id="cubic" d="M-300 270C-100 -270,100 270,300 -270" />
              > <path style="stroke:#cc0066; fill:none; stroke-width:2;"
              > id="linear" d="M-300 -270L300 270" />
              > </defs>
              > <use xlink:href="#cubic"/>
              > <use xlink:href="#linear"/>
              > <g style="font-style:italic; font-size:24pt; font-family:serif;
              > font-weight:bold;stroke:none;">
              > <text fill="#930" dy="30">
              > <textPath id="inc" xlink:href="#cubic" startOffset="0%">
              > y = x³</textPath></text>
              > <text fill="#c06" dy="-10" text-anchor="end">
              > <textPath id="dec" xlink:href="#linear" startOffset="0%">
              > y = −9x</textPath></text>
              > </g>
              > </svg>
              >
              >
              >
              > --- In svg-developers@yahoogroups.com, "ivana.moric" <ivana.moric@>
              > wrote:
              > >
              > > --- In svg-developers@yahoogroups.com, "Samuel Dagan" <dagan@> wrote:
              > > >
              > > > Hi Ivana,
              > > > You'll find the answers in http://jwatt.org/svg/authoring/
              > > > Good luck, Samy
              > > >
              > > >
              > > > --- In svg-developers@yahoogroups.com, "ivana.moric"
              > > > <ivana.moric@> wrote:
              > > > >
              > > > > Hi all. I am havig trouble using JS functioned from Adobe SVG in
              > > > > firefox. I have the program which uses them and it works in IE
              with
              > > > > asv3.0 installed (6.0 doesn't work at all). but when i open
              the same
              > > > > file in forefox, it doesnt show svg element or move it. i have
              tried
              > > > > switching native support off and copying NPSVG3.dll and . zip to
              > > > > plugins folder of mozilla, but that doesn't work and causes
              mozilla
              > > > to
              > > > > crash. can anyone help me. I will put a part of used code here, i
              > > > can
              > > > > put it all if necessary:
              > > > >
              > > > > <script type="text/ecmascript" a3:scriptImplementation="Adobe"><!
              > > > [CDATA[
              > > > > function init(evt){
              > > > > if (!window.svgDocument)svgDocument =
              > > > evt.target.ownerDocument;
              > > > > vozilopogled=svgDocument.getElementById("pogled")
              > > > > voziloPointer=svgDocument.getElementById("pointer")
              > > > > voziloime=svgDocument.getElementById("trackime")
              > > > >
              > > > > getURL("Files/data.xml",loaded);
              > > > > }
              > > > > function loaded(obj){
              > > > > if(obj.success){
              > > > > var frag = parseXML(obj.content, svgDocument)
              > > > > //stvaranje instance widgeta "vozilo", te prosljedivanje
              ID-a
              > > > kao
              > > > > argumenta.
              > > > > vozilo=new vozilo(frag.firstChild.getAttribute("id"))
              > > > > vozilo.parseData(frag.firstChild.firstChild.getData())
              > > > > }
              > > > > }
              > > > > ...
              > > > >
              > > >
              > >
              > > i have read that link but i am inexpirienced in this so i don't know
              > > what and how to change. if someone would be kind enough to help me, i
              > > would be most grateful. i can send him whole cose (there is not much
              > > of it)
              > >
              >

              errr... this is suppose to do something? cause all i get is This XML
              file does not appear to have any style information associated with it.
              The document tree is shown below message (after i have corrected some
              typos) :(

              the thing is i'm on a deadline and don't have time to test and change
              things. but i promise i will after it has passed :)
            • Samuel Dagan
              Hi Ivana, The code I ve sent you is an SVG file not a XML file. You should copy all of of its content to a file called something.svg , for example
              Message 6 of 8 , Jun 20, 2008
                Hi Ivana,
                The code I've sent you is an SVG file not a XML file. You should copy
                all of of its content to a file called "something.svg", for example
                "ivana.svg". It runs with IE+ASV, Firefox and Opera. Good luck, Samy

                --- In svg-developers@yahoogroups.com, "Ivana" <ivana.moric@...> wrote:
                >
                > --- In svg-developers@yahoogroups.com, "Samuel Dagan" <dagan@> wrote:
                > >
                > > Hi Ivana,
                > > I found that most of the lines of your example are not conformed to
                > > the J.Watt's authoring guide, but if I'll correct the them, it won't
                > > help you to learn anything. Instead of it I am writing below a svg
                > > file, written according to the rules. First run it, and try to
                > > understand it. Afterwards you can change few lines, run it again and
                > > look at the error console (in Firefox: tools, Error console). That way
                > > you'll have less errors and you'll be able to do easily the
                corrections.
                > > Here comes the file, cheers:
                > >
                > > <?xml version="1.0" encoding="UTF-8"?>
                > > <svg version="1.1" baseProfile="full"
                > > xmlns="http://www.w3.org/2000/svg"
                > > xmlns:xlink="http://www.w3.org/1999/xlink"
                > > xmlns:ev="http://www.w3.org/2001/xml-events"
                > > width="100%" height="100%"
                > > viewBox="-320 -280 630 570"
                > > onload="init(evt);">
                > >
                > > <title>Monotonic functions</title>
                > > <rect x="-320" y="-280" width="630" height="570"
                > > style="stroke:red; stroke-width:2; fill:none" />
                > >
                > > <script type="text/ecmascript"><![CDATA[
                > > if (!window) window = this;
                > > var obj; //object
                > > var dtime=50; //delta time (msec)
                > > var timer; //timer for animation
                > > var del=0.4; //step = 0.4 %
                > > var beg=0; //beg value "
                > > var end=100; //end value for "
                > > var val=0; //current value for "
                > > function init(evt){
                > > show();
                > > }
                > > function show(){
                > > if((end-val)<=del){
                > > val=end;
                > > get();
                > > val=beg;
                > > timer=setTimeout("show()", dtime);
                > > return;
                > > }
                > > val=val+del;
                > > timer=setTimeout("show()", dtime);
                > > get();
                > > }
                > > function get(){
                > > obj = document.getElementById("inc");
                > > obj.setAttributeNS(null,"startOffset",""+val+"%");
                > > obj = document.getElementById("dec");
                > > obj.setAttributeNS(null,"startOffset",""+val+"%");
                > > }
                > > //
                > > ]]>
                > > </script>
                > >
                > > <defs>
                > > <path style="stroke:#993300; fill:none; stroke-width:2;"
                > > id="cubic" d="M-300 270C-100 -270,100 270,300 -270" />
                > > <path style="stroke:#cc0066; fill:none; stroke-width:2;"
                > > id="linear" d="M-300 -270L300 270" />
                > > </defs>
                > > <use xlink:href="#cubic"/>
                > > <use xlink:href="#linear"/>
                > > <g style="font-style:italic; font-size:24pt; font-family:serif;
                > > font-weight:bold;stroke:none;">
                > > <text fill="#930" dy="30">
                > > <textPath id="inc" xlink:href="#cubic" startOffset="0%">
                > > y = x³</textPath></text>
                > > <text fill="#c06" dy="-10" text-anchor="end">
                > > <textPath id="dec" xlink:href="#linear" startOffset="0%">
                > > y = −9x</textPath></text>
                > > </g>
                > > </svg>
                > >
                > >
                > >
                > > --- In svg-developers@yahoogroups.com, "ivana.moric" <ivana.moric@>
                > > wrote:
                > > >
                > > > --- In svg-developers@yahoogroups.com, "Samuel Dagan" <dagan@>
                wrote:
                > > > >
                > > > > Hi Ivana,
                > > > > You'll find the answers in http://jwatt.org/svg/authoring/
                > > > > Good luck, Samy
                > > > >
                > > > >
                > > > > --- In svg-developers@yahoogroups.com, "ivana.moric"
                > > > > <ivana.moric@> wrote:
                > > > > >
                > > > > > Hi all. I am havig trouble using JS functioned from Adobe SVG in
                > > > > > firefox. I have the program which uses them and it works in IE
                > with
                > > > > > asv3.0 installed (6.0 doesn't work at all). but when i open
                > the same
                > > > > > file in forefox, it doesnt show svg element or move it. i have
                > tried
                > > > > > switching native support off and copying NPSVG3.dll and . zip to
                > > > > > plugins folder of mozilla, but that doesn't work and causes
                > mozilla
                > > > > to
                > > > > > crash. can anyone help me. I will put a part of used code
                here, i
                > > > > can
                > > > > > put it all if necessary:
                > > > > >
                > > > > > <script type="text/ecmascript"
                a3:scriptImplementation="Adobe"><!
                > > > > [CDATA[
                > > > > > function init(evt){
                > > > > > if (!window.svgDocument)svgDocument =
                > > > > evt.target.ownerDocument;
                > > > > > vozilopogled=svgDocument.getElementById("pogled")
                > > > > > voziloPointer=svgDocument.getElementById("pointer")
                > > > > > voziloime=svgDocument.getElementById("trackime")
                > > > > >
                > > > > > getURL("Files/data.xml",loaded);
                > > > > > }
                > > > > > function loaded(obj){
                > > > > > if(obj.success){
                > > > > > var frag = parseXML(obj.content, svgDocument)
                > > > > > //stvaranje instance widgeta "vozilo", te prosljedivanje
                > ID-a
                > > > > kao
                > > > > > argumenta.
                > > > > > vozilo=new vozilo(frag.firstChild.getAttribute("id"))
                > > > > > vozilo.parseData(frag.firstChild.firstChild.getData())
                > > > > > }
                > > > > > }
                > > > > > ...
                > > > > >
                > > > >
                > > >
                > > > i have read that link but i am inexpirienced in this so i don't know
                > > > what and how to change. if someone would be kind enough to help
                me, i
                > > > would be most grateful. i can send him whole cose (there is not much
                > > > of it)
                > > >
                > >
                >
                > errr... this is suppose to do something? cause all i get is This XML
                > file does not appear to have any style information associated with it.
                > The document tree is shown below message (after i have corrected some
                > typos) :(
                >
                > the thing is i'm on a deadline and don't have time to test and change
                > things. but i promise i will after it has passed :)
                >
              • Ivana
                I know it s an svg file, i have copied the code in file.svg, corrected 2 typoes, and tried to run it in mozilla...
                Message 7 of 8 , Jun 20, 2008
                  I know it's an svg file, i have copied the code in file.svg, corrected
                  2 typoes, and tried to run it in mozilla...
                • steltenpower
                  Are you running it of an ill-configured server maybe? Put the file right on your desktop and try (again).
                  Message 8 of 8 , Jun 23, 2008
                    Are you running it of an ill-configured server maybe?
                    Put the file right on your desktop and try (again).


                    --- In svg-developers@yahoogroups.com, "Ivana" <ivana.moric@...> wrote:
                    >
                    > I know it's an svg file, i have copied the code in file.svg, corrected
                    > 2 typoes, and tried to run it in mozilla...
                    >
                  Your message has been successfully submitted and would be delivered to recipients shortly.