mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Fix execution when contains &&
This commit is contained in:
@@ -6,8 +6,8 @@ define([
|
||||
], function($, execute, analytic, state){
|
||||
// Bind an exercise
|
||||
var prepareExercise = function($exercise) {
|
||||
var codeSolution = $exercise.find(".code-solution").html();
|
||||
var codeValidation = $exercise.find(".code-validation").html();
|
||||
var codeSolution = $exercise.find(".code-solution").text();
|
||||
var codeValidation = $exercise.find(".code-validation").text();
|
||||
|
||||
var editor = ace.edit($exercise.find(".editor").get(0));
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
|
||||
@@ -65,17 +65,12 @@ define(function(){
|
||||
};
|
||||
|
||||
|
||||
var ass = "function assert(condition, message) { \nif (!condition) { \n throw message || \"Assertion failed\"; \n } \n }\n";
|
||||
|
||||
var code = {
|
||||
"base": "var firstName = \"John\";\nvar middleName = \"James\";\nvar lastName = \"Smith\";\n\nvar fullName =",
|
||||
"solution": "var firstName = \"John\";\nvar middleName = \"James\";\nvar lastName = \"Smith\";\n\nvar fullName = firstName + \" \" + middleName + \" \" + lastName;",
|
||||
"validation": "console.log(fullName); assert(fullName == 'John James Smith');"
|
||||
};
|
||||
var ass = "function assert(condition, message) { \nif (!condition) { \n throw message || \"Assertion failed\"; \n } \n }\n";
|
||||
|
||||
var execute = function(solution, validation, callback) {
|
||||
// Validate with validation code
|
||||
evalJS([solution, ass, validation].join(";\n"), function(err, res) {
|
||||
var code = [solution, ass, validation].join(";\n");
|
||||
evalJS(code, function(err, res) {
|
||||
if(err) return callback(err);
|
||||
|
||||
if (res.type == "error") callback(new Error(res.value));
|
||||
|
||||
Reference in New Issue
Block a user