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

Re: Relative File Path

Expand Messages
  • iwelina79
    Jan, you re right that ActiveXObject function does not exist in SVG, but when svg is embeded in html it works.
    Message 1 of 5 , Mar 31, 2004
    • 0 Attachment
      Jan, you're right that ActiveXObject function does not exist in SVG,
      but when svg is embeded in html it works.
    • Jan-Klaas Kollhof
      Hi, ... I know it works. I just don t agree with using it unless there is no other way. SVG 1.2 will bring us file access in a well mannered way!? If you
      Message 2 of 5 , Mar 31, 2004
      • 0 Attachment
        Hi,

        > but when svg is embeded in html it works.

        I know it works. I just don't agree with using it unless there is no
        other way.
        SVG 1.2 will bring us file access in a well mannered way!?

        If you really really need it,
        try to get the location of the SVG and then just take the path part
        without the file name of that url and concatenate it with the file
        name you need to create the file with. That should work.


        Jan
      • paulroubekas
        The following function should help you get a start. ======================================================= /***** * * calcDirectoryNavigationPrefix() * * *
        Message 3 of 5 , Mar 31, 2004
        • 0 Attachment
          The following function should help you get a start.


          =======================================================
          /*****
          *
          * calcDirectoryNavigationPrefix()
          *
          *
          * This function stores the directory structure of the CMIDTFDA
          application
          * in it's directoryLevelsUpToRoot Object. Should the directory
          structure change
          * hardcoded directoryLevelsUpToRoot initilizations
          * statements need adjusted. From a purest perspecive this not the
          best way to
          * design this. It is
          * hardcoding that
          * should not be a maintenace nightmare. There is also nothing
          stopping a latter
          * version from replacing this hardcoded logic with a better design.
          *
          * This function will calculate the directory navigation needed to
          get back to the
          * applicatin root directory.
          *
          *****/
          function calcDirectoryNavigationPrefix() {

          var directoryLevelsUpToRoot = new Object;
          var workWithPath;

          directoryLevelsUpToRoot.CascadingStyleSheets = 1;
          directoryLevelsUpToRoot.ECMAScript = 1;
          directoryLevelsUpToRoot.Centers = 1;
          directoryLevelsUpToRoot.svgFragments = 1;

          directoryLevelsUpToRoot.c1 = 2;
          directoryLevelsUpToRoot.c2 = 2;
          directoryLevelsUpToRoot.c3 = 2;
          directoryLevelsUpToRoot.c4 = 2;
          directoryLevelsUpToRoot.c5 = 2;
          directoryLevelsUpToRoot.c6 = 2;
          directoryLevelsUpToRoot.c7 = 2;
          directoryLevelsUpToRoot.c8 = 2;
          directoryLevelsUpToRoot.c9 = 2;
          directoryLevelsUpToRoot.c10 = 2;
          directoryLevelsUpToRoot.c11 = 2;
          directoryLevelsUpToRoot.c12 = 2;

          directoryLevelsUpToRoot.c1Facilities = 3;

          directoryLevelsUpToRoot.c110X10 = 4;
          directoryLevelsUpToRoot.c11NW = 4;
          directoryLevelsUpToRoot.c18x6 = 4;
          directoryLevelsUpToRoot.c19x15 = 4;
          directoryLevelsUpToRoot.c1AAPL = 4;
          directoryLevelsUpToRoot.c1ALF5 = 4;
          directoryLevelsUpToRoot.c1ALF6 = 4;
          directoryLevelsUpToRoot.c1ALF8 = 4;
          directoryLevelsUpToRoot.c1APSIM = 4;
          directoryLevelsUpToRoot.c1ARMOLD = 4;
          directoryLevelsUpToRoot.c1ASCR = 4;
          directoryLevelsUpToRoot.c1B2 = 4;

          directoryLevelsUpToRoot.c110x10Archives = 5;
          directoryLevelsUpToRoot.c11NWArchives = 5;
          directoryLevelsUpToRoot.c18x6Archives = 5;
          directoryLevelsUpToRoot.c19x15Archives = 5;
          directoryLevelsUpToRoot.c1AAPLArchives = 5;
          directoryLevelsUpToRoot.c1ALF5Archives = 5;
          directoryLevelsUpToRoot.c1ALF6Archives = 5;
          directoryLevelsUpToRoot.c1ALF8Archives = 5;
          directoryLevelsUpToRoot.c1APSIMArchives = 5;
          directoryLevelsUpToRoot.c1ARMOLDArchives = 5;
          directoryLevelsUpToRoot.c1ASCRArchives = 5;
          directoryLevelsUpToRoot.c1B2Archives = 5;


          /*** Debugging
          var i = 0;
          names = "";
          for(name in directoryLevelsUpToRoot){names += name + "\t";
          i++ }
          var workWithString = names + "\n" + i;
          alert(workWithString);
          */

          var workWithString;
          var workWithSplitPath;
          var workWithDirectory;
          var evalString;
          var result;
          var matchArray = null;
          workWithString = location.pathname;
          locationString = location.toString();

          // First try assuming you are on a server and the directory
          seperator
          // is a '/'. If that does not work, try a using a '\' for
          when you
          // on a local harddrive.
          matchArray = locationString.match("file:///");
          if (matchArray == null || matchArray == undefined) {
          workWithSplitPath = workWithString.split("/");
          } else {
          workWithSplitPath = workWithString.split("\\");
          }

          workWithDirectory = workWithSplitPath
          [workWithSplitPath.length - 2];
          evalString = "directoryLevelsUpToRoot" + "." +
          workWithDirectory + ";";
          result = eval(evalString);
          workWithString = "";
          for (var i = 0; i < result; i++){
          workWithString = "../".concat(workWithString)
          }

          /** Debugging
          alert(workWithString);
          */
          // The result should never change during the rendering of a
          // SVG Document so
          // to save time save the result in a global variable for later
          // reference.
          truckSVGDocumentPrefixToRootDirectory = workWithString;
          return workWithString;
          }

          =======================================================


          --- In svg-developers@yahoogroups.com, "Jan-Klaas Kollhof"
          <keyjaque@y...> wrote:
          > Hi,
          >
          > > but when svg is embeded in html it works.
          >
          > I know it works. I just don't agree with using it unless there is no
          > other way.
          > SVG 1.2 will bring us file access in a well mannered way!?
          >
          > If you really really need it,
          > try to get the location of the SVG and then just take the path part
          > without the file name of that url and concatenate it with the file
          > name you need to create the file with. That should work.
          >
          >
          > Jan
        Your message has been successfully submitted and would be delivered to recipients shortly.