From 1053479c039e120fc892384084a76ff0ed11e1a9 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 9 Jan 2022 23:43:40 +0100 Subject: Add a game script At the moment this script does not do much, it simply registers an event listener to inform the server about when one of the clients resigns the game which activates when someone clicks the "resign" button. In the future this script will most likely house all the client-side functionality related to the game. --- draughts/public/game.html | 81 +++++++++++++++++++------------------ draughts/public/javascripts/game.js | 4 ++ 2 files changed, 45 insertions(+), 40 deletions(-) create mode 100644 draughts/public/javascripts/game.js diff --git a/draughts/public/game.html b/draughts/public/game.html index 9b1ac7a..726007a 100644 --- a/draughts/public/game.html +++ b/draughts/public/game.html @@ -6,6 +6,7 @@ + Draughts @@ -28,46 +29,46 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/draughts/public/javascripts/game.js b/draughts/public/javascripts/game.js new file mode 100644 index 0000000..ede6459 --- /dev/null +++ b/draughts/public/javascripts/game.js @@ -0,0 +1,4 @@ +//const ws = new WebSocket("ws://localhost:3000") +//ws.addEventListener("open", () => console.log("We are connected!")) + +document.getElementById("resign").addEventListener("click", () => ws.send("RESIGN")) -- cgit v1.2.3