]> git.cworth.org Git - zombocom-ai/blob - bus.html
Add Zombo's corruptions to the Magic School Bus artwork
[zombocom-ai] / bus.html
1 <!DOCTYPE html>
2 <html>
3
4 <head>
5   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6   <title>ZOMBO</title>
7   <link href="/zombo.css" rel="stylesheet" type="text/css">
8   <meta name="viewport" content="width=device-width,initial-scale=1">
9   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
10   <meta name="HandheldFriendly" content="true">
11
12   <style>
13     @keyframes zoom {
14         from {
15             opacity: 100%;
16             transform: scale(1);
17         }
18         to {
19             opacity: 0%;
20             transform: scale(30);
21         }
22     }
23     .zoom-into {
24         animation-name: zoom;
25         animation-duration: 2s;
26         animation-timing-function: ease-in;
27         animation-fill-mode: forwards;
28     }
29     @keyframes fade {
30         from {
31             opacity: 100%;
32         }
33         to {
34             opacity: 0%;
35         }
36     }
37     .fade-out {
38         animation-name: fade;
39         animation-duration: 0.8s;
40         animation-timing-function: ease-in;
41         animation-fill-mode: forwards;
42     }
43     #welcome {
44         position: fixed;
45         width: 100%;
46         top: 50%;
47         left: 50%;
48         transform: translate(-50%, -50%);
49     }
50     #game {
51         position: relative;
52     }
53     #word {
54         text-align: center;
55         font-size: 400%;
56         font-weight: bold;
57     }
58     #interface {
59         width: 100%;
60     }
61     #input {
62         display: block;
63         margin-left: auto;
64         margin-right: auto;
65         width: 60%;
66         font-size: 200%;
67         border-width: 5px;
68     }
69     #jumpstart {
70         position: fixed;
71         right: 5px;
72         bottom: 5px;
73     }
74     #welcome-message {
75         font-size: 120%;
76         font-weight: bold;
77         text-align: center;
78     }
79     #result {
80         position: fixed;
81         width: 100%;
82         top: 50%;
83         left: 50%;
84         transform: translate(-50%, -50%);
85         font-size: 500%;
86         text-align: center;
87     }
88     #form {
89         width: 100%;
90     }
91     #code {
92         width: 95%;
93     }
94     #output {
95         width: 100%;
96     }
97   </style>
98 </head>
99
100 <body>
101   <div id="content">
102
103     <div id="welcome" style="visibility: hidden">
104       <div id="header" align="center">
105         <p>
106           <img src="images/1403010940_The_Magic_School_Bus_in_the_apocalypse.png">
107         </p>
108       </div>
109
110       <div id="welcome-message">
111         <div id="timer_div" style="visibility: hidden">
112           Entering Magic School Bus in <span id="timer"></span> seconds.
113         </div>
114         <br>
115         Students present: <span id="students">1</span>/4
116       </div>
117     </div>
118
119     <div id="program" style="visibility: hidden">
120       <h1>Magic School Bus</h1>
121       </h1>
122       <form id="form">
123         <textarea id="code" rows="15" width="100%"></textarea>
124         <button type="submit">Run code</button>
125       </form>
126       <img id="output"></img>
127     </div>
128
129     <button id="jumpstart">
130       Jumpstart Magic School Bus
131     </button>
132
133   </div>
134
135   <script src="/socket.io/socket.io.js"></script>
136   <script>
137     const socket = io("/bus");
138
139     const welcome = document.getElementById("welcome");
140     const program = document.getElementById("program");
141     const header = document.getElementById("header");
142     const companions = document.getElementById("students");
143     const timer_div = document.getElementById("timer_div");
144     const timer = document.getElementById("timer");
145     const form = document.getElementById("form");
146     const code = document.getElementById("code");
147     const welcome_message = document.getElementById("welcome-message");
148     const jumpstart = document.getElementById("jumpstart");
149     const output = document.getElementById("output");
150
151     function fade_element(elt) {
152         elt.style.opacity = "100%";
153         elt.className = "fade-out";
154         // Arrange to clear the class name when the animation is over
155         // This will allow for it to be restarted on the next word.
156         setTimeout(() => {
157             elt.style.opacity = "0%";
158             elt.className = "";
159         }, 900);
160     }
161
162     jumpstart.addEventListener('click', event => {
163         socket.emit('jumpstart');
164     });
165
166     form.addEventListener('submit', event => {
167         event.preventDefault();
168         socket.emit('run', code.value);
169     });
170
171     socket.on('students', (count) => {
172         students.textContent = count.toString();
173     });
174
175     socket.on('code', (code_string) => {
176         code.value = code_string;
177     });
178
179     socket.on('timer', (value) => {
180         timer_div.style.visibility = "visible";
181         timer.textContent = value.toString();
182
183         if (value === 0) {
184             welcome_message.style.visibility = "hidden";
185             timer_div.style.visibility = "hidden";
186             header.className = "zoom-into";
187             // Clear that className after the animation is complete
188             setTimeout(() => {
189                 header.style.visibility = "hidden"
190                 header.className = "";
191             }, 2200);
192         }
193     });
194
195     socket.on('state', (state) => {
196         if (state === "program") {
197             welcome.style.visibility = "hidden";
198             program.style.visibility = "visible";
199         } else if (state === "welcome") {
200             welcome.style.visibility = "visible";
201             welcome_message.style.visibility = "visible";
202             header.style.opacity = "100%";
203             header.style.transform = "scale(1)";
204             header.style.visibility = "visible";
205             program.style.visibility = "hidden";
206             output.src = "";
207         }
208     });
209
210     socket.on('output', (filename) => {
211         output.src = filename;
212     });
213
214   </script>
215 </body>
216 </html>