Skip to content

Commit 6ee46b2

Browse files
committed
gitting ready for deploy soon
1 parent 891a353 commit 6ee46b2

6 files changed

Lines changed: 100 additions & 16 deletions

File tree

‎v3/css/opt-live.css‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@
2828
text-align: center;
2929
}
3030

31+
/* keep it a fixed min height so that footer below it doesn't jiggle up
32+
and down */
33+
#frontendErrorOutput {
34+
min-height: 40px;
35+
}
36+
37+
/* copied from pytutor.css */
38+
div#legendDiv {
39+
margin-top: 8px;
40+
padding: 0px;
41+
text-align: left;
42+
color: #666;
43+
font-size: 9pt;
44+
width: 500px;
45+
}
46+
47+
#prevLegendArrowSVG, #curLegendArrowSVG {
48+
width: 18px;
49+
height: 10px;
50+
}
51+
52+
3153
/* translucent dimmed div: http://stackoverflow.com/a/21457838 */
3254
.dimmed {
3355
position: relative;

‎v3/css/pytutor.css‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ div.ExecutionVisualizer div#progOutputs {
137137
}
138138

139139
div.ExecutionVisualizer div#legendDiv {
140-
margin-top: 10px;
141140
padding: 0px;
142141
text-align: left;
143142
color: #666;

‎v3/js/opt-frontend-common.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ var useCodeMirror = false; // true -> use CodeMirror, false -> use Ace
123123
// a list of previous consecutive executions with "compile"-time exceptions
124124
var prevExecutionExceptionObjLst = [];
125125

126+
var CODE_SNAPSHOT_DEBOUNCE_MS = 1000;
127+
126128

127129
// From http://stackoverflow.com/a/8809472
128130
function generateUUID(){
@@ -197,7 +199,7 @@ function initAceEditor(height) {
197199

198200
initDeltaObj();
199201
pyInputAceEditor.on('change', function(e) {
200-
$.doTimeout('pyInputAceEditorChange', 1000, snapshotCodeDiff); // debounce
202+
$.doTimeout('pyInputAceEditorChange', CODE_SNAPSHOT_DEBOUNCE_MS, snapshotCodeDiff); // debounce
201203
clearFrontendError();
202204
s.clearAnnotations();
203205
});
@@ -745,11 +747,10 @@ function redrawConnectors() {
745747

746748
function setFronendError(lines) {
747749
$("#frontendErrorOutput").html(lines.map(htmlspecialchars).join('<br/>'));
748-
$("#frontendErrorOutput").show();
749750
}
750751

751752
function clearFrontendError() {
752-
$("#frontendErrorOutput").hide();
753+
$("#frontendErrorOutput").html('');
753754
}
754755

755756

‎v3/js/opt-live.js‎

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4242
- make Ace editor resizable width-wise using jQuery resizable
4343
(stackoverflow has some tips for how to do that)
4444
45+
- also add in general directions about live mode and a switchback option
46+
to regular mode
47+
48+
- add footer
49+
4550
- support pasting in code via URL, which will be important for
4651
transporting the user from regular OPT to live mode
4752
- add "Generate permanent link" button, but no need for iframe embed btn
@@ -106,6 +111,8 @@ function toggleSyntaxError(x) {
106111
} else {
107112
hasSyntaxError = false;
108113
$("#dataViz,#curInstr").removeClass('dimmed'); // un-dim the visualization
114+
var s = pyInputAceEditor.getSession();
115+
s.clearAnnotations(); // remove any lingering syntax error labels in gutter
109116
}
110117
}
111118

@@ -156,7 +163,6 @@ function updateStepLabels() {
156163
} else {
157164
$("#frontendErrorOutput").html(htmlspecialchars(curEntry.exception_msg));
158165
}
159-
$("#frontendErrorOutput").show();
160166

161167
if (myVisualizer.curLineNumber) {
162168
var Range = ace.require('ace/range').Range;
@@ -333,13 +339,9 @@ function initAceEditor(height) {
333339
$('#codeInputPane').css('height', height + 'px'); // VERY IMPORTANT so that it works on I.E., ugh!
334340

335341
pyInputAceEditor.on('change', function(e) {
336-
$.doTimeout('pyInputAceEditorChange', 500, function() {
337-
// don't execute empty string:
338-
if ($.trim(pyInputGetValue()) === '') {
339-
return;
340-
}
341-
executeCode();
342-
}); // debounce
342+
$.doTimeout('pyInputAceEditorChange',
343+
CODE_SNAPSHOT_DEBOUNCE_MS /* match the value in opt-frontend-common.js for consistency and easy apples-to-apples comparisons later on */,
344+
executeCode); // debounce
343345
clearFrontendError();
344346
s.clearAnnotations();
345347
});
@@ -490,6 +492,13 @@ function optliveExecuteCodeAndCreateViz(codeToExec,
490492
}
491493

492494
function executeCode(forceStartingInstr, forceRawInputLst) {
495+
var cod = pyInputGetValue();
496+
497+
// don't run empty code
498+
if ($.trim(cod) === '') {
499+
return;
500+
}
501+
493502
if (forceRawInputLst !== undefined) {
494503
rawInputLst = forceRawInputLst; // UGLY global across modules, FIXME
495504
}
@@ -509,7 +518,7 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
509518
jumpToEnd: true,
510519
}
511520

512-
optliveExecuteCodeAndCreateViz(pyInputGetValue(),
521+
optliveExecuteCodeAndCreateViz(cod,
513522
backend_script, backendOptionsObj,
514523
frontendOptionsObj,
515524
'pyOutputPane',
@@ -520,6 +529,20 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
520529
$(document).ready(function() {
521530
genericOptFrontendReady();
522531

532+
$('#legendDiv')
533+
.append('<svg id="prevLegendArrowSVG"/> line that has just executed')
534+
.append('<p style="margin-top: 4px"><svg id="curLegendArrowSVG"/> next line to execute</p>');
535+
536+
d3.select('svg#prevLegendArrowSVG')
537+
.append('polygon')
538+
.attr('points', SVG_ARROW_POLYGON)
539+
.attr('fill', lightArrowColor);
540+
541+
d3.select('svg#curLegendArrowSVG')
542+
.append('polygon')
543+
.attr('points', SVG_ARROW_POLYGON)
544+
.attr('fill', darkArrowColor);
545+
523546
$('#pythonVersionSelector').change(function() {
524547
setAceMode();
525548
// force a recompile on a toggle switch

‎v3/js/pytutor.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ ExecutionVisualizer.prototype.render = function() {
413413
<div id="langDisplayDiv"></div>\
414414
<div id="pyCodeOutputDiv"/>\
415415
<div id="editCodeLinkDiv"><a id="editBtn">Edit code</a></div>\
416+
<div id="legendDiv"/>\
417+
<div id="executionSliderDocs"><font color="#e93f34">NEW!</font> Click on a line of code to set a <b>breakpoint</b> where you want to jump. Then use the <b>Left</b> and <b>Right</b> arrow keys and the Back and Forward buttons to jump there.</div>\
416418
<div id="executionSlider"/>\
417419
<div id="executionSliderFooter"/>\
418420
<div id="vcrControls">\
@@ -422,14 +424,12 @@ ExecutionVisualizer.prototype.render = function() {
422424
<button id="jmpStepFwd", type="button">Forward &gt;</button>\
423425
<button id="jmpLastInstr", type="button">Last &gt;&gt;</button>\
424426
</div>\
425-
<div id="executionSliderDocs"><font color="#e93f34">NEW!</font> Click on a line of code to set a <b>breakpoint</b> where you want to jump. Then use the <b>Left</b> and <b>Right</b> arrow keys and the Back and Forward buttons to jump there.</div>\
426427
<div id="rawUserInputDiv">\
427428
<span id="userInputPromptStr"/>\
428429
<input type="text" id="raw_input_textbox" size="30"/>\
429430
<button id="raw_input_submit_btn">Submit</button>\
430431
</div>\
431432
<div id="errorOutput"/>\
432-
<div id="legendDiv"/>\
433433
<div id="stepAnnotationDiv">\
434434
<textarea class="annotationText" id="stepAnnotationEditor" cols="60" rows="3"></textarea>\
435435
<div class="annotationText" id="stepAnnotationViewer"></div>\

‎v3/live.html‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
-->
3333

3434
<head>
35-
<title>OPT Live Programming Prototype</title>
35+
<title>Python Tutor Live - Live Programming and Visualizations</title>
3636
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
3737

3838
<!-- requirements for pytutor.js -->
@@ -89,6 +89,7 @@
8989
</div>
9090

9191
<div id="codeInputPane"></div>
92+
<div id="legendDiv"></div>
9293
<div id="executionSlider" style="margin-top: 10px;"></div>
9394
<div id="curInstr"></div>
9495
<div id="frontendErrorOutput"></div>
@@ -99,5 +100,43 @@
99100
</td>
100101
</tr>
101102
</table>
103+
104+
<div id="footer">
105+
106+
<p>
107+
<button id="genUrlBtn" class="smallBtn" type="button">Generate permanent link</button> <input type="text" id="urlOutput" size="70"/>
108+
</p>
109+
110+
<p>Click the button above to create a permanent link to your
111+
visualization. To report a bug, paste the link along with a brief error
112+
description in an email addressed to philip@pgbovine.net</p>
113+
114+
<p style="margin-top: 35px;">
115+
This live programming version of
116+
<a href="http://pythontutor.com/">Python Tutor</a> (<a href="https://github.com/pgbovine/OnlinePythonTutor">code on GitHub</a>) supports three
117+
languages: Python <a href="http://www.python.org/doc/2.7/">2.7</a> and <a
118+
href="http://www.python.org/doc/3.3.0/">3.3</a> with limited module
119+
imports and no file I/O, and
120+
JavaScript running in Node.js v6.0.0 with limited support for ES6.
121+
</p>
122+
123+
<p>Try the regular
124+
<a href="http://pythontutor.com/">Python Tutor</a>
125+
tool for additional language support.</p>
126+
127+
<p style="margin-top: 30px;">Privacy Policy: By using Online Python
128+
Tutor, your visualized code, options, user interactions, text chats, and
129+
IP address are logged on our server and may be analyzed for research
130+
purposes. Nearly all Web services collect this basic information from
131+
users. However, the Online Python Tutor website (pythontutor.com) does
132+
not collect any personal information or session state from users, nor
133+
does it issue any cookies.</p>
134+
135+
<p style="margin-top: 25px;">
136+
Copyright &copy; <a href="http://www.pgbovine.net/">Philip Guo</a>. All rights reserved.
137+
</p>
138+
139+
</div>
140+
102141
</body>
103142
</html>

0 commit comments

Comments
 (0)