Created by staff of the U.S. Securities and Exchange Commission.
Data and content created by government employees within the scope of their employment are not subject to domestic copyright protection. 17 U.S.C. 105.

# init.js README

## Purpose

High level Developer information regarding the initialization of the entire IXViewer.

## Variables

- N/A

## Functions

- IIFE begins entire application (on initial load by user).
  - Arguments: N/A
  - Run `AppInit.init()`
  - If `AppInit.init()` has a callback of `true`
    - Run `AppInit.initialSetup()`
  - If `AppInit.init()` has a callback of `false`
    - Run `ErrorsMajor.inactive()`
- `AppInit.init`
  - Arguments:
    - internalUrl
      - If empty, get XHTML location via URL (typical)
      - Else user is in a multi-form, and is requesting another form
    - callback
  - Run `AppInit.emptySidebars()`
  - Run `AjaxForm.init()`.
  - Run `HelpersUrl.init()`
  - If `HelpersUrl.init()` has a callback of `true`
    - Run `AjaxForm.init()`
    - If `AjaxForm.init()` has a callback of `true`
      - Run `Images.updateLinks()`
      - If `HelpersUrl.getAnchorTag`, scroll user to proper location.
      - `callback(true)` indicating the application is good
    - If `AjaxForm.init()` has a callback of `false`
      - Run `ErrorsMajor.formLinksNotFound()`
  - If `HelpersUrl.init()` has a callback of `false`
    - Hide Loading section from User
    - Run `Taxonomies.updateTaxonomyCount()`
    - Run `ErrorsMajor.urlParams()`
    - `callback(false)` indicating an error has occurred
- `AppInit.initialSetup`
  - Arguments: N/A
  - Run `AjaxMeta.init()`.
  - Run `Taxonomies.AddEventAttributes()`
  - Run `Links.init()`
  - If `AjaxMeta.init()` has a callback of `true`
    - We find all disabled classes and attributes under .navbar and remove these classes or attributes, as they are now usable to the User.
  - If `AjaxMeta.init()` has a callback of `false`
    - We find all disabled classes and attributes under .navbar that do not contain the meta-required CSS class, and remove these classes or attributes, as the User will have limited functionality based on the MetaLinks.json not loading properly.
- `AppInit.additionalSetup`
  - Arguments: N/A
  - This function is only used if the User changes XHTML forms (in a multi-form)
  - Run `Taxonomies.addEventAttributes()`
  - Run `Taxonomies.setFilterAttributes()`
  - Run `Links.init()`
  - Run `Sections.formChange()`
  - Run `TaxonomiesMenu.formChange()`
- `AppInit.emptySidebars`
  - Arguments: N/A
  - This function exists for when a User changes XHTML forms (in a muti-form), however is ran in single-form and multi-forms
  - Set `UserFiltersMoreFiltersPeriodSetUp.filtersSet = false`
  - Set `UserFiltersMoreFiltersMeasureSetUp.filtersSet = false`
  - Set `UserFiltersMoreFiltersAxesSetUp.filtersSet = false`
  - Set `UserFiltersMoreFiltersScaleSetUp.filtersSet = false`
  - Set `#error-container` innerHTML to empty
  - Adds Loading indicator to all Taxonomy Counters
  - Empties Sections Sidebar, and adds Loading Message
  - Empties Facts Sidebar (including pagination), and adds Loading Message.

## Related

- AjaxForm
- AjaxMeta
- Constants
- ErrorsMajor
- HelpersUrl
- Images
- Links
- Sections
- Taxonomies
- TaxonomiesMenu
- UserFiltersMoreFiltersAxesSetUp
- UserFiltersMoreFiltersMeasureSetUp
- UserFiltersMoreFiltersPeriodSetUp
- UserFiltersMoreFiltersScaleSetUp