Show tests on html view
This commit is contained in:
@@ -59,11 +59,14 @@ editor.on("change", function () {
|
||||
});
|
||||
var nodeEnv = prodOrDev === 'production' ? 'http://www.freecodecamp.com' : 'http://localhost:3001';
|
||||
function updatePreview() {
|
||||
goodTests = 0;
|
||||
var previewFrame = document.getElementById('preview');
|
||||
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
|
||||
preview.open();
|
||||
$('#testSuite').empty();
|
||||
preview.write(libraryIncludes + editor.getValue() + otherTestsForNow);
|
||||
preview.close();
|
||||
|
||||
}
|
||||
setTimeout(updatePreview, 300);
|
||||
|
||||
@@ -71,17 +74,27 @@ setTimeout(updatePreview, 300);
|
||||
* "post" methods
|
||||
*/
|
||||
|
||||
var postSuccess = function() {
|
||||
showCompletion();
|
||||
var postSuccess = function(data) {
|
||||
var testDoc = document.createElement("div");
|
||||
$(testDoc)
|
||||
.html("<div class='row'><div class='col-xs-2 text-center'><i class='ion-checkmark-circled big-success-icon'></i></div><div class='col-xs-10 test-output test-vertical-center wrappable'>" + JSON.parse(data) + "</div></div><div class='ten-pixel-break'/>")
|
||||
.appendTo($('#testSuite'));
|
||||
testSuccess();
|
||||
};
|
||||
|
||||
var postError = function(data) {
|
||||
console.log(Object.keys(data));
|
||||
var testDoc = document.createElement("div");
|
||||
$(testDoc)
|
||||
.html("<div class='row'><div class='col-xs-1 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-11 test-output wrappable'>" + data + "</div></div><div class='ten-pixel-break'/>")
|
||||
.html("<div class='row'><div class='col-xs-2 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-10 test-output wrappable'>" + JSON.parse(data) + "</div></div><div class='ten-pixel-break'/>")
|
||||
.prependTo($('#testSuite'))
|
||||
};
|
||||
var goodTests = 0;
|
||||
var testSuccess = function() {
|
||||
goodTests++;
|
||||
if (goodTests === tests.length) {
|
||||
showCompletion();
|
||||
}
|
||||
};
|
||||
var challengeSeed = challengeSeed || null;
|
||||
var tests = tests || [];
|
||||
var allSeeds = '';
|
||||
@@ -116,7 +129,7 @@ function doLinting () {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
//$('#testSuite').empty();
|
||||
function showCompletion() {
|
||||
var time = Math.floor(Date.now() / 1000) - started;
|
||||
ga('send', 'event', 'Challenge', 'solved', challengeName + ', Time: ' + time);
|
||||
|
Reference in New Issue
Block a user