Browse Source

Wait for login window to load before using it

Yuri Iozzelli 2 years ago
parent
commit
1d5e225fd4
1 changed files with 8 additions and 6 deletions
  1. 8 6
      index.html

+ 8 - 6
index.html

@@ -91,15 +91,17 @@
         window.networkInterface.listen = listen;
         loginElem.style.cursor = "pointer";
         statusElem.style.color = "white";
-        loginElem.onclick = async () => {
+        loginElem.onclick = () => {
             loginElem.onclick = null;
             statusElem.innerHTML = "Downloading network code...";
             const w = window.open("login.html", "_blank");
-            await up();
-            w.document.body.innerHTML = "Starting login...";
-            statusElem.innerHTML = "Starting login...";
-            const url = await loginPromise;
-            w.location.href = url;
+            w.onload = async () => {
+                await up();
+                w.document.body.innerHTML = "Starting login...";
+                statusElem.innerHTML = "Starting login...";
+                const url = await loginPromise;
+                w.location.href = url;
+            };
         };
     </script>
     <script src="./xterm/xterm.js"></script>