From b841e066b9962e62b9b639e0f6eab58a81e8461d Mon Sep 17 00:00:00 2001 From: Arthur Beck Date: Fri, 11 Apr 2025 18:30:05 +0000 Subject: [PATCH] hrtjji[erj[iogrst --- client.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client.js b/client.js index 9606260..bd25e31 100644 --- a/client.js +++ b/client.js @@ -17,6 +17,11 @@ function log(...args) { let wsurl = new URL(document.location.toString()); wsurl.port = 3000; +if (document.location.protocol == "http") { + wsurl.protocol = "ws"; +} else { + wsurl.protocol = "wss"; +} let conn = new WebSocket(wsurl); conn.onmessage = (ev) => { @@ -27,9 +32,10 @@ conn.onmessage = (ev) => { newMsg.appendChild(messageContents); document.getElementById("chat-body").appendChild(newMsg); }; + /** - * @type {HTMLInputElement} - */ + * @type {HTMLInputElement} + */ let input = document.getElementById("chat-input"); input.onchange = (_) => { conn.send(input.value.toString());