Skip to content

Commit 768ad7b

Browse files
author
Philip Guo
committed
almost ready
1 parent 67212e4 commit 768ad7b

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

edu-python.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ span {
9494
margin-bottom: 35px;
9595
}
9696

97-
table#stackHeapTable td {
97+
td#stack_td,
98+
td#heap_td {
9899
vertical-align:top;
100+
font-size: 12pt;
99101
}
100102

101103
table#pyOutputPane {

edu-python.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2626

2727
// set to true to use jsPlumb library to render connections between
2828
// stack and heap objects
29-
var useJsPlumbRendering = false;
29+
var useJsPlumbRendering = true;
3030

3131
// if true, then render the stack as growing downwards
3232
// (if useJsPlumbRendering is true)
@@ -157,8 +157,7 @@ function highlightCodeLine(curLine, visitedLinesSet, hasError, isTerminated) {
157157

158158
// relies on curTrace and curInstr globals
159159
function updateOutput() {
160-
// update based on experimental checkbox ...
161-
useJsPlumbRendering = $("#useJsPlumbCheckbox").prop("checked");
160+
useJsPlumbRendering = !($("#classicModeCheckbox").prop("checked"));
162161

163162
var curEntry = curTrace[curInstr];
164163
var hasError = false;
@@ -413,7 +412,7 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
413412

414413
// create a tabular layout for stack and heap side-by-side
415414
// TODO: figure out how to do this using CSS in a robust way!
416-
$(vizDiv).html('<table id="stackHeapTable"><tr><td><div id="stack"></div></td><td><div id="heap"></div></td></tr></table>');
415+
$(vizDiv).html('<table id="stackHeapTable"><tr><td id="stack_td"><div id="stack"></div></td><td id="heap_td"><div id="heap"></div></td></tr></table>');
417416

418417

419418
var nonEmptyGlobals = false;
@@ -1226,7 +1225,7 @@ $(document).ready(function() {
12261225

12271226

12281227
// select an example on start-up:
1229-
$("#tutorialExampleLink").trigger('click');
1228+
$("#aliasExampleLink").trigger('click');
12301229

12311230

12321231
// disable controls initially ...

example-code/aliasing.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
# Example of aliasing
12
x = [1, 2, 3]
23
y = x
34
x.append(4)
45
y.append(5)
56
z = [1, 2, 3, 4, 5]
67
x.append(6)
8+
y.append(7)
79
y = "hello"
810

911
def foo(lst):
10-
lst.append("hi there")
12+
lst.append("hello")
13+
print lst
1114

1215
foo(x)
1316
foo(z)

index.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,24 @@
7272

7373
<button id="executeBtn" class="bigBtn" type="button">Visualize execution</button>
7474

75-
<br/><br/><input type="checkbox" id="useJsPlumbCheckbox"/> Draw connector diagrams (experimental)
76-
7775
</p>
7876

7977
<p style="margin-top: 25px;">Try these small examples:<br/>
8078

79+
<a id="aliasExampleLink" href="#">aliasing</a> |
8180
<a id="tutorialExampleLink" href="#">intro</a> |
8281
<a id="factExampleLink" href="#">factorial</a> |
8382
<a id="fibonacciExampleLink" href="#">fibonacci</a> |
8483
<a id="memoFibExampleLink" href="#">memoized fib</a> |
8584
<a id="newtonExampleLink" href="#">square root</a> |
86-
<a id="insSortExampleLink" href="#">insertion sort</a> |
87-
<a id="strtokExampleLink" href="#">tokenize</a>
85+
<a id="insSortExampleLink" href="#">insertion sort</a>
8886
<br/>
8987
<a id="filterExampleLink" href="#">filter</a> |
90-
<a id="aliasExampleLink" href="#">aliasing</a> |
88+
<a id="strtokExampleLink" href="#">tokenize</a> |
9189
<a id="oopSmallExampleLink" href="#">OOP</a> |
9290
<a id="pwGcdLink" href="#">gcd</a> |
9391
<a id="pwSumListLink" href="#">sumList</a> |
94-
<a id="towersOfHanoiLink" href="#">hanoi</a> |
92+
<a id="towersOfHanoiLink" href="#">towers of hanoi</a> |
9593
<a id="pwTryFinallyLink" href="#">exceptions</a>
9694

9795
</p>
@@ -107,6 +105,10 @@
107105

108106
</p>
109107

108+
<p>
109+
<br/><input type="checkbox" id="classicModeCheckbox"/> Use low-bandwidth mode (for older browsers)
110+
</p>
111+
110112
</div>
111113

112114

0 commit comments

Comments
 (0)