Created
January 23, 2012 17:44
-
-
Save natecavanaugh/1664461 to your computer and use it in GitHub Desktop.
Recursive module loader that shows the full dependency tree of AlloyUI and YUI modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="../build/yui/yui.js" type="text/javascript"></script> | |
<script src="../build/aui-base/aui-base.js" type="text/javascript"></script> | |
<link rel="stylesheet" href="../build/aui-skin-classic/css/aui-skin-classic-all-min.css" type="text/css" media="screen" /> | |
</head> | |
<style type="text/css" media="screen"> | |
body { | |
font-size: 12px; | |
} | |
#wrapper { | |
padding: 10px; | |
} | |
/* ---------- All rounded corners ---------- */ | |
.yui3-yui3-widget-content-box, | |
.yui3-yui3-widget-tabs, | |
.yui3-yui3-widget-box-2, | |
.yui3-yui3-widget-box-2 { | |
-moz-border-radius: 8px; | |
} | |
/* ---------- These elements get a shadow ---------- */ | |
.aui-combobox-content { | |
float: left; | |
} | |
.aui-combobox-input { | |
} | |
.aui-combobox-input, .aui-combobox-trigger { | |
vertical-align: middle; | |
} | |
.aui-combobox-trigger { | |
cursor: pointer; | |
float: right; | |
margin: 0; | |
border-width: 0; | |
} | |
.aui-combobox-results { | |
} | |
.aui-combobox-results ul { | |
list-style: none; | |
margin: 0; | |
} | |
.aui-combobox-list-item { | |
margin: 0; | |
list-style: none; | |
padding: 0 3px; | |
border: 1px solid #fff; | |
} | |
.aui-combobox-results-content { | |
border: 1px solid #98c0f4; | |
overflow-y: auto; | |
height: 100%; | |
} | |
.aui-overlay-hidden { | |
visibility: hidden; | |
} | |
.aui-combobox-selected { | |
background: #dfe8f6; | |
border-color: #a3bae9; | |
} | |
.aui-combobox-icon-loading { | |
background-image: url(../themes/base/images/loading_indicator.gif); | |
background-position: 0 0; | |
} | |
</style> | |
<body> | |
<!-- | |
<input id="myTestWidget" type="text" value="" /> | |
<input class="aui-combobox-input" id="comboBox" type="text" value="" />--> | |
<div id="wrapper"> | |
<h1>Alloy Base File</h1> | |
<div id="hello"> | |
<!-- <ul id="deps"></ul> --> | |
</div> | |
<div id="myAutoComplete"></div> | |
</div> | |
<script type="text/javascript" charset="utf-8"> | |
AUI().use(function(A) { | |
var obj = MOD = YUI.AUI_config.groups.alloy.modules; | |
var YMOD = A.Env.meta.modules; | |
var depthTracker = 0; | |
var deps = document.getElementById('hello'); | |
var buffer = []; | |
var format = function(item, depth) { | |
var topLevel = (depth == 1); | |
buffer.unshift((topLevel ? '<b>' : '') + (new Array(depth*2).join(' ') + item + (topLevel ? '</b>' : '') + '<br />')); | |
// console.log(topLevel && item); | |
}; | |
var _recurse = function(obj, depth) { | |
A.Array.each( | |
obj, | |
function(item, index, collection){ | |
var mod; | |
if ((mod=(MOD[item]) || YMOD[item])) { | |
// console.log(new Array(depth*2).join('-'), item, mod, name, depth+1, mod.requires); | |
recurse(item, mod, depth+1); | |
// depthTracker = depth+1; | |
// deps.innerHTML += (new Array(depth*2).join('-') + item +'<br />'); | |
format(item, depth); | |
} | |
} | |
); | |
}; | |
var recurse = function(name, obj, depth) { | |
var requires = obj.requires; | |
var submodules = obj.submodules; | |
var req; | |
var mod; | |
// depth = depth || 1; | |
// console.log(name, requires); | |
if (requires) { | |
_recurse(requires, depth); | |
// for (var j = 0; j < requires.length; j++) { | |
// req = requires[j]; | |
// if ((mod=MOD[req])) { | |
// console.log(new Array(depth*2).join('-'), req, mod, name, depth, mod.requires); | |
// recurse(req, mod, depth++); | |
// }; | |
// }; | |
} | |
if (submodules) { | |
// buffer.push('<div style="border:1px solid #ccc; padding: 5px;">'); | |
// console.log(buffer.length); | |
for (var j in submodules) { | |
var sub = submodules[j] && submodules[j].requires; | |
if (sub) { | |
//buffer.push('<<<'); | |
_recurse(sub, depth+1); | |
//buffer.push('>>>'); | |
} | |
} | |
// console.log(buffer.length); | |
} | |
}; | |
var req; | |
for (var i in obj) { | |
if ((req=obj[i])) { | |
// console.warn(i); | |
// console.log(i, req, req.submodules); | |
recurse(i, req, 0); | |
// console.info('-------------------------------'); | |
var submodules = req.submodules; | |
if (submodules) { | |
// buffer.push('<div style="border:1px solid #ccc; padding: 5px;">'); | |
// console.log(buffer.length); | |
for (var j in submodules) { | |
var sub = submodules[j] && submodules[j].requires; | |
if (sub) { | |
//buffer.push('<<<'); | |
_recurse(sub, 1); | |
//buffer.push('>>>'); | |
} | |
} | |
// console.log(buffer.length); | |
} | |
format(i, 0); | |
}; | |
} | |
deps.innerHTML = buffer.join(''); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment