-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re formatting code + Adding additional comments
- Loading branch information
1 parent
b3881d6
commit 9bf4843
Showing
5 changed files
with
75 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// -------------------------------------------------------------------------------------- | ||
// Helper Functions | ||
|
||
// Adding the message to the client side | ||
const outputMessage = function (message) { | ||
const div = document.createElement("div"); | ||
div.classList.add("message"); | ||
div.innerHTML = ` | ||
<div class="message"> | ||
<p class="meta">${message.username}<span> ${message.time}</span></p> | ||
<p class="text">${message.text}</p> | ||
</div>`; | ||
document.querySelector(".chat-messages").appendChild(div); | ||
}; | ||
|
||
// Adding the name of users in any field | ||
const outputNames = function (users, listName) { | ||
const element = document.getElementById(listName); | ||
while (element.firstChild) { | ||
element.removeChild(element.firstChild); | ||
} | ||
for (let i = 0; i < users.length; i++) { | ||
const li = document.createElement("li"); | ||
li.innerHTML = `${users[i].username}`; | ||
document.getElementById(listName).appendChild(li); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
outputMessage, | ||
outputNames, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
const { | ||
getCurrUser, | ||
userJoin, | ||
leaveChat, | ||
getWaitingUsers, | ||
getTeamOneUsers, | ||
getReferee, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters