Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: experimental/webtry/js/run.js

Issue 246823004: Factor out common template code. Send stdout back to web page. (Closed) Base URL: https://skia.googlesource.com/skia.git@clickhistory
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/webtry/css/webtry.css ('k') | experimental/webtry/templates/content.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/webtry/js/run.js
diff --git a/experimental/webtry/js/run.js b/experimental/webtry/js/run.js
index c69e2bcc22c7494ce671aeced6c78f5fec53f241..d44e81817ba4583a95993fd3da93aa85df705211 100644
--- a/experimental/webtry/js/run.js
+++ b/experimental/webtry/js/run.js
@@ -43,6 +43,7 @@
var embedButton = document.getElementById('embedButton');
var code = document.getElementById('code');
var output = document.getElementById('output');
+ var stdout = document.getElementById('stdout');
var img = document.getElementById('img');
var tryHistory = document.getElementById('tryHistory');
var parser = new DOMParser();
@@ -70,11 +71,20 @@
alert('Something bad happened: ' + e);
}
+ function clearOutput() {
+ output.innerText = "";
+ if (stdout) {
+ stdout.innerText = "";
+ }
+ embed.style.display='none';
+ }
+
/**
* Called when an image in the workspace history is clicked.
*/
function historyClick() {
beginWait();
+ clearOutput();
var req = new XMLHttpRequest();
req.addEventListener('load', historyComplete);
req.addEventListener('error', xhrError);
@@ -132,6 +142,9 @@
console.log(e.target.response);
body = JSON.parse(e.target.response);
output.innerText = body.message;
+ if (stdout) {
+ stdout.innerText = body.stdout;
+ }
if (body.hasOwnProperty('img')) {
img.src = 'data:image/png;base64,' + body.img;
} else {
@@ -159,6 +172,7 @@
function onSubmitCode() {
beginWait();
+ clearOutput();
var req = new XMLHttpRequest();
req.addEventListener('load', codeComplete);
req.addEventListener('error', xhrError);
« no previous file with comments | « experimental/webtry/css/webtry.css ('k') | experimental/webtry/templates/content.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698