Skip to content

Commit e98e3f4

Browse files
committed
index.html update
1 parent 92f33d3 commit e98e3f4

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

CREDITS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ https://stackoverflow.com/questions/16452699/how-to-reset-a-form-using-jquery-wi
132132
https://stackoverflow.com/questions/3955229/remove-all-child-elements-of-a-dom-node-in-javascript
133133
https://stackoverflow.com/questions/11478324/syntaxerror-unexpected-eof-when-evaluating-javascript-in-ios-uiwebview
134134
https://stackoverflow.com/questions/42053775/getting-error-form-submission-canceled-because-the-form-is-not-connected
135+
https://stackoverflow.com/questions/4467044/proper-way-to-catch-exception-from-json-parse
136+
https://stackoverflow.com/questions/29797946/handling-bad-json-parse-in-node-safely
135137

136138
https://jquery.com/
137139
http://youmightnotneedjquery.com/

resources/app/index.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,21 @@
7474

7575
interactive_one.stdoutFunction = function (stdout) {
7676
var target = document.getElementById('instance-one-output');
77-
var output = JSON.parse(stdout);
77+
78+
var output = null;
79+
try {
80+
output = JSON.parse(stdout);
81+
} catch(exception) {
82+
return null;
83+
}
84+
7885
var html;
7986
if ("user_input" in output) {
8087
html = output.time + '<br>' + output.user_input;
8188
} else {
8289
html = output.time;
8390
};
91+
8492
target.innerHTML = html;
8593
}
8694

@@ -103,13 +111,21 @@
103111

104112
interactive_two.stdoutFunction = function (stdout) {
105113
var target = document.getElementById('instance-two-output');
106-
var output = JSON.parse(stdout);
114+
115+
var output = null;
116+
try {
117+
output = JSON.parse(stdout);
118+
} catch(exception) {
119+
return null;
120+
}
121+
107122
var html;
108123
if ("user_input" in output) {
109124
html = output.time + '<br>' + output.user_input;
110125
} else {
111126
html = output.time;
112127
};
128+
113129
target.innerHTML = html;
114130
}
115131

0 commit comments

Comments
 (0)