Explorar o código

Use asynchronous configuration and alignment requests

SybexXx hai 1 día
pai
achega
bf1c1d9e4e
Modificáronse 1 ficheiros con 18 adicións e 22 borrados
  1. 18 22
      sd-card/html/edit_alignment.html

+ 18 - 22
sd-card/html/edit_alignment.html

@@ -234,18 +234,18 @@
                     WriteConfigININew();
     
                     if (neueref1 == 1 && neueref2 == 1) {
-                        UpdateConfigReferences(domainname);
+                        await UpdateConfigReferences(domainname);
                     }
                     else if (neueref1 == 1) {
                         var anzneueref = 1;
-                        UpdateConfigReference(anzneueref, domainname);
+                        await UpdateConfigReference(anzneueref, domainname);
                     }
                     else if (neueref2 == 1) {
                         var anzneueref = 2;
-                        UpdateConfigReference(anzneueref, domainname);
+                        await UpdateConfigReference(anzneueref, domainname);
                     }
 
-                    SaveConfigToServer(domainname);
+                    await SaveConfigToServer(domainname);
             
                     document.getElementById("updatemarker").disabled = false;
                     // document.getElementById("savemarker").disabled = true;
@@ -291,7 +291,7 @@
                         return;
                     }
 		
-                    var ret = MakeRefImageZW(refInfo[aktindex], enhanceCon, domainname);
+                    var ret = await MakeRefImageZW(refInfo[aktindex], enhanceCon, domainname);
 			
                     if (ret) {
                         UpdateReference();
@@ -307,16 +307,14 @@
                     }
                     else {
                         // Get status
-                        var xhttp = new XMLHttpRequest();
+                        var statusText = "";
                         durchlaufe = durchlaufe + 1;
-				
                         try {
-                            xhttp.open("GET", domainname + "/statusflow", false);
-                            xhttp.send();
+                            const response = await fetch(domainname + "/statusflow");
+                            statusText = await response.text();
                         }
-                        catch (error){}
-
-                        document.getElementById("overlaytext").innerHTML = "Device is busy, waiting for the current round to finish and the flow to pause...<br><br>Current step: " + xhttp.responseText;
+                        catch (error) {}
+                        document.getElementById("overlaytext").innerHTML = "Device is busy, waiting for the current round to finish and the flow to pause...<br><br>Current step: " + statusText;
                         console.log("Device is busy, waiting 5s then checking again...");
                         await sleep(5000);
                     }
@@ -419,7 +417,7 @@
             draw();
         }	
 	
-        function init() {
+        async function init() {
             openDescription();
 	
             document.getElementById("updatemarker").disabled = false;
@@ -429,7 +427,7 @@
             EnDisableItem(false, "savemarker", true);
             EnDisableItem(false, "enhancecontrast", true);
 
-            if (!loadConfig(domainname)) {
+            if (!await loadConfig(domainname)) {
                 firework.launch('Configuration could not be loaded! Please reload the page!', 'danger', 30000);
                 return;
             }
@@ -484,7 +482,7 @@
                         return;
                     }
 
-                    var ret = MakeRefImageZW(refInfo[aktindex], enhanceCon, domainname);
+                    var ret = await MakeRefImageZW(refInfo[aktindex], enhanceCon, domainname);
             
                     if (ret) {
                         UpdateReference();
@@ -508,16 +506,14 @@
                     }
                     else {
                         // Get status
-                        var xhttp = new XMLHttpRequest();
+                        var statusText = "";
                         durchlaufe = durchlaufe + 1;
-				
                         try {
-                            xhttp.open("GET", domainname + "/statusflow", false);
-                            xhttp.send();
+                            const response = await fetch(domainname + "/statusflow");
+                            statusText = await response.text();
                         }
-                        catch (error){}
-
-                        document.getElementById("overlaytext").innerHTML = "Device is busy, waiting for the current round to finish and the flow to pause...<br><br>Current step: " + xhttp.responseText;
+                        catch (error) {}
+                        document.getElementById("overlaytext").innerHTML = "Device is busy, waiting for the current round to finish and the flow to pause...<br><br>Current step: " + statusText;
                         console.log("Device is busy, waiting 5s then checking again...");
                         await sleep(5000);
                     }