Module: utils.js

Contains miscellaneous utilities used throughout
Version:
  • 1.0.0
Author:
  • Ali Izoyev
  • Colin Rice
Source:

Methods

(inner) createElement(type, id, classes, text) → {HTMLElement}

Creates and returns an element with the given type, id, and class.
Parameters:
Name Type Description
type string The type of the element. Must be a valid HTML tag
id string The ID to apply to this element. May be an empty string / null if no ID should be applied
classes string The classes to apply to this element. May be an empty string / null if no classes should be applied
text string The text content to apply to this element. May be omitted if no text content should be applied
Source:
Returns:
A element that contains whatever the programmer has put as the arguments during the usage
Type
HTMLElement

(inner) generateCreateEvent() → {HTMLDivElement}

Creates a reusable div that holds a UI image for making draggable calendar events
Source:
Returns:
Container that creates draggable calendar events
Type
HTMLDivElement

(inner) generateDeleteDiv(element) → {HTMLDivElement}

This method creates a reusable delete button element with a trash can icon. It also activates a popup behavior that is already in the html. When the trash can is clicked, the user will be ask to confirm deletion before removing the target element (element as parameter) in the DOM. If you need something else to happen when the button is clicked besides the deletion of the tag, you need to implement it inside of this function, inside of the event listener
Parameters:
Name Type Description
element HTMLElement The element that will be used for deletion when the user approves there desision.
Source:
Returns:
A reusable div with a delete button, trash can icon, and some behavior tied to the button / trash can
Type
HTMLDivElement

(inner) getScheduleDate(element, asJSDateRange) → {string|Array.<Date>}

This method gets the type of schedule from whatever the user is using to add in a schedule (week or month) It gets the value from whatever the user has choosen, formats it to a usable date, then returned as a string.
Parameters:
Name Type Default Description
element HTMLElement In this case, the closest element with the ".generate-new-schedule" tag to insert a new table
asJSDateRange boolean false Whether to return the schedule date as a string (for table headers) or as an array of Date objects (for table creation)
Source:
Returns:
Returns a string or array of Dates based on if the user chooses the week selection or the month selection
Type
string | Array.<Date>