-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodwiz.js
155 lines (134 loc) · 4.53 KB
/
modwiz.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// get the rhino script arguments
var __jsfiles = [].concat(arguments);
(function() {
/// ==================================================================
// need to fake the browser stuff here
window = this;
this.setTimeout = function() {};
this.addEventListener = function() {};
this._dummyElement = {
getElementsByTagName: function() { return []; },
getElementsById: function() { return []; },
getElementById: function() { return null; },
firstChild: null,
style: {
cssText: ''
},
src: '',
sheet: {
cssRules: [{style: {}}]
},
addEventListener: window.addEventListener,
addClass: function() {},
setAttribute: function() {},
getAttribute: function() { return window._dummyElement; }
};
this.navigator = {
userAgent: 'console',
appVersion: '0',
language: 'en',
platform: 'mac',
plugins: []
};
this.location = {
href: 'http://localhost',
search: ''
};
this.document = {
firstChild: window._dummyElement,
body: window._dummyElement,
location: window.location,
navigator: window.navigator,
documentElement: window._dummyElement,
createElement: function() { return window._dummyElement; },
hasAttribute: function() {},
getElementsByTagName: window._dummyElement.getElementsByTagName,
getElementsById: window._dummyElement.getElementsById,
getElementById: window._dummyElement.getElementById,
addEventListener: window._dummyElement.addEventListener,
removeEventListener: function() {}
};
document = this.document;
/// ==================================================================
var modules = {};
dojo = undefined;
YUI = {
Env: { mods: {} },
// a copy of the add() function from the yui3.0.0/build/yui/yui.js
add: function(name, fn, version, details) {
YUI.Env.mods[name] = {
name: name,
fn: fn,
version: version,
details: details || {}
};
return this; // chain support
}
};
// load JS files
for (var f=0, len=__jsfiles.length; f<len; f++) {
var filename = __jsfiles[f];
var filemodules = {};
java.lang.System.err.println('// load: ' + filename);
// YUI hack -> collecting the file modules separately
YUI.Env.mods = filemodules;
// dojo require hack -> no dynamic loading
if (dojo) { dojo.require = function() {}; }
load(filename);
for (var name in filemodules) {
if (!filemodules.hasOwnProperty(name)) continue;
var mod = filemodules[name];
var m = {
name: name,
path: filename,
version: mod.version,
requires: mod.details.requires
}
modules[name] = m;
}
}
// required-by dependencies
for (var name in modules) {
if (!modules.hasOwnProperty(name)) continue;
var m = modules[name];
if (!m.requires) continue;
for(var i=0, len=m.requires.length; i<len; i++) {
var dependson = modules[m.requires[i]];
if (!dependson) continue;
dependson.requiredby = dependson.requiredby || [];
dependson.requiredby.push(m.name);
}
}
print('<?xml version="1.0"?>')
print('<TOUCHGRAPH_LB version="1.20">');
print(' <NODESET>');
var edges = '';
var x = 0, y = 0;
for (var name in modules) {
if (!modules.hasOwnProperty(name)) continue;
// if (name.substring(0,3) != 'GDC') continue;
var m = modules[name];
y += 30;
m.requires = m.requires || [];
m.requiredby = m.requiredby || [];
print('<NODE nodeID="'+name+'"><NODE_LOCATION x="'+x+'" y="'+y+'" visible="true"/><NODE_LABEL label="'+name+'" shape="1" backColor="349D69" textColor="FFFFFF" fontSize="16"/><NODE_URL url="'+m.path+'" urlIsLocal="true" urlIsXML="false"/><NODE_HINT hint="module: '+name+'<br>Requires: '+m.requires+'<br>RequiredBy: '+m.requiredby+'<br>Path: '+m.path+'" width="600" height="400" isHTML="true"/></NODE>');
if (!m.requires) continue;
for(var i=0, len=m.requires.length; i<len; i++) {
var dependson = m.requires[i];
if (modules[dependson]) {
edges += '<EDGE fromID="'+name+'" toID="'+dependson+'" type="1" length="100" visible="true" color="0000B0"/>';
}
}
}
print(' </NODESET>');
print(' <EDGESET>');
print(edges);
print(' </EDGESET>');
print(' <PARAMETERS>');
print(' <PARAM name="offsetX" value="'+(x-100)+'"/>');
print(' <PARAM name="offsetY" value="'+(y-100)+'"/>');
print(' <PARAM name="rotateSB" value="0"/>');
print(' <PARAM name="zoomSB" value="-7"/>');
print(' </PARAMETERS>');
print('</TOUCHGRAPH_LB>');
})();