Conduit and Wire Weight Calculator Documentation

Overview

The Conduit and Wire Weight Calculator assists in planning electrical conduit runs by calculating total weights, determining fill percentages, checking ampacity and grounding requirements, and exporting data to PDF.

HTML Structure

index.html: The main HTML file that includes the structure of the calculator, forms, and buttons.

JavaScript Modules

addEntries.js

Handles adding conduits and wires to the entry list.

addConduit()

Function: Adds a conduit entry to the list.

  1. Check "Free Air" Checkbox:
  2. Retrieve Conduit Details:
  3. Create List Item:
  4. Append to Entry List:
  5. Reset Input Fields:
  6. Update Total Weight and Wire Fill:
  7. Update Empty Entries:

addWire()

Function: Adds a wire entry to the list.

  1. Retrieve Wire Details:
  2. Create List Item:
  3. Append to Entry List:
  4. Reset Input Fields:
  5. Update Total Weight and Wire Fill:
  6. Update Empty Entries:

addNonCccWire()

Similar to addWire(), but specifically for non-CCC wires.

addEgc()

Similar to addWire(), but specifically for EGC wires.

addGec()

Similar to addWire(), but specifically for GEC wires.

addSbj()

Similar to addWire(), but specifically for SBJ wires.

removeItem(button)

Function: Removes a specific item from the entry list.

  1. Retrieve List Item:
  2. Remove List Item:
  3. Update Total Weight and Wire Fill:
  4. Update Empty Entries:

resetCurrentList()

Function: Resets the current list of entries.

  1. Clear Entry List:
  2. Reset Total Weight and Wire Fill:
  3. Reset Input Fields:
  4. Populate Conduit Sizes:
  5. Populate Wire Sizes:
  6. Update Empty Entries:

ampacity.js

Handles checking ampacity based on wire size, temperature rating, and derating factors.

checkAmpacity(setId)

Function: Initiates an ampacity check for a specific set of wires.

  1. Retrieve Set Item:
  2. Extract Conductor Details:
  3. Show Ampacity Results:

extractConductorDetails(text)

Function: Extracts conductor details from a given text input.

  1. Match Conduit Details:
  2. Match Wire Details:
  3. Extract and Return Details:

getBaseAmpacity(wireSize, tempRating)

Function: Retrieves the base ampacity for a given wire size and temperature rating.

  1. Lookup Ampacity Value:
  2. Return Base Ampacity:

applyDerating(baseAmpacity, wireCount)

Function: Applies derating factors based on the number of wires.

  1. Determine Derating Factor:
  2. Apply Derating Factor:

calculateAmpacities(detailsList, tempRating, conduitType)

Function: Calculates the ampacities of wires considering conduit type and temperature rating.

  1. Initialize Variables:
  2. Calculate Base and Derated Ampacity:
  3. Return Calculated Ampacities:

applyAmbientTemperatureDerating(ampacities, ambientTemperature, tempRating)

Function: Applies ambient temperature derating to the calculated ampacities.

  1. Determine Derating Factor:
  2. Apply Derating Factor:

showAmpacityResults(setId, conductorDetails)

Function: Displays the ampacity results.

  1. Prompt for Temperature Rating:
  2. Calculate Ampacities:
  3. Apply Ambient Temperature Derating:
  4. Display Results:

calculate.js

Contains functions for calculating the total weight and wire fill percentage.

calculateWeight()

Function: Calculates the total weight of conduits and wires, determines the fill percentage, and adds the set to the list.

  1. Initialize Variables:
  2. Iterate Over Entry List Items:
  3. Process Conduit Items:
  4. Process Wire Items:
  5. Calculate Fill Percentage:
  6. Update Total Weight Display:

editSet(setId)

Function: Allows editing of a specific set.

  1. Retrieve Set Item:
  2. Extract Conduit Details:
  3. Extract Wire Details:
  4. Remove Set:

removeEntries.js

Contains functions for removing items and sets.

removeItem(button)

Function: Removes a specific item from the entry list.

  1. Retrieve List Item:
  2. Remove List Item:
  3. Update Total Weight and Wire Fill:
  4. Update Empty Entries:

removeSet(setId)

Function: Removes a specific set from the list of sets.

  1. Retrieve Set Item:
  2. Extract Weight:
  3. Subtract Set's Weight:
  4. Remove Set Item:

resetEntries.js

Contains functions for resetting the entry list and sets.

resetList()

Function: Resets the entire list of entries and sets.

  1. Clear Entry List:
  2. Clear Sets List:
  3. Reset Cumulative Weight:
  4. Reset Input Fields:
  5. Populate Conduit Sizes:
  6. Populate Wire Sizes:
  7. Update Empty Entries:

resetCurrentList()

Function: Resets the current list of entries.

  1. Clear Entry List:
  2. Reset Total Weight and Wire Fill:
  3. Reset Input Fields:
  4. Populate Conduit Sizes:
  5. Populate Wire Sizes:
  6. Update Empty Entries:

updateCalculations.js

Contains functions for updating the total weight and wire fill.

updateTotalWeightAndWireFill()

Function: Updates the total weight and wire fill percentage based on the current entries.

  1. Initialize Variables:
  2. Iterate Over Entry List Items:
  3. Process Conduit Items:
  4. Process Wire Items:
  5. Calculate Fill Percentage:
  6. Update Total Weight Display:

checkEgc.js

Contains functions for checking EGC requirements.

checkEgc(setId)

Function: Initiates an EGC check for a specific set.

  1. Retrieve Set Item:
  2. Prompt for Breaker or Fuse Size:
  3. Get Matching EGC Data:
  4. Extract EGC Details:
  5. Show EGC Results:

getMatchingEgcData(breakerSize)

Function: Finds the appropriate EGC size based on the breaker or fuse size.

  1. Find Matching Data:
  2. Return Matching Data:

extractEgcDetails(text)

Function: Extracts EGC details from a given text input.

  1. Match Wire Details:
  2. Extract and Return Details:

showEgcResults(detailsList, breakerFuseSize, matchingData)

Function: Displays the EGC results.

  1. Iterate Over EGC Details:
  2. Display Results:

data.js

Contains data used for calculations and checks.

main.js

Initializes the application and handles event listeners.

window.addEventListener('DOMContentLoaded', (event) => {...})

Function: Initializes the application when the page is fully loaded.

exportConduits()

Function: Exports the conduit and wire data to a PDF.

  1. Create PDF Document:
  2. Add Title:
  3. Add Content:
  4. Save PDF:

utils.js

Contains utility functions for the application.

getAllowableFillPercentage(numConductors)

Function: Returns the allowable fill percentage based on the number of conductors.

populateConduitSizes(selectElement, conduitType)

Function: Populates a dropdown with conduit sizes based on the selected conduit type.

  1. Clear Existing Options:
  2. Add New Options:

populateWireSizes(selectElement)

Function: Populates a dropdown with wire sizes.

  1. Clear Existing Options:
  2. Add New Options:

toggleFreeAir()

Function: Toggles the display of conduit type, size, and length fields based on the "Free Air" checkbox.

updateEmptyEntries(listId)

Function: Updates the display if the list is empty.

compareSizes(size1, size2)

Function: Compares two wire sizes.

  1. Define Order:
  2. Compare Sizes: