|  | @@ -2,23 +2,27 @@ portal = new function(){
 | 
	
		
			
				|  |  |      this.setWifi = async () => {
 | 
	
		
			
				|  |  |          const ssid = getId("input_ssid").value;
 | 
	
		
			
				|  |  |          const pw   = getId("input_pw").value;
 | 
	
		
			
				|  |  | -        const resp_div   = getId("input_resp");
 | 
	
		
			
				|  |  |          const resp = await postData("", {
 | 
	
		
			
				|  |  |              "set_wifi":{
 | 
	
		
			
				|  |  |                  "ssid":ssid,
 | 
	
		
			
				|  |  |                  "pw":pw,
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  | -        resp_div.value = JSON.stringify(resp, null, 2);
 | 
	
		
			
				|  |  | +        error_box.value = JSON.stringify(resp, null, 2);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      this.disablePortal = async () => {
 | 
	
		
			
				|  |  |          const resp = await postData("", {
 | 
	
		
			
				|  |  |              "disable_portal":true
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  | -        resp_div.value = JSON.stringify(resp, null, 2);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      async function postData(url = '', data = {}) {
 | 
	
		
			
				|  |  |          // Default options are marked with *
 | 
	
		
			
				|  |  | +        const progress_bar   = getId("progress_bar");
 | 
	
		
			
				|  |  | +        const error_box   = getId("error_box");
 | 
	
		
			
				|  |  | +        progress_bar.classList.add("progress-bar-striped")
 | 
	
		
			
				|  |  | +        progress_bar.classList.add("progress-bar-animated")
 | 
	
		
			
				|  |  | +        progress_bar.classList.remove("bg-success")
 | 
	
		
			
				|  |  | +        progress_bar.classList.remove("bg-danger")
 | 
	
		
			
				|  |  |          const response = await fetch(url, {
 | 
	
		
			
				|  |  |              method: 'POST', // *GET, POST, PUT, DELETE, etc.
 | 
	
		
			
				|  |  |              mode: 'cors', // no-cors, *cors, same-origin
 | 
	
	
		
			
				|  | @@ -32,7 +36,17 @@ portal = new function(){
 | 
	
		
			
				|  |  |              referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
 | 
	
		
			
				|  |  |              body: JSON.stringify(data) // body data type must match "Content-Type" header
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        return response.json(); // parses JSON response into native JavaScript objects
 | 
	
		
			
				|  |  | +        progress_bar.classList.remove("progress-bar-striped")
 | 
	
		
			
				|  |  | +        progress_bar.classList.remove("progress-bar-animated")
 | 
	
		
			
				|  |  | +        resp = await response.json(); // parses JSON response into native JavaScript objects
 | 
	
		
			
				|  |  | +        if (resp["ok"]){
 | 
	
		
			
				|  |  | +            error_box.innerText = "";
 | 
	
		
			
				|  |  | +            progress_bar.classList.add("bg-success")
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            progress_bar.classList.add("bg-danger")
 | 
	
		
			
				|  |  | +            error_box.innerText = JSON.stringify(resp, null, 2);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return resp;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      function getId(id){
 | 
	
		
			
				|  |  |          return document.getElementById(id);
 |