diff options
-rw-r--r-- | src/shell.html | 11 | ||||
-rw-r--r-- | src/shell_minimal.html | 11 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/shell.html b/src/shell.html index cbf8c0d8..226f12b9 100644 --- a/src/shell.html +++ b/src/shell.html @@ -1222,7 +1222,7 @@ postRun: [], print: (function() { var element = document.getElementById('output'); - element.value = ''; // clear browser cache + if (element) element.value = ''; // clear browser cache return function(text) { text = Array.prototype.slice.call(arguments).join(' '); // These replacements are necessary if you render to raw HTML @@ -1230,8 +1230,11 @@ //text = text.replace(/</g, "<"); //text = text.replace(/>/g, ">"); //text = text.replace('\n', '<br>', 'g'); - element.value += text + "\n"; - element.scrollTop = element.scrollHeight; // focus on bottom + console.log(text); + if (element) { + element.value += text + "\n"; + element.scrollTop = element.scrollHeight; // focus on bottom + } }; })(), printErr: function(text) { @@ -1239,7 +1242,7 @@ if (0) { // XXX disabled for safety typeof dump == 'function') { dump(text + '\n'); // fast, straight to the real console } else { - console.log(text); + console.error(text); } }, canvas: document.getElementById('canvas'), diff --git a/src/shell_minimal.html b/src/shell_minimal.html index 7a3a8d08..6f483719 100644 --- a/src/shell_minimal.html +++ b/src/shell_minimal.html @@ -78,7 +78,7 @@ postRun: [], print: (function() { var element = document.getElementById('output'); - element.value = ''; // clear browser cache + if (element) element.value = ''; // clear browser cache return function(text) { text = Array.prototype.slice.call(arguments).join(' '); // These replacements are necessary if you render to raw HTML @@ -86,8 +86,11 @@ //text = text.replace(/</g, "<"); //text = text.replace(/>/g, ">"); //text = text.replace('\n', '<br>', 'g'); - element.value += text + "\n"; - element.scrollTop = element.scrollHeight; // focus on bottom + console.log(text); + if (element) { + element.value += text + "\n"; + element.scrollTop = element.scrollHeight; // focus on bottom + } }; })(), printErr: function(text) { @@ -95,7 +98,7 @@ if (0) { // XXX disabled for safety typeof dump == 'function') { dump(text + '\n'); // fast, straight to the real console } else { - console.log(text); + console.error(text); } }, canvas: document.getElementById('canvas'), |