web-wiki/resources/mediawiki/mediawiki.js
/**
			 * Recursively resolves dependencies and detects circular references
			 */
Recursively resolves dependencies and detects circular references
Recursively resolves dependencies and detects circular references
function recurse( module, resolved, unresolved ) {
				var n, deps, len;
				if ( registry[module] === undefined ) {
					throw new Error( 'Unknown dependency: ' + module );
				}
				if ( $.isFunction( registry[module].dependencies ) ) {
					registry[module].dependencies = registry[module].dependencies();
					if ( typeof registry[module].dependencies !== 'object' ) {
						registry[module].dependencies = [registry[module].dependencies];
					}
				}
				deps = registry[module].dependencies;
				len = deps.length;
				for ( n = 0; n < len; n += 1 ) {
					if ( $.inArray( deps[n], resolved ) === -1 ) {
						if ( $.inArray( deps[n], unresolved ) !== -1 ) {
							throw new Error(
								'Circular reference detected: ' + module +
								' -> ' + deps[n]
							);
						}
						unresolved[unresolved.length] = module;
						recurse( deps[n], resolved, unresolved );
						unresolved.pop();
					}
				}
				resolved[resolved.length] = module;
			}
function recurse ( module , resolved , unresolved ) { var n , deps , len ; if ( registry [ module ] === undefined ) { throw new Error ( 'Unknown dependency: ' + module ) ; } if ( $ . isFunction ( registry [ module ] . dependencies ) ) { registry [ module ] . dependencies = registry [ module ] . dependencies ( ) ; if ( typeof registry [ module ] . dependencies !== 'object' ) { registry [ module ] . dependencies = [ registry [ module ] . dependencies ] ; } } deps = registry [ module ] . dependencies ; len = deps . length ; for ( n = 0 ; n < len ; n += 1 ) { if ( $ . inArray ( deps [ n ] , resolved ) === - 1 ) { if ( $ . inArray ( deps [ n ] , unresolved ) !== - 1 ) { throw new Error ( 'Circular reference detected: ' + module + ' -> ' + deps [ n ] ) ; } unresolved [ unresolved . length ] = module ; recurse ( deps [ n ] , resolved , unresolved ) ; unresolved . pop ( ) ; } } resolved [ resolved . length ] = module ; }
Recursively resolves dependencies and detects circular references
Recursively resolves dependencies and detects circular references
// Resolves dynamic loader function and replaces it with its own results
 // Ensures the module's dependencies are always in an array
 // Tracks down dependencies
 // Add to unresolved
 // module is at the end of unresolved
