@@ -665,6 +665,57 @@ function genericOptFrontendReady() {
665665 $ ( "#embedLinkDiv" ) . hide ( ) ;
666666 $ ( "#executeBtn" ) . attr ( 'disabled' , false ) ;
667667 $ ( "#executeBtn" ) . click ( executeCodeFromScratch ) ;
668+
669+
670+ // for survey-related stuff
671+ // Version 1 - started experiment on 2014-04-09, put on hold on 2014-05-02
672+ /*
673+ $('.surveyBtn').click(function(e) {
674+ // wow, massive copy-and-paste action from above!
675+ var myArgs = getAppState();
676+
677+ var buttonPrompt = $(this).html();
678+ var res = prompt('"' + buttonPrompt + '"' + '\nPlease elaborate if you can and hit OK to submit:');
679+ // don't do ajax call when Cancel button is pressed
680+ // (note that if OK button is pressed with no response, then an
681+ // empty string will still be sent to the server
682+ if (res !== null) {
683+ myArgs.surveyQuestion = buttonPrompt;
684+ myArgs.surveyResponse = res;
685+ $.get('survey.py', myArgs, function(dat) {});
686+ }
687+ });
688+ */
689+
690+ // Version 2 - started running on 2014-05-24
691+ $ ( '#iJustLearnedSubmission' ) . click ( function ( e ) {
692+ var resp = $ ( "#iJustLearnedInput" ) . val ( ) ;
693+
694+ if ( ! $ . trim ( resp ) ) {
695+ return ;
696+ }
697+
698+ // wow, massive copy-and-paste action from above!
699+ var myArgs = getAppState ( ) ;
700+
701+ // myArgs.surveyQuestion = "I just learned that ..."; // retired on 2014-06-04
702+ myArgs . surveyQuestion = "What did you just learn?" ;
703+ myArgs . surveyResponse = resp ;
704+ myArgs . surveyVersion = 'v2' ;
705+
706+ // 2014-05-25: implemented more detailed tracing for surveys
707+ if ( myVisualizer ) {
708+ myArgs . updateHistoryJSON = JSON . stringify ( myVisualizer . updateHistory ) ;
709+ }
710+
711+ $ . get ( 'survey.py' , myArgs , function ( dat ) { } ) ;
712+
713+ $ ( "#iJustLearnedInput" ) . val ( '' ) ;
714+ $ ( "#iJustLearnedThanks" ) . show ( ) ;
715+ $ . doTimeout ( 'iJustLearnedThanksFadeOut' , 1200 , function ( ) {
716+ $ ( "#iJustLearnedThanks" ) . fadeOut ( 1000 ) ;
717+ } ) ;
718+ } ) ;
668719}
669720
670721
0 commit comments