]> git.cworth.org Git - zombocom-ai/blobdiff - bus.html
Reword Coda's final message
[zombocom-ai] / bus.html
index f16a509ae18bfea5b72955cf5a0f9d30be55c1d6..40e50d38b6aab2ebf6ec8eab755cd98f1f7737df 100644 (file)
--- a/bus.html
+++ b/bus.html
     #output {
        width: 100%;
     }
+    #error {
+       font-family: monospace;
+       color: red;
+       white-space: pre-wrap;
+    }
   </style>
 </head>
 
     </div>
 
     <div id="program" style="visibility: hidden">
-      <h1>
-       Magic School Bus Central Processor
+      <h1>Magic School Bus</h1>
       </h1>
       <form id="form">
-       <textarea id="code" rows="10" width="100%">def random_dot():
-  x = 200 * random()
-  y = 200 * random()
-  radius = 4 + 6 * random()
-  circle(x, y, radius)
-  fill()
-
-for i in range(100):
-  if i %2 == 0:
-    set_color('red')
-  else:
-    set_color('blue')
-  random_dot()</textarea>
+       <textarea id="code" rows="15" width="100%"></textarea>
        <button type="submit">Run code</button>
       </form>
+      <div id="error">
+      </div>
       <img id="output"></img>
-    </div>
+   </div>
 
     <button id="jumpstart">
       Jumpstart Magic School Bus
@@ -160,6 +154,7 @@ for i in range(100):
     const welcome_message = document.getElementById("welcome-message");
     const jumpstart = document.getElementById("jumpstart");
     const output = document.getElementById("output");
+    const error = document.getElementById("error");
 
     function fade_element(elt) {
        elt.style.opacity = "100%";
@@ -185,6 +180,10 @@ for i in range(100):
        students.textContent = count.toString();
     });
 
+    socket.on('code', (code_string) => {
+       code.value = code_string;
+    });
+
     socket.on('timer', (value) => {
        timer_div.style.visibility = "visible";
        timer.textContent = value.toString();
@@ -201,6 +200,10 @@ for i in range(100):
        }
     });
 
+    socket.on('error', (error_message) => {
+       error.textContent = error_message;
+    });
+
     socket.on('state', (state) => {
        if (state === "program") {
            welcome.style.visibility = "hidden";
@@ -217,6 +220,7 @@ for i in range(100):
     });
 
     socket.on('output', (filename) => {
+       error.textContent = "";
        output.src = filename;
     });