Changeset 63

Show
Ignore:
Timestamp:
07/20/08 23:13:30 (2 months ago)
Author:
bi..@lilyapp.org
Message:

Fix itmes 2 & 3 from bug #28

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lily/lily/chrome/content/externals.js

    r57 r63  
    6969        */ 
    7070        add:function(leafName,filePath) { 
    71                 if(typeof this.objLeaf[leafName]=="undefined") { //no dupes 
    72                         this.objArray.push({name:leafName,path:filePath});       
     71                var stripped = LilyUtils.stripExtension(leafName); 
     72                if(typeof this.objLeaf["_"+stripped]=="undefined") { //no dupes 
     73                        if(LilyUtils.isLegalID(stripped)) { 
     74                                this.objArray.push({name:leafName,path:filePath}); 
     75                                this.objLeaf["_"+stripped]=leafName;     
     76                        } else { 
     77                                LilyDebugWindow.error("Couldn't load the patch or external "+stripped+" because the name contains illegal characters."); 
     78                        }                
     79                } else { 
     80                        LilyDebugWindow.error("Couldn't load the patch or external "+stripped+". An object with that name is already exists."); 
    7381                }        
    7482        }, 
     
    127135                 
    128136                for(var i=0;i<this.objArray.length;i++) { //don't load patches 
    129                         if(this.isLoadable(this.objArray[i].name) && this.objArray[i].path && typeof this.objLeaf[this.objArray[i].name]=="undefined") { 
     137                        if(this.isLoadable(this.objArray[i].name) && this.objArray[i].path) { 
    130138                                var extName = LilyUtils.stripExtension(this.objArray[i].name); 
    131139                                try { 
     
    139147                                        this.objDisplay[((this.objArray[i].menuName)?this.objArray[i].menuName:"tmp")]=objName; 
    140148                                        this.objDisplay[objName]=objName; 
    141                                         this.objLeaf[this.objArray[i].name]=this.objArray[i].name; 
    142149                                } catch(e) { 
    143150                                        LilyDebugWindow.error("External object "+extName.toUpperCase()+" couldn't be loaded: "+e.name + ": " + e.message+" "+e.fileName+",  line: "+e.lineNumber) 
    144                                 }                               
     151                                } 
    145152                        }        
    146153                }        
     
    156163        include:function(name) { 
    157164                var o=this.search(name); 
    158                 if(o && this.isLoadable(o.name) && o.path && typeof this.objLeaf[o.name]=="undefined") { 
     165                if(o && this.isLoadable(o.name) && o.path) { 
    159166                        o.sourceCode=this.load(o.path);                  
    160167                        var objName = LilyUtils.stripExtension(o.name);  
     
    165172                        o.objArguments=LilyUtils.getObjectMetaData(objName).objectArguments;                                                             
    166173                        this.objDisplay[((o.menuName)?o.menuName:"tmp")]=objName; 
    167                         this.objDisplay[objName]=objName; 
    168                         this.objLeaf[o.name]=o.name;                     
     174                        this.objDisplay[objName]=objName;                        
    169175                        return o; 
    170176                } 
  • trunk/lily/lily/chrome/content/utils.js

    r61 r63  
    12931293                        return false; 
    12941294                } 
     1295        }, 
     1296         
     1297        /* 
     1298                Method: isLegalID 
     1299                        determine if a string is a valid identifier. 
     1300         
     1301                Arguments:  
     1302                        str - string to test 
     1303                 
     1304                Returns:  
     1305                        bool- true if name contains no illegal characters. 
     1306        */ 
     1307        isLegalID: function(str) { 
     1308                return !(/[\-\*\+\)\(\&\#\!\@\$\^\%\–\<\?\"\'\;\:\[\]\}\{\=]/.test(str)); 
    12951309        },       
    12961310         
     
    13061320        */ 
    13071321        hasExtension: function(str) { 
    1308                 return str.match(/\.\S{2,4}$/, ''); 
     1322                return str.match(/\.\S{2,4}$/); 
    13091323        },       
    13101324