<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="HandheldFriendly" content="true">
+
+ <style>
+ @keyframes zoom {
+ to {
+ opacity: 0%;
+ transform: scale(30);
+ }
+ }
+ .zoom-tardis {
+ animation-name: zoom;
+ animation-duration: 2s;
+ animation-timing-function: ease-in;
+ animation-fill-mode: forwards;
+ }
+ @keyframes fade {
+ from {
+ opacity: 100%;
+ }
+ to {
+ opacity: 0%;
+ }
+ }
+ .fade-out {
+ animation-name: fade;
+ animation-duration: 0.8s;
+ animation-timing-function: ease-in;
+ animation-fill-mode: forwards;
+ }
+ #welcome {
+ position: fixed;
+ width: 100%;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ }
+ #game {
+ position: relative;
+ }
+ #word {
+ text-align: center;
+ font-size: 500%;
+ font-weight: bold;
+ }
+ #interface {
+ width: 100%;
+ }
+ #input {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ width: 60%;
+ font-size: 200%;
+ border-width: 5px;
+ }
+ #reboot {
+ position: fixed;
+ right: 5px;
+ bottom: 5px;
+ }
+ #welcome-message {
+ font-size: 120%;
+ font-weight: bold;
+ text-align: center;
+ }
+ </style>
</head>
<body>
<div id="content">
- <div id="header" align="center">
- <p>
- <img src="/images/928785925_A_Van_Gogh_painting_of_the_Tardis.png">
- </p>
+ <div id="welcome">
+ <div id="header" align="center">
+ <p>
+ <img src="/images/928785925_A_Van_Gogh_painting_of_the_Tardis.png">
+ </p>
+ </div>
+
+ <div id="welcome-message">
+ <div id="timer_div" style="visibility: hidden">
+ Entering TARDIS in <span id="timer"></span> seconds.
+ </div>
+ <br>
+ Companions present: <span id="companions">1</span>/4
+ </div>
</div>
- <p>
- This tardis is locked. Do you have a sonic screwdriver?
- </p>
+ <div id="game" style="visibility: hidden">
+ <h1 id="level"></h1>
+
+ <div id="word">
+
+ </div>
+ <div id="interface">
+ <input id="input">
+ </input>
+ </div>
+ <button id="reboot">
+ Reboot Tardis
+ </button>
+ </div>
</div>
+
+ <script src="/socket.io/socket.io.js"></script>
+ <script>
+ const socket = io("/tardis");
+
+ const welcome = document.getElementById("welcome");
+ const game = document.getElementById("game");
+ const level_div = document.getElementById("level");
+ const word_div = document.getElementById("word");
+ const header = document.getElementById("header");
+ const companions = document.getElementById("companions");
+ const timer_div = document.getElementById("timer_div");
+ const timer = document.getElementById("timer");
+ const welcome_message = document.getElementById("welcome-message");
+
+ socket.on('companions', (count) => {
+ companions.textContent = count.toString();
+ });
+
+ socket.on('timer', (value) => {
+ console.log("Receiving timer value of " + value);
+ timer_div.style.visibility = "visible";
+ timer.textContent = value.toString();
+
+ if (value === 0) {
+ welcome_message.style.visibility = "hidden";
+ timer_div.style.visibility = "hidden";
+ header.className = "zoom-tardis";
+ }
+ });
+
+ socket.on('state', (state) => {
+ if (state === "game") {
+ welcome.style.visibility = "hidden";
+ game.style.visibility = "visible";
+ }
+ });
+
+ socket.on('level', (level) => {
+ level_div.textContent = level;
+ });
+
+ socket.on('show-word', (word) => {
+ word_div.textContent = word;
+ word_div.style.opacity = "100%";
+ word_div.className = "fade-out";
+ // Arrange to clear the class name when the animation is over
+ // This will allow for it to be restarted on the next word.
+ setTimeout(() => {
+ word_div.style.opacity = "0%";
+ word_div.className = "";
+ }, 900);
+ });
+
+ </script>
</body>
</html>