]> git.cworth.org Git - zombocom-ai/commitdiff
Generate new structure for images
authorCarl Worth <cworth@cworth.org>
Wed, 7 Dec 2022 18:17:52 +0000 (10:17 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 7 Dec 2022 18:17:52 +0000 (10:17 -0800)
Using both a figure and a figcaption for each image. This allows for
more structured styling.

index.html

index fb8cbc0d3a7f52006518d8c1baf172378a50b843..b7e3521aeb547020dc36d61dabde85209f14d2fc 100644 (file)
@@ -32,7 +32,7 @@
       <form action="" id="zombo-form">
         <div class="form-row large">
           <label for="prompt">
-            What do you imagine?
+            What can you imagine?
           </label>
           <textarea id="prompt" rows="4" width="100%" autocomplete="off" required></textarea>
         </div>
@@ -132,17 +132,15 @@ 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.appendChild(figure);
     });
 
     zombo_form.addEventListener('submit', function(e) {