PlayerHistory. PlayerHistory

PlayerHistory uses an array to store the list of projects and activities done by the user.
This class allows JClicPlayer objects to rewind a sequence or to go back to a caller menu.

Constructor

new PlayerHistory(player)

PlayerHistory constructor

Parameters:
NameTypeDescription
playermodule:JClicPlayer.JClicPlayer

The JClicPlayer associated to this history

Members

HistoryElement

Inner class used to store history elements.

player :module:JClicPlayer.JClicPlayer

The JClicPlayer object to which this PlayerHistory belongs

sequenceStack :Array.<module:PlayerHistory.PlayerHistory#HistoryElement>

This is the main member of the class. PlayerHistory puts and retrieves
on it information about the proects and activities done by the current user.

testMode :boolean

When in test mode, jumps are only simulated.

Type:
  • boolean

Methods

clearHistory()

Removes all elements from sequenceStack

jumpToSequence(sequence, pathopt, allowReturnopt)

Performs a jump to the specified sequence

Parameters:
NameTypeAttributesDefaultDescription
sequencestring

The ActivitySequence tag to jump to.

pathstring<optional>
null

When not null, indicates a new project file that must be loaded.
Otherwise, the sequence parameter refers to a tag on the ActivitySequence of the
current project.

allowReturnboolean<optional>
false

When this parameter is true, the jump will be recorded, thus
allowing to return to the current activity.

pop() → {boolean}

Retrieves the HistoryElement placed at the top of the
stack (if any) and instructs JClicPlayer to load it. The obtained effect is to
"rewind" or "go back", usually to an activity that acts as a menu.

Returns:
Type: 
boolean

processJump(ji, allowReturn) → {boolean}

Processes the provided JumpInfo object, instructing JClicPlayer to go back,
stop or jump to another point in the sequence.

Parameters:
NameTypeDescription
jimodule:bags/JumpInfo.JumpInfo

The object to be processed

allowReturnboolean

When this parameter is true, the jump instructed by ji (if any)
will be recorded, thus allowing to return to the current activity.

Returns:
  • true if the jump can be processed without errors, false otherwise.
Type: 
boolean

processPopStateEvent(state)

Process the state object received in a popstate event

Parameters:
NameTypeDescription
statePlayerHistory#HistoryElement

The previously stored state

push()

Adds the current project and activity to the top of the history stack.

pushBrowserHistory()

Push a new entry on the window.History stack,
only when browserHistory is true and there is no popstate event in progress

storedElementsCount() → {number}

Counts the number of HistoryElement objects stored in
sequenceStack

Returns:
Type: 
number