Skip to content

Commit

Permalink
add chat button, js method
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Nov 16, 2023
1 parent 4b54cbd commit 2460886
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions springChatRoom/src/main/resources/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,28 @@ function updateOnlineUsers(users) {
// Append the username span to the list item
listItem.appendChild(usernameSpan);


// Create a "Chat" button
const chatButton = document.createElement('button');
chatButton.textContent = 'Chat';
chatButton.addEventListener('click', () => startChat(user)); // Replace with your chat initiation logic

// Append the "Chat" button to the list item
listItem.appendChild(chatButton);


// Append the list item to the user list
userList.appendChild(listItem);
});

}

// 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);
}

// Call the fetchUserList function to initially populate the user list
fetchUserList();

Expand Down

0 comments on commit 2460886

Please sign in to comment.