diff --git a/public/js/lib/chai/chai.js b/public/js/lib/chai/chai.js
index 77451223e0..4191939dfa 100644
--- a/public/js/lib/chai/chai.js
+++ b/public/js/lib/chai/chai.js
@@ -1,5 +1,5 @@
-;(function(){
+(function(){
/**
* Require the module at `name`.
@@ -4797,4 +4797,4 @@
} else {
(this || window)["chai"] = require("chai");
}
-})()
\ No newline at end of file
+})();
diff --git a/public/js/lib/coursewares/commonFrameWork.js b/public/js/lib/coursewares/commonFrameWork.js
index c2c461500a..22294f9265 100644
--- a/public/js/lib/coursewares/commonFrameWork.js
+++ b/public/js/lib/coursewares/commonFrameWork.js
@@ -150,6 +150,7 @@ var libraryIncludes = "";
@@ -160,25 +161,41 @@ editor.on("keyup", function () {
delay = setTimeout(updatePreview, 300);
});
+function workerError(error){
+ var display = $('.runTimeError');
+ var housing = $('#testSuite');
+ if(display.html() != error){
+ display.remove();
+ housing.prepend("
" + error + "
");
+ display.hide().fadeIn(function(){
+ setTimeout(function(){
+ display.fadeOut(function(){
+ display.remove();
+ });
+ }, 1000)
+ });
+ }
+}
+
+function scopejQuery(s){
+ return(s.replace(/\$/gi, "j$").replace(/document/gi, "jdocument").replace(/jQuery/gi, "jjQuery"));
+}
+
function safeHTMLRun(test){
var previewFrame = document.getElementById('preview');
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
if(editor.getValue().match(/\");
- codeStorage.updateStorage();
- preview.close();
- }
- }
-
}
};
function bonfireExecute() {
+ goodTests = 0;
attempts++;
ga('send', 'event', 'Challenge', 'ran-code', challenge_Name);
userTests = null;
+ $('#testSuite').empty();
if(challengeType !== "0"){
var userJavaScript = myCodeMirror.getValue();
var failedCommentTest = false;
@@ -482,23 +489,30 @@ function bonfireExecute() {
userJavaScript = scrapeTests(userJavaScript);
// simple fix in case the user forgets to invoke their function
- submit(userJavaScript, function (cls, message) {
- if (failedCommentTest) {
- myCodeMirror.setValue(myCodeMirror.getValue() + "*/");
- console.log('Caught Unfinished Comment');
- codeOutput.setValue("Unfinished mulit-line comment");
- failedCommentTest = false;
+ if(userJavaScript.match(/function/gi)){
+ if(userJavaScript.match(/function\s+?\(|function\s+\w+\s*?\(/gi)){
+ submit(userJavaScript, function (cls, message) {
+ if (failedCommentTest) {
+ myCodeMirror.setValue(myCodeMirror.getValue() + "*/");
+ console.log('Caught Unfinished Comment');
+ codeOutput.setValue("Unfinished mulit-line comment");
+ failedCommentTest = false;
+ }
+ else if (cls) {
+ codeOutput.setValue(message.error);
+ runTests('Error', null);
+ } else {
+ codeOutput.setValue(message.output);
+ codeOutput.setValue(codeOutput.getValue().replace(/\\\"/gi, ''));
+ message.input = removeLogs(message.input);
+ runTests(null, message);
+ }
+ });
}
- else if (cls) {
- codeOutput.setValue(message.error);
- runTests('Error', null);
- } else {
- codeOutput.setValue(message.output);
- codeOutput.setValue(codeOutput.getValue().replace(/\\\"/gi, ''));
- message.input = removeLogs(message.input);
- runTests(null, message);
+ else{
+ codeOutput.setValue("Unsafe or Unfinished function declaration");
}
- });
+ }
}
else {
editorValueForIFrame = editor.getValue();
@@ -506,7 +520,9 @@ function bonfireExecute() {
editor.setValue(editor.getValue() + "-->");
editorValueForIFrame = editorValueForIFrame + "-->";
}
- safeHTMLRun(true);
+ if(!editor.getValue().match(/\$\(\$\)/gi) && challengeType === "0") {
+ safeHTMLRun(true);
+ }
}
}
diff --git a/server/views/coursewares/showBonfire.jade b/server/views/coursewares/showBonfire.jade
index 769311c29c..58a00b5f54 100644
--- a/server/views/coursewares/showBonfire.jade
+++ b/server/views/coursewares/showBonfire.jade
@@ -123,7 +123,9 @@ block content
form.code
.form-group.codeMirrorView
textarea#codeEditor(autofocus=true, style='display: none;')
- script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.6.js')
+ script(src='/js/lib/coursewares/commonFrameWork.js')
+ script.
+ editor.setOption("mode", "javascript");
#complete-courseware-dialog.modal(tabindex='-1')
.modal-dialog.animated.zoomIn.fast-animation