Skip to content

Commit 09671ab

Browse files
committed
made code warnings pane better
1 parent eaef7cf commit 09671ab

3 files changed

Lines changed: 8 additions & 12 deletions

File tree

‎v3/composingprograms.html‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@
100100

101101
<div id="pyInputPane">
102102

103-
Write your Python code here:
104-
<br/>
105-
103+
<div id="codeInputWarnings">Write Python code here:</div>
106104
<div id="codeInputPane"></div> <!-- populate with a CodeMirror instance -->
107105
<div id="frontendErrorOutput"></div>
108106
<div id="surveyPane"></div>

‎v3/csc108h.html‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@
9999

100100
<div id="pyInputPane">
101101

102-
Write your Python code here:
103-
<br/>
104-
102+
<div id="codeInputWarnings">Write Python code here:</div>
105103
<div id="codeInputPane"></div> <!-- populate with a CodeMirror instance -->
106104
<div id="frontendErrorOutput"></div>
107105
<div id="surveyPane"></div>

‎v3/js/opt-frontend-common.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ var TogetherJSConfig_toolName = "Online Python Tutor shared session";
9494
var updateOutputSignalFromRemote = false;
9595
var executeCodeSignalFromRemote = false;
9696
var togetherjsSyncRequested = false;
97-
var codeMirrorWarningTimeoutId = undefined;
9897
var pendingCodeOutputScrollTop = null;
9998

10099
var codeMirrorScroller = '#codeInputPane .CodeMirror-scroll';
@@ -249,15 +248,16 @@ function initTogetherJS() {
249248
});
250249

251250
TogetherJS.hub.on("codemirror-edit", function(msg) {
252-
if (codeMirrorWarningTimeoutId !== undefined) {
253-
clearTimeout(codeMirrorWarningTimeoutId); // don't let these events pile up
251+
if (!$("#codeInputWarnings").data('orig-html')) { // set only once
252+
$("#codeInputWarnings").data('orig-html', $("#codeInputWarnings").html());
254253
}
255254

256255
$("#codeInputWarnings").html('<span style="color: #e93f34; font-weight: bold">\
257256
Hold on, someone else is typing ...</span>');
258-
codeMirrorWarningTimeoutId = setTimeout(function() {
259-
$("#codeInputWarnings").html('Write Python code here:');
260-
}, 1000);
257+
258+
$.doTimeout('codeMirrorWarningTimeout', 1000, function() { // debounce
259+
$("#codeInputWarnings").html($("#codeInputWarnings").data('orig-html'));
260+
});
261261
});
262262

263263
TogetherJS.hub.on("requestSync", function(msg) {

0 commit comments

Comments
 (0)