Changeset 676
- Timestamp:
- 03/12/08 07:16:16 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/config-service/src/chrome/chromeFiles/content/config.js
r667 r676 28 28 _notifyObservers: function(script, event, data) { 29 29 var observers = this._observers.concat(script._observers); 30 for (var i = 0, observer; observer = observers[i]; i++) 30 for (var i = 0, observer; observer = observers[i]; i++) { 31 31 observer.notifyEvent(script, event, data); 32 } 32 33 }, 33 34 … … 45 46 name = aScript._name.toLowerCase(); 46 47 47 for (var i = 0, script; script = this._scripts[i]; i++) 48 if (script._namespace.toLowerCase() == namespace && script._name.toLowerCase() == name) 48 for (var i = 0, script; script = this._scripts[i]; i++) { 49 if (script._namespace.toLowerCase() == namespace 50 && script._name.toLowerCase() == name 51 ) { 49 52 return i; 53 } 54 } 50 55 51 56 return -1; … … 139 144 resourceNode.setAttribute("filename", imp._filename); 140 145 resourceNode.setAttribute("mimetype", imp._mimetype); 141 if (imp._charset) 146 if (imp._charset) { 142 147 resourceNode.setAttribute("charset", imp._charset); 148 } 143 149 144 150 scriptNode.appendChild(doc.createTextNode("\n\t\t")); … … 195 201 196 202 while ((result = lines[lnIdx++])) { 197 if (result.indexOf("// ==/UserScript==") == 0) 203 if (result.indexOf("// ==/UserScript==") == 0) { 198 204 break; 205 } 199 206 200 207 var match = result.match(/\/\/ \@(\S+)\s+([^\n]+)/); … … 248 255 249 256 // if no meta info, default to reasonable values 250 if (script._name == null) 251 script._name = parseScriptName(uri); 252 253 if (script._namespace == null) 254 script._namespace = uri.host; 255 256 if (!script._description) 257 script._description = ""; 258 259 if (script._includes.length == 0) 260 script._includes.push("*"); 257 if (script._name == null) script._name = parseScriptName(uri); 258 if (script._namespace == null) script._namespace = uri.host; 259 if (!script._description) script._description = ""; 260 if (script._includes.length == 0) script._includes.push("*"); 261 261 262 262 return script; … … 267 267 268 268 var existingIndex = this._find(script); 269 if (existingIndex > -1) 269 if (existingIndex > -1) { 270 270 this.uninstall(this._scripts[existingIndex], false); 271 } 271 272 272 273 script._initFile(script._tempFile); 273 274 script._tempFile = null; 274 275 275 for (var i = 0; i < script._requires.length; i++) 276 for (var i = 0; i < script._requires.length; i++) { 276 277 script._requires[i]._initFile(); 277 278 for (var i = 0; i < script._resources.length; i++) 278 } 279 280 for (var i = 0; i < script._resources.length; i++) { 279 281 script._resources[i]._initFile(); 282 } 280 283 281 284 this._scripts.push(script); … … 291 294 292 295 // watch out for cases like basedir="." and basedir="../gm_scripts" 293 if (!script._basedirFile.equals(this._scriptDir)) 296 if (!script._basedirFile.equals(this._scriptDir)) { 294 297 // if script has its own dir, remove the dir + contents 295 298 script._basedirFile.remove(true); 296 else299 } else { 297 300 // if script is in the root, just remove the file 298 301 script._file.remove(false); 299 300 if (uninstallPrefs) // Remove saved preferences 301 GM_prefRoot.remove("scriptvals." + script._namespace + "/" + script._name + "."); 302 } 303 304 if (uninstallPrefs){ 305 // Remove saved preferences 306 GM_prefRoot.remove("scriptvals." + script._namespace + "/" + script._name + "."); 307 } 302 308 }, 303 309 … … 315 321 316 322 // Make sure the user script is installed 317 if (from == -1) 318 return; 323 if (from == -1) return; 319 324 320 325 if (typeof destination == 'number') { // if destination is an offset … … 326 331 } 327 332 328 if (to == -1) 329 return; 333 if (to == -1) return; 330 334 331 335 var tmp = this._scripts.splice(from, 1)[0]; … … 336 340 get _scriptDir() { 337 341 var newDir = this._newScriptDir; 338 if (newDir.exists()) 339 return newDir; 342 if (newDir.exists()) return newDir; 340 343 341 344 var oldDir = this._oldScriptDir; 342 if (oldDir.exists()) 343 return oldDir; 345 if (oldDir.exists()) return oldDir; 344 346 345 347 // if we called this function, we want a script dir. … … 471 473 472 474 // If no Latin characters found - use default 473 if (!name) 474 name = "gm_script"; 475 if (!name) name = "gm_script"; 475 476 476 477 // 24 is a totally arbitrary max length 477 if (name.length > 24) 478 name = name.substring(0, 24); 479 480 if (ext) 481 name += "." + ext; 478 if (name.length > 24) name = name.substring(0, 24); 479 480 if (ext) name += "." + ext; 482 481 483 482 return name; … … 526 525 _initFile: function() { 527 526 var name = this._downloadUrl.substr(this._downloadUrl.lastIndexOf("/") + 1); 528 if(name.indexOf("?") > 0) 527 if(name.indexOf("?") > 0) { 529 528 name = name.substr(0, name.indexOf("?")); 529 } 530 530 name = this._script._initFileName(name, true); 531 531
