Class UIManager

A UIManager is responsible for updating the HTML DOM and reacting to user input.

Hierarchy

  • UIManager

Constructors

Properties

fileManager: undefined | FileManager = undefined
listenersRegistered: boolean = false
mistakeCategoriesTemplate: string = ...
mistakeItemsTemplate: string = ...
mistakeManager: undefined | MistakeManager = undefined

Methods

  • Clears the current list of mistakes.

    Returns

    true if the list was cleared successfully

    Returns true

  • Removes all previous edits from the edit form.

    Returns

    true if the form was cleared successfully

    Returns true

  • Closes the editor popup that is used to modify a single mistake.

    Returns boolean

  • Deletes a mistake according to the user's input, by calling MistakeManager#deleteMistakeByID.

    Returns

    boolean indicating whether the mistake was deleted successfully

    Throws

    IllegalArgumentError if the HTML element is invalid

    Parameters

    • htmlElement: JQuery<HTMLElement>

      the HTML element that was clicked to delete the mistake

    Returns boolean | IllegalArgumentError

  • Displays an error alert with a generic introduction (if wanted) and, if provided, the given error code and custom error message.

    Parameters

    • Optional displayGenericIntroduction: boolean

      boolean indicating whether the generic introduction should be displayed

    • Optional errorCode: ErrorCode

      optional error code to be displayed beneath the generic introduction

    • Optional customErrorMessage: string

      an optional custom error message to be displayed beneath the generic introduction and the error code

    Returns true

  • Extracts all valid mistake UIDs from the given array, and returns them. Mistake IDs are converted to UIDs by looking them up in the mistake manager.

    Returns

    the array of valid mistake UIDs

    Throws

    IllegalArgumentError if the given array contains invalid related mistakes

    Parameters

    • related: string[]

      the array of related mistakes

    Returns string[] | IllegalArgumentError

  • Does something UID-related. Not sure what. TODO: Document this method.

    Returns void

  • Displays a list of all mistake identifications in the UI.

    Returns boolean

  • Moves a mistake up or down, calling moveMistake.

    Returns

    boolean indicating whether the mistake was moved successfully

    Throws

    IllegalArgumentError if the mistake ID is invalid or does not exist

    Parameters

    • htmlElement: JQuery<HTMLElement>

      the HTML element that was clicked by the user

    • moveDirection: MoveDirection

      the direction in which the mistake should be moved

    Returns boolean | IllegalArgumentError | IllegalDOMchangeError

  • Reads the file that was chosen by the user in the GUI and parses it by calling FileManager#parseFile.

    Returns

    boolean indicating whether choosing the file was successful

    Throws

    IllegalArgumentError if the HTML element is null

    Parameters

    • htmlElement: JQuery<HTMLElement>

      the file input element that was clicked

    Returns boolean | IllegalArgumentError

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Displays the editor popup with the mistake to be edited.

    Returns

    true if the mistake was successfully edited or false if the mistake was not found

    Throws

    IllegalDOMchangeError if the DOM was changed in a way that is not allowed

    Parameters

    • mistake: Mistake

      the mistake to be edited

    • editMode: EditMode

      whether a new mistake is being added or an existing one is being edited

    Returns true | IllegalDOMchangeError

  • Displays the editor popup with the mistake of the given ID.

    Returns

    true if the mistake was successfully edited or false otherwise

    Throws

    IllegalArgumentError if the given ID does not exist

    Throws

    IllegalDOMchangeError if the DOM has been changed in an illegal way

    Parameters

    • id: GrammleID

      the ID of the mistake to be edited

    • editMode: EditMode

      whether a new mistake is created or an existing one is edited

    Returns boolean | IllegalArgumentError | IllegalDOMchangeError

  • Displays a toast with the given status and text.

    Returns

    true if the toast was displayed successfully

    Parameters

    • status: "success" | "fail"

      the CSS class to be added to the toast, either "success" (green) or "fail" (red)

    • text: string

      the text to be displayed in the toast

    Returns true

  • Toggles the enabled/disabled status of the output button.

    Returns

    true if the button was toggled successfully

    Parameters

    • targetStatus: boolean

      whether the button should be enabled (true) or disabled (false)

    Returns true

  • Checks if the given array contains empty, white-space-only or non-alphanumeric items.

    Returns

    true if the array contains empty items, false otherwise

    Parameters

    • array: string[]

      the array to be checked

    Returns boolean

  • Private

    Checks whether the given string contains any empty, white-space-only or non-alphanumeric items.

    Returns

    true if the string is empty, false otherwise

    Parameters

    • string: string

      the string to be checked

    Returns boolean

  • Removes all empty, white-space-only or non-alphanumeric items from the given array.

    Returns

    the cleaned array

    Parameters

    • array: string[]

      the array to be cleaned

    Returns string[]

Generated using TypeDoc