|
From: Pascal B. <pa...@dy...> - 2001-01-05 20:09:00
|
minor modification:
include : function(src,path)
srcArray=src.split('.')
if (srcArray.length>3) srcArray.length-=1
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].libs[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>')
}
} else {
document.write('<script language="Javascript1.2"
src="'+path+'/'+src+'"><\/script>')
}
}
makes sure that other files (not in packages, etc) can also be
correctly.included when specifying a path.. Also when a .js extension IS
supplied this code will take care of it.
Other point is that the DynAPI.addLibrary() calls should NOT specify a the
.js extension to make it work correctly.
cya,
Pascal Bestebroer
pa...@dy...
http://www.dynamic-core.net
-----Oorspronkelijk bericht-----
Van: dyn...@li...
[mailto:dyn...@li...]Namens Michael Pemberton
Verzonden: vrijdag 5 januari 2001 15:26
Aan: dyn...@li...
Onderwerp: Re: [Dynapi-Dev] DynAPI.include()
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" <mb...@st...>
To: <dyn...@li...>
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
> Dyn...@li...
> http://lists.sourceforge.net/mailman/listinfo/dynapi-dev
_______________________________________________
Dynapi-Dev mailing list
Dyn...@li...
http://lists.sourceforge.net/mailman/listinfo/dynapi-dev
_______________________________________________ Dynapi-Dev mailing list
Dyn...@li...
http://lists.sourceforge.net/mailman/listinfo/dynapi-dev
|