comparison mrjunejune/src/talk/index.html @ 136:75c144fd6964

[MrJuneJune] Fix the js file to hit correct endpoints.
author June Park <parkjune1995@gmail.com>
date Fri, 09 Jan 2026 11:21:54 -0800
parents f236c895604e
children 095f7dc5bfce
comparison
equal deleted inserted replaced
135:ffb764d2fcc5 136:75c144fd6964
21 <input type="text" id="messageInput" placeholder="Type a message..."> 21 <input type="text" id="messageInput" placeholder="Type a message...">
22 <button id="sendBtn">Send</button> 22 <button id="sendBtn">Send</button>
23 </div> 23 </div>
24 {{/parts/footer.html}} 24 {{/parts/footer.html}}
25 <script> 25 <script>
26 const ws = new WebSocket('ws://localhost:6969/echo'); 26 const host = window.location.hostname;
27 const port = '6969';
28 const ws = new WebSocket(`ws://${host}:${port}/echo`);
27 const messagesDiv = document.getElementById('messages'); 29 const messagesDiv = document.getElementById('messages');
28 30
29 ws.onopen = () => { 31 ws.onopen = () => {
30 console.log('Connected!'); 32 console.log('Connected!');
31 appendMessage('System: Connected to server'); 33 appendMessage('System: Connected to server');
55 } 57 }
56 58
57 messageInput.addEventListener('keydown', (event) => { 59 messageInput.addEventListener('keydown', (event) => {
58 if (event.key === 'Enter' && !event.shiftKey) 60 if (event.key === 'Enter' && !event.shiftKey)
59 { 61 {
60 event.preventDefault(); 62 event.preventDefault();
61 sendBtn.click(); 63 sendBtn.click();
62 } 64 }
63 }); 65 });
64 </script> 66 </script>
65 </body> 67 </body>
66 </html> 68 </html>