Timeline

Timeline

DALS.Timeline: Represents a singular timeline in an undo/redo tree within the Delta Action Logging System (DALS). .value is structured as an Array<Object>, with [0] representing the head state, and subsequent elements state mutations.

Note that actions should generally be pushed to a timeline using the corresponding addAction(arg0_json:Object|string) function. DALS.undo()/DALS.redo() should generally be called instead of specific jumpTo() instructions within a timeline.

Constructor:
  • arg0_options: Object
    • .name: string
    • .parent_timeline: Array<string, number> - [0] represents the DALS.Timeline .id belonging to the parent timeline, and [1] the index of the parent branch node.
Instance:
  • .id=Class.generateRandomID(DALS.Timeline): string
  • .initial_timeline: boolean
  • .name="Timeline " + this.id: string
  • .parent_timeline: Array<string, number>
  • .value: Array<string> - Array of JSON strings. [0] represents the state head, [n] represents state mutations.
Methods:
  • addAction(arg0_json:Object|string, arg1_options:{ do_not_parse_action:boolean }) | DALS.Action - Pushes an action to the timeline, and attempts to parse it automatically.
  • branch(arg0_options:Object) | DALS.Timeline - arg0_options is the same as the options asked for DALS.Timeline.
  • delete() - Deletes and removes the present timeline.
  • jumpToAction(arg0_action_id:number|string)
  • jumpToEnd()
  • jumpToStart()
  • removeAction(arg0_action_id:number|string) - arg0_action_id is either the index of the action, or its .id.
Static Fields:
  • .current_index: number - The index of the current timeline the state is at.
  • .current_timeline: string - The ID of the current timeline being displayed.
  • .instances: Array<DALS.Timeline>
Static Methods:
  • getTimeline(arg0_timeline_id:string) | DALS.Timeline - Returns a DALS.Timeline object given a timeline ID.
  • load(arg0_file_path:string) - Loads a new head state from a given file.
  • jumpToTimeline(arg0_timeline_id:string) - Jumps to the head state of a specific timeline.
  • save(arg0_file_path:string) - Saves the present state to a given file.

Constructor

new Timeline()

Source:

Members

current_index :number

Source:
Type:
  • number

current_timeline :string

Source:
Type:
  • string

Methods

addAction(arg0_json, arg1_optionsopt) → {DALS.Action}

Adds a given action to the current timeline and immediately parses it by default.

Source:
Parameters:
Name Type Attributes Description
arg0_json Object | string
arg1_options Object <optional>
Name Type Attributes Default Description
di_not_parse_action boolean <optional>
false
Returns:
Type:
DALS.Action

assignChildTimelines()

Assigns the .child_timelines field for the present timeline by looking for any attached DALS.Timeline instances.

Source:

branch(arg0_optionsopt) → {DALS.Timeline}

Branches off a new timeline from the current timeline. If the current timeline is not selected, the branch node is automatically placed at the end of the timeline.

Source:
Parameters:
Name Type Attributes Default Description
arg0_options Object <optional>
{}

Refer to DALS.Timeline.options for information on what options are acceptable.

Returns:
Type:
DALS.Timeline

delete()

Deletes the present timeline and removes its references.

Source:

generateFlippedGraph() → {Object}

Flips a generated graph from generateGraph() by switching the .x/.y coordinates of each node.

Source:
Returns:
Type:
Object

generateGraph(arg0_options) → {Object}

Generates a timeline graph starting from the current DALS.Timeline instance with plotted .x/.y fields for node positions. Used in ve.Component.UndoRedo for rendering canvas displays.

Source:
Parameters:
Name Type Description
arg0_options Object
Returns:
Type:
Object

getGroups() → {Array.<Array.<DALS.Action>>}

Groups together actions with the same .key field to avoid their duplication and returns the grouped .value of the present timeline acoordingly.

Source:
Returns:
Type:
Array.<Array.<DALS.Action>>

getTimelineWidth() → {number}

Returns the width of the present timeline, accounting for any .child_timelines that may exist.

Source:
Returns:
Type:
number

jumpToAction(arg0_action_id)

Jumps to a specific action ID in the timeline, starting from its head, utilising .parseAction()

Source:
Parameters:
Name Type Description
arg0_action_id number | string

jumpToEnd()

Jumps to the end of this timeline.

Source:

jumpToStart()

Jumps to the start of this timeline.

Source:

removeAction(arg0_action_id)

Removes an action from the timeline based upon its ID.

Source:
Parameters:
Name Type Description
arg0_action_id string

(static) generateGraph() → {Object}

Generates a global timeline graph from the root DALS.Timeline.initial_timeline.

Source:
Returns:
Type:
Object

(static) getGraphMaxX(arg0_graph) → {number}

Returns the max .x value from a given graph from DALS.Timeline.generateGraph() to assess its dimensions.

Source:
Parameters:
Name Type Description
arg0_graph Object
Returns:
Type:
number

(static) getGraphMaxY(arg0_graph) → {number}

Returns the max .y value from a given graph from DALS.Timeline.generateGraph() to assess its dimensions.

Source:
Parameters:
Name Type Description
arg0_graph Object
Returns:
Type:
number

(static) getTimeline(arg0_timeline_id) → {DALS.Timeline}

Returns a DALS.Timeline object based upon a timeline ID string.

Source:
Parameters:
Name Type Description
arg0_timeline_id Object | string
Returns:
Type:
DALS.Timeline

(static) jumpToTimeline(arg0_timeline_id)

Jumps to the start of a timeline based off its ID.

Source:
Parameters:
Name Type Description
arg0_timeline_id DALS.Timeline | string

(static) load(arg0_file_path)

Loads in a new state based upon the JSON data contained at a file path.

Source:
Parameters:
Name Type Description
arg0_file_path string

(static) loadState(arg0_json)

Loads the current state for DALS/ve.UndoRedo. Contract function.

Source:
Parameters:
Name Type Description
arg0_json Object | string

(static) parseAction(arg0_jsonopt)

Parses an action for DALS/ve.UndoRedo. Contract function.

Source:
Parameters:
Name Type Attributes Description
arg0_json Object | string <optional>
Name Type Attributes Description
options Object <optional>
Name Type Attributes Default Description
name string <optional>
"New Action"
key string <optional>
value Array.<Object> <optional>

[n]: { type: string, <action_key>: any }

(static) redo() → {number}

Redoes an action group in the current timeline. Returns the jumped to index.

Source:
Returns:
Type:
number

(static) save(arg0_file_path)

Saves the present state as JSON to a new file path.

Source:
Parameters:
Name Type Description
arg0_file_path string

(static) saveState() → {Object}

Saves the current state for DALS/ve.UndoRedo. Contract function.

Source:
Returns:
Type:
Object

(static) undo() → {number}

Undoes an action group in the current timeline. Returns the jumped to index.

Source:
Returns:
Type:
number