@@ -66,6 +66,7 @@ $(document).ready(function() {
6666 setSurveyHTML ( ) ;
6767
6868 $ ( "#embedLinkDiv" ) . hide ( ) ;
69+ $ ( "#surveyHeader" ) . hide ( ) ;
6970
7071 pyInputCodeMirror = CodeMirror ( document . getElementById ( 'codeInputPane' ) , {
7172 mode : 'python' ,
@@ -87,7 +88,7 @@ $(document).ready(function() {
8788
8889 if ( appMode === undefined || appMode == 'edit' ) {
8990 $ ( "#pyInputPane" ) . show ( ) ;
90- $ ( "#pyOutputPane" ) . hide ( ) ;
91+ $ ( "#pyOutputPane,#surveyHeader " ) . hide ( ) ;
9192 $ ( "#embedLinkDiv" ) . hide ( ) ;
9293
9394 $ ( ".surveyQ" ) . val ( '' ) ; // clear all survey results when user hits forward/back
@@ -99,8 +100,7 @@ $(document).ready(function() {
99100 }
100101 else if ( appMode == 'display' || appMode == 'visualize' /* 'visualize' is deprecated */ ) {
101102 $ ( "#pyInputPane" ) . hide ( ) ;
102- $ ( "#pyOutputPane" ) . show ( ) ;
103-
103+ $ ( "#pyOutputPane,#surveyHeader" ) . show ( ) ;
104104 $ ( "#embedLinkDiv" ) . show ( ) ;
105105
106106 $ ( '#executeBtn' ) . html ( "Visualize Execution" ) ;
@@ -119,7 +119,7 @@ $(document).ready(function() {
119119 }
120120 else if ( appMode == 'display_no_frills' ) {
121121 $ ( "#pyInputPane" ) . hide ( ) ;
122- $ ( "#pyOutputPane" ) . show ( ) ;
122+ $ ( "#pyOutputPane,#surveyHeader " ) . show ( ) ;
123123 $ ( "#embedLinkDiv" ) . show ( ) ;
124124 }
125125 else {
@@ -619,5 +619,32 @@ $(document).ready(function() {
619619 var iframeStr = '<iframe width="800" height="500" frameborder="0" src="' + embedUrlStr + '"> </iframe>' ;
620620 $ ( '#embedCodeOutput' ) . val ( iframeStr ) ;
621621 } ) ;
622+
623+
624+ // for survey-related stuff
625+ $ ( '.surveyBtn' ) . click ( function ( e ) {
626+ // wow, massive copy-and-paste action from above!
627+ var myArgs = { code : pyInputCodeMirror . getValue ( ) ,
628+ mode : appMode ,
629+ cumulative : $ ( '#cumulativeModeSelector' ) . val ( ) ,
630+ heapPrimitives : $ ( '#heapPrimitivesSelector' ) . val ( ) ,
631+ drawParentPointers : $ ( '#drawParentPointerSelector' ) . val ( ) ,
632+ textReferences : $ ( '#textualMemoryLabelsSelector' ) . val ( ) ,
633+ showOnlyOutputs : $ ( '#showOnlyOutputsSelector' ) . val ( ) ,
634+ py : $ ( '#pythonVersionSelector' ) . val ( ) } ;
635+
636+ if ( appMode == 'display' || appMode == 'visualize' /* 'visualize' is deprecated */ ) {
637+ myArgs . curInstr = myVisualizer . curInstr ;
638+ }
639+
640+ var buttonPrompt = $ ( this ) . html ( ) ;
641+ var res = prompt ( '"' + buttonPrompt + '"' + ' Please elaborate:' ) ;
642+ // don't submit EMPTY results with no feedback or when Cancel button is pressed
643+ if ( res ) {
644+ myArgs . surveyQuestion = buttonPrompt ;
645+ myArgs . surveyResponse = res ;
646+ $ . get ( 'survey.py' , myArgs , function ( dat ) { } ) ;
647+ }
648+ } ) ;
622649} ) ;
623650
0 commit comments