forked from hcientist/OnlinePythonTutor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pytutor-embed-demo.html
60 lines (47 loc) · 2.49 KB
/
pytutor-embed-demo.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
<!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">
<!--
Python Tutor: https://github.com/pgbovine/OnlinePythonTutor/
Copyright (C) Philip Guo ([email protected])
LICENSE: https://github.com/pgbovine/OnlinePythonTutor/blob/master/LICENSE.txt
-->
<head>
<title>Online Python Tutor v5 embedding demo</title>
<script type="text/javascript" src="build/pytutor-embed.bundle.js?825d985a87" charset="utf-8"></script>
</head>
<body style="background-color: white;">
<!-- Step 1: create 3 JSON trace files (listSum.json, hanoi.json, happy.json)
by running generate_json_trace.py
python generate_json_trace.py --compact ../v3/tests/backend-tests/list_sum.txt > pytutor-embed-demo/listSum.json
python generate_json_trace.py --compact example-code/python/towers_of_hanoi.txt > pytutor-embed-demo/hanoi.json
python generate_json_trace.py --compact example-code/python/happy.txt > pytutor-embed-demo/happy.json
-->
<!-- Step 2: add proper attributes to divs to embed the respective visualizers within those divs -->
<p>Recursive list sum (from <a href="http://pythontutor.com">pythontutor.com</a> home page):</p>
<div class="pytutorVisualizer" id="listSumDiv"
data-tracefile="pytutor-embed-demo/listSum.json">
</div>
<p>Towers of Hanoi:</p>
<!-- The "startingInstruction: 15" optional parameter means to jump to
step 15 in the visualization when it loads. (The webpage will
actually display "Step 16 of 79" since indices are zero-indexed.)
verticalStack means to stack the code and visualizations
vertically atop one another (rather than side-by-side) -->
<div class="pytutorVisualizer" id="hanoiDiv"
data-tracefile="pytutor-embed-demo/hanoi.json"
data-params ='{"startingInstruction": 15, "verticalStack": true}'>
</div>
<p>Happy Birthday:</p>
<!-- "embeddedMode: false" displays the full visualizer widget with the
"Program Output" pane; "jumpToEnd: true" means to jump to the end of
execution upon loading. -->
<div class="pytutorVisualizer" id="happyDiv"
data-tracefile="pytutor-embed-demo/happy.json"
data-params='{"embeddedMode": false, "jumpToEnd": true, "codeDivWidth": 450, "codeDivHeight": 150}'>
</div>
<!-- Step 3: Finally, put this one JS call at the very bottom so it will load after all divs appear -->
<script type="text/javascript">
createAllVisualizersFromHtmlAttrs();
</script>
</body>
</html>