-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualizer.html
112 lines (100 loc) · 2.82 KB
/
visualizer.html
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
<html>
<head>
</head>
<body>
See your console.
<script src="typesafe.js" type="text/javascript"></script>
<script src="generics.js" type="text/javascript"></script>
<script src="visualizer/interfaces/com.scottbyrns.geo.Location.js" type="text/javascript"></script>
<script type="text/javascript">
new Interface({
type: "com.scottbyrns.Visualization",
constructor: {
'return-value': {
type: 'com.scottbyrns.Visualization'
}
},
methods: [
{
name: "drawInterface",
interface: {
'scope': 'public',
'input-parameters': [
{
name: "interface",
type: "object"
},
// {
// name: "location",
// type: "com.scottbyrns.geo.Location"
// }
]
}
}
]
});
new TypeSafeClass({
type: 'com.scottbyrns.Visualization',
implements: 'com.scottbyrns.Visualization',
drawInterface: function (interface) {
var methods = interface.methods;
var name = interface.__objectType__;
var constructor = interface.constructor;
var html = [
'<h1>',
name,
'</h1>',
'<h2>+ ',
'Constructor (',
];
for (var i = 0; i < constructor['input-parameters'].length; i += 1) {
html.push("(" + constructor['input-parameters'][i].name + ")" + constructor['input-parameters'][i].type);
html.push(", ");
}
html.pop();
html = html.concat([
') : ',
constructor['return-value'].type,
'</h2>',
'<ul>',
]);
for (var i = 0; i < methods.length; i += 1) {
html.push("<li>");
var scope = methods[i].interface.scope || 'private';
html.push(scope);
html.push(" (" + methods[i].interface['return-value'].type + ") ");
html.push("<strong>" + methods[i].name + "</strong> ");
// html.push("(" + constructor['input-parameters'][i].name + ")" + constructor['input-parameters'][i].type + ", ");
try {
html.push("(");
for (var j = 0; j < methods[i].interface['input-parameters'].length; j += 1) {
html.push("(" + methods[i].interface['input-parameters'][j].name + ")" + constructor['input-parameters'][j].type);
html.push(", ");
}
html.pop();
html.push(")");
}
catch (e) {
html.pop();
html.push(" ()");
}
html.push("</li>");
}
html.push("</ul>");
document.getElementsByTagName("body")[0].innerHTML = html.join("");
}
});
new TypeSafeClass({
type: 'com.scottbyrns.geo.Location',
implements: 'com.scottbyrns.geo.Location',
properties: [
{name:"latitude", type:"number"},
{name:"longitude", type:"number"}
]
});
var a = new com.scottbyrns.Visualization();
var b = new com.scottbyrns.geo.Location();
a.drawInterface(Interface.getInterfaceNamed('com.example.Integer'));
</script>
</body>
</html>