check invalid and complete statuses
This commit is contained in:
		
							parent
							
								
									148cda8516
								
							
						
					
					
						commit
						79648af88c
					
				| @ -3,6 +3,7 @@ | ||||
| 
 | ||||
| var meta = {}; | ||||
| var magic; | ||||
| var domainname; | ||||
| 
 | ||||
| function checkStatus() { | ||||
|   // TODO use Location or Link
 | ||||
| @ -36,7 +37,24 @@ function submitCode(pair) { | ||||
|   , cors: true | ||||
|   }).then(function (resp) { | ||||
|     return resp.json().then(function (data) { | ||||
|       // TODO check for error (i.e. bad Pair Code / PIN)
 | ||||
|       // shouldn't be pending (because we get here by being ready)
 | ||||
|       // should poll over 'ready'
 | ||||
|       if ('invalid' === data.status) { | ||||
|         window.alert("something went wrong"); | ||||
|         return; | ||||
|       } | ||||
|       if ('complete' === data.status) { | ||||
|         setTimeout(function () { | ||||
|           window.document.body.innerHTML += ('<img src="https://' + domainname + '/">'); | ||||
|           // TODO once this is loaded (even error) Let's Encrypt is done,
 | ||||
|           // then it's time to redirect to the domain. Yay!
 | ||||
|         }, 1 * 1000); | ||||
|         return; | ||||
|       } | ||||
| 
 | ||||
|       setTimeout(checkStatus, 0); | ||||
| 
 | ||||
|       document.querySelector('.js-authz').hidden = false; | ||||
|       console.log(data); | ||||
|       /* | ||||
| @ -45,6 +63,7 @@ function submitCode(pair) { | ||||
|       }); | ||||
|       */ | ||||
|       document.querySelectorAll('.js-new-href').forEach(function ($el) { | ||||
|         domainname = data.domains[0]; | ||||
|         $el.href = 'https://' + data.domains[0] + '/'; | ||||
|         $el.innerText = '🔐 https://' + data.domains[0]; | ||||
|       }); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user