Changeset 264 for lang/javascript/misc/loader.js.inc
- Timestamp:
- 09/23/07 20:48:05 (16 months ago)
- Files:
-
- 1 modified
-
lang/javascript/misc/loader.js.inc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/misc/loader.js.inc
r245 r264 1 1 (function(entries) { 2 function isString(obj) { 3 return (typeof obj == 'string' || obj instanceof String); 2 function defined(prop) { 3 try{ 4 return eval('typeof ' + prop) != "undefined"; 5 } catch(e) { 6 } 7 return false; 4 8 } 5 9 6 function hasLoaded(prop) { 7 try{ 8 return eval(prop + '.toString'); 9 } catch(e) { 10 } 11 } 12 13 function load(src) { 10 function loadScript(src) { 14 11 var script = document.createElement('script'); 15 12 script.type = 'text/javascript'; 16 script.charset = 'UTF-8';17 13 script.src = src; 18 14 (document.body || document.documentElement).appendChild(script); … … 20 16 21 17 var onComplete; 22 (function do Entry() {18 (function doNextEntry() { 23 19 var entry = entries.shift(); 24 20 if (!entry) { 25 if (onComplete) { 26 onComplete(); 27 } 28 return; 21 return onComplete && onComplete(); 29 22 } 30 23 31 if (isString(entry)) { 32 load(entry); 33 doEntry(); 34 return; 24 if (typeof entry == 'string' || entry instanceof String) { 25 entry = {'window':entry}; 35 26 } 36 37 27 for (var prop in entry) { 38 if ( !hasLoaded(prop)) {39 load (entry[prop]);28 if (prop == 'window' || !defined(prop)) { 29 loadScript(entry[prop]); 40 30 } 41 31 } 42 32 var timer = setInterval(function() { 43 33 for (var prop in entry) { 44 if (! hasLoaded(prop)) {34 if (!defined(prop)) { 45 35 return; 46 36 } 47 37 } 48 38 clearInterval(timer); 49 do Entry();39 doNextEntry(); 50 40 }, 99); 51 41 })(); … … 55 45 var args = arguments; 56 46 onComplete = function() { 57 callback.apply( null, args);47 callback.apply(callback, args); 58 48 }; 59 49 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)