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

SaveSnapshotAs from javascipt

Expand Messages
  • Bernhard Zwischenbrugger
    Hi Peoples Is there a javascipt function similar to SaveSnapshotAs in ASV? It is possible to do that with customizing the context menu but I want to make my
    Message 1 of 14 , May 28, 2003
    • 0 Attachment
      Hi Peoples

      Is there a javascipt function similar to SaveSnapshotAs in ASV?
      It is possible to do that with customizing the
      context menu but I want to make my own button to
      save the current snapshop to the local HD - is this possible?
      If yes how can I do that?

      Bernhard
    • Francis Hemsher
      ... I created the functions below to climb the current SVG tree in the embed on the web page, and send it as text to a textarea. It shouldn t be a problem to
      Message 2 of 14 , May 28, 2003
      • 0 Attachment
        Bernhard Zwischenbrugger wrote:

        > Is there a javascipt function similar to SaveSnapshotAs in ASV?
        > It is possible to do that with customizing the
        > context menu but I want to make my own button to
        > save the current snapshop to the local HD - is this possible?
        > If yes how can I do that?

        I created the functions below to climb the current SVG tree in the
        embed on the web page, and send it as text to a textarea. It
        shouldn't be a problem to make it a legitimate SVG file on your HD.

        I assume you have an embed in your html file that contains an svg file

        Give it an id:
        <embed id="svgEmbed" ....>

        Assume you have a textarea in HTML with the id="svgTextarea">

        Here is your button:

        <button onClick=getSnapshot()>Snapshot</button>

        <script>

        function getSnapshot()
        {
        var docSVG=document.embeds["svgEmbed"].getSVGDocument()
        var snapSVG=docSVG.documentElement
        SVGtext= showSVGstring(snapSVG, 0);
        svgTextarea.value=SVGtext
        }

        function showSVGstring(svgElement, level)
        {
        var nodeString = '';
        var childCount = 0;
        var nodeIndex = 0;
        if (svgElement.nodeName.indexOf("#") != 0 )
        {
        nodeString+="\n\r"
        nodeString += elementString(svgElement)
        }
        childCount = svgElement.childNodes.length;
        if (childCount > 0)
        {
        if(childCount==0 )nodeString
        += "</"+svgElement.nodeName+">\n\r"
        for (nodeIndex = 0; nodeIndex < childCount;
        nodeIndex++)
        {
        nodeString += showSVGstring
        (svgElement.childNodes.item(nodeIndex), level + 1);
        }
        nodeString += "</"+svgElement.nodeName+">\n\r"
        }
        return nodeString;
        }

        function elementString(svgElement)
        {
        elementNodeName=svgElement.nodeName

        elementText="<"+elementNodeName
        myAttribs=doAttribs(svgElement)
        if(myAttribs==" ")elementText+=">\n\r\n\r"
        else
        {
        elementText+=myAttribs
        if(svgElement.childNodes.length>0)
        elementText+=">\n\r\n\r"
        else
        elementText+="/>\n\r\n\r"
        }
        //----text, tspan, textSpan data
        if(elementNodeName=="text")
        {
        firstNode=svgElement.firstChild.nodeName
        if(firstNode=="#text")//---not a tspan
        elementText+=svgElement.firstChild.getData()
        }
        else if(elementNodeName=="tspan" ||
        elementNodeName=="textPath" )
        elementText+=svgElement.firstChild.getData()

        return elementText
        }

        function doAttribs(svgObject)
        {
        attribText=" "
        Attr=svgObject.attributes
        attribs=Attr.length
        for(i=0;i<attribs;i++)
        {
        attrName=Attr.item(i).nodeName
        attrValue=Attr.item
        (i).nodeValue

        attribText+=attrName+"=\""+attrValue+"\" "
        }
        return attribText
        }
        </SCRIPT>
      • Jim Ley
        Francis Hemsher wrote in message news:bb3bor+320i@eGroups.com... ... ASV provides printNode which serialises the tree, it s not
        Message 3 of 14 , May 29, 2003
        • 0 Attachment
          "Francis Hemsher" <francishemsher@...> wrote in message
          news:bb3bor+320i@......
          > Bernhard Zwischenbrugger wrote:
          >
          > > Is there a javascipt function similar to SaveSnapshotAs in ASV?
          > > It is possible to do that with customizing the
          > > context menu but I want to make my own button to
          > > save the current snapshop to the local HD - is this possible?
          > > If yes how can I do that?
          >
          > I created the functions below to climb the current SVG tree in the
          > embed on the web page, and send it as text to a textarea. It
          > shouldn't be a problem to make it a legitimate SVG file on your HD.

          ASV provides printNode which serialises the tree, it's not perfect (it can't
          cope with namespaces properly) but it's I think identical to the
          SaveSnapShotAs


          In an ASV document in IE, (from a file: url with lowered security for the
          intranet zone), you can do:

          output=printNode(SVGDoc)

          //Prompt for the output file.

          ref=parent.prompt("save to?",savePath)
          if (ref != null){
          parent.window.execScript('document.embeds[0].window.fso=new
          ActiveXObject("Scripting.FileSystemObject")')

          //Open it and write.
          of=fso.OpenTextFile(ref,2,true)
          of.Write(output)
          of.close()
          }

          No need to have an HTML wrapper or anything else.

          Jim.
        • arvind_sareen
          Hi I am creating a dynamic svg file which contains JavaScript files as part of xlink:href. I right click on the map and click on Save Current State , it saves
          Message 4 of 14 , Jun 2, 2003
          • 0 Attachment
            Hi

            I am creating a dynamic svg file which contains JavaScript files as
            part of xlink:href. I right click on the map and click on Save
            Current State , it saves the current svg file with its content but I
            am not able to save the JavaScript files which I have included as
            xlink:href .

            Please provide a workaround or solution to the above problem. If
            possible please provide with the sample code also.


            Regards

            Arvind
          • Jim Ley
            arvind_sareen wrote in message news:bbf7rk+u4d5@eGroups.com... ... If they are statically added, just bring them within the
            Message 5 of 14 , Jun 2, 2003
            • 0 Attachment
              "arvind_sareen" <arvind_sareen@...> wrote in message
              news:bbf7rk+u4d5@......
              > I am creating a dynamic svg file which contains JavaScript files as
              > part of xlink:href. I right click on the map and click on Save
              > Current State , it saves the current svg file with its content but I
              > am not able to save the JavaScript files which I have included as
              > xlink:href .

              If they are statically added, just bring them within the document, that will
              far and away be the easiest, the alternative is quite complicated.

              Jim.
            • arvind_sareen
              Hi They can be added in the svg file itself but the problem is that the js file itself is of 4000 lines which has been broken into 3 - 4 files so that they can
              Message 6 of 14 , Jun 2, 2003
              • 0 Attachment
                Hi

                They can be added in the svg file itself but the problem is that the
                js file itself is of 4000 lines which has been broken into 3 - 4
                files so that they can be accessed properly. For clarity should I
                paste a part of my code .

                Regards
                Arvind

                --- In svg-developers@yahoogroups.com, "Jim Ley" <jim@j...> wrote:
                >
                > "arvind_sareen" <arvind_sareen@y...> wrote in message
                > news:bbf7rk+u4d5@e...
                > > I am creating a dynamic svg file which contains JavaScript files
                as
                > > part of xlink:href. I right click on the map and click on Save
                > > Current State , it saves the current svg file with its content
                but I
                > > am not able to save the JavaScript files which I have included as
                > > xlink:href .
                >
                > If they are statically added, just bring them within the document,
                that will
                > far and away be the easiest, the alternative is quite complicated.
                >
                > Jim.
              • Chris Peto
                Hi, Just use getURL to get the js text and then postURL to write it with your svg by SnapShot. Mit freundlichen Grüßen/Regards Chris Peto Freelance System
                Message 7 of 14 , Jun 2, 2003
                • 0 Attachment
                  Hi,

                  Just use getURL to get the js text and then postURL to write it with your
                  svg by SnapShot.

                  Mit freundlichen Grüßen/Regards
                  Chris Peto
                  Freelance System Development
                  ------------------------------------
                  Resource Solutions
                  Höhenweg 34
                  63303 Dreieich - Götzenhain
                  Germany
                  Mobile: +49 (0) 173 308 7843
                  Tel:+49(0) 6103 80 21 98
                  Web: http://www.resource-solutions.de
                  mailto:CPeto@...
                  ------------------------------------
                  Member of: SPARK - SVG Programmers' Application Resource Kit
                  http://www.schemasoft.org/






                  -----Original Message-----
                  From: arvind_sareen [mailto:arvind_sareen@...]
                  Sent: Montag, 2. Juni 2003 12:11
                  To: svg-developers@yahoogroups.com
                  Subject: [svg-developers] SaveSnapshotAs for JavaScript files


                  Hi

                  I am creating a dynamic svg file which contains JavaScript files as
                  part of xlink:href. I right click on the map and click on Save
                  Current State , it saves the current svg file with its content but I
                  am not able to save the JavaScript files which I have included as
                  xlink:href .

                  Please provide a workaround or solution to the above problem. If
                  possible please provide with the sample code also.


                  Regards

                  Arvind




                  Yahoo! Groups Sponsor
                  ADVERTISEMENT




                  -----
                  To unsubscribe send a message to:
                  svg-developers-unsubscribe@yahoogroups.com
                  -or-
                  visit http://groups.yahoo.com/group/svg-developers and click "edit my
                  membership"
                  ----

                  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


                  [Non-text portions of this message have been removed]
                • Jim Ley
                  Chris Peto wrote in message news:NNEFIAKJNDEJDBOCDAMMIEKGCIAA.CPeto@resource-solutions.de... ... Save Snapshot is to save it
                  Message 8 of 14 , Jun 2, 2003
                  • 0 Attachment
                    "Chris Peto" <CPeto@...> wrote in message
                    news:NNEFIAKJNDEJDBOCDAMMIEKGCIAA.CPeto@......

                    >Just use getURL to get the js text and then postURL to write it with your
                    >svg by SnapShot.

                    Save Snapshot is to save it locally though, not to post it back to the
                    server, hence the complication... You would need to getURL the javascript as
                    you say, and then replace the script elements referencing the external doc,
                    with a script element with the content inline, cope with any encoding issues
                    you then find, and allow that to be saved.

                    I'm wondering if there is an easier approach to what the OP wants to achieve
                    though if we get the server involved and don't use saveSnapShot - but have
                    the server produce a static document to be saved.

                    Jim.
                  • Chris Peto
                    What function makes a non static picture of the svg? printNode? Mit freundlichen Gru?en/Regards Chris Peto Freelance System Development ... Resource Solutions
                    Message 9 of 14 , Jun 2, 2003
                    • 0 Attachment
                      What function makes a non static picture of the svg? printNode?

                      Mit freundlichen Gru?en/Regards
                      Chris Peto
                      Freelance System Development
                      ------------------------------------
                      Resource Solutions
                      Hohenweg 34
                      63303 Dreieich - Gotzenhain
                      Germany
                      Mobile: +49 (0) 173 308 7843
                      Tel:+49(0) 6103 80 21 98
                      Web: http://www.resource-solutions.de
                      mailto:CPeto@...
                      ------------------------------------
                      Member of: SPARK - SVG Programmers' Application Resource Kit
                      http://www.schemasoft.org/






                      -----Original Message-----
                      From: news [mailto:news@...]On Behalf Of Jim Ley
                      Sent: Montag, 2. Juni 2003 12:37
                      To: svg-developers@yahoogroups.com
                      Subject: [svg-developers] Re: SaveSnapshotAs for JavaScript files



                      "Chris Peto" <CPeto@...> wrote in message
                      news:NNEFIAKJNDEJDBOCDAMMIEKGCIAA.CPeto@......

                      >Just use getURL to get the js text and then postURL to write it with your
                      >svg by SnapShot.

                      Save Snapshot is to save it locally though, not to post it back to the
                      server, hence the complication... You would need to getURL the javascript
                      as
                      you say, and then replace the script elements referencing the external
                      doc,
                      with a script element with the content inline, cope with any encoding
                      issues
                      you then find, and allow that to be saved.

                      I'm wondering if there is an easier approach to what the OP wants to
                      achieve
                      though if we get the server involved and don't use saveSnapShot - but have
                      the server produce a static document to be saved.

                      Jim.




                      Yahoo! Groups Sponsor



                      -----
                      To unsubscribe send a message to:
                      svg-developers-unsubscribe@yahoogroups.com
                      -or-
                      visit http://groups.yahoo.com/group/svg-developers and click "edit my
                      membership"
                      ----

                      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


                      [Non-text portions of this message have been removed]
                    • arvind_sareen
                      Hi Can u provide a sample code for the same so that I become more clear about how to go about it and I am able to proceed forward. Regards Arvind ... with your
                      Message 10 of 14 , Jun 2, 2003
                      • 0 Attachment
                        Hi

                        Can u provide a sample code for the same so that I become more clear
                        about how to go about it and I am able to proceed forward.

                        Regards

                        Arvind

                        --- In svg-developers@yahoogroups.com, "Jim Ley" <jim@j...> wrote:
                        >
                        > "Chris Peto" <CPeto@r...> wrote in message
                        > news:NNEFIAKJNDEJDBOCDAMMIEKGCIAA.CPeto@r...
                        >
                        > >Just use getURL to get the js text and then postURL to write it
                        with your
                        > >svg by SnapShot.
                        >
                        > Save Snapshot is to save it locally though, not to post it back to
                        the
                        > server, hence the complication... You would need to getURL the
                        javascript as
                        > you say, and then replace the script elements referencing the
                        external doc,
                        > with a script element with the content inline, cope with any
                        encoding issues
                        > you then find, and allow that to be saved.
                        >
                        > I'm wondering if there is an easier approach to what the OP wants
                        to achieve
                        > though if we get the server involved and don't use saveSnapShot -
                        but have
                        > the server produce a static document to be saved.
                        >
                        > Jim.
                      • Jim Ley
                        arvind_sareen wrote in message news:bbfapg+qf05@eGroups.com... ... It s non-trivial, if you say what you re trying to achieve,
                        Message 11 of 14 , Jun 2, 2003
                        • 0 Attachment
                          "arvind_sareen" <arvind_sareen@...> wrote in message
                          news:bbfapg+qf05@......
                          > Can u provide a sample code for the same so that I become more clear
                          > about how to go about it and I am able to proceed forward.

                          It's non-trivial, if you say what you're trying to achieve, (such as I want
                          the user to be able to paint a picture then have it saved locally) there
                          might be a better approach involving the server.

                          Otherwise getURL, createElement/ appendChild/ removeChild etc. are the
                          methods you'll need to use.

                          Jim.
                        • ronan@roasp.com
                          Hi Arvind, Look in your browser cache. Your javascript file will be there. In IE, it will be clearly named, but in NS/MOZ you may want to clear your cache
                          Message 12 of 14 , Jun 2, 2003
                          • 0 Attachment
                            Hi Arvind,

                            Look in your browser cache. Your javascript file will be there. In IE, it will
                            be clearly named, but in NS/MOZ you may want to clear your cache first since
                            the name is obfuscated.

                            Ronan

                            Quoting arvind_sareen <arvind_sareen@...>:

                            > Hi
                            >
                            > I am creating a dynamic svg file which contains JavaScript files as
                            > part of xlink:href. I right click on the map and click on Save
                            > Current State , it saves the current svg file with its content but I
                            > am not able to save the JavaScript files which I have included as
                            > xlink:href .
                            >
                            > Please provide a workaround or solution to the above problem. If
                            > possible please provide with the sample code also.
                            >
                            >
                            > Regards
                            >
                            > Arvind
                            >
                            >
                            >
                            >
                            >
                            > -----
                            > To unsubscribe send a message to: svg-developers-unsubscribe@yahoogroups.com
                            > -or-
                            > visit http://groups.yahoo.com/group/svg-developers and click "edit my
                            > membership"
                            > ----
                            >
                            > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                            >
                            >
                            >
                          • Arvind Sareen
                            Hi Ronan, But how will i save these files on the local hard disk of the client, so that the svg file saved on the hard disk of the client functions on his
                            Message 13 of 14 , Jun 2, 2003
                            • 0 Attachment
                              Hi Ronan,

                              But how will i save these files on the local hard disk
                              of the client, so that the svg file saved on the hard
                              disk of the client functions on his machine without
                              giving any error i.e. uses all the functions of these
                              js files.

                              Arvind
                              --- ronan@... wrote:
                              > Hi Arvind,
                              >
                              > Look in your browser cache. Your javascript file
                              > will be there. In IE, it will
                              > be clearly named, but in NS/MOZ you may want to
                              > clear your cache first since
                              > the name is obfuscated.
                              >
                              > Ronan
                              >
                              > Quoting arvind_sareen <arvind_sareen@...>:
                              >
                              > > Hi
                              > >
                              > > I am creating a dynamic svg file which contains
                              > JavaScript files as
                              > > part of xlink:href. I right click on the map and
                              > click on Save
                              > > Current State , it saves the current svg file with
                              > its content but I
                              > > am not able to save the JavaScript files which I
                              > have included as
                              > > xlink:href .
                              > >
                              > > Please provide a workaround or solution to the
                              > above problem. If
                              > > possible please provide with the sample code also.
                              > >
                              > >
                              > > Regards
                              > >
                              > > Arvind
                              > >
                              > >
                              > >
                              > >
                              > >
                              > > -----
                              > > To unsubscribe send a message to:
                              > svg-developers-unsubscribe@yahoogroups.com
                              > > -or-
                              > > visit http://groups.yahoo.com/group/svg-developers
                              > and click "edit my
                              > > membership"
                              > > ----
                              > >
                              > > Your use of Yahoo! Groups is subject to
                              > http://docs.yahoo.com/info/terms/
                              > >
                              > >
                              > >
                              >
                              >
                              >
                              >


                              __________________________________
                              Do you Yahoo!?
                              Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
                              http://calendar.yahoo.com
                            • Jim Ley
                              Arvind Sareen wrote in message news:20030602164944.55278.qmail@web9904.mail.yahoo.com... ... I think my favoured solution for this
                              Message 14 of 14 , Jun 2, 2003
                              • 0 Attachment
                                "Arvind Sareen" <arvind_sareen@...> wrote in message
                                news:20030602164944.55278.qmail@......
                                > Hi Ronan,
                                >
                                > But how will i save these files on the local hard disk
                                > of the client, so that the svg file saved on the hard
                                > disk of the client functions on his machine without
                                > giving any error i.e. uses all the functions of these
                                > js files.

                                I think my favoured solution for this will be to postURL some SVG snippets
                                back to the server, and have the server generate the complete document ready
                                to be saved, saveSnapShotAs isn't ideal, and the complication of external js
                                files will complicate life.

                                Jim.
                              Your message has been successfully submitted and would be delivered to recipients shortly.