]> git.cworth.org Git - zombocom-ai/blobdiff - index.html
Generate new structure for images
[zombocom-ai] / index.html
index 167c97ef840e51dc69d19157a06cc156acda7875..b7e3521aeb547020dc36d61dabde85209f14d2fc 100644 (file)
@@ -24,7 +24,7 @@
     </div>
 
     <p>
-      Welcome to Zombocom. You can do anything at Zombcom, anything at
+      Welcome to Zombocom. You can do anything at Zombocom, anything at
       all. The only limit is yourself!
     </p>
 
       <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>
+          <textarea id="prompt" rows="4" width="100%" autocomplete="off" required></textarea>
         </div>
 
         <div class="form-row small left">
-          <label for="code">
-            Numeric code
-          </label>
-          <input id="code" type="text" size="10" autocomplete="off" placeholder="(Chosen randomly)" />
+          <div class="labeled-row">
+            <label for="code">
+              Numeric code:
+            </label>
+            <input id="code" type="text" autocomplete="off" placeholder="(Leave blank for random)" />
+          </div>
         </div>
 
         <div class="form-row small right">
           <button id="safety" class="right" type="button">Safety prompt</button>
-          <script>
-            const prompt = document.querySelector("#prompt");
-            const safety= document.querySelector("#safety");
-            // TODO: Dynamically generate many different prompts here
-            safety.addEventListener("click", () => {
-                prompt.value = "Matte painting of a Samurai warrior";
-                return false;
-            })
-          </script>
         </div>
 
         <div class="form-row large">
@@ -64,6 +56,9 @@
       </form>
     </p>
 
+    <div id="images">
+    </div>
+
     <ul id="comments">
     </ul>
 
@@ -110,11 +105,19 @@ mute.addEventListener("click", () => {
   <script>
     var socket = io();
 
-    var comments = document.querySelector("#comments");
-    var form = document.querySelector("#comment-form");
-    var comment = document.querySelector("#comment");
+    const images = document.querySelector("#images");
+
+    const comments = document.querySelector("#comments");
+    const comment_form = document.querySelector("#comment-form");
+    const comment = document.querySelector("#comment");
 
-    form.addEventListener('submit', function(e) {
+    const zombo_form = document.querySelector("#zombo-form");
+    const prompt = document.querySelector("#prompt");
+    const code = document.querySelector("#code");
+
+    const safety= document.querySelector("#safety");
+
+    comment_form.addEventListener('submit', function(e) {
         e.preventDefault();
         if (comment.value) {
             socket.emit('comment', comment.value);
@@ -127,6 +130,31 @@ mute.addEventListener("click", () => {
         item.textContent = msg;
         comments.appendChild(item);
     });
+
+    socket.on('image', (image) => {
+        const figure = document.createElement('figure');
+        const img = document.createElement('img');
+        img.src = image.filename;
+        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) {
+        e.preventDefault();
+        socket.emit('generate', {"prompt": prompt.value, "code": code.value});
+        prompt.value = '';
+    });
+
+    // TODO: Dynamically generate many different prompts here
+    safety.addEventListener("click", () => {
+        prompt.value = "Matte painting of a Samurai warrior";
+        return false;
+    });
+
   </script>
 </body>
 </html>