Skip to content

Commit 98b5587

Browse files
committed
updating matrix code
1 parent 67409cd commit 98b5587

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

‎v3/js/matrixtutor.js‎

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ var pyTestInputCodeMirror; // CodeMirror object that contains the test code
5656

5757

5858
$(document).ready(function() {
59+
useCodeMirror = true; // set global defined in opt-frontend-common.js
60+
5961
problemName = window.location.search;
6062
if (!problemName) {
6163
alert("Error! Pass in a valid problem name in the url as '?<problem name>'");
@@ -162,36 +164,34 @@ $(document).ready(function() {
162164
jumpToEnd: true,
163165
}
164166

167+
function f1(errorLineNo) {
168+
pyInputCodeMirror.removeLineClass(errorLineNo, null, 'errorLine'); // reset line back to normal
169+
pyInputCodeMirror.off('change', f1);
170+
}
171+
function f2(errorLineNo) {
172+
pyTestInputCodeMirror.removeLineClass(errorLineNo, null, 'errorLine'); // reset line back to normal
173+
pyTestInputCodeMirror.off('change', f2);
174+
}
175+
165176
function handleUncaughtExceptionFunc(trace) {
166177
if (trace.length == 1) {
167178
var errorLineNo = trace[0].line - 1; /* CodeMirror lines are zero-indexed */
168179
if (errorLineNo !== undefined) {
169-
170180
if (errorLineNo < nCodeLines) {
171181
// highlight the faulting line in pyInputCodeMirror
172182
pyInputCodeMirror.focus();
173183
pyInputCodeMirror.setCursor(errorLineNo, 0);
174-
// TODO: refactor to use new CodeMirror version
175-
pyInputCodeMirror.setLineClass(errorLineNo, null, 'errorLine');
176-
177-
pyInputCodeMirror.setOption('onChange', function() {
178-
pyInputCodeMirror.setLineClass(errorLineNo, null, null); // reset line back to normal
179-
pyInputCodeMirror.setOption('onChange', null); // cancel
180-
});
184+
pyInputCodeMirror.addLineClass(errorLineNo, null, 'errorLine');
185+
pyInputCodeMirror.on('change', f1.bind(errorLineNo));
181186
}
182187
else {
183188
// instead highlight the faulting line in pyTestInputCodeMirror
184189
errorLineNo -= nCodeLines;
185190

186-
// TODO: refactor to use new CodeMirror version
187191
pyTestInputCodeMirror.focus();
188192
pyTestInputCodeMirror.setCursor(errorLineNo, 0);
189-
pyTestInputCodeMirror.setLineClass(errorLineNo, null, 'errorLine');
190-
191-
pyTestInputCodeMirror.setOption('onChange', function() {
192-
pyTestInputCodeMirror.setLineClass(errorLineNo, null, null);
193-
pyTestInputCodeMirror.setOption('onChange', null); // cancel
194-
});
193+
pyTestInputCodeMirror.addLineClass(errorLineNo, null, 'errorLine');
194+
pyTestInputCodeMirror.on('change', f2.bind(errorLineNo));
195195
}
196196
}
197197

@@ -277,13 +277,6 @@ $(document).ready(function() {
277277
},
278278
"json");
279279

280-
// stent
281-
/*
282-
pyInputCodeMirror.setValue('x = 5');
283-
pyTestInputCodeMirror.setValue('y = 10');
284-
$(".problemDescClass").html('testing testing testing');
285-
*/
286-
287280
$('#submitGradeBtn').bind('click', function() {
288281
$('#submitGradeBtn').html('Now Grading ...');
289282
$('#submitGradeBtn').attr('disabled', true);

‎v3/matrix.html‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
<script type="text/javascript" src="js/jquery.ba-dotimeout.min.js"></script> <!-- for event debouncing -->
4242
<script type="text/javascript" src="js/jquery.jsPlumb-1.3.10-all-min.js "></script> <!-- for rendering SVG connectors
4343
DO NOT UPGRADE ABOVE 1.3.10 OR ELSE BREAKAGE WILL OCCUR -->
44+
<script type="text/javascript" src="js/diff_match_patch.js"></script>
45+
4446
<script type="text/javascript" src="js/jquery-ui-1.8.24.custom.min.js"></script> <!-- for sliders and other UI elements -->
4547
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.24.custom.css" rel="stylesheet" />
4648

@@ -51,6 +53,11 @@
5153

5254
<!-- requirements for opt-frontend.js -->
5355

56+
<!-- codemirror.net online code editor -->
57+
<script type="text/javascript" src="js/codemirror/codemirror.js"></script>
58+
<link type="text/css" href="css/codemirror.css" rel="stylesheet" />
59+
<script type="text/javascript" src="js/codemirror/python.js"></script>
60+
5461
<!-- Ace online code editor -->
5562
<script type="text/javascript" src="js/ace/src-min-noconflict/ace.js" charset="utf-8"></script>
5663

0 commit comments

Comments
 (0)