]> git.cworth.org Git - zombocom-ai/blobdiff - index.html
Add the second half necessary for functional comments
[zombocom-ai] / index.html
index b7b82de7068bedb0c4b3f1910ee11c2e78c2867d..167c97ef840e51dc69d19157a06cc156acda7875 100644 (file)
@@ -64,6 +64,9 @@
       </form>
     </p>
 
+    <ul id="comments">
+    </ul>
+
     <p>
       <form action="" id="comment-form">
         <input id="comment" type="text" style="width:100%" autocomplete="off" placeholder="Add a comment" />
@@ -107,6 +110,7 @@ mute.addEventListener("click", () => {
   <script>
     var socket = io();
 
+    var comments = document.querySelector("#comments");
     var form = document.querySelector("#comment-form");
     var comment = document.querySelector("#comment");
 
@@ -117,6 +121,12 @@ mute.addEventListener("click", () => {
             comment.value = '';
         }
     });
+
+    socket.on('comment', function(msg) {
+        var item = document.createElement('li');
+        item.textContent = msg;
+        comments.appendChild(item);
+    });
   </script>
 </body>
 </html>