Skip to content

Commit 72d5010

Browse files
committed
moar refactoringz
1 parent f69d458 commit 72d5010

File tree

1 file changed

+78
-59
lines changed

1 file changed

+78
-59
lines changed

v3/js/opt-frontend-common.js

Lines changed: 78 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -765,56 +765,7 @@ function genericOptFrontendReady() {
765765
$("#executeBtn").attr('disabled', false);
766766
$("#executeBtn").click(executeCodeFromScratch);
767767

768-
769-
// for survey-related stuff
770-
// Version 1 - started experiment on 2014-04-09, put on hold on 2014-05-02
771-
/*
772-
$('.surveyBtn').click(function(e) {
773-
// wow, massive copy-and-paste action from above!
774-
var myArgs = getAppState();
775-
776-
var buttonPrompt = $(this).html();
777-
var res = prompt('"' + buttonPrompt + '"' + '\nPlease elaborate if you can and hit OK to submit:');
778-
// don't do ajax call when Cancel button is pressed
779-
// (note that if OK button is pressed with no response, then an
780-
// empty string will still be sent to the server
781-
if (res !== null) {
782-
myArgs.surveyQuestion = buttonPrompt;
783-
myArgs.surveyResponse = res;
784-
$.get('survey.py', myArgs, function(dat) {});
785-
}
786-
});
787-
*/
788-
789-
// Version 2 - started running on 2014-05-24
790-
$('#iJustLearnedSubmission').click(function(e) {
791-
var resp = $("#iJustLearnedInput").val();
792-
793-
if (!$.trim(resp)) {
794-
return;
795-
}
796-
797-
// wow, massive copy-and-paste action from above!
798-
var myArgs = getAppState();
799-
800-
// myArgs.surveyQuestion = "I just learned that ..."; // retired on 2014-06-04
801-
myArgs.surveyQuestion = "What did you just learn?";
802-
myArgs.surveyResponse = resp;
803-
myArgs.surveyVersion = 'v2';
804-
805-
// 2014-05-25: implemented more detailed tracing for surveys
806-
if (myVisualizer) {
807-
myArgs.updateHistoryJSON = JSON.stringify(myVisualizer.updateHistory);
808-
}
809-
810-
$.get('survey.py', myArgs, function(dat) {});
811-
812-
$("#iJustLearnedInput").val('');
813-
$("#iJustLearnedThanks").show();
814-
$.doTimeout('iJustLearnedThanksFadeOut', 1200, function() {
815-
$("#iJustLearnedThanks").fadeOut(1000);
816-
});
817-
});
768+
initializeDisplayModeSurvey();
818769
}
819770

820771

@@ -1345,13 +1296,11 @@ What did you just learn? <input type="text" id="sharedSessionWhatLearned" class=
13451296
</div>'
13461297

13471298

1348-
/* display-mode survey, which is shown when the user is in 'display' mode
1299+
// display-mode survey, which is shown when the user is in 'display' mode
1300+
function initializeDisplayModeSurvey() {
1301+
/* Version 1 - started experiment on 2014-04-09, put on hold on 2014-05-02
13491302
1350-
Version 1 -- deployed on 2014-04-09 and revoked on 2014-05-02
1351-
1352-
As of 2014-05-03, remove the button click survey questions from the
1353-
visualizer so as not to clutter up the screen. i started running this
1354-
experiment on 2014-04-09 and put it on hold on 2014-05-02:
1303+
Hard-coded HTML in surveyHeader:
13551304
13561305
<div id="surveyHeader" style="margin-bottom: 5pt; display: none;">
13571306
<div id="vizSurveyLabel" style="font-size: 8pt; color: #666;">
@@ -1369,9 +1318,27 @@ experiment on 2014-04-09 and put it on hold on 2014-05-02:
13691318
[when any button is clicked a pop-up modal prompt tells the user to type
13701319
in some details elaborating on what they just clicked]
13711320
1321+
$('.surveyBtn').click(function(e) {
1322+
// wow, massive copy-and-paste action from above!
1323+
var myArgs = getAppState();
1324+
1325+
var buttonPrompt = $(this).html();
1326+
var res = prompt('"' + buttonPrompt + '"' + '\nPlease elaborate if you can and hit OK to submit:');
1327+
// don't do ajax call when Cancel button is pressed
1328+
// (note that if OK button is pressed with no response, then an
1329+
// empty string will still be sent to the server
1330+
if (res !== null) {
1331+
myArgs.surveyQuestion = buttonPrompt;
1332+
myArgs.surveyResponse = res;
1333+
$.get('survey.py', myArgs, function(dat) {});
1334+
}
1335+
});
1336+
1337+
*/
1338+
1339+
/* Version 2 - greatly simplified and deployed on 2014-05-24, revoked on 2014-07-13
13721340
1373-
Version 2 of my display-mode survey, greatly simplified and deployed on
1374-
2014-05-24, revoked on 2014-07-13
1341+
Hard-coded HTML in surveyHeader:
13751342
13761343
<div id="surveyHeader" style="display: none;">
13771344
<div id="vizSurveyLabel" style="font-size: 8pt; color: #666; margin-bottom: 5pt;">
@@ -1406,5 +1373,57 @@ Version 2 of my display-mode survey, greatly simplified and deployed on
14061373
</div>
14071374
</div>
14081375
1409-
*/
1376+
[when the user clicks the "Submit" button, send results to survey.py and
1377+
display a brief "Thanks!" note]
1378+
1379+
$('#iJustLearnedSubmission').click(function(e) {
1380+
var resp = $("#iJustLearnedInput").val();
1381+
1382+
if (!$.trim(resp)) {
1383+
return;
1384+
}
1385+
1386+
// wow, massive copy-and-paste action from above!
1387+
var myArgs = getAppState();
1388+
1389+
// myArgs.surveyQuestion = "I just learned that ..."; // retired on 2014-06-04
1390+
myArgs.surveyQuestion = "What did you just learn?";
1391+
myArgs.surveyResponse = resp;
1392+
myArgs.surveyVersion = 'v2';
1393+
1394+
// 2014-05-25: implemented more detailed tracing for surveys
1395+
if (myVisualizer) {
1396+
myArgs.updateHistoryJSON = JSON.stringify(myVisualizer.updateHistory);
1397+
}
1398+
1399+
$.get('survey.py', myArgs, function(dat) {});
1400+
1401+
$("#iJustLearnedInput").val('');
1402+
$("#iJustLearnedThanks").show();
1403+
$.doTimeout('iJustLearnedThanksFadeOut', 1200, function() {
1404+
$("#iJustLearnedThanks").fadeOut(1000);
1405+
});
1406+
});
1407+
1408+
*/
1409+
1410+
/* Version 3 - deployed on 2014-07-13
14101411
1412+
*/
1413+
1414+
var display_mode_survey_v3 = '\n\
1415+
<div id="vizSurveyLabel" style="font-size: 8pt; color: #666;">\n\
1416+
Support our research by clicking a button when you see something interesting in the visualization.<br/>\n\
1417+
</div>\n\
1418+
<div>\n\
1419+
<button class="surveyBtn" type="button">I learned something new!</button>\n\
1420+
<button class="surveyBtn" type="button">I cleared up a misunderstanding!</button>\n\
1421+
<button class="surveyBtn" type="button">I found a bug in my code!</button>\n\
1422+
</div>\n\
1423+
</div>\n';
1424+
1425+
1426+
var display_mode_survey_HTML = display_mode_survey_v3;
1427+
$("#surveyHeader").html(display_mode_survey_HTML);
1428+
1429+
}

0 commit comments

Comments
 (0)