-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
80 lines (64 loc) · 3.2 KB
/
index.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="main.min.js"></script>
</head>
<style>
#input-container {
display: inline-block;
position: absolute;
left: 0;
top: 30px;
bottom: 0;
width: 50%;
}
#output-container {
display: inline-block;
position: absolute;
top: 30px;
bottom: 0;
right: 0;
width: 50%;
}
label {
display: block;
}
textarea {
display: block;
width: 100%;
height: 100%;
}
a {
float: right;
}
</style>
<script>
function do_convert() {
var IN = document.getElementById('input');
var OUT = document.getElementById('output');
try {
OUT.value = convert(IN.value);
} catch (e) {
OUT.value = e.message;
throw e;
}
}
function show_example() {
var IN = document.getElementById('input');
IN.value = 'goog.provide(\'example\');\r\ngoog.provide(\'example.Interface\');\r\ngoog.provide(\'example.A\');\r\ngoog.provide(\'example.B\');\r\ngoog.provide(\'example.C\');\r\n\r\n\/**\r\n * No param docs\r\n *\/\r\nexample.missingParams = function(x, y) {\r\n\r\n};\r\n\r\n\/**\r\n * No params at all\r\n *\/\r\nexample.noParams = function() {\r\n\r\n};\r\n\r\n\/**\r\n * @param {number|string} x\r\n *\/\r\nexample.overloadedFunction = function(x) {\r\n\r\n};\r\n\r\n\/**\r\n * @interface\r\n *\/\r\nexample.Interface;\r\n\r\n\/**\r\n * @param {number|string} x\r\n *\/\r\nexample.Interface.prototype.interfaceMethod = function(x) {\r\n\r\n};\r\n\r\n\/**\r\n * @interface\r\n * @extends {example.Interface}\r\n *\/\r\nexample.SubInterface;\r\n\r\n\/**\r\n * @constructor\r\n * @implements {example.Interface}\r\n * @param {number|string} x\r\n *\/\r\nexample.Class = function(x) {\r\n\r\n};\r\n\r\n\/**\r\n * @param {number|string} x\r\n *\/\r\nexample.Class.prototype.overloadedMethod = function(x) {\r\n\r\n};\r\n\r\n\/**\r\n * @override\r\n *\/\r\nexample.Class.prototype.interfaceMethod = function(x) { };\r\n\r\n\/**\r\n * @extends {example.Class}\r\n * @constructor\r\n *\/\r\nexample.SubClass = function() { };\r\n\r\n\/**\r\n * @interface\r\n *\/\r\nexample.A;\r\n\r\n\/**\r\n * @interface\r\n *\/\r\nexample.B;\r\n\r\n\/**\r\n * @interface\r\n *\/\r\nexample.C;\r\n\r\n\/**\r\n * @interface\r\n *\/\r\nexample.D;\r\n\r\n\/**\r\n * @typedef {string|number}\r\n *\/\r\nexample.UnionType;\r\n\r\n\/**\r\n * @param {example.UnionType} x\r\n *\/\r\nexample.unionFunction = function(x) { };\r\n\r\n\/**\r\n * @param {{myProperty: example.UnionType}} x\r\n *\/\r\nexample.deepUnionFunction = function(x) { };';
}
</script>
<body>
<button onclick="do_convert()">Convert</button>
<button onclick="show_example()">Example</button>
<a href="https://github.com/fivetran/closure-definitions">https://github.com/fivetran/closure-definitions</a>
<div id="input-container">
<label for="input">Javascript with Closure-style JSDoc annotations</label><textarea id="input"></textarea>
</div>
<div id="output-container">
<label for="output">Typescript declaration</label><textarea id="output"></textarea>
</div>
</body>
</html>