diff --git a/public/js/lib/coursewares/coursewaresHCJQFramework_0.1.9.js b/public/js/lib/coursewares/coursewaresHCJQFramework_0.1.9.js index 94d8bb7e93..6b004bafe6 100644 --- a/public/js/lib/coursewares/coursewaresHCJQFramework_0.1.9.js +++ b/public/js/lib/coursewares/coursewaresHCJQFramework_0.1.9.js @@ -71,6 +71,17 @@ editor.on("keyup", function () { var nodeEnv = prodOrDev === 'production' ? 'http://www.freecodecamp.com' : 'http://localhost:3001'; function updatePreview() { editorValueForIFrame = editor.getValue(); + var failedCommentTest = false; + if(editorValueForIFrame.match(/\<\!\-\-/gi) && editorValueForIFrame.match(/\-\-\>/gi) == null){ + failedCommentTest = true; + } + else if(editorValueForIFrame.match(/\<\!\-\-/gi) && editorValueForIFrame.match(/\<\!\-\-/gi).length > editorValueForIFrame.match(/\-\-\>/gi).length){ + failedCommentTest = true; + } + if(failedCommentTest){ + editor.setValue(editor.getValue()+ "-->"); + editorValueForIFrame = editorValueForIFrame + "-->"; + } goodTests = 0; var previewFrame = document.getElementById('preview'); var preview = previewFrame.contentDocument || previewFrame.contentWindow.document; diff --git a/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js index 564b9decae..712811c9c1 100644 --- a/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js +++ b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js @@ -100,12 +100,25 @@ function bonfireExecute() { userTests = null; $('#codeOutput').empty(); var userJavaScript = myCodeMirror.getValue(); + var failedCommentTest = false; + if(userJavaScript.match(/\/\*/gi) && userJavaScript.match(/\*\//gi) == null){ + failedCommentTest = true; + } + else if(!failedCommentTest && userJavaScript.match(/\/\*/gi) && userJavaScript.match(/\/\*/gi).length > userJavaScript.match(/\*\//gi).length){ + failedCommentTest = true; + } userJavaScript = removeComments(userJavaScript); userJavaScript = scrapeTests(userJavaScript); // simple fix in case the user forgets to invoke their function submit(userJavaScript, function(cls, message) { - if (cls) { + 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 {