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

Side by Side Diff: experimental/webtry/res/js/webtry.js

Issue 638003008: Re-land ganesh checkbox. I needed to increase the size of the address (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « experimental/webtry/main.cpp ('k') | experimental/webtry/scripts/fiddle_gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * namespace. If workspaceName is the empty string then we know we aren't 11 * namespace. If workspaceName is the empty string then we know we aren't
12 * running on a workspace page. 12 * running on a workspace page.
13 * 13 *
14 * If we are on a workspace page we also look for a 'history_' 14 * If we are on a workspace page we also look for a 'history_'
15 * variable in the global namespace which contains the list of tries 15 * variable in the global namespace which contains the list of tries
16 * that are included in this workspace. That variable is used to 16 * that are included in this workspace. That variable is used to
17 * populate the history list. 17 * populate the history list.
18 */ 18 */
19 (function() { 19 (function() {
20 function onLoad() { 20 function onLoad() {
21 var run = document.getElementById('run'); 21 var run = document.getElementById('run');
22 var permalink = document.getElementById('permalink'); 22 var permalink = document.getElementById('permalink');
23 var embed = document.getElementById('embed'); 23 var embed = document.getElementById('embed');
24 var embedButton = document.getElementById('embedButton'); 24 var embedButton = document.getElementById('embedButton');
25 var code = document.getElementById('code'); 25 var code = document.getElementById('code');
26 var output = document.getElementById('output'); 26 var output = document.getElementById('output');
27 var stdout = document.getElementById('stdout'); 27 var stdout = document.getElementById('stdout');
28 var gpu = document.getElementById('use-gpu');
28 var img = document.getElementById('img'); 29 var img = document.getElementById('img');
29 var imageWidth = document.getElementById('image-width'); 30 var imageWidth = document.getElementById('image-width');
30 var imageHeight = document.getElementById('image-height'); 31 var imageHeight = document.getElementById('image-height');
31 var tryHistory = document.getElementById('tryHistory'); 32 var tryHistory = document.getElementById('tryHistory');
32 var parser = new DOMParser(); 33 var parser = new DOMParser();
33 var tryTemplate = document.getElementById('tryTemplate'); 34 var tryTemplate = document.getElementById('tryTemplate');
34 var sourcesTemplate = document.getElementById('sourcesTemplate'); 35 var sourcesTemplate = document.getElementById('sourcesTemplate');
35 36
36 var enableSource = document.getElementById('enableSource'); 37 var enableSource = document.getElementById('enableSource');
37 var selectedSource = document.getElementById('selectedSource'); 38 var selectedSource = document.getElementById('selectedSource');
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // "hash": "unique id for a try", 209 // "hash": "unique id for a try",
209 // "code": "source code for try" 210 // "code": "source code for try"
210 // } 211 // }
211 endWait(); 212 endWait();
212 body = JSON.parse(e.target.response); 213 body = JSON.parse(e.target.response);
213 code.value = body.code; 214 code.value = body.code;
214 editor.setValue(body.code); 215 editor.setValue(body.code);
215 img.src = '/i/'+body.hash+'.png'; 216 img.src = '/i/'+body.hash+'.png';
216 imageWidth.value = body.width; 217 imageWidth.value = body.width;
217 imageHeight.value = body.height; 218 imageHeight.value = body.height;
219 gpu.checked = body.gpu;
218 sourceSelectByID(body.source); 220 sourceSelectByID(body.source);
219 if (permalink) { 221 if (permalink) {
220 permalink.href = '/c/' + body.hash; 222 permalink.href = '/c/' + body.hash;
221 permalink.style.display='inline-block'; 223 permalink.style.display='inline-block';
222 } 224 }
223 } 225 }
224 226
225 227
226 /** 228 /**
227 * Add the given try image to the history of a workspace. 229 * Add the given try image to the history of a workspace.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 288
287 function onSubmitCode() { 289 function onSubmitCode() {
288 beginWait(); 290 beginWait();
289 clearOutput(); 291 clearOutput();
290 var req = new XMLHttpRequest(); 292 var req = new XMLHttpRequest();
291 req.addEventListener('load', codeComplete); 293 req.addEventListener('load', codeComplete);
292 req.addEventListener('error', xhrError); 294 req.addEventListener('error', xhrError);
293 req.overrideMimeType('application/json'); 295 req.overrideMimeType('application/json');
294 req.open('POST', '/', true); 296 req.open('POST', '/', true);
295 req.setRequestHeader('content-type', 'application/json'); 297 req.setRequestHeader('content-type', 'application/json');
296 req.send(JSON.stringify({'code': editor.getValue(), 'width': parseInt(im ageWidth.value), 'height': parseInt(imageHeight.value), 'name': workspaceName, ' source': sourceId})); 298 req.send(JSON.stringify({
299 'code': editor.getValue(),
300 'width': parseInt(imageWidth.value),
301 'height': parseInt(imageHeight.value),
302 'name': workspaceName,
303 'source': sourceId,
304 'gpu': gpu.checked
305 }));
297 } 306 }
298 run.addEventListener('click', onSubmitCode); 307 run.addEventListener('click', onSubmitCode);
299 308
300 309
301 function onEmbedClick() { 310 function onEmbedClick() {
302 embed.style.display='inline'; 311 embed.style.display='inline';
303 } 312 }
304 313
305 if (embedButton) { 314 if (embedButton) {
306 embedButton.addEventListener('click', onEmbedClick); 315 embedButton.addEventListener('click', onEmbedClick);
(...skipping 10 matching lines...) Expand all
317 } 326 }
318 327
319 // If loaded via HTML Imports then DOMContentLoaded will be long done. 328 // If loaded via HTML Imports then DOMContentLoaded will be long done.
320 if (document.readyState != "loading") { 329 if (document.readyState != "loading") {
321 onLoad(); 330 onLoad();
322 } else { 331 } else {
323 this.addEventListener('load', onLoad); 332 this.addEventListener('load', onLoad);
324 } 333 }
325 334
326 })(); 335 })();
OLDNEW
« no previous file with comments | « experimental/webtry/main.cpp ('k') | experimental/webtry/scripts/fiddle_gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698