X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=tictactoe%2Ftictactoe.jsx;h=849a6f2a113f6141ceaf1e33927bb10d2bbadd23;hp=eff7eff32f6df572437130d0ec2c0e8ecf8c2a7b;hb=1292fbceb528e33906f7f28f7205d57d6ff19b61;hpb=f0c30f7cd59ecfca24e6a7332910f87a6b2045e6
diff --git a/tictactoe/tictactoe.jsx b/tictactoe/tictactoe.jsx
index eff7eff..849a6f2 100644
--- a/tictactoe/tictactoe.jsx
+++ b/tictactoe/tictactoe.jsx
@@ -1,3 +1,30 @@
+function undisplay(element) {
+ element.style.display="none";
+}
+
+function add_message(severity, message) {
+ message = `
+×
+${message}
+
`;
+ const message_area = document.getElementById('message-area');
+ message_area.insertAdjacentHTML('beforeend', message);
+}
+
+const events = new EventSource("events");
+
+events.onerror = function(event) {
+ if (event.target.readyState === EventSource.CLOSED) {
+ add_message("danger", "Connection to server lost.");
+ }
+};
+
+events.addEventListener("move", event => {
+ const square = JSON.parse(event.data);
+
+ window.game.receiveMove(square);
+});
+
function Square(props) {
return (