Merge pull request #450 from Zengor/master

Call playground with /execute
This commit is contained in:
Mathieu David 2017-09-23 21:35:41 +02:00 committed by GitHub
commit a6d4881e00
1 changed files with 11 additions and 9 deletions

View File

@ -358,22 +358,24 @@ function run_rust_code(code_block) {
result_block = code_block.find(".result"); result_block = code_block.find(".result");
} }
let text = playpen_text(code_block);; let text = playpen_text(code_block);
var params = { var params = {
version: "stable", channel: "stable",
optimize: "0", mode: "debug",
code: text, crateType: "bin",
}; tests: false,
code: text,
}
if(text.indexOf("#![feature") !== -1) { if(text.indexOf("#![feature") !== -1) {
params.version = "nightly"; params.channel = "nightly";
} }
result_block.text("Running..."); result_block.text("Running...");
$.ajax({ $.ajax({
url: "https://play.rust-lang.org/evaluate.json", url: "https://play.rust-lang.org/execute",
method: "POST", method: "POST",
crossDomain: true, crossDomain: true,
dataType: "json", dataType: "json",
@ -381,7 +383,7 @@ function run_rust_code(code_block) {
data: JSON.stringify(params), data: JSON.stringify(params),
timeout: 15000, timeout: 15000,
success: function(response){ success: function(response){
result_block.text(response.result); result_block.text(response.success ? response.stdout : response.stderr);
}, },
error: function(qXHR, textStatus, errorThrown){ error: function(qXHR, textStatus, errorThrown){
result_block.text("Playground communication " + textStatus); result_block.text("Playground communication " + textStatus);