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 |
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'); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 function onEmbedClick() { | 280 function onEmbedClick() { |
281 embed.style.display='inline'; | 281 embed.style.display='inline'; |
282 } | 282 } |
283 | 283 |
284 if (embedButton) { | 284 if (embedButton) { |
285 embedButton.addEventListener('click', onEmbedClick); | 285 embedButton.addEventListener('click', onEmbedClick); |
286 } | 286 } |
287 | 287 |
288 // Add the images to the history if we are on a workspace page. | 288 // Add the images to the history if we are on a workspace page. |
289 if (tryHistory && history) { | 289 if (tryHistory && history_) { |
290 for (var i=0; i<history.length; i++) { | 290 for (var i=0; i<history_.length; i++) { |
291 addToHistory(history[i].hash, '/i/'+history[i].hash+'.png'); | 291 addToHistory(history_[i].hash, '/i/'+history_[i].hash+'.png'); |
292 } | 292 } |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 // If loaded via HTML Imports then DOMContentLoaded will be long done. | 296 // If loaded via HTML Imports then DOMContentLoaded will be long done. |
297 if (document.readyState != "loading") { | 297 if (document.readyState != "loading") { |
298 onLoad(); | 298 onLoad(); |
299 } else { | 299 } else { |
300 this.addEventListener('DOMContentLoaded', onLoad); | 300 this.addEventListener('load', onLoad); |
301 } | 301 } |
302 | 302 |
303 })(); | 303 })(); |
OLD | NEW |