Skip to content

Commit

Permalink
Merge pull request #74 from thecodingaviator/documentation-01-09
Browse files Browse the repository at this point in the history
documenting javascript files
  • Loading branch information
gordoncd committed Jan 9, 2024
2 parents 6f59721 + ed84314 commit 106b784
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils/js/explore.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 32 additions & 0 deletions utils/js/readme.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 => {
Expand Down
13 changes: 13 additions & 0 deletions utils/js/submit.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit 106b784

Please sign in to comment.