@@ -14,6 +14,7 @@ var editorDiv = document.getElementById("editor");
14
14
var staticCode = document . getElementById ( "static-code" ) ;
15
15
var runButton = document . getElementById ( "run-code" ) ;
16
16
var resultDiv = document . getElementById ( "result" ) ;
17
+ var playLink = document . getElementById ( "playlink" ) ;
17
18
18
19
// Background colors for program result on success/error
19
20
var successColor = "#E2EEF6" ;
@@ -125,10 +126,11 @@ function handleResult(statusCode, message) {
125
126
function handleSuccess ( message ) {
126
127
resultDiv . style . backgroundColor = successColor ;
127
128
var program = encodeURIComponent ( editor . getValue ( ) ) ;
128
- var output = "<a href=\"http://play.rust-lang.org/?code=" + program +
129
- "&run=1\"><i class=\"icon-link-ext\"></i></a>"
130
- // console.log(output);
131
- resultDiv . innerHTML = output + escapeHTML ( message ) ;
129
+ playLink . href = "http://play.rust-lang.org/?code=" + program + "&run=1"
130
+ // console.log(playLink.href);
131
+ resultDiv . innerHTML = '' ; // clear resultDiv, then add
132
+ resultDiv . appendChild ( playLink ) ; // playLink icon and message
133
+ resultDiv . innerHTML += escapeHTML ( message ) ;
132
134
}
133
135
134
136
// Called when program run results in warning(s)
@@ -168,7 +170,12 @@ function handleProblem(message, problem) {
168
170
} ) . join ( "<br />" ) ;
169
171
170
172
// Setting message
171
- resultDiv . innerHTML = cleanMessage ;
173
+ var program = encodeURIComponent ( editor . getValue ( ) ) ;
174
+ playLink . href = "http://play.rust-lang.org/?code=" + program + "&run=1"
175
+ // console.log(playLink.href);
176
+ resultDiv . innerHTML = '' ; // clear resultDiv, then add
177
+ resultDiv . appendChild ( playLink ) ; // playLink icon and error message
178
+ resultDiv . innerHTML += cleanMessage ;
172
179
173
180
// Highlighting the lines
174
181
var ranges = parseProblems ( lines ) ;
0 commit comments