Skip to content

Commit 5bb21b0

Browse files
committed
boom
1 parent c15cfc4 commit 5bb21b0

4 files changed

Lines changed: 57 additions & 47 deletions

File tree

v3/css/opt-frontend.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,37 @@ button.surveyBtn {
174174
.star-rating i ~ i ~ i ~ i ~ i {
175175
width: 100%;
176176
}
177+
178+
179+
#syntaxErrBubbleContents {
180+
font-size: 9pt;
181+
cursor: default;
182+
}
183+
184+
#syntaxErrHeader {
185+
margin-bottom: 3pt;
186+
}
187+
188+
#syntaxErrCodeDisplay {
189+
border: 1px solid #ddd;
190+
}
191+
192+
#syntaxErrMsg {
193+
color: #e93f34; /* should match brightRed JavaScript variable */
194+
font-size: 10pt;
195+
margin-top: 3pt;
196+
margin-bottom: 2pt;
197+
}
198+
199+
#syntaxErrQuestion {
200+
margin-top: 10px;
201+
}
202+
203+
#syntaxErrTxtInput {
204+
margin-top: 3px;
205+
margin-bottom: 6px;
206+
}
207+
208+
#syntaxErrSubmitBtn, #syntaxErrCloseBtn {
209+
margin-right: 5px;
210+
}

v3/css/pytutor.css

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -793,39 +793,6 @@ div.ExecutionVisualizer .pycrazy-highlight-prev-and-cur {
793793
}
794794

795795

796-
#syntaxErrBubbleContents {
797-
font-size: 9pt;
798-
cursor: default;
799-
}
800-
801-
#syntaxErrHeader {
802-
margin-bottom: 4pt;
803-
}
804-
805-
#syntaxErrCodeDisplay {
806-
border: 1px solid #ddd;
807-
}
808-
809-
#syntaxErrMsg {
810-
color: #e93f34; /* should match brightRed JavaScript variable */
811-
font-size: 10pt;
812-
margin-bottom: 4pt;
813-
}
814-
815-
#syntaxErrQuestion {
816-
margin-top: 10px;
817-
}
818-
819-
#syntaxErrTxtInput {
820-
margin-top: 3px;
821-
margin-bottom: 6px;
822-
}
823-
824-
#syntaxErrSubmitBtn, #syntaxErrCloseBtn {
825-
margin-right: 5px;
826-
}
827-
828-
829796
/* BEGIN Java frontend by David Pritchard and Will Gwozdz */
830797

831798
/* stack and queue css by Will Gwozdz */

v3/js/opt-frontend-common.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ var pyInputAceEditor; // Ace editor object that contains the input code
7777

7878
var useCodeMirror = false; // true -> use CodeMirror, false -> use Ace
7979

80-
var prevExecutionExceptionObj = null; // did the PREVIOUS execution have an exception? if so, what was its context?
80+
// a list of previous consecutive executions with "compile"-time exceptions
81+
var prevExecutionExceptionObjLst = [];
8182

8283

8384
var loggingSocketIO = undefined; // socket.io instance -- OPTIONAL: not all frontends use it
@@ -1122,6 +1123,7 @@ function updateAppDisplay(newAppMode) {
11221123

11231124
$.doTimeout('pyCodeOutputDivScroll'); // cancel any prior scheduled calls
11241125

1126+
// TODO: this might interfere with experimentalPopUpSyntaxErrorSurvey (2015-04-19)
11251127
myVisualizer.domRoot.find('#pyCodeOutputDiv').scroll(function(e) {
11261128
var elt = $(this);
11271129
// debounce
@@ -1370,9 +1372,9 @@ function executePythonCode(pythonSourceCode,
13701372

13711373
if (killerException) {
13721374
var excObj = {killerException: killerException, myAppState: getAppState()};
1373-
prevExecutionExceptionObj = excObj;
1375+
prevExecutionExceptionObjLst.push(excObj);
13741376
} else {
1375-
prevExecutionExceptionObj = null; // reset!!!
1377+
prevExecutionExceptionObjLst = []; // reset!!!
13761378
}
13771379

13781380
// tricky hacky reset

v3/js/opt-frontend.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,15 @@ SyntaxErrorSurveyBubble.prototype.qTipID = function() {
223223

224224
// created on 2015-04-18
225225
function experimentalPopUpSyntaxErrorSurvey() {
226-
if (prevExecutionExceptionObj &&
227-
prevExecutionExceptionObj.killerException.line !== undefined) {
226+
if (prevExecutionExceptionObjLst.length > 0) {
227+
// work with the most recent entry
228+
var prevExecutionExceptionObj = prevExecutionExceptionObjLst[prevExecutionExceptionObjLst.length - 1];
228229
var offendingLine = prevExecutionExceptionObj.killerException.line;
230+
231+
if (offendingLine === undefined) {
232+
return; // get out early!
233+
}
234+
229235
// make sure jquery.qtip has been imported
230236

231237
var codelineIDs = [];
@@ -242,7 +248,6 @@ function experimentalPopUpSyntaxErrorSurvey() {
242248
// because the code changed so much that the line number in question
243249
// is no longer available
244250
if (codelineIDs.length === 1) {
245-
console.log('PREV', prevExecutionExceptionObj);
246251
var codLineId = codelineIDs[0];
247252

248253
var bub = new SyntaxErrorSurveyBubble(myVisualizer, codLineId);
@@ -256,7 +261,7 @@ function experimentalPopUpSyntaxErrorSurvey() {
256261
my: bub.my,
257262
at: bub.at,
258263
adjust: {
259-
x: -10,
264+
x: -6,
260265
},
261266
effect: null, // disable all cutesy animations
262267
},
@@ -269,10 +274,10 @@ function experimentalPopUpSyntaxErrorSurvey() {
269274
$(bub.qTipID()).css('max-width', '350px').width('350px');
270275

271276
$(bub.qTipContentID()).html('<div id="syntaxErrBubbleContents"><div id="syntaxErrHeader">You just fixed the following error:</div>\
272-
<div id="syntaxErrMsg">[ERROR MSG]</div>\
273277
<div id="syntaxErrCodeDisplay"></div>\
278+
<div id="syntaxErrMsg"></div>\
274279
<div id="syntaxErrQuestion">\
275-
What would have been a better error message here?<br/>\
280+
If you think this message wasn\'t helpful, what would have been the ideal error message for you here?<br/>\
276281
<input type="text" id="syntaxErrTxtInput" size=60 maxlength=150/><br/>\
277282
<button class="syntaxErrSubmitBtn" type="button">Submit</button>\
278283
<button class="syntaxErrCloseBtn" type="button">Cancel</button>\
@@ -287,6 +292,10 @@ function experimentalPopUpSyntaxErrorSurvey() {
287292

288293

289294
var bubbleAceEditor = ace.edit('syntaxErrCodeDisplay');
295+
// set the size and value ASAP to get alignment working well ...
296+
bubbleAceEditor.setOptions({minLines: 1, maxLines: 5}); // keep this SMALL
297+
bubbleAceEditor.setValue(prevExecutionExceptionObj.myAppState.code.rtrim() /* kill trailing spaces */,
298+
-1 /* do NOT select after setting text */);
290299

291300
var s = bubbleAceEditor.getSession();
292301
// tab -> 4 spaces
@@ -300,10 +309,9 @@ function experimentalPopUpSyntaxErrorSurvey() {
300309

301310
bubbleAceEditor.setFontSize(10);
302311

303-
bubbleAceEditor.setOptions({minLines: 5, maxLines: 5}); // keep this SMALL
304312

305313
$('#syntaxErrCodeDisplay').css('width', '320px');
306-
$('#syntaxErrCodeDisplay').css('height', '200px'); // VERY IMPORTANT so that it works on I.E., ugh!
314+
$('#syntaxErrCodeDisplay').css('height', '90px'); // VERY IMPORTANT so that it works on I.E., ugh!
307315

308316
// don't do real-time syntax checks:
309317
// https://github.com/ajaxorg/ace/wiki/Syntax-validation
@@ -320,8 +328,6 @@ function experimentalPopUpSyntaxErrorSurvey() {
320328
}
321329
s.setMode("ace/mode/" + mod);
322330

323-
bubbleAceEditor.setValue(prevExecutionExceptionObj.myAppState.code.rtrim() /* kill trailing spaces */,
324-
-1 /* do NOT select after setting text */);
325331
bubbleAceEditor.setReadOnly(true);
326332

327333
s.setAnnotations([{row: offendingLine - 1 /* zero-indexed */,
@@ -338,8 +344,9 @@ function experimentalPopUpSyntaxErrorSurvey() {
338344
// don't forget htmlspecialchars
339345
$("#syntaxErrMsg").html(htmlspecialchars(prevExecutionExceptionObj.killerException.exception_msg));
340346

341-
// TODO: why is this positioning so wonky in the beginning?!?
342347
bub.redrawCodelineBubble(); // do an initial redraw to align everything
348+
349+
//globalBub = bub; // for debugging
343350
}
344351
}
345352
}

0 commit comments

Comments
 (0)