Class: Timer

modules/Timer.Timer()

Manages session time and interacts with DOM elements related to it.

Constructor

new Timer()

Source:
See:
  • Communicator

Extends

  • Communicator

Members

domElements :Object.<string, Element>

Type:
  • Object.<string, Element>
Properties:
Name Type Description
clock Element

Displays the elapsed session time.

start Element

Can be clicked to start a session.

pause Element

Can be clicked to pause a session.

end Element

Can be clicked to end a session.

timescaleMultiplier Element

Displays the session timescale multiplier.

timescaleMultiplierDecrease Element

Can be clicked to decrease the timescale multiplier.

timescaleMultiplierIncrease Element

Can be clicked to increase the timescale multiplier.

Source:

interval :setInterval|false|null

The session interval.

Type:
  • setInterval | false | null
Source:

seconds :number

The session seconds.

Type:
  • number
Source:

sessionSegments :Array.<SessionSegment>

An array with a maximum length of 2. Index 0 represents the time at which a session started. The optional index 1 represents the time at which the session paused.

Type:
  • Array.<SessionSegment>
Source:

timescaleMultiplier :number

The session timescale multiplier.

Type:
  • number
Source:

Methods

endElementClick()

An event listener delegatee that ends a session.

Source:

initialize()

Sets the initial state.

Source:

interval(interval)

Conditionally clears the session interval, then conditionally sets the interval depending on the value of the interval parameter.

Parameters:
Name Type Description
interval null | boolean | number

The interval state to set the interval to.

Source:

pauseElementClick()

An event listener delegatee that pauses a session.

Source:

seconds(seconds)

Sets the session seconds, then updates the clock DOM element.

Parameters:
Name Type Description
seconds number

The session seconds.

Source:

sessionSegments(value)

Adds a timestamp that represents the start or end value of a session segment. Each session segment is initially assigned the start property. The end property is assigned when the session is paused. When the session is restarted, creates a new session segment and adds it to the session segments. When the session ends, sets the session segments to an empty array.

Parameters:
Name Type Description
value Array | number

An empty array or a number representing a timestamp.

Source:

startElementClick()

An event listener delegatee that starts a session.

Source:

timescaleMultiplier(timescaleMultiplier)

Conditionally sets the timescale multiplier, then updates the timescale multiplier DOM element.

Parameters:
Name Type Description
timescaleMultiplier number

The number to set the session timescale multiplier to.

Source:

timescaleMultiplierDecreaseElementClick()

An event listener delegatee that decreases the session timescale multiplier.

Source:

timescaleMultiplierIncreaseElementClick()

An event listener delegatee that increases the timescale multiplier.

Source:

updateClockElementText()

Sets the clock DOM element to the formatted value of the session seconds.

Source:
See:
  • Timer.formatTime.

updateTimescaleMultiplierElementText()

Updates the timescale multiplier DOM element.

Source:

(static) formatTime(seconds) → {string}

Calculates minutes and remainder seconds of seconds, then left-pads both.

Parameters:
Name Type Description
seconds number

The number of seconds to format as a time string.

Source:
Returns:

A time string formatted as mm:ss.

Type
string