forked from leesue630/tree-to-sml-converter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
163 lines (148 loc) · 5.85 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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="icon" href="favicon.ico">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description"
content="A data type visualization tool to help students with Tree-to-SML text conversion and vice-versa. This site also supports shrubs and roses!" />
<meta name="google-site-verification" content="pff5CEzPG93pzW54tQ00vtOX37N5WNX-ODcCHw5mlq8" />
<title>Tree-to-SML Text Converter</title>
</head>
<body align="center" onload="setFunFact()">
<marquee class="gif-mq" behavior="scroll" direction="down" scrollamount="4" scrolldelay="30" style="top:30px;">
<img src=https://dl8.glitter-graphics.net/pub/129/129498dwdy8d462k.gif>
</marquee>
<marquee id="fact" behavior="alternate" bgcolor="green"></marquee>
<div class="tab" align="center">
<button class="tab-links" onclick="openTab(event, 'tree')" id="default_open">
Tree
</button>
<button class="tab-links" onclick="openTab(event, 'shrub')">
Shrub
</button>
<button class="tab-links" onclick="openTab(event, 'rose')">
Rose
</button>
<button class="tab-links" onclick="openTab(event, 'lazytree')">
LazyTree
</button>
<button class="tab-links" onclick="openTab(event, 'sml')">
SML
</button>
</div>
<!-- Tab content -->
<div id="tree" class="tab-content">
<h1>Tree-to-SML</h1>
This tree-to-text converter will fit the datatype:
<br />
<p class="left-inner type-p">
<tt>datatype 'a tree =<br />
Empty<br />
| Node of 'a tree * 'a * 'a tree</tt>
</p>
</div>
<div id="shrub" class="tab-content">
<h1>Shrub-to-SML</h1>
This shrub-to-text converter will fit the datatype:
<br />
<p class="left-inner type-p">
<tt>datatype 'a shrub = Empty <br />
| Leaf of 'a <br />
| Branch of 'a shrub * 'a shrub</tt>
</p>
</div>
<div id="rose" class="tab-content">
<h1>Rose-to-SML</h1>
This rose-to-text converter will fit the datatype:
<br />
<p class="left-inner type-p">
<tt>datatype 'a rose =<br />
Rose of 'a * 'a rose list</tt>
</p>
</div>
<div id="lazytree" class="tab-content">
<h1>LazyTree-to-SML</h1>
This lazyTree-to-text converter will fit the datatype:
<br />
<p class="left-inner type-p">
<tt>datatype 'a lazyTree = <br />
LT of unit -> 'a treeFront <br />
and 'a treeFront = <br />
LEAF <br />
| NODE of 'a lazyTree * 'a * 'a lazyTree</tt>
</p>
</div>
<div id="sml" class="tab-content">
<h1>SML-to-Tree</h1>
This text-to-tree converter will fit the datatype:
<br />
<p class="left-inner type-p">
<tt>datatype 'a tree = Empty<br />
| Node of 'a tree * 'a * 'a tree</tt>
</p>
</div>
<div align="center" id="to_sml_content">
<span id="depth_content">
1. Depth:
<input type="number" name="depth_form" id="depth_form" class="form" placeholder="e.g. 0" min="0" max="5"/>
<p id="depth_error_text" class="error-text"></p>
<input id="enter_depth_btn" type="button" class="btn" value="Enter depth" onclick="depthEntered()" />
<br />
<br />
</span>
2. Enter node values:
<br />
<table id="input_table"></table>
<p id="table_warning_text" class="error-text"></p>
<p id="negative_warning_text" class="error-text"></p>
<input type="button" class="btn" value="Generate SML Text" id="generate_sml_text_btn" onclick="generateText()" />
<p>3. Copy and paste the text below:</p>
<tt>
<p id="sml_output_text" class="sml-box">
~SML Text will appear here~
</p>
</tt>
<p style="color:gray">
Note: only nodes with non-empty parents (aka a valid path to the root)
will appear in the output.
<br />
Leave values blank to generate an unbalanced tree/shrub.
</p>
</div>
<div align="center" id="from_sml_content">
1. Enter SML Text:<br />
<!-- <br /> -->
<input type="text" name="sml_form" id="sml_form" class="sml-box form"
placeholder="e.g. Node(Empty, 2, Empty)" /><br />
<p id="sml_error_text" class="error-text"></p>
<input id="generate_tree_btn" type="button" class="btn" value="Generate Tree" onclick="smlEntered()" />
<br />
<br />
2. View your tree below:<br />
<!-- <br /> -->
<table id="output_table"></table>
<p style="color:gray">
Note: does not work if parentheses or commas are enclosed in quotes.
<br />
Empty nodes not shown.
</p>
</div>
<script type="text/javascript" src="to-sml-script.js"></script>
<script type="text/javascript" src="from-rose-script.js"></script>
<script type="text/javascript" src="from-sml-script.js"></script>
<script type="text/javascript" src="fun-facts.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
</body>
</html>