I was looking at a way of making the DynAPI.include method more simple.  Here's what I came up with:

include : function(src,path) {
  srcArray = src.split('.');
  if (!path) var path=DynAPI.librarypath;
  var pckg=srcArray[0];
  var grp=srcArray[1];
  var file=srcArray[2];
  if (file=='*') {
    if (DynAPI.packages[pckg]) group=DynAPI.packages[pckg][grp];
    if (group) for (var i in group) document.write('<script language="Javascript1.2" src="'+path+pckg+'/'+grp+'/'+group[i]+'.js"><\/script>');
    else alert('include()\n\nThe following package could not be loaded:\n'+src+'\n\nmake sure you specified the correct path.');
  } else {
     if (path[path.length-1] != "/") path += "/";
     document.write('<script language="Javascript1.2" src="'+path+srcArray.join('/')+'.js"><\/script>');
  };
}

This way, there is no more searching for '.' over and over again.
Also, you can now refer to individual files (even you own external files) using '.' instead of '/'.  This way, it fits the library syntax.  Hope this is of some use.

Robert Rainwater wrote:

I've updated my current version to do this for a while, but just haven't put
it in CVS.  I will update CVS soon so that the include will work that way.

Robert
----- Original Message -----
From: "Michael Bürge" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 02, 2001 6:58 PM
Subject: [Dynapi-Dev] DynAPI.include()

> hi there.
>
> this is my first post to this list, and i would like to use the
opportunity to thank you for the great work you're all doing. i just started
dealing with
> the dynapi after having spent a _lot_ of time putting together something
similar on my own (i now finally gave up, mainly because it's just way too
much
> work keeping everything up to date).
>
> now to the real issue of this post:
>
> the following is an excerpt from part 1 one of the tutorials written by
Pascal, describing the include() function:
>
> * DynAPI.include('myownfile.js','location/path')
> Include your own file not located in the [dynapi base path] location
> * DynAPI.include('myownfile.js','./')
> Include your own file located at the current file location.
>
> i like these features, so i tried to use them bu it didn't work. looking
at the code i realised that they weren't implemented at all. i don't know if
> somebody did already implement them, but both the current distro and the
current CVS-version do not contain them.
> so here's my version:
>
>  include : function(src,path) {
>   if(src.substring(src.length-3)!=".js") src+=".js";
>   if (!path) var path=DynAPI.librarypath;
>   else {
>       if (path=="./") path = "";
>       else if (path[path.length-1] != "/") path += "/";
>       document.write('<script language="Javascript1.2" src="'+ path + src
+ '"></script>');
>       return;
>   }
>     ....some more stuff....
>  }
>
> hope this is usefull, and sorry if i missed the version containing those
features. (BTW: is was pretty hard for me to find out where to get the
current
> files, so a few hints on the project-webpage would save a great deal of
time to people interested in looking at the current work going on)
>
> that all for now.
> greets.
> michael buerge
>
>
> _______________________________________________
> Dynapi-Dev mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/mailman/listinfo/dynapi-dev

_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/dynapi-dev

_______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/mailman/listinfo/dynapi-dev

Reply via email to