diff --git a/springChatRoom/src/main/resources/static/js/main.js b/springChatRoom/src/main/resources/static/js/main.js index c69f4ee6c..71d72a5ac 100644 --- a/springChatRoom/src/main/resources/static/js/main.js +++ b/springChatRoom/src/main/resources/static/js/main.js @@ -176,19 +176,38 @@ function updateOnlineUsers(users) { // Function to handle chat initiation function startChat(username) { - // Add your logic here to start a private chat with the selected user - console.log('>>> Start chat with ' + username); - // Open a popup window for the chat const popupWindow = window.open('', '_blank', 'width=400,height=300'); - // Add your logic to customize the popup window content - popupWindow.document.write('
This is the chat content. Customize it as needed.
'); - popupWindow.document.write(''); + // Add your logic to customize the popup window content + popupWindow.document.write('You: ' + message + '
'; + + // Add your logic to send the message to the other user + // Example: stompClient.send('/app/private/' + username, {}, JSON.stringify({ sender: 'You', content: message, type: 'CHAT' })); + + // Clear the input field + messageInput.value = ''; + } + }; } + + // Call the fetchUserList function to initially populate the user list fetchUserList();