aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-04-10 10:35:07 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-04-10 10:35:07 -0700
commit6e06d8e9c442966f07479c3a4d8d7e48630620b9 (patch)
tree9a8e84cc2a7387d72e9851b07a6bedd240d0974e
parentd7f14cea09e8d2911dc44ede06d28b34e5fd555f (diff)
parent577f405c425e131600180611c04efd95032f58f6 (diff)
Merge pull request #2280 from juj/revise_shell_print
Revise shell prints.
-rw-r--r--src/shell.html11
-rw-r--r--src/shell_minimal.html11
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, "&lt;");
//text = text.replace(/>/g, "&gt;");
//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, "&lt;");
//text = text.replace(/>/g, "&gt;");
//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'),