]> git.cworth.org Git - zombocom-ai/commitdiff
Display spinner while image is being generated
authorCarl Worth <cworth@cworth.org>
Thu, 8 Dec 2022 00:47:43 +0000 (16:47 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 8 Dec 2022 00:50:55 +0000 (16:50 -0800)
And hide it again when that's over.

index.html

index 13fc62af92a00c9e5dc6f0f3e7da2848c0ae0b72..f88dd5bf6d15a320fec0cb3daa78773863a62d85 100644 (file)
     </p>
 
     <p>
+      <div id="spinner" align="center">
+        <div class="animate-flicker">
+          <p>
+            <img src="/pngwheel.png" class="rotate thefade">
+          </p>
+        </div>
+      </div>
+
       <form action="" id="zombo-form">
         <div class="form-row large">
           <label for="prompt">
       </form>
     </p>
 
-    <div align="center">
-      <div class="animate-flicker">
-        <p>
-          <img src="/pngwheel.png" class="rotate thefade">
-        </p>
-      </div>
-    </div>
-
     <audio loop="" src="/zombo_words.mp3" type="audio/mpeg"></audio>
     <button id="mute" class="fade volume">
       <div>🔊</div>
@@ -114,6 +114,8 @@ mute.addEventListener("click", () => {
 
     const safety= document.querySelector("#safety");
 
+    const spinner = document.querySelector("#spinner");
+
     comment_form.addEventListener('submit', function(e) {
         e.preventDefault();
         if (comment.value) {
@@ -142,15 +144,17 @@ mute.addEventListener("click", () => {
 
     zombo_form.addEventListener('submit', function(e) {
         e.preventDefault();
-        /* Hide the form while generation is happening. */
+        /* Hide the form and show spinner while generation is happening. */
         zombo_form.style.display = "none";
+        spinner.style.display = "block";
         socket.emit('generate', {"prompt": prompt.value, "code": code.value});
         prompt.value = '';
     });
 
     socket.on('generation-done', () => {
-        /* Re-display the form now that image-generation is over. */
+        /* Re-display the form and hide spinner now that generation is over. */
         zombo_form.style.display = "grid";
+        spinner.style.display = "none";
     });
 
     // TODO: Dynamically generate many different prompts here