Class: Items

modules/Items.Items()

Manages items and interacts with DOM elements related to them. Item event listener delegatees can accept or ignore browser click events depending on the item state. Item DOM elements are dynamically added to the DOM. Item event listener delegatees are dynamically added to the class object when the item elements are added to the DOM.

Constructor

new Items()

Sets the properties required to initialize the DOM.

Source:
See:
  • Communicator

Extends

  • Communicator

Members

domElements :Object.<string, Element>

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

The parent DOM element that contains item DOM elements.

Source:

items :Array.<Item>

The items' configurations.

Type:
  • Array.<Item>
Source:

Methods

createItemsDomElements(items)

Creates a DOM element for each item, styles the elements, then creates event listener delegatees.

Parameters:
Name Type Description
items Array.<Items.Item>

The item configurations for which to create DOM elements and event listener delegatees.

Source:

initialize()

Sets the initial state.

Source:

items(items)

Sets the items, then creates the items' DOM elements.

Parameters:
Name Type Description
items Array.<Item>

The items' configurations to set.

Source:

itemsElementClick(event)

An event listener delegatee that determines if the item is accepting clicks to add points to the session score, then creates a click log entry. The initial points value of a clicked item is the item's spawn interval. One point is deducted per second that a click time follows the item's spawn time, to a maximum value of the item's spawn time, meaning that the minimum number of points that can be scored is zero.

Parameters:
Name Type Description
event Event

The DOM click event.

Source:

processReceive()

Clears the items DOM element, resets each item's spawn time to 0, then recreates the items' DOM elements and event listener delegatees.

Source:

resetItemsDomElementText()

Clear the items DOM element.

Source: