Skip to content

Commit 1760f35

Browse files
author
Philip Guo
committed
bah
1 parent f7efcbc commit 1760f35

3 files changed

Lines changed: 34 additions & 244 deletions

File tree

‎v3/css/opt-lessons.css‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* CSS accompanying ../tutor.html */
1+
/* CSS accompanying ../lesson.html */
22

33
h1 {
44
font-weight: normal;
@@ -25,6 +25,24 @@ body {
2525
background-color: white;
2626
font-family: verdana, arial, helvetica, sans-serif;
2727
font-size: 10pt;
28+
29+
max-width: 900px;
30+
/* center align */
31+
margin-left: auto;
32+
margin-right: auto;
33+
}
34+
35+
div#lessonHeader {
36+
margin-bottom: 15pt;
37+
}
38+
39+
div#lessonTitle {
40+
font-size: 16pt;
41+
margin-bottom: 10pt;
42+
}
43+
44+
div#lessonExposition {
45+
font-size: 12pt;
2846
}
2947

3048
a,
@@ -72,10 +90,5 @@ button.bigBtn {
7290
border-top: 1px solid #bbbbbb;
7391
padding-top: 5px;
7492
margin-top: 5px;
75-
76-
max-width: 700px;
77-
/* center align */
78-
margin-left: auto;
79-
margin-right: auto;
8093
}
8194

‎v3/js/opt-lessons.js‎

Lines changed: 5 additions & 224 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ var backend_script = 'exec'; // URL of backend script, which must eventually cal
3333

3434
var appMode = 'edit'; // 'edit' or 'visualize'
3535

36-
var preseededCode = null; // if you passed in a 'code=<code string>' in the URL, then set this var
37-
var preseededCurInstr = null; // if you passed in a 'curInstr=<number>' in the URL, then set this var
38-
3936

4037
var myVisualizer = null; // singleton ExecutionVisualizer instance
4138

@@ -70,18 +67,6 @@ $(document).ready(function() {
7067
$(window).bind("hashchange", function(e) {
7168
appMode = $.bbq.getState('mode'); // assign this to the GLOBAL appMode
7269

73-
preseededCode = $.bbq.getState('code'); // yuck, global!
74-
var preseededMode = $.bbq.getState('mode');
75-
76-
if ($.bbq.getState('cumulative_mode') == 'true') {
77-
$('#cumulativeMode').prop('checked', true);
78-
}
79-
80-
// only bother with curInstr when we're visualizing ...
81-
if (!preseededCurInstr && preseededMode == 'visualize') { // TODO: kinda gross hack
82-
preseededCurInstr = Number($.bbq.getState('curInstr'));
83-
}
84-
8570
// default mode is 'edit'
8671
if (appMode == undefined) {
8772
appMode = 'edit';
@@ -91,13 +76,7 @@ $(document).ready(function() {
9176
// nothing to visualize:
9277
if (!myVisualizer) {
9378
appMode = 'edit';
94-
95-
if (preseededCode && preseededMode == 'visualize') {
96-
// punt for now ...
97-
}
98-
else {
99-
$.bbq.pushState({ mode: 'edit' }, 2 /* completely override other hash strings to keep URL clean */);
100-
}
79+
$.bbq.pushState({ mode: 'edit' }, 2 /* completely override other hash strings to keep URL clean */);
10180
}
10281

10382

@@ -180,17 +159,9 @@ $(document).ready(function() {
180159
$('#executeBtn').attr('disabled', false);
181160
}
182161
else {
183-
var startingInstruction = 0;
184-
185-
// only do this at most ONCE, and then clear out preseededCurInstr
186-
if (preseededCurInstr && preseededCurInstr < trace.length) { // NOP anyways if preseededCurInstr is 0
187-
startingInstruction = preseededCurInstr;
188-
preseededCurInstr = null;
189-
}
190-
191162
myVisualizer = new ExecutionVisualizer('pyOutputPane',
192163
dataFromBackend,
193-
{startingInstruction: startingInstruction});
164+
{embeddedMode: true});
194165

195166
$.bbq.pushState({ mode: 'visualize' }, 2 /* completely override other hash strings to keep URL clean */);
196167
}
@@ -199,199 +170,6 @@ $(document).ready(function() {
199170
});
200171

201172

202-
203-
// canned examples
204-
205-
$("#tutorialExampleLink").click(function() {
206-
$.get("example-code/py_tutorial.txt", setCodeMirrorVal);
207-
return false;
208-
});
209-
210-
$("#strtokExampleLink").click(function() {
211-
$.get("example-code/strtok.txt", setCodeMirrorVal);
212-
return false;
213-
});
214-
215-
$("#fibonacciExampleLink").click(function() {
216-
$.get("example-code/fib.txt", setCodeMirrorVal);
217-
return false;
218-
});
219-
220-
$("#memoFibExampleLink").click(function() {
221-
$.get("example-code/memo_fib.txt", setCodeMirrorVal);
222-
return false;
223-
});
224-
225-
$("#factExampleLink").click(function() {
226-
$.get("example-code/fact.txt", setCodeMirrorVal);
227-
return false;
228-
});
229-
230-
$("#filterExampleLink").click(function() {
231-
$.get("example-code/filter.txt", setCodeMirrorVal);
232-
return false;
233-
});
234-
235-
$("#insSortExampleLink").click(function() {
236-
$.get("example-code/ins_sort.txt", setCodeMirrorVal);
237-
return false;
238-
});
239-
240-
$("#aliasExampleLink").click(function() {
241-
$.get("example-code/aliasing.txt", setCodeMirrorVal);
242-
return false;
243-
});
244-
245-
$("#newtonExampleLink").click(function() {
246-
$.get("example-code/sqrt.txt", setCodeMirrorVal);
247-
return false;
248-
});
249-
250-
$("#oopSmallExampleLink").click(function() {
251-
$.get("example-code/oop_small.txt", setCodeMirrorVal);
252-
return false;
253-
});
254-
255-
$("#mapExampleLink").click(function() {
256-
$.get("example-code/map.txt", setCodeMirrorVal);
257-
return false;
258-
});
259-
260-
$("#oop1ExampleLink").click(function() {
261-
$.get("example-code/oop_1.txt", setCodeMirrorVal);
262-
return false;
263-
});
264-
265-
$("#oop2ExampleLink").click(function() {
266-
$.get("example-code/oop_2.txt", setCodeMirrorVal);
267-
return false;
268-
});
269-
270-
$("#inheritanceExampleLink").click(function() {
271-
$.get("example-code/oop_inherit.txt", setCodeMirrorVal);
272-
return false;
273-
});
274-
275-
$("#sumExampleLink").click(function() {
276-
$.get("example-code/sum.txt", setCodeMirrorVal);
277-
return false;
278-
});
279-
280-
$("#pwGcdLink").click(function() {
281-
$.get("example-code/wentworth_gcd.txt", setCodeMirrorVal);
282-
return false;
283-
});
284-
285-
$("#pwSumListLink").click(function() {
286-
$.get("example-code/wentworth_sumList.txt", setCodeMirrorVal);
287-
return false;
288-
});
289-
290-
$("#towersOfHanoiLink").click(function() {
291-
$.get("example-code/towers_of_hanoi.txt", setCodeMirrorVal);
292-
return false;
293-
});
294-
295-
$("#pwTryFinallyLink").click(function() {
296-
$.get("example-code/wentworth_try_finally.txt", setCodeMirrorVal);
297-
return false;
298-
});
299-
300-
$("#sumCubesLink").click(function() {
301-
$.get("example-code/sum-cubes.txt", setCodeMirrorVal);
302-
return false;
303-
});
304-
305-
$("#decoratorsLink").click(function() {
306-
$.get("example-code/decorators.txt", setCodeMirrorVal);
307-
return false;
308-
});
309-
310-
311-
312-
$('#closure1Link').click(function() {
313-
$.get("example-code/closures/closure1.txt", setCodeMirrorVal);
314-
return false;
315-
});
316-
$('#closure2Link').click(function() {
317-
$.get("example-code/closures/closure2.txt", setCodeMirrorVal);
318-
return false;
319-
});
320-
$('#closure3Link').click(function() {
321-
$.get("example-code/closures/closure3.txt", setCodeMirrorVal);
322-
return false;
323-
});
324-
$('#closure4Link').click(function() {
325-
$.get("example-code/closures/closure4.txt", setCodeMirrorVal);
326-
return false;
327-
});
328-
$('#closure5Link').click(function() {
329-
$.get("example-code/closures/closure5.txt", setCodeMirrorVal);
330-
return false;
331-
});
332-
$('#lambdaParamLink').click(function() {
333-
$.get("example-code/closures/lambda-param.txt", setCodeMirrorVal);
334-
return false;
335-
});
336-
337-
338-
$('#aliasing1Link').click(function() {
339-
$.get("example-code/aliasing/aliasing1.txt", setCodeMirrorVal);
340-
return false;
341-
});
342-
$('#aliasing2Link').click(function() {
343-
$.get("example-code/aliasing/aliasing2.txt", setCodeMirrorVal);
344-
return false;
345-
});
346-
$('#aliasing3Link').click(function() {
347-
$.get("example-code/aliasing/aliasing3.txt", setCodeMirrorVal);
348-
return false;
349-
});
350-
$('#aliasing4Link').click(function() {
351-
$.get("example-code/aliasing/aliasing4.txt", setCodeMirrorVal);
352-
return false;
353-
});
354-
$('#aliasing5Link').click(function() {
355-
$.get("example-code/aliasing/aliasing5.txt", setCodeMirrorVal);
356-
return false;
357-
});
358-
$('#aliasing6Link').click(function() {
359-
$.get("example-code/aliasing/aliasing6.txt", setCodeMirrorVal);
360-
return false;
361-
});
362-
$('#aliasing7Link').click(function() {
363-
$.get("example-code/aliasing/aliasing7.txt", setCodeMirrorVal);
364-
return false;
365-
});
366-
$('#aliasing8Link').click(function() {
367-
$.get("example-code/aliasing/aliasing8.txt", setCodeMirrorVal);
368-
return false;
369-
});
370-
371-
372-
$('#ll1Link').click(function() {
373-
$.get("example-code/linked-lists/ll1.txt", setCodeMirrorVal);
374-
return false;
375-
});
376-
$('#ll2Link').click(function() {
377-
$.get("example-code/linked-lists/ll2.txt", setCodeMirrorVal);
378-
return false;
379-
});
380-
381-
382-
if (preseededCode) {
383-
setCodeMirrorVal(preseededCode);
384-
385-
if ($.bbq.getState('mode') != 'edit') {
386-
$("#executeBtn").trigger('click');
387-
}
388-
}
389-
else {
390-
// select a canned example on start-up:
391-
$("#aliasExampleLink").trigger('click');
392-
}
393-
394-
395173
// log a generic AJAX error handler
396174
$(document).ajaxError(function() {
397175
alert("Server error (possibly due to memory/resource overload).");
@@ -418,5 +196,8 @@ $(document).ready(function() {
418196
2);
419197
$('#urlOutput').val(urlStr);
420198
});
199+
200+
201+
$.get("example-code/aliasing.txt", setCodeMirrorVal);
421202
});
422203

‎v3/lesson.html‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,31 @@
5858

5959
<body>
6060

61-
<div id="pyInputPane">
61+
<div id="lessonHeader">
62+
63+
<div id="lessonTitle">Set Intersection and Union</div>
64+
65+
<div id="lessonExposition">Let's say you have several sets of people
66+
that you want to union and intersect ...</div>
6267

63-
Write your Python code here:
64-
<br/>
68+
</div>
69+
70+
<div id="pyInputPane">
6571

6672
<div id="codeInputPane"></div> <!-- populate with a CodeMirror instance -->
6773

6874
<p>
6975
<button id="executeBtn" class="bigBtn" type="button">Visualize execution</button>
7076
</p>
7177

78+
</div>
7279

7380
<div id="pyOutputPane">
7481
</div>
7582

7683
<div id="footer">
7784

7885
<p>
79-
80-
This version of the Online Python Tutor runs <a
81-
href="http://www.python.org/doc/2.7/">Python 2.7</a> on <a
82-
href="https://developers.google.com/appengine/docs/python/python27/newin27">Google
83-
App Engine</a> with limited module imports and no file I/O. It is
84-
designed for teaching programming, not for running or debugging
85-
production code.
86-
87-
</p>
88-
89-
<p style="margin-top: 8px;"/>
9086
Check out the <a
9187
href="https://github.com/pgbovine/OnlinePythonTutor/">GitHub</a>
9288
repository and send bug reports, feedback, and suggestions to philip@pgbovine.net

0 commit comments

Comments
 (0)