| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Common JS that talks XHR back to the server and runs the code and receives | 2 * Common JS that talks XHR back to the server and runs the code and receives |
| 3 * the results. | 3 * the results. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * A polyfill for HTML Templates. | 7 * A polyfill for HTML Templates. |
| 8 * | 8 * |
| 9 * This just adds in the content attribute, it doesn't stop scripts | 9 * This just adds in the content attribute, it doesn't stop scripts |
| 10 * from running nor does it stop other side-effects. | 10 * from running nor does it stop other side-effects. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 /** | 65 /** |
| 66 * Callback when there's an XHR error. | 66 * Callback when there's an XHR error. |
| 67 * @param e The callback event. | 67 * @param e The callback event. |
| 68 */ | 68 */ |
| 69 function xhrError(e) { | 69 function xhrError(e) { |
| 70 endWait(); | 70 endWait(); |
| 71 alert('Something bad happened: ' + e); | 71 alert('Something bad happened: ' + e); |
| 72 } | 72 } |
| 73 | 73 |
| 74 function clearOutput() { | 74 function clearOutput() { |
| 75 output.innerText = ""; | 75 output.textContent = ""; |
| 76 if (stdout) { | 76 if (stdout) { |
| 77 stdout.innerText = ""; | 77 stdout.textContent = ""; |
| 78 } | 78 } |
| 79 embed.style.display='none'; | 79 embed.style.display='none'; |
| 80 } | 80 } |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * Called when an image in the workspace history is clicked. | 83 * Called when an image in the workspace history is clicked. |
| 84 */ | 84 */ |
| 85 function historyClick() { | 85 function historyClick() { |
| 86 beginWait(); | 86 beginWait(); |
| 87 clearOutput(); | 87 clearOutput(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // { | 134 // { |
| 135 // "message": "you had an error...", | 135 // "message": "you had an error...", |
| 136 // "img": "<base64 encoded image but only on success>" | 136 // "img": "<base64 encoded image but only on success>" |
| 137 // } | 137 // } |
| 138 // | 138 // |
| 139 // The img is optional and only appears if there is a valid | 139 // The img is optional and only appears if there is a valid |
| 140 // image to display. | 140 // image to display. |
| 141 endWait(); | 141 endWait(); |
| 142 console.log(e.target.response); | 142 console.log(e.target.response); |
| 143 body = JSON.parse(e.target.response); | 143 body = JSON.parse(e.target.response); |
| 144 output.innerText = body.message; | 144 output.textContent = body.message; |
| 145 if (stdout) { | 145 if (stdout) { |
| 146 stdout.innerText = body.stdout; | 146 stdout.textContent = body.stdout; |
| 147 } | 147 } |
| 148 if (body.hasOwnProperty('img')) { | 148 if (body.hasOwnProperty('img')) { |
| 149 img.src = 'data:image/png;base64,' + body.img; | 149 img.src = 'data:image/png;base64,' + body.img; |
| 150 } else { | 150 } else { |
| 151 img.src = ''; | 151 img.src = ''; |
| 152 } | 152 } |
| 153 // Add the image to the history if we are on a workspace page. | 153 // Add the image to the history if we are on a workspace page. |
| 154 if (tryHistory) { | 154 if (tryHistory) { |
| 155 addToHistory(body.hash, 'data:image/png;base64,' + body.img); | 155 addToHistory(body.hash, 'data:image/png;base64,' + body.img); |
| 156 } else { | 156 } else { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 | 195 |
| 196 // Add the images to the history if we are on a workspace page. | 196 // Add the images to the history if we are on a workspace page. |
| 197 if (tryHistory && history) { | 197 if (tryHistory && history) { |
| 198 for (var i=0; i<history.length; i++) { | 198 for (var i=0; i<history.length; i++) { |
| 199 addToHistory(history[i].hash, '/i/'+history[i].hash+'.png'); | 199 addToHistory(history[i].hash, '/i/'+history[i].hash+'.png'); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 })(workspaceName); | 203 })(workspaceName); |
| OLD | NEW |