| 
									
										
										
										
											2015-11-13 11:10:23 -08:00
										 |  |  | window.common = (function(global) { | 
					
						
							|  |  |  |   const { | 
					
						
							|  |  |  |     CodeMirror, | 
					
						
							|  |  |  |     document: doc, | 
					
						
							|  |  |  |     common = { init: [] } | 
					
						
							|  |  |  |   } = global; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-22 19:42:53 -08:00
										 |  |  |   const { challengeTypes, challengeType = '0' } = common; | 
					
						
							| 
									
										
										
										
											2015-11-13 11:10:23 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if ( | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |     !CodeMirror || | 
					
						
							| 
									
										
										
										
											2015-11-24 15:01:22 -08:00
										 |  |  |     challengeType !== challengeTypes.JS && | 
					
						
							| 
									
										
										
										
											2015-11-22 19:42:53 -08:00
										 |  |  |     challengeType !== challengeTypes.BONFIRE | 
					
						
							| 
									
										
										
										
											2015-11-13 11:10:23 -08:00
										 |  |  |   ) { | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |     common.updateOutputDisplay = () => {}; | 
					
						
							|  |  |  |     common.appendToOutputDisplay = () => {}; | 
					
						
							|  |  |  |     return common; | 
					
						
							| 
									
										
										
										
											2015-11-13 11:10:23 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |   var codeOutput = CodeMirror.fromTextArea( | 
					
						
							| 
									
										
										
										
											2015-11-13 11:10:23 -08:00
										 |  |  |     doc.getElementById('codeOutput'), | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       lineNumbers: false, | 
					
						
							|  |  |  |       mode: 'text', | 
					
						
							|  |  |  |       theme: 'monokai', | 
					
						
							|  |  |  |       readOnly: 'nocursor', | 
					
						
							|  |  |  |       lineWrapping: true | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-19 21:51:38 -08:00
										 |  |  |   codeOutput.setValue(`/**
 | 
					
						
							|  |  |  |   * Your output will go here. | 
					
						
							|  |  |  |   * Console.log() -type statements | 
					
						
							|  |  |  |   * will appear in your browser\'s | 
					
						
							|  |  |  |   * DevTools JavaScript console. | 
					
						
							| 
									
										
										
										
											2015-11-21 19:48:24 -08:00
										 |  |  |   */`); | 
					
						
							| 
									
										
										
										
											2015-11-13 11:10:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |   codeOutput.setSize('100%', '100%'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-19 21:51:38 -08:00
										 |  |  |   common.updateOutputDisplay = function updateOutputDisplay(str = '') { | 
					
						
							| 
									
										
										
										
											2016-01-13 13:17:30 +04:00
										 |  |  |     if (typeof str !== 'string') { | 
					
						
							|  |  |  |       str = JSON.stringify(str); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |     codeOutput.setValue(str); | 
					
						
							|  |  |  |     return str; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-19 21:51:38 -08:00
										 |  |  |   common.appendToOutputDisplay = function appendToOutputDisplay(str = '') { | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |     codeOutput.setValue(codeOutput.getValue() + str); | 
					
						
							|  |  |  |     return str; | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2015-11-13 11:10:23 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return common; | 
					
						
							|  |  |  | }(window)); |