forked from daveagp/java_visualize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
413 lines (345 loc) · 14.7 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
This file, java_visualize/index.html, is based on
visualize.html from the Online Python Tutor.
Changes made by David Pritchard ([email protected]);
see README for more details.
Summary of changes made:
- different file locations
- uses Java, not Python
- uses CodeMirror latest version
- lazier approach for loading examples
==== Header from visualize.html ====
Online Python Tutor
https://github.com/pgbovine/OnlinePythonTutor/
Copyright (C) 2010-2013 Philip J. Guo ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<head>
<title>Java Visualizer</title>
<!-- requirements for pytutor.js -->
<script type="text/javascript" src="./OnlinePythonTutor/v3/js/d3.v2.min.js"></script>
<script type="text/javascript" src="./OnlinePythonTutor/v3/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="./OnlinePythonTutor/v3/js/jquery.ba-bbq.min.js"></script> <!-- for handling back button and URL hashes -->
<script type="text/javascript" src="./OnlinePythonTutor/v3/js/jquery.jsPlumb-1.3.10-all-min.js "></script> <!-- for rendering SVG connectors
DO NOT UPGRADE ABOVE 1.3.10 OR ELSE BREAKAGE WILL OCCUR -->
<script type="text/javascript" src="./OnlinePythonTutor/v3/js/jquery-ui-1.8.24.custom.min.js"></script> <!-- for sliders and other UI elements -->
<link type="text/css" href="./OnlinePythonTutor/v3/css/ui-lightness/jquery-ui-1.8.24.custom.css" rel="stylesheet" />
<!-- for annotation bubbles -->
<script type="text/javascript" src="./OnlinePythonTutor/v3/js/jquery.qtip.min.js"></script>
<link type="text/css" href="./OnlinePythonTutor/v3/css/jquery.qtip.css" rel="stylesheet" />
<script type="text/javascript" src="./OnlinePythonTutor/v3/js/pytutor.js"></script>
<script type="text/javascript" src="./OnlinePythonTutor/v3/js/hooks.js"></script>
<script type="text/javascript" src="pytutor-customizations.js?2"></script>
<link rel="stylesheet" href="./OnlinePythonTutor/v3/css/pytutor.css"/>
<link rel="stylesheet" href="pytutor-customizations.css"/>
<!-- requirements for opt-frontend.js -->
<!-- codemirror.net online code editor -->
<script type="text/javascript" src="./CodeMirror/lib/codemirror.js"></script>
<link type="text/css" href="./CodeMirror/lib/codemirror.css" rel="stylesheet" />
<script type="text/javascript" src="./CodeMirror/mode/clike/clike.js"></script>
<script type="text/javascript" src="./CodeMirror/addon/edit/matchbrackets.js"></script>
<script type="text/javascript" src="./config.js.php"></script> <!-- used to be opt-frontend.js -->
<script type="text/javascript" src="./jv-frontend.js?7"></script> <!-- used to be opt-frontend.js -->
<link rel="stylesheet" href="./OnlinePythonTutor/v3/css/opt-frontend.css"/>
<script type="text/javascript">
window.jv_cpp = false; // c++ fake visualizer extensions
</script>
</head>
<body>
<table style="margin:0px auto 0px auto;"><tr><td><img title="Based on icons by Jacob Halton and Francesco Terzini of the Noun Project" src="img/jv64.png"></td><td style="text-align: center"><span style="font-size:150%">Java Visualizer</span><br><i>(beta:</i>
<a href="mailto:[email protected]">report a bug</a>)
</td></table>
<div id="pyInputPane">
<p style="text-align:center;">Write your Java code here:</p>
<div id="codeInputPane">
</div> <!-- populate with a CodeMirror instance -->
<table><tr>
<td>
<button onclick="$('#options').toggle()">options</button>
</td>
<td>
<span id='options' style='display:none'>
<span style="white-space: nowrap;">
<input id='showStringsAsObjects' type='checkbox'>
<label for='showStringsAsObjects'>
Show String/Integer/etc objects, not just values
</span>
<span style="white-space: nowrap;">
<input id='showAllFields' type='checkbox'>
<label for='showAllFields'>
Show overridden fields, synthetics
</span>
<span style="white-space: nowrap;">
<input id='disableNesting' type='checkbox'>
<label for='disableNesting'>
Avoid nesting instances within instances
</span>
</span> <!-- #options -->
</td>
</tr></table>
<div id='args'>
<code>args</code>: <span id='argslist'></span>
<button id='addarg' onclick='javascript:addArg("")'>+command-line argument</button>
</div>
<div id='stdin'>
<button id='stdin-button' onclick='$("#stdin-xdiv").toggle()'>stdin</button>
(also visualizes consumption of <a href="http://introcs.cs.princeton.edu/java/stdlib/"><code>StdIn</code></a>)
<div id='stdin-xdiv' style='display:none;position:relative'>
<textarea id='stdinarea' style='-webkit-box-sizing: border-box;width:100%;height:100px;font-family:monospace'>
</textarea>
<sup style='position:absolute;top:5px;right:5px' class='closestdin' onclick='$("#stdin-xdiv").toggle()'>x</sup>
</div>
</div>
<style>
button {
font-family: verdana, arial, helvetica, sans-serif;
}
.arg, #stdin-xdiv {
margin-right: 1px;
padding: 5px 3px;
border:1px solid #DDD;
background-color: #EEE;
border-radius: 5px;
-webkit-border-radius: 5px;
}
.arg input {
width: 50px
}
.closex {
font-weight:bold;
position:relative;
top:-4px;
left:2px;
text-decoration:none;
color:red;
cursor:pointer;
}
.closestdin {
font-weight:bold;
text-decoration:none;
color:red;
cursor:pointer;
}
.toggler { text-align:center; }
</style>
<script type='text/javascript'>
addArg = function(init) {
$('#argslist').append('<span class="arg"><input type="text"></input><sup class="closex">x</sup></span>');
$('#argslist .arg:last-child input').val(init);
};
$('#args').on('click', '.closex', function(event) {
$(this).parents('span.arg').remove();
});
$(function(){ $('.toggler a').on('click', function(event) {
$('#faq').toggle();
return false;
});
});
topics = [
["basic",["(Default)","Variables","CmdLineArgs","StdIn","ControlFlow","Sqrt","ExecLimit","Strings"]],
["method",["PassByValue","Recursion","StackOverflow"]],
["oop",["Rolex","Person","Complex","Casting"]],
["data structure",["LinkedList","StackQueue","Postfix","SymbolTable"]],
["java feature",["ToString","Reflect","Exception","ExceptionFlow","TwoClasses"]]
];
</script>
<!--
<p style="margin-top: 10px; line-height: 200%;">
Execute code using
<select id="pythonVersionSelector">
<option value="2">Python 2.7</option>
<option value="3">Python 3.3</option>
</select>,
-->
<!-- these two make sense, but are not implemented yet
<select id="cumulativeModeSelector">
<option value="false">hide frames of exited functions</option>
<option value="true">show frames of exited functions</option>
</select>,
<select id="heapPrimitivesSelector">
<option value="false">inline primitives and nested objects</option>
<option value="true">render all objects on the heap</option>
</select>,
-->
<!--
<select id="drawParentPointerSelector">
<option value="false">hide environment parent pointers</option>
<option value="true">show environment parent pointers</option>
</select>,
<select id="textualMemoryLabelsSelector">
<option value="false">draw references using arrows</option>
<option value="true">use text labels for references</option>
</select>, and
<select id="showOnlyOutputsSelector">
<option value="false">show everything</option>
<option value="true">show only outputs</option>
</select>.
</p>
-->
<p style="text-align:center">
<button id="executeBtn" class="bigBtn" type="button">Visualize Execution</button>
</p>
<p style="margin-top: 25px;" id="examplesHolder">
<!--
<a id="aliasExampleLink" href="#">hello</a> |
<a id="happyExampleLink" href="#">happy</a> |
<a id="tutorialExampleLink" href="#">intro</a> |
<a id="filterExampleLink" href="#">filter</a> |
<a id="strtokExampleLink" href="#">tokenize</a> |
<a id="insSortExampleLink" href="#">insertion sort</a> |
<a id="listCompLink" href="#">list comprehension</a>
</p>
<p style="margin-top: 15px;">Math-Related Fun:<br/>
<a id="factExampleLink" href="#">factorial</a> |
<a id="fibonacciExampleLink" href="#">fibonacci</a> |
<a id="memoFibExampleLink" href="#">memoized fibonacci</a> |
<a id="newtonExampleLink" href="#">square root</a> |
<a id="pwGcdLink" href="#">gcd</a> |
<a id="towersOfHanoiLink" href="#">towers of hanoi</a>
</p>
<p style="margin-top: 15px;">Higher-Order Functions:<br/>
<a id="closure1Link" href="#">closure 1</a> |
<a id="closure2Link" href="#">closure 2</a> |
<a id="closure3Link" href="#">closure 3</a> |
<a id="closure4Link" href="#">closure 4</a> |
<a id="closure5Link" href="#">closure 5</a>
<br/>
<! -- <a id="sumCubesLink" href="#">sum cubes</a> | -- >
<a id="mapExampleLink" href="#">list map</a> |
<a id="sumExampleLink" href="#">summation</a> |
<a id="lambdaParamLink" href="#">lambda param</a> |
<a id="tortureLink" href="#">student torture</a>
</p>
<p style="margin-top: 15px;">User Input:<br/>
<a id="rawInputExampleLink" href="#">raw input</a>
</p>
<p style="margin-top: 15px;">Object-Oriented Programming:<br/>
<a id="oop1ExampleLink" href="#">OOP 1</a> |
<a id="oop2ExampleLink" href="#">OOP 2</a> |
<a id="oopSmallExampleLink" href="#">OOP 3</a> |
<a id="inheritanceExampleLink" href="#">inheritance</a>
</p>
<p style="margin-top: 15px;">Linked Lists:<br/>
<a id="ll1Link" href="#">LL 1</a> |
<a id="ll2Link" href="#">LL 2</a> |
<a id="sumListLink" href="#">LL sum</a>
</p>
<p style="margin-top: 15px;">Pointer Aliasing:<br/>
<a id="aliasing1Link" href="#">aliasing 1</a> |
<a id="aliasing2Link" href="#">aliasing 2</a> |
<a id="aliasing3Link" href="#">aliasing 3</a> |
<a id="aliasing4Link" href="#">aliasing 4</a>
<br/>
<a id="aliasing5Link" href="#">aliasing 5</a> |
<a id="aliasing6Link" href="#">aliasing 6</a> |
<a id="aliasing7Link" href="#">aliasing 7</a> |
<a id="aliasing8Link" href="#">aliasing 8</a> |
<a id="pwSumListLink" href="#">sumList</a>
</p>
<p style="margin-top: 15px;">More Python Tricks:<br/>
<a id="decoratorsLink" href="#">decorators</a> |
<a id="genPrimesLink" href="#">generators</a> |
<a id="genExprLink" href="#">gen expr</a> |
<a id="varargsLink" href="#">varargs</a> |
<a id="pwTryFinallyLink" href="#">exceptions</a> |
<a id="forElseLink" href="#">for-else</a> |
<a id="nonlocalLink" href="#">nonlocal</a>
</p>
-->
<div>The visualizer supports
<code><a href="http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdIn.html">StdIn</a></code>,
<code><a href="http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdOut.html">StdOut</a></code>,
most other <a href="http://introcs.cs.princeton.edu/java/stdlib"><tt>stdlib</tt> libraries</a>,
<a href="http://introcs.cs.princeton.edu/java/43stack/Stack.java.html"><tt>Stack</tt></a>,
<a href="http://introcs.cs.princeton.edu/java/43stack/Queue.java.html"><tt>Queue</tt></a>,
and <a href="http://introcs.cs.princeton.edu/java/44st/ST.java.html"><tt>ST</tt></a>.
<br>
<div class='toggler'>
<a style='text-decoration:none' href='#'>Click for FAQ.</a>
</div>
<div id='faq' style='display:none'>
<ul>
<li><i>How can I access Java's built-in <tt>Stack</tt>/<tt>Queue</tt> instead of the introcs one?</i> At the top of your program, write <tt>import java.util.Stack;</tt> — note, <tt>import java.util.*;</tt> won't work.
<li><i>How do I get shorter URLs?</i> For example code, you can use <a target="_blank" href="#sampleFile=ExecLimit"><tt>#sampleFile=ExecLimit</tt></a> but
in general, this is a feature that still <a href="TODO">needs to be implemented</a>. You could use <a href="http://goo.gl">goo.gl</a> for now.
</li>
</ul>
</div>
</div>
</div>
<div id="pyOutputPane">
</div>
<div id="footer">
<div id="data-div" style="display: none;">Data for WordPress: <textarea id="data" style="word-wrap:break-word;"></textarea></div>
<p>
<button id="genUrlBtn" class="smallBtn" type="button">Generate URL</button> <input type="text" id="urlOutput" size="70"/>
</p>
<p>To share this visualization, click the 'Generate URL' button above
and share that URL. To report a bug, paste the URL along with a brief
error description in an email addressed to [email protected]</p>
<!--
<div id="embedLinkDiv">
<p>
<button id="genEmbedBtn" class="smallBtn" type="button">Generate embed code</button> <input type="text" id="embedCodeOutput" size="70"/>
</p>
<p>To embed this visualization in your webpage, click the 'Generate
embed code' button above and paste the resulting HTML code into your
webpage. Adjust the height and width parameters as needed.</p>
</div>
-->
<!--
<a href="http://pythontutor.com/">Online Python Tutor</a> supports <a
href="http://www.python.org/doc/2.7/">Python 2.7</a> and <a
href="http://www.python.org/doc/3.3.0/">Python 3.3</a> with limited module
imports and no file I/O.
The following modules may be imported:
bisect,
collections,
datetime,
functools,
heapq,
json,
math,
operator,
random,
re,
string
</p>
<p>Have a question? Maybe the <a
href="https://github.com/pgbovine/OnlinePythonTutor/blob/master/v3/docs/user-FAQ.md">FAQ</a>
or other <a
href="https://github.com/pgbovine/OnlinePythonTutor/blob/master/v3/docs/">documentation</a>
can help. Or check out its code at <a
href="https://github.com/pgbovine/OnlinePythonTutor/">GitHub</a>.</p>
<p>Join the <a
href="https://groups.google.com/forum/#!forum/pythontutor-users">pythontutor-users</a>
mailing list to participate in user discussions and <a
href="https://groups.google.com/forum/#!forum/pythontutor-announce">pythontutor-announce</a>
to receive occasional announcements.
(Your name and email address will be kept private; only the list owner can see them.)</p>
-->
<p style="margin-top: 8px;">
Based on <a href="http://www.pythontutor.com">Online Python Tutor</a>, © 2010-2013 <a href="http://www.pgbovine.net/">Philip Guo</a> all rights reserved. Java version by <a href="mailto:[email protected]">David Pritchard</a>, <a href="https://github.com/wgwozdz">Will Gwozdz</a>.
Source code: for this version's <a href="https://github.com/daveagp/java_jail/tree/master/cp/traceprinter">backend</a>;
the <a href="https://github.com/daveagp/java_visualize">frontend and installation instructions</a>.
</p>
</div>
</body>
</html>