Skip to content

Commit 7397b6d

Browse files
committed
More tweaks to code sandbox
1 parent 7f13b8e commit 7397b6d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

html/js/code.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ addEventListener("load", function() {
88
lineNumbers: true
99
});
1010
function guessType(code) {
11-
return /^[\s\w]*</.test(code) ? "html" : "js";
11+
console.log("guess", /^[\s\w:\n]*</.test(code) ? "html" : "js", "for " + code);
12+
return /^[\s\w\n:]*</.test(code) ? "html" : "js";
1213
}
1314
var reGuess;
1415
editor.on("change", function() {
@@ -101,7 +102,9 @@ addEventListener("load", function() {
101102
clearSandbox();
102103
var chapter = getChapter(chapters.value), visible;
103104
if (value == "box") {
104-
var code = "Run code here in the context of Chapter " + chapter.number;
105+
var code = chapters.value < 20
106+
? "Run code here in the context of Chapter " + chapter.number
107+
: "Code from Node.js chapters can't be run in the browser";
105108
var guessed = guessType(chapter.start_code);
106109
if (guessed == "js")
107110
code = "// " + code;

0 commit comments

Comments
 (0)