From: Michael P. <mp...@ph...> - 2001-01-08 06:29:25
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> oops. array should be srcArray. That should fix it. <p>Pascal Bestebroer wrote: <blockquote TYPE=CITE> <span class=330130509-06012001><font face="Arial"><font color="#0000FF"><font size=-1>when you remove that line, and include files with a .js</font></font></font></span><span class=330130509-06012001></span><span class=330130509-06012001><font face="Arial"><font color="#0000FF"><font size=-1>the join later on causes the files to be named dynapi/api/layer/js.js</font></font></font></span><span class=330130509-06012001></span> <font size=-1>Pascal Bestebroer</font> <br><font size=-1>pa...@dy...</font> <br><font size=-1><a href="http://www.dynamic-core.net/" target="_blank">http://www.dynamic-core.net</a></font> <blockquote style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px"> <div class="OutlookMessageHeader" dir="ltr"><font face="Tahoma"><font size=-1>-----Oorspronkelijk bericht-----</font></font> <br><font face="Tahoma"><font size=-1><b>Van:</b> dyn...@li... [<A HREF="mailto:dyn...@li...">mailto:dyn...@li...</A>]<b>Namens </b>Michael Pemberton</font></font> <br><font face="Tahoma"><font size=-1><b>Verzonden:</b> zaterdag 6 januari 2001 1:46</font></font> <br><font face="Tahoma"><font size=-1><b>Aan:</b> dyn...@li...</font></font> <br><font face="Tahoma"><font size=-1><b>Onderwerp:</b> Re: [Dynapi-Dev] DynAPI.include()</font></font> <br> </div> Those changes are not needed. If a non library file is entered, there is no problem. It just gets split and then rejoined later. <p><tt> srcArray = src.split('.');</tt> <br><tt>--> if (srcArray[srcArray.length-1] == 'js') array.length -= 1;</tt> <br><tt> if (!path) var path=DynAPI.librarypath;</tt> <p>Adding this additional line allows for removal of the '.js' extension if it has been included. <p>Also, there is no point in testing for an array length of > 3. This allows for any of the following to work: <p><tt>DynAPI.include('afroapi.ext.keyevents','../../js')</tt> <br><tt>DynAPI.include('afroapi/ext/keyevents','../../js')</tt> <br><tt>DynAPI.include('js/afroapi/ext/keyevents','../../')</tt> <br><tt>DynAPI.include('js.afroapi.ext.keyevents','../../')</tt> <p>This allows for further breaking down your directories to make them easier to understand. <br> <p>Pascal Bestebroer wrote: <blockquote TYPE="CITE"><span class=530091120-05012001><font face="Arial"><font color="#0000FF"><font size=-1>minor modification:</span><span class=530091120-05012001></span> include : function(src,path) {</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> srcArray=src.split('.')</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> if (srcArray.length>3) srcArray.length-=1</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> if (!path) {</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> var path=DynAPI.librarypath</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> var pckg=srcArray[0]</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> var grp=srcArray[1]</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> var file=srcArray[2]</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> if (file=='*') {</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> if (DynAPI.packages[pckg]) group=DynAPI.packages[pckg].libs[grp]</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> if (group) for (var i in group) document.write('<script language="Javascript1.2" src="'+path+pckg+'/'+grp+'/'+group[i]+'.js"><\/script>')</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> else alert('include()\n\nThe following package could not be loaded:\n'+src+'\n\nmake sure you specified the correct path.')</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> } else {</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> if (path[path.length-1] != "/") path += "/"</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> document.write('<script language="Javascript1.2" src="'+path+srcArray.join('/')+'.js"><\/script>')</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> }</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> } else {</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> document.write('<script language="Javascript1.2" src="'+path+'/'+src+'"><\/script>')</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> }</font></font></font> <br><font face="Arial"><font color="#0000FF"><font size=-1> }<span class=530091120-05012001>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.</span><span class=530091120-05012001>Other point is that the DynAPI.addLibrary() calls should NOT specify a the js extension to make it work correctly.</span><span class=530091120-05012001></span><span class=530091120-05012001>cya,</span></font></font></font> <font size=-1>Pascal Bestebroer</font> <br><font size=-1>pa...@dy...</font> <br><font size=-1><a href="http://www.dynamic-core.net/" target="_blank">http://www.dynamic-core.net</a></font> <blockquote style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px"> <div class=OutlookMessageHeader dir=ltr><font face="Tahoma"><font size=-1>-----Oorspronkelijk bericht-----</font></font> <br><font face="Tahoma"><font size=-1><b>Van:</b> dyn...@li... [<a href="mailto:dyn...@li...">mailto:dyn...@li...</a>]<b>Namens </b>Michael Pemberton</font></font> <br><font face="Tahoma"><font size=-1><b>Verzonden:</b> vrijdag 5 januari 2001 15:26</font></font> <br><font face="Tahoma"><font size=-1><b>Aan:</b> dyn...@li...</font></font> <br><font face="Tahoma"><font size=-1><b>Onderwerp:</b> Re: [Dynapi-Dev] DynAPI.include()</font></font></div> 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> </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> </blockquote> </html> |