Counter

Source: Counter.js:36

This class encapsulates the operation of a numeric counter, used to display the current
values of score, actions and time.


Constructor

new Counter(id: string, $div?: external:jQuery): Counter

Counter constructor

Parameters

  • id (string) — The type of information stored on this counter
  • $div (external:jQuery, optional) — The HTML element where this counter will show values (can be null)

Instance Methods

getDisplayValue(): number

Gets the current display value of this counter

Returns

  • number

refreshDisplay()

Paints the value of this counter on screen
(method to be overridden by subclasses)

setEnabled(enabled: boolean)

Enables or disables this counter

Parameters

  • enabled (boolean) — State been assigned to this counter

setCountDown(maxValue: number)

Sets the initial value of the counter

Parameters

  • maxValue (number) — Value from which the countdown will start

incValue()

Increments by one the value of this counter

setValue(value: number)

Sets a specific value to this counter

Parameters

  • value (number) — The value to set

Instance Fields

id: string

Type of counter (usually: score, actions or time)

$div: external:jQuery

The HTML element where this counter shows its value

value: number

Current value of this counter

countDown: number

When set, the counter displays a countdown from this value to zero

enabled: boolean

Flag indicating if this counter is currently enabled

MAX_DISPLAY_VALUE: number

Maximum value to be displayed by this counter

displayDiffFrom: module:skins/Counter.Counter

An optional Counter used as a subtractor to display the current value.
Useful to display errors subtracting score from actions.