| 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 /** | 7 /** |
| 8 * All the functionality is wrapped up in this anonymous closure, but we need | 8 * All the functionality is wrapped up in this anonymous closure, but we need |
| 9 * to be told if we are on the workspace page or a normal try page, so the | 9 * to be told if we are on the workspace page or a normal try page, so the |
| 10 * workspaceName is passed into the closure, it must be set in the global | 10 * workspaceName is passed into the closure, it must be set in the global |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 enableSource.addEventListener('click', sourceClick, true); | 139 enableSource.addEventListener('click', sourceClick, true); |
| 140 selectedSource.addEventListener('click', sourceClick, true); | 140 selectedSource.addEventListener('click', sourceClick, true); |
| 141 | 141 |
| 142 | 142 |
| 143 var editor = CodeMirror.fromTextArea(code, { | 143 var editor = CodeMirror.fromTextArea(code, { |
| 144 theme: "default", | 144 theme: "default", |
| 145 lineNumbers: true, | 145 lineNumbers: true, |
| 146 matchBrackets: true, | 146 matchBrackets: true, |
| 147 lineWrapping: true, |
| 147 mode: "text/x-c++src", | 148 mode: "text/x-c++src", |
| 148 indentUnit: 4, | 149 indentUnit: 4, |
| 149 }); | 150 }); |
| 150 | 151 |
| 151 // Match the initial textarea size. | 152 // Match the initial textarea width, but leave the height alone |
| 153 // The css will automatically resize the editor vertically. |
| 152 editor.setSize(editor.defaultCharWidth() * code.cols, | 154 editor.setSize(editor.defaultCharWidth() * code.cols, |
| 153 editor.defaultTextHeight() * code.rows); | 155 null); |
| 154 | 156 |
| 155 | 157 |
| 156 /** | 158 /** |
| 157 * Callback when there's an XHR error. | 159 * Callback when there's an XHR error. |
| 158 * @param e The callback event. | 160 * @param e The callback event. |
| 159 */ | 161 */ |
| 160 function xhrError(e) { | 162 function xhrError(e) { |
| 161 endWait(); | 163 endWait(); |
| 162 alert('Something bad happened: ' + e); | 164 alert('Something bad happened: ' + e); |
| 163 } | 165 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 296 } |
| 295 | 297 |
| 296 // If loaded via HTML Imports then DOMContentLoaded will be long done. | 298 // If loaded via HTML Imports then DOMContentLoaded will be long done. |
| 297 if (document.readyState != "loading") { | 299 if (document.readyState != "loading") { |
| 298 onLoad(); | 300 onLoad(); |
| 299 } else { | 301 } else { |
| 300 this.addEventListener('load', onLoad); | 302 this.addEventListener('load', onLoad); |
| 301 } | 303 } |
| 302 | 304 |
| 303 })(); | 305 })(); |
| OLD | NEW |