@@ -328,6 +328,7 @@ ExecutionVisualizer.prototype.render = function() {
328328 <button id="jmpStepFwd", type="button">Forward ></button>\
329329 <button id="jmpLastInstr", type="button">Last >></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