From ed8431454fb8d56c9438ad790b015f4af524d299 Mon Sep 17 00:00:00 2001 From: Gordon Doore Date: Tue, 9 Jan 2024 12:16:34 -0500 Subject: [PATCH] documenting javascript files --- utils/js/explore.js | 13 +++++++++++++ utils/js/readme.js | 32 ++++++++++++++++++++++++++++++++ utils/js/submit.js | 13 +++++++++++++ 3 files changed, 58 insertions(+) diff --git a/utils/js/explore.js b/utils/js/explore.js index 870fcc41..05985380 100644 --- a/utils/js/explore.js +++ b/utils/js/explore.js @@ -1,3 +1,16 @@ +/** + * Filename: explore.js + * Author: Parth Parth + * Date: 01/09/2023 + * Description: Handles searching and downloading functionality for an ag-Grid-based table. + * + * @fileOverview + * This script utilizes ag-Grid to display search results in a tabular format. + * It includes functionality to handle AJAX requests for fetching table data based on user input, + * display the data in an ag-Grid, and allow users to download the displayed data in CSV format. + * + */ + 'use strict'; // We'll need some way to show errors diff --git a/utils/js/readme.js b/utils/js/readme.js index 0f40df79..44d88b34 100644 --- a/utils/js/readme.js +++ b/utils/js/readme.js @@ -1,3 +1,23 @@ +/** + * Filename: readme.js + * Author: Gordon Doore, Parth Parth + * Date: 01/09/2023 + * Description: This script provides functionality to fill readme submission form dynamically + * based on user-selected data fetched through AJAX in conenected database. It also + * includes event handling for button clicks and text node + * manipulation for asterisk wrapping allowing for formatting the selected data. + */ + + +/** + * Fills a form with data fetched through AJAX based on the selected title. + * If the selected title is "None," an alert is shown, and the function exits. + * Uses the fetched data to populate various form fields. + * Also includes event attachment for a button and a function to wrap asterisks in the document body. + * + * @function fillForm + * @throws {Error} If there is an issue with the AJAX request. + */ function fillForm() { var selectedTitle = document.getElementById('selected_title').value; @@ -109,12 +129,24 @@ function fillForm() { .catch(error => console.error('Error:', error)); } +/** + * Attaches the `fillForm` function to a button click event. + * Removes any existing click event to prevent multiple event bindings. + * + * @function attachFillFormEvent + */ function attachFillFormEvent() { var fillFormButton = document.getElementById('fill_from_title'); fillFormButton.removeEventListener('click', fillForm); fillFormButton.addEventListener('click', fillForm); } +/** + * Recursively wraps asterisks within text nodes with a span element for styling. + * + * @function wrapAsterisks + * @param {Node} element - The HTML element to traverse and wrap asterisks. + */ function wrapAsterisks(element) { if (element.hasChildNodes()) { element.childNodes.forEach(child => { diff --git a/utils/js/submit.js b/utils/js/submit.js index 7ebd8af9..c622fed2 100644 --- a/utils/js/submit.js +++ b/utils/js/submit.js @@ -1,3 +1,16 @@ +/** + * Filename: submit.js + * Author: Gordon Doore, Parth Parth + * Date: 01/09/2023 + * Code for submission of uploaded file + * + * @function handleFileUpload + * @description + * Fetches form data from the specified HTML form, sends it to the server-side + * script (upload.php) using AJAX, and displays a loader during the upload process. + * Upon successful upload, it logs the success message and redirects to a confirmation page. + * In case of an error, it logs the error message. + */ function handleFileUpload() { var form = document.getElementById('upload_form'); var formData = new FormData(form);