| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  | window.common = (function(global) { | 
					
						
							|  |  |  |   const { | 
					
						
							|  |  |  |     $, | 
					
						
							|  |  |  |     ga = (() => {}), | 
					
						
							|  |  |  |       common = { init: [] } | 
					
						
							|  |  |  |   } = global; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   common.showCompletion = function showCompletion() { | 
					
						
							| 
									
										
										
										
											2015-12-13 01:06:33 -08:00
										 |  |  |     var time = Math.floor(Date.now() - common.started); | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ga( | 
					
						
							|  |  |  |       'send', | 
					
						
							|  |  |  |       'event', | 
					
						
							|  |  |  |       'Challenge', | 
					
						
							|  |  |  |       'solved', | 
					
						
							|  |  |  |       common.challengeName + ', Time: ' + time + ', Attempts: ' + 0 | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-08 13:52:03 -08:00
										 |  |  |     var solution = common.editor.getValue(); | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |     var didCompleteWith = $('#completed-with').val() || null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $('#complete-courseware-dialog').modal('show'); | 
					
						
							|  |  |  |     $('#complete-courseware-dialog .modal-header').click(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $('#submit-challenge').click(function(e) { | 
					
						
							|  |  |  |       e.preventDefault(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $('#submit-challenge') | 
					
						
							|  |  |  |         .attr('disabled', 'true') | 
					
						
							|  |  |  |         .removeClass('btn-primary') | 
					
						
							|  |  |  |         .addClass('btn-warning disabled'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       var $checkmarkContainer = $('#checkmark-container'); | 
					
						
							|  |  |  |       $checkmarkContainer.css({ height: $checkmarkContainer.innerHeight() }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $('#challenge-checkmark') | 
					
						
							|  |  |  |         .addClass('zoomOutUp') | 
					
						
							|  |  |  |         // .removeClass('zoomInDown')
 | 
					
						
							|  |  |  |         .delay(1000) | 
					
						
							|  |  |  |         .queue(function(next) { | 
					
						
							|  |  |  |           $(this).replaceWith( | 
					
						
							|  |  |  |             '<div id="challenge-spinner" ' + | 
					
						
							|  |  |  |             'class="animated zoomInUp inner-circles-loader">' + | 
					
						
							|  |  |  |             'submitting...</div>' | 
					
						
							|  |  |  |           ); | 
					
						
							|  |  |  |           next(); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-08 13:52:03 -08:00
										 |  |  |       const data = { | 
					
						
							|  |  |  |         id: common.challengeId, | 
					
						
							|  |  |  |         name: common.challengeName, | 
					
						
							|  |  |  |         completedWith: didCompleteWith, | 
					
						
							|  |  |  |         challengeType: common.challengeType, | 
					
						
							|  |  |  |         solution | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $.post('/completed-challenge/', data, function(res) { | 
					
						
							|  |  |  |         if (res) { | 
					
						
							|  |  |  |           window.location = | 
					
						
							|  |  |  |             '/challenges/next-challenge?id=' + common.challengeId; | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-12-08 13:52:03 -08:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-11-17 21:25:16 -08:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return common; | 
					
						
							|  |  |  | }(window)); |