From: Robert R. <rra...@ya...> - 2000-10-30 23:56:02
|
Here's the patch that was posted: // This version of DynAPI.include prevents a file from being included twice. // This allows extension .js files to include their prerequisite // extension .js files with relative impunity. // NOTE: core.api.* should be included in the html file normally. // DynLayer and DynDocument need to be defined properly for widgets // to be defined. include : function(src,path) { if (!DynAPI.included) DynAPI.included = '' if (!path) path=DynAPI.librarypath groupname=src.substring(src.indexOf('.')+1) groupname=groupname.substring(0,groupname.indexOf('.')) var newhtml='' if (src.indexOf('.*')>0) { src=src.substring(0,src.indexOf('.*')) group=eval('DynAPI.'+groupname) if (group) for (var i in group) { if (0>DynAPI.included.indexOf(path+groupname+'/'+src+'.'+group[i])) { newhtml+='<script language="Javascript1.2" src="'+path+groupname+'/'+src+'.'+group[i]+'"><\/script>' DynAPI.included+=path+groupname+'/'+src+'.'+group[i]+'\n' } } else alert(DynAPI.toString()+'\n\nError occured\nThe following package could not be loaded:\n'+src+'\n\nmake sure you specified the correct path.') } else { if (0>DynAPI.included.indexOf(path+groupname+'/'+src)) { newhtml+='<script language="Javascript1.2" src="'+path+groupname+'/'+src+'"><\/script>' DynAPI.included+=path+groupname+'/'+src+'\n' } } if (''!=newhtml) document.write(newhtml) } Robert -- Email: <mailto:rra...@ya...> PGP Key ID: 0x703D7F7C > We could just do this: > > src = src.split(".").join("/") > > That would transform "core.gui.widget" into "core/gui/widget" > > We would have to be careful with files ending in ".js" so they aren't > interpreted as "core/gui/widget/js" > > RE duplicate includes: I have some sample scripts that include the > utility files they need to function. For example, a certain widget > script would include the colorops.js, slide.js, etc. from inside itself, > without me having to declare it in the main document. However, if a > script has already been included then we could save a little > time/resources by skipping those files if requested again. > > Robert Rainwater wrote: >> >> > Am I the only one who hates having to name my scripts after the path to >> > them? :-) >> > >> > core.gui.window.js >> > core.ibs.scroll.js >> > core.sa.this.js >> > core.api.that.js >> >> I've never figured out why the dynapi files were named that way. In java >> core.gui.window.js would mean core/gui/window.js. That seems more >> logical to me as well. And since we are using a directory scheme, >> there shouldn't be a problem with files having the same name. >> >> > Also: there was a proposed patch a SourceForge that would have prevented >> > scripts from being loaded twice, but never implemented. Was there >> > something wrong with this approach? >> >> The fix can easily be dropped in the include method. But, I'm still not >> sure why its needed. Its only a couple of lines so I guess it >> wouldn't hurt... >> >> Robert >> >> _______________________________________________ >> 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 |