]> git.cworth.org Git - zombocom-ai/blobdiff - index.html
Prepend images as they are generated
[zombocom-ai] / index.html
index fb8cbc0d3a7f52006518d8c1baf172378a50b843..13fc62af92a00c9e5dc6f0f3e7da2848c0ae0b72 100644 (file)
@@ -5,7 +5,7 @@
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>ZOMBO</title>
   <link href="/zombo.css" rel="stylesheet" type="text/css">
-  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
+  <meta name="viewport" content="width=device-width,initial-scale=1">
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
   <meta name="HandheldFriendly" content="true">
 </head>
@@ -32,8 +32,9 @@
       <form action="" id="zombo-form">
         <div class="form-row large">
           <label for="prompt">
-            What do you imagine?
+            What can you imagine?
           </label>
+          <button id="safety" type="button">Safety prompt</button>
           <textarea id="prompt" rows="4" width="100%" autocomplete="off" required></textarea>
         </div>
 
           </div>
         </div>
 
-        <div class="form-row small right">
-          <button id="safety" class="right" type="button">Safety prompt</button>
-        </div>
-
         <div class="form-row large">
           <button id="generate" type="submit">Make the infinite possible</button>
         </div>
@@ -132,25 +129,30 @@ mute.addEventListener("click", () => {
     });
 
     socket.on('image', (image) => {
+        const figure = document.createElement('figure');
         const img = document.createElement('img');
         img.src = image.filename;
-        const p_prompt = document.createElement('p');
-        const prompt_text = document.createTextNode(`Prompt: ${image.prompt}`);
-        p_prompt.appendChild(prompt_text);
-        const p_code = document.createElement('p');
-        const code_text = document.createTextNode(`Code: ${image.code}`);
-        p_code.appendChild(code_text);
-        images.appendChild(img);
-        images.appendChild(p_prompt);
-        images.appendChild(p_code);
+        const figcaption = document.createElement('figcaption');
+        const caption_text = document.createTextNode(`${image.prompt} (${image.code})`);
+        figcaption.appendChild(caption_text);
+        figure.appendChild(img);
+        figure.appendChild(figcaption);
+        images.prepend(figure);
     });
 
     zombo_form.addEventListener('submit', function(e) {
         e.preventDefault();
+        /* Hide the form while generation is happening. */
+        zombo_form.style.display = "none";
         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. */
+        zombo_form.style.display = "grid";
+    });
+
     // TODO: Dynamically generate many different prompts here
     safety.addEventListener("click", () => {
         prompt.value = "Matte painting of a Samurai warrior";