update host fix
This commit is contained in:
		
							
								
								
									
										39
									
								
								js/script.js
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								js/script.js
									
									
									
									
									
								
							| @ -5,19 +5,28 @@ function showCard(card, button) { | ||||
| } | ||||
|  | ||||
| function updateHost(input) { | ||||
|     input.parentElement.classList.remove("ok") | ||||
|     input.parentElement.classList.remove("nok") | ||||
|     input.parentElement.classList.add("pending") | ||||
|     fetch(new Request("updateHost.php", { | ||||
|         method:"POST", | ||||
|         body:new FormData(input.form), | ||||
|         mode:"cors" | ||||
|     })).then(response => { | ||||
|         input.parentElement.classList.remove("pending") | ||||
|         if (response.ok) { | ||||
|             input.parentElement.classList.add("ok") | ||||
|         } else { | ||||
|             input.parentElement.classList.add("nok") | ||||
|         } | ||||
|     }) | ||||
|     if (input.form.checkValidity()) { | ||||
|         var td = input.parentElement | ||||
|         var tr = td.parentElement | ||||
|         tr.classList.remove("ok") | ||||
|         tr.classList.remove("nok") | ||||
|         tr.classList.add("pending") | ||||
|         fetch(new Request("updateHost.php", { | ||||
|             method:"POST", | ||||
|             body:new FormData(input.form), | ||||
|             mode:"cors" | ||||
|         })).then(response => { | ||||
|             tr.classList.remove("pending") | ||||
|             if (response.ok) { | ||||
|                 tr.classList.add("ok") | ||||
|                 var linkInput = tr.getElementsByTagName('input')[7] | ||||
|                 var linkA = tr.getElementsByTagName('a')[0] | ||||
|                 linkA.href = linkInput.value | ||||
|             } else { | ||||
|                 tr.classList.add("nok") | ||||
|             } | ||||
|         }) | ||||
|     } else { | ||||
|         input.form.reportValidity() | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user