documentation for all JS files

This commit is contained in:
2025-05-28 16:01:18 +02:00
parent 1134f5b099
commit 5c5829c487
22 changed files with 984 additions and 26 deletions

View File

@@ -1,3 +1,20 @@
/**
* @fileoverview Manages the conversation creation functionality.
* This file handles:
* - User selection interface using Select2
* - Member management for new conversations
* - Form submission with member data
* - UI updates and validation
*/
/**
* Initializes conversation creation functionality when the document is ready.
* Sets up:
* - Select2 dropdown for user selection
* - Member tracking and management
* - Form handling
* @function
*/
$(document).ready(function() {
$('.select2').select2({
theme: 'bootstrap-5',
@@ -11,14 +28,22 @@ $(document).ready(function() {
var creatorId = document.querySelector('.member-row').dataset.userId;
addedMembers.add(creatorId);
// Function to show alert modal
/**
* Shows an alert modal with the specified message.
* @function
* @param {string} message - The message to display in the alert modal
*/
function showAlert(message) {
$('#alertModalMessage').text(message);
var alertModal = new bootstrap.Modal(document.getElementById('alertModal'));
alertModal.show();
}
// Handle Add Member button click
/**
* Handles adding a new member to the conversation.
* Validates the selection and updates the UI accordingly.
* @event
*/
$('#addMemberBtn').click(function() {
var selectedUserId = $('#user_id').val();
var selectedUserName = $('#user_id option:selected').text();
@@ -69,6 +94,11 @@ $(document).ready(function() {
updateHiddenInputs();
});
/**
* Updates the hidden form inputs with the current member list.
* Removes existing member inputs and adds new ones for each current member.
* @function
*/
function updateHiddenInputs() {
// Remove any existing members inputs
$('#conversationForm input[name="members"]').remove();