Started work on JSDoc for www/js/channel

This commit is contained in:
rainbow napkin 2025-09-04 05:45:33 -04:00
parent 5ad20f6823
commit ac06f839ea
97 changed files with 18556 additions and 91 deletions

View file

@ -14,15 +14,28 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
/**
* Class for object containing logic behind userlist UX
*/
class userList{
/**
* Instantiates a new userList object
* @param {channel} client - Parent client mgmt object
*/
constructor(client){
//Client object
/**
* Parent Client Management object
*/
this.client = client
//Click Dragger Object
/**
* Click Dragger object for handling userlist resizes
*/
this.clickDragger = new canopyUXUtils.clickDragger("#chat-panel-users-drag-handle", "#chat-panel-users-div", true, this.client.chatBox.clickDragger);
//Strings
/**
* Userlist color array (Maps to css classes)
*/
this.userColors = [
"userlist-color0",
"userlist-color1",
@ -32,13 +45,29 @@ class userList{
"userlist-color5",
"userlist-color6"];
//Maps
/**
* Map of usernames to assigned username color
*/
this.colorMap = new Map();
//Element Nodes
/**
* users div
*/
this.userDiv = document.querySelector("#chat-panel-users-div");
/**
* userlist div
*/
this.userList = document.querySelector("#chat-panel-users-list-div");
/**
* user count label
*/
this.userCount = document.querySelector("#chat-panel-user-count");
/**
* userlist toggle button
*/
this.toggleIcon = document.querySelector("#chat-panel-users-toggle");
//Call setup functions
@ -46,12 +75,17 @@ class userList{
this.defineListeners();
}
//Setup functions
/**
* Defines input-related event listeners
*/
setupInput(){
this.toggleIcon.addEventListener("click", ()=>{this.toggleUI()});
this.userCount.addEventListener("click", ()=>{this.toggleUI()});
}
/**
* Defines network-related event listeners
*/
defineListeners(){
this.client.socket.on('userList', (data) => {
this.updateList(data);
@ -62,6 +96,10 @@ class userList{
})
}
/**
* Updates UX after user list change
* @param {Array} list - Userlist data from server
*/
updateList(list){
//Clear list and set user count
this.userCount.textContent = list.length == 1 ? '1 User' : `${list.length} Users`;
@ -91,6 +129,11 @@ class userList{
this.clickDragger.fixCutoff();
}
/**
* Renders out a single username to the userlist
* @param {String} user - Username to render
* @param {String} flair - Flair to render as
*/
renderUser(user, flair){
//Create user span