euchre-live

Euchre web-app for the socially distant family
git clone git://git.alexkarle.com/euchre-live.git
Log | Files | Refs | README | LICENSE

commit 025d3c0aef8c25e38b6162e575b01a7acaf19f54 (patch)
parent 0b63bc2ec8cdda6cbd1dc92e3dc6ff69dabadfdb
Author: Alex Karle <alex@karle.co>
Date:   Sun, 29 Mar 2020 23:52:42 -0400

debug.html: Add specific sections for Game/Errors

This adds some debug logic to make the Game State a single view (that
updates) and the errors a new trailing view.

It has been useful already -- adding it identified a bug in send_error
(fixed in previous commit).

Diffstat:
Mpublic/debug.html | 19+++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/public/debug.html b/public/debug.html @@ -11,10 +11,15 @@ ws.onmessage = function (event) { msg = JSON.parse(JSON.parse(event.data)); // double parsed? console.log(msg) - gameState = '<br>Game: ' + msg.game.id + '<br>' + - 'Players: ' + msg.game.players + '<br>' + - 'Spectators: ' + msg.game.spectators + '<br>' - document.getElementById('game').innerHTML = gameState + + if (msg.msg_type === 'game_state') { + gameState = '<br>Game: ' + msg.game.id + '<br>' + + 'Players: ' + msg.game.players + '<br>' + + 'Spectators: ' + msg.game.spectators + '<br>' + document.getElementById('game').innerHTML = gameState + } else if (msg.msg_type === 'error') { + document.getElementById('error').innerHTML += msg.msg + '<br>' + } }; function joinGame() { @@ -45,7 +50,9 @@ <input type="number" id="seat_no"> <button onclick="sit()">Sit</button> - <div id="game"> - </div> + <br><br> + <div id="game">Not in a game</div> + <br><br> + <div id="error" style="color:red"> </div> </body> </html>