|
From: Michael P. <mp...@ph...> - 2001-01-05 14:34:35
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
You may also find it interesting that individual files can be referred
to with as many subdirectories as you want. This is one of the advantages
of using an array rather than a fixed search system.
<p>Michael Pemberton wrote:
<blockquote TYPE=CITE>I was looking at a way of making the DynAPI.include
method more simple. Here's what I came up with:
<p><tt>include : function(src,path) {</tt>
<br><tt> srcArray = src.split('.');</tt>
<br><tt> if (!path) var path=DynAPI.librarypath;</tt>
<br><tt> var pckg=srcArray[0];</tt>
<br><tt> var grp=srcArray[1];</tt>
<br><tt> var file=srcArray[2];</tt>
<br><tt> if (file=='*') {</tt>
<br><tt> if (DynAPI.packages[pckg]) group=DynAPI.packages[pckg][grp];</tt>
<br><tt> if (group) for (var i in group) document.write('<script
language="Javascript1.2" src="'+path+pckg+'/'+grp+'/'+group[i]+'.js"><\/script>');</tt>
<br><tt> else alert('include()\n\nThe following package
could not be loaded:\n'+src+'\n\nmake sure you specified the correct path.');</tt>
<br><tt> } else {</tt>
<br><tt> if (path[path.length-1] != "/") path +=
"/";</tt>
<br><tt> document.write('<script language="Javascript1.2"
src="'+path+srcArray.join('/')+'.js"><\/script>');</tt>
<br><tt> };</tt>
<br><tt>}</tt>
<p>This way, there is no more searching for '.' over and over again.
<br>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.
<p>Robert Rainwater wrote:
<blockquote TYPE=CITE>I've updated my current version to do this for a
while, but just haven't put
<br>it in CVS. I will update CVS soon so that the include will work
that way.
<p>Robert
<br>----- Original Message -----
<br>From: "Michael Bürge" <mb...@st...>
<br>To: <dyn...@li...>
<br>Sent: Tuesday, January 02, 2001 6:58 PM
<br>Subject: [Dynapi-Dev] DynAPI.include()
<p>> hi there.
<br>>
<br>> this is my first post to this list, and i would like to use the
<br>opportunity to thank you for the great work you're all doing. i just
started
<br>dealing with
<br>> the dynapi after having spent a _lot_ of time putting together something
<br>similar on my own (i now finally gave up, mainly because it's just
way too
<br>much
<br>> work keeping everything up to date).
<br>>
<br>> now to the real issue of this post:
<br>>
<br>> the following is an excerpt from part 1 one of the tutorials written
by
<br>Pascal, describing the include() function:
<br>>
<br>> * DynAPI.include('myownfile.js','location/path')
<br>> Include your own file not located in the [dynapi base path] location
<br>> * DynAPI.include('myownfile.js','./')
<br>> Include your own file located at the current file location.
<br>>
<br>> i like these features, so i tried to use them bu it didn't work.
looking
<br>at the code i realised that they weren't implemented at all. i don't
know if
<br>> somebody did already implement them, but both the current distro
and the
<br>current CVS-version do not contain them.
<br>> so here's my version:
<br>>
<br>> include : function(src,path) {
<br>> if(src.substring(src.length-3)!=".js") src+=".js";
<br>> if (!path) var path=DynAPI.librarypath;
<br>> else {
<br>> if (path=="./") path = "";
<br>> else if (path[path.length-1]
!= "/") path += "/";
<br>> document.write('<script language="Javascript1.2"
src="'+ path + src
<br>+ '"></script>');
<br>> return;
<br>> }
<br>> ....some more stuff....
<br>> }
<br>>
<br>> hope this is usefull, and sorry if i missed the version containing
those
<br>features. (BTW: is was pretty hard for me to find out where to get
the
<br>current
<br>> files, so a few hints on the project-webpage would save a great deal
of
<br>time to people interested in looking at the current work going on)
<br>>
<br>> that all for now.
<br>> greets.
<br>> michael buerge
<br>>
<br>>
<br>> _______________________________________________
<br>> Dynapi-Dev mailing list
<br>> Dyn...@li...
<br>> <a href="http://lists.sourceforge.net/mailman/listinfo/dynapi-dev">http://lists.sourceforge.net/mailman/listinfo/dynapi-dev</a>
<p>_______________________________________________
<br>Dynapi-Dev mailing list
<br>Dyn...@li...
<br><a href="http://lists.sourceforge.net/mailman/listinfo/dynapi-dev">http://lists.sourceforge.net/mailman/listinfo/dynapi-dev</a></blockquote>
_______________________________________________ Dynapi-Dev mailing list
Dyn...@li... <A HREF="http://lists.sourceforge.net/mailman/listinfo/dynapi-dev">http://lists.sourceforge.net/mailman/listinfo/dynapi-dev</A></blockquote>
</html>
|