forked from mshang/syntree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
209 lines (189 loc) · 8.48 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta name="description" content="An app for producing linguistics syntax trees from labelled bracket notation." />
<link rel="canonical" href="http://mshang.ca/syntree" />
<title>Syntax Tree Generator</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25344866-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<a href="https://github.com/mshang/syntree"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub"></a>
<div id="accordion">
<h3><a href="#">Syntax Tree Generator</a></h3><div style="text-align:left">
<textarea id="i" rows="4">[S [NP This] [VP [V is] [^NP a wug]]]</textarea>
(C) 2011 by <a href="http://mshang.ca/">Miles Shang</a>, see <a href="LICENSE.txt">license</a>.
</div>
<h3><a href="#">Options</a></h3><div>
<table>
<col width="1*">
<col width="1*">
<tr>
<td colspan="2" align="center"><div id="font-style-radio" class="nobr">
<input type="radio" name="font-style" id="serif" value="serif" class="redraw" /><label for="serif">Serif</label>
<input type="radio" name="font-style" id="sans-serif" value="sans-serif" class="redraw" checked /><label for="sans-serif">Sans-Serif</label>
<input type="radio" name="font-style" id="monospace" value="monospace" class="redraw" /><label for="monospace">Monospace</label>
</div></td>
</tr>
<tr>
<td align="center">Terminals:</td>
<td align="center">Non-terminals:</td>
</tr>
<tr>
<td align="center"><div id="term-font-check" class="nobr">
<input type="checkbox" id="term-bold" class="redraw" /><label for="term-bold">Bold</label>
<input type="checkbox" id="term-ital" class="redraw" /><label for="term-ital">Italic</label>
</span></td>
<td align="center"><div id="nonterm-font-check" class="nobr">
<input type="checkbox" id="nonterm-bold" class="redraw" /><label for="nonterm-bold">Bold</label>
<input type="checkbox" id="nonterm-ital" class="redraw" /><label for="nonterm-ital">Italic</label>
</span></td>
</tr>
<tr>
<td align="left">Font size:</td>
<td><div id="font-size-slider"></div></td>
</tr>
<tr>
<td align="left">Height:</td>
<td><div id="vert-space-slider"></div></td>
</tr>
<tr>
<td align="left">Width:</td>
<td><div id="hor-space-slider"></div></td>
</tr>
<tr>
<td align="center" colspan="2"><div class="nobr">
<input type="checkbox" id="color-check" class="redraw" checked /><label for="color-check">Color</label>
<input type="checkbox" id="term-lines" class="redraw" checked /><label for="term-lines">Terminal lines</label>
<a href="#" id="make-link">Link</a>
</div></td>
</tr>
</table>
</div>
<h3><a href="#">Help</a></h3><div class="help">
<p>Use labelled bracket notation. This app will build the tree as you type and will attempt to close any brackets that you may be missing. Save the image to your computer by right-clicking on it and selecting "Save image as". For more information, including on how to draw movement lines, visit the <a href="https://github.com/mshang/syntree/wiki">wiki</a>.</p>
<h3>Examples</h3>
<a class="example" href="?i=[NP^ Alice]">[NP^ Alice]</a><br />
<a class="example" href="?i=[NP [N Alice] and [N Bob]]">[NP [N Alice] and [N Bob]]</a><br />
<a class="example" href="?i=[S[NP[N Alice]][VP[V is][NP[N'[N a student][PP^ of physics">[S[NP[N Alice]][VP[V is][NP[N'[N a student][PP^ of physics</a><br />
<a class="example" href="?i=[S [X_a Movement] [Y example <a>]]">[S [X_a Movement] [Y example <a>]]</a>
</div>
</div>
<br />
<div id="image-goes-here"></div>
<style type="text/css">
body { font-size: small !important; font-family: sans-serif; margin: 20px; background-color: #ffffff}
#accordion { margin: 0px auto; width: 500px; text-align: center; }
table { margin: 0px auto; }
//.ui-widget { font-size:small !important; }
td {font-size:small !important;}
textarea {resize: vertical; width: 100%}
a.example { text-decoration: none; color: #4183C4!important; }
.help {text-align: left;}
#image-goes-here { text-align: center; }
img { border: 1px solid #bbbbbb; }
.nobr { white-space: nowrap; }
</style>
<link type="text/css" href="css/cupertino/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript" src="js/base64.js"></script>
<script type="text/javascript" src="js/canvas2image.js"></script>
<script type="text/javascript" src="js/syntree.js"></script>
<script type="text/javascript">
function handler(font_size_update, vert_space_update, hor_space_update) {
try {
// Initialize the various options.
var term_font = "";
var nonterm_font = "";
var color = false;
var term_lines = false;
if (document.getElementById("term-ital").checked)
term_font = term_font + "italic ";
if (document.getElementById("term-bold").checked)
term_font = term_font + "bold ";
if (document.getElementById("nonterm-ital").checked)
nonterm_font = nonterm_font + "italic ";
if (document.getElementById("nonterm-bold").checked)
nonterm_font = nonterm_font + "bold ";
if (document.getElementById("color-check").checked)
color = true;
if (document.getElementById("term-lines").checked)
term_lines = true;
font_size = $("#font-size-slider").slider( "option", "value" );
vert_space = $("#vert-space-slider").slider( "option", "value" );
hor_space = $("#hor-space-slider").slider( "option", "value" );
if (font_size_update) font_size = font_size_update;
if (vert_space_update) vert_space = vert_space_update;
if (hor_space_update) hor_space = hor_space_update;
term_font = term_font + font_size + "pt ";
nonterm_font = nonterm_font + font_size + "pt ";
term_font = term_font + $('input:radio[name=font-style]:checked').val();
nonterm_font = nonterm_font + $('input:radio[name=font-style]:checked').val();
// Get the string.
var str = document.getElementById("i").value;
/*$("#image-goes-here").text(str + ", " + font_size + ", " +
term_font + ", " + nonterm_font + ", " + vert_space + ", " + hor_space);*/
var img = go(str, font_size, term_font, nonterm_font, vert_space, hor_space, color, term_lines);
$("#image-goes-here").empty();
$("#image-goes-here").append(img);
} catch (err) {
if (debug) {
throw(err);
} else {
if (err == "canvas")
$("#image-goes-here").text("Browser not supported.");
}
} // try-catch
return false;
} // handler()
$(function() {
// UI
$("#make-link, #color-check, #term-lines").button();
$("#font-size-slider").slider({value: 12, min: 8, max: 16, step: 1});
$("#vert-space-slider").slider({value: 35, min: 35, max: 70, step: 5});
$("#hor-space-slider").slider({value: 10, min: 10, max: 50, step: 5});
$("#font-style-radio, #term-font-check, #nonterm-font-check").buttonset();
$("#accordion").accordion({collapsible: true, icons: false, autoHeight: false});
try {
var qs = decodeURIComponent(window.location.search.slice(1));
qs = qs.replace(/^i=/,"");
qs = qs.replace(/\+/g," ");
if (qs == "") throw "";
document.getElementById("i").value = qs;
} catch (err) {}
handler();
// Events
$("#i").keypress(function() {handler(); return true;});
$("#i").keyup(function() {handler(); return true;});
$("#i").keydown(function() {handler(); return true;});
$("#i").change(function() {handler(); return true;});
$(".redraw").change(function() {return handler()});
$("#make-link").click(function() {
var loc = window.location.href;
loc = loc.replace(window.location.search, "");
window.prompt ("Link for this tree:", loc + "?i=" +
encodeURIComponent(document.getElementById("i").value));
return false;
});
$("#font-size-slider").bind("slide", function (event, ui) {
handler(ui.value, null, null); return true;
});
$("#vert-space-slider").bind("slide", function (event, ui) {
handler(null, ui.value, null); return true;
});
$("#hor-space-slider").bind("slide", function (event, ui) {
handler(null, null, ui.value); return true;
});
});
</script>
</body>
</html>