Changeset 63
- Timestamp:
- 07/20/08 23:13:30 (2 months ago)
- Files:
-
- trunk/lily/lily/chrome/content/externals.js (modified) (5 diffs)
- trunk/lily/lily/chrome/content/utils.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lily/lily/chrome/content/externals.js
r57 r63 69 69 */ 70 70 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."); 73 81 } 74 82 }, … … 127 135 128 136 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) { 130 138 var extName = LilyUtils.stripExtension(this.objArray[i].name); 131 139 try { … … 139 147 this.objDisplay[((this.objArray[i].menuName)?this.objArray[i].menuName:"tmp")]=objName; 140 148 this.objDisplay[objName]=objName; 141 this.objLeaf[this.objArray[i].name]=this.objArray[i].name;142 149 } catch(e) { 143 150 LilyDebugWindow.error("External object "+extName.toUpperCase()+" couldn't be loaded: "+e.name + ": " + e.message+" "+e.fileName+", line: "+e.lineNumber) 144 } 151 } 145 152 } 146 153 } … … 156 163 include:function(name) { 157 164 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) { 159 166 o.sourceCode=this.load(o.path); 160 167 var objName = LilyUtils.stripExtension(o.name); … … 165 172 o.objArguments=LilyUtils.getObjectMetaData(objName).objectArguments; 166 173 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; 169 175 return o; 170 176 } trunk/lily/lily/chrome/content/utils.js
r61 r63 1293 1293 return false; 1294 1294 } 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)); 1295 1309 }, 1296 1310 … … 1306 1320 */ 1307 1321 hasExtension: function(str) { 1308 return str.match(/\.\S{2,4}$/ , '');1322 return str.match(/\.\S{2,4}$/); 1309 1323 }, 1310 1324
