]> git.cworth.org Git - zombocom-ai/blob - tardis.html
cca4e97f60eaaa2580cbeb7c649f6973910e54e3
[zombocom-ai] / tardis.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         to {
15             opacity: 0%;
16             transform: scale(30);
17         }
18     }
19     .zoom-tardis {
20         animation-name: zoom;
21         animation-duration: 2s;
22         animation-timing-function: ease-in;
23         animation-fill-mode: forwards;
24     }
25     @keyframes fade {
26         from {
27             opacity: 100%;
28         }
29         to {
30             opacity: 0%;
31         }
32     }
33     .fade-out {
34         animation-name: fade;
35         animation-duration: 0.8s;
36         animation-timing-function: ease-in;
37         animation-fill-mode: forwards;
38     }
39     #welcome {
40         position: fixed;
41         width: 100%;
42         top: 50%;
43         left: 50%;
44         transform: translate(-50%, -50%);
45     }
46     #game {
47         position: relative;
48     }
49     #word {
50         text-align: center;
51         font-size: 500%;
52         font-weight: bold;
53     }
54     #interface {
55         width: 100%;
56     }
57     #input {
58         display: block;
59         margin-left: auto;
60         margin-right: auto;
61         width: 60%;
62         font-size: 200%;
63         border-width: 5px;
64     }
65     #reboot {
66         position: fixed;
67         right: 5px;
68         bottom: 5px;
69     }
70     #welcome-message {
71         font-size: 120%;
72         font-weight: bold;
73         text-align: center;
74     }
75   </style>
76 </head>
77
78 <body>
79   <div id="content">
80
81     <div id="welcome">
82       <div id="header" align="center">
83         <p>
84           <img src="/images/928785925_A_Van_Gogh_painting_of_the_Tardis.png">
85         </p>
86       </div>
87
88       <div id="welcome-message">
89         <div id="timer_div" style="visibility: hidden">
90           Entering TARDIS in <span id="timer"></span> seconds.
91         </div>
92         <br>
93         Companions present: <span id="companions">1</span>/4
94       </div>
95     </div>
96
97     <div id="game" style="visibility: hidden">
98       <h1 id="level"></h1>
99
100       <div id="word">
101         &nbsp;
102       </div>
103       <div id="interface">
104         <input id="input">
105         </input>
106       </div>
107       <button id="reboot">
108         Reboot Tardis
109       </button>
110     </div>
111
112   </div>
113
114   <script src="/socket.io/socket.io.js"></script>
115   <script>
116     const socket = io("/tardis");
117
118     const welcome = document.getElementById("welcome");
119     const game = document.getElementById("game");
120     const level_div = document.getElementById("level");
121     const word_div = document.getElementById("word");
122     const header = document.getElementById("header");
123     const companions = document.getElementById("companions");
124     const timer_div = document.getElementById("timer_div");
125     const timer = document.getElementById("timer");
126     const welcome_message = document.getElementById("welcome-message");
127
128     socket.on('companions', (count) => {
129         companions.textContent = count.toString();
130     });
131
132     socket.on('timer', (value) => {
133         console.log("Receiving timer value of " + value);
134         timer_div.style.visibility = "visible";
135         timer.textContent = value.toString();
136
137         if (value === 0) {
138             welcome_message.style.visibility = "hidden";
139             timer_div.style.visibility = "hidden";
140             header.className = "zoom-tardis";
141         }
142     });
143
144     socket.on('state', (state) => {
145         if (state === "game") {
146             welcome.style.visibility = "hidden";
147             game.style.visibility = "visible";
148         }
149     });
150
151     socket.on('level', (level) => {
152         level_div.textContent = level;
153     });
154
155     socket.on('show-word', (word) => {
156         word_div.textContent = word;
157         word_div.style.opacity = "100%";
158         word_div.className = "fade-out";
159         // Arrange to clear the class name when the animation is over
160         // This will allow for it to be restarted on the next word.
161         setTimeout(() => {
162             word_div.style.opacity = "0%";
163             word_div.className = "";
164         }, 900);
165     });
166
167   </script>
168 </body>
169 </html>