Fixed my stupid mistake that almost killed the server again

This commit is contained in:
benmcmahon100
2015-08-26 20:22:29 +01:00
parent 695ad48778
commit a63d6bd00b
4 changed files with 18 additions and 13 deletions

View File

@ -133,7 +133,7 @@ editor.setOption("extraKeys", {
} }
}, },
"Ctrl-Enter": function() { "Ctrl-Enter": function() {
bonfireExecute(); bonfireExecute(true);
return false; return false;
} }
}); });
@ -480,7 +480,7 @@ var runTests = function(err, data) {
} }
}; };
function bonfireExecute() { function bonfireExecute(test) {
goodTests = 0; goodTests = 0;
attempts++; attempts++;
ga('send', 'event', 'Challenge', 'ran-code', challenge_Name); ga('send', 'event', 'Challenge', 'ran-code', challenge_Name);
@ -501,6 +501,7 @@ function bonfireExecute() {
if(userJavaScript.match(/function/gi)){ if(userJavaScript.match(/function/gi)){
if(userJavaScript.match(/function\s*?\(|function\s+\w+\s*?\(/gi)){ if(userJavaScript.match(/function\s*?\(|function\s+\w+\s*?\(/gi)){
submit(userJavaScript, function (cls, message) { submit(userJavaScript, function (cls, message) {
if (failedCommentTest) { if (failedCommentTest) {
myCodeMirror.setValue(myCodeMirror.getValue() + "*/"); myCodeMirror.setValue(myCodeMirror.getValue() + "*/");
@ -510,11 +511,13 @@ function bonfireExecute() {
} }
else if (cls) { else if (cls) {
codeOutput.setValue(message.error); codeOutput.setValue(message.error);
if(test)
runTests('Error', null); runTests('Error', null);
} else { } else {
codeOutput.setValue(message.output); codeOutput.setValue(message.output);
codeOutput.setValue(codeOutput.getValue().replace(/\\\"/gi, '')); codeOutput.setValue(codeOutput.getValue().replace(/\\\"/gi, ''));
message.input = removeLogs(message.input); message.input = removeLogs(message.input);
if(test)
runTests(null, message); runTests(null, message);
} }
}); });
@ -533,11 +536,13 @@ function bonfireExecute() {
} }
else if (cls) { else if (cls) {
codeOutput.setValue(message.error); codeOutput.setValue(message.error);
if(test)
runTests('Error', null); runTests('Error', null);
} else { } else {
codeOutput.setValue(message.output); codeOutput.setValue(message.output);
codeOutput.setValue(codeOutput.getValue().replace(/\\\"/gi, '')); codeOutput.setValue(codeOutput.getValue().replace(/\\\"/gi, ''));
message.input = removeLogs(message.input); message.input = removeLogs(message.input);
if(test)
runTests(null, message); runTests(null, message);
} }
}); });
@ -550,7 +555,7 @@ function bonfireExecute() {
editorValueForIFrame = editorValueForIFrame + "-->"; editorValueForIFrame = editorValueForIFrame + "-->";
} }
if(!editor.getValue().match(/\$\s*?\(\s*?\$\s*?\)/gi) && challengeType === "0") { if(!editor.getValue().match(/\$\s*?\(\s*?\$\s*?\)/gi) && challengeType === "0") {
safeHTMLRun(true); safeHTMLRun(test);
} }
else{ else{
workerError("Unsafe $($)"); workerError("Unsafe $($)");
@ -563,7 +568,7 @@ function bonfireExecute() {
} }
$('#submitButton').on('click', function() { $('#submitButton').on('click', function() {
bonfireExecute(); bonfireExecute(true);
}); });
$(document).ready(function(){ $(document).ready(function(){
@ -573,9 +578,9 @@ $(document).ready(function(){
myCodeMirror.setValue(editorValue.replace(/fccss/gi, '<script>').replace(/fcces/gi, "</script>")); myCodeMirror.setValue(editorValue.replace(/fccss/gi, '<script>').replace(/fcces/gi, "</script>"));
if(typeof $preview.html() !== 'undefined') { if(typeof $preview.html() !== 'undefined') {
$preview.load(function(){ $preview.load(function(){
bonfireExecute(); bonfireExecute(false);
}); });
} else{ } else{
bonfireExecute(); bonfireExecute(false);
} }
}); });

View File

@ -124,7 +124,7 @@ block content
form.code form.code
.form-group.codeMirrorView .form-group.codeMirrorView
textarea#codeEditor(autofocus=true, style='display: none;') textarea#codeEditor(autofocus=true, style='display: none;')
script(src='/js/lib/coursewares/commonFrameWork_0.0.3.js') script(src='/js/lib/coursewares/commonFrameWork_0.0.4.js')
script. script.
editor.setOption("mode", "javascript"); editor.setOption("mode", "javascript");

View File

@ -72,7 +72,7 @@ block content
form.code form.code
.codeMirrorView .codeMirrorView
textarea#codeEditor(autofocus=true, style='display: none;') textarea#codeEditor(autofocus=true, style='display: none;')
script(src = '/js/lib/coursewares/commonFrameWork_0.0.3.js') script(src = '/js/lib/coursewares/commonFrameWork_0.0.4.js')
script. script.
editor.setOption("mode", "text/html"); editor.setOption("mode", "text/html");
.col-md-4.col-lg-3 .col-md-4.col-lg-3

View File

@ -72,7 +72,7 @@ block content
form.code form.code
.codeMirrorView .codeMirrorView
textarea#codeEditor(autofocus=true, style='display: none;') textarea#codeEditor(autofocus=true, style='display: none;')
script(src = '/js/lib/coursewares/commonFrameWork_0.0.3.js') script(src = '/js/lib/coursewares/commonFrameWork_0.0.4.js')
script. script.
editor.setOption("mode", "javascript"); editor.setOption("mode", "javascript");
#complete-courseware-dialog.modal(tabindex='-1') #complete-courseware-dialog.modal(tabindex='-1')