Skip to content

Commit 30534a8

Browse files
committed
made raw user input box NOT a modal pop-up prompt!
1 parent 4865848 commit 30534a8

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

v3/css/pytutor.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,13 @@ div.ExecutionVisualizer .highlight-legend {
723723
border-color: #dddddd;
724724
}
725725

726+
div.ExecutionVisualizer div#rawUserInputDiv {
727+
padding: 5px;
728+
width: 95%;
729+
margin: 5px auto;
730+
text-align: center;
731+
border: 1px #e93f34 solid;
732+
}
726733

727734
/* for pyCrazyMode */
728735

v3/js/opt-frontend-common.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,6 @@ function updateAppDisplay(newAppMode) {
333333
}
334334

335335
$('#urlOutput,#embedCodeOutput').val(''); // clear to avoid stale values
336-
337-
console.log('END updateAppDisplay', appMode);
338336
}
339337

340338

@@ -366,12 +364,10 @@ function doneExecutingCode() {
366364

367365

368366
function enterDisplayMode() {
369-
console.log('enterDisplayMode');
370367
updateAppDisplay('display');
371368
}
372369

373370
function enterEditMode() {
374-
console.log('enterEditMode');
375371
updateAppDisplay('edit');
376372
}
377373

v3/js/pytutor.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ ExecutionVisualizer.prototype.render = function() {
328328
<button id="jmpStepFwd", type="button">Forward &gt;</button>\
329329
<button id="jmpLastInstr", type="button">Last &gt;&gt;</button>\
330330
</div>\
331+
<div id="rawUserInputDiv"/>\
331332
<div id="errorOutput"/>\
332333
<div id="legendDiv"/>\
333334
<div id="stepAnnotationDiv">\
@@ -1388,7 +1389,7 @@ ExecutionVisualizer.prototype.updateOutputFull = function(smoothTransition) {
13881389

13891390
if (isLastInstr) {
13901391
if (this.promptForUserInput || this.promptForMouseInput) {
1391-
vcrControls.find("#curInstr").html('<b><font color="' + brightRed + '">user input</font></b>');
1392+
vcrControls.find("#curInstr").html('<b><font color="' + brightRed + '">Enter user input:</font></b>');
13921393
// looks ugly when userInputPromptStr is TOO LONG
13931394
//vcrControls.find("#curInstr").html('<b><font color="' + brightRed + '">' + this.userInputPromptStr + '</font></b>');
13941395

@@ -1740,19 +1741,22 @@ ExecutionVisualizer.prototype.updateOutputFull = function(smoothTransition) {
17401741
}
17411742
}
17421743

1744+
// handle raw user input
1745+
var ruiDiv = myViz.domRoot.find('#rawUserInputDiv');
1746+
ruiDiv.hide(); // hide by default
17431747

1744-
if (isLastInstr && this.executeCodeWithRawInputFunc) {
1745-
if (this.promptForUserInput) {
1746-
// blocking prompt dialog!
1747-
// put a default string of '' or else it looks ugly in IE
1748-
var userInput = prompt(this.userInputPromptStr, '');
1748+
if (isLastInstr && myViz.executeCodeWithRawInputFunc) {
1749+
if (myViz.promptForUserInput) {
1750+
ruiDiv.html(myViz.userInputPromptStr +
1751+
' <input id="raw_input_textbox" type="textbox" size="30"/>' +
1752+
' <button id="raw_input_submit_btn">Submit</button>');
1753+
ruiDiv.show();
17491754

1750-
// if you hit 'Cancel' in prompt(), it returns null
1751-
if (userInput !== null) {
1752-
// after executing, jump back to this.curInstr to give the
1753-
// illusion of continuity
1754-
this.executeCodeWithRawInputFunc(userInput, this.curInstr);
1755-
}
1755+
ruiDiv.find('#raw_input_submit_btn').click(function() {
1756+
var userInput = ruiDiv.find('#raw_input_textbox').val();
1757+
// advance instruction count by 1 to get to the NEXT instruction
1758+
myViz.executeCodeWithRawInputFunc(userInput, myViz.curInstr + 1);
1759+
});
17561760
}
17571761
}
17581762

0 commit comments

Comments
 (0)