From 1133aeda9b71d2c15b38df541d17d53225ea5c39 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Tue, 25 Aug 2015 16:10:11 +0100 Subject: [PATCH] Stopped the scripts needed for the preview being loaded on each keyDown --- public/js/lib/coursewares/commonFrameWork.js | 42 ++++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/public/js/lib/coursewares/commonFrameWork.js b/public/js/lib/coursewares/commonFrameWork.js index c2bdd3c56d..e2db213eff 100644 --- a/public/js/lib/coursewares/commonFrameWork.js +++ b/public/js/lib/coursewares/commonFrameWork.js @@ -1,4 +1,6 @@ var editor; +var blockRender = true; +var allowCompletetion = false; var widgets = []; editor = CodeMirror.fromTextArea(document.getElementById("codeEditor"), { lineNumbers: true, @@ -139,7 +141,33 @@ editor.setOption("extraKeys", { editor.setSize("100%", "auto"); -var libraryIncludes = "" + +if(challengeType === "0") { + var libraryIncludes = ""; + + $.getScript('/js/lib/jquery-2.1.1.min.js', function (scriptOne) { + $.getScript('/js/lib/chai/chai.js', function (scriptTwo) { + $.getScript('/js/lib/chai/chai-jquery.js', function (scriptThree) { + $.getScript('//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js', function (scriptFour) { + libraryIncludes = "" + "" + + "" + + "" + + "" + + ""; + blockRender = false; + editorValue = (codeStorage.isAlive()) ? codeStorage.getEditorValue() : allSeeds; + myCodeMirror.setValue(editorValue); + setTimeout(function () { + $(document).ready(function () { + bonfireExecute(); + }); + }, 100); + }); + }); + }); + }); +} + +/*var libraryIncludes = "" + "" + "" + "" + @@ -147,7 +175,7 @@ var libraryIncludes = ""; + "";*/ var editorValueForIFrame; @@ -466,6 +494,9 @@ var runTests = function(err, data) { }; function bonfireExecute() { + if(!blockRender){ + + } goodTests = 0; attempts++; ga('send', 'event', 'Challenge', 'ran-code', challenge_Name); @@ -523,10 +554,5 @@ function bonfireExecute() { $('#submitButton').on('click', function() { bonfireExecute(); -}); - -$(document).ready(function(){ - editorValue = (codeStorage.isAlive())? codeStorage.getEditorValue() : allSeeds; - myCodeMirror.setValue(editorValue); - bonfireExecute(); + allowCompletetion = true; });