Passage

This class represents an individual passage.  This is analogous to the Tiddler class in the core TiddlyWiki code.

Summary
This class represents an individual passage.
The title of the passage, displayed at its top.
An internal id of the passage.
The initial text of the passage.
The current text of the passage.
An array of strings, each corresponding to a tag the passage belongs to.
Initializes a new Passage object.
Renders the passage to a DOM element, including its title, toolbar, and content.
Resets the passage’s text property to its initialText property.
A static function used by the constructor to convert string literals used by TiddlyWiki to indicate newlines into actual newlines.

Properties

title

The title of the passage, displayed at its top.

id

An internal id of the passage.  This is never seen by the reader, but it is used by the History class.

initialText

The initial text of the passage.  This is used by the reset method.

text

The current text of the passage.  This is usually the same as the initialText property, though macros such as <<choice>> may alter it.

tags

An array of strings, each corresponding to a tag the passage belongs to.

Functions

Passage

function Passage (title,
el,
order)

Initializes a new Passage object.  You may either call this with a DOM element, which creates the passage from the text stored in the element, or you may pass only a title,

Parameters

titlethe title of the passage to create.  This parameter is required.
elthe DOM element storing the content of the passage.  This parameter is optional.  If it is omitted, “this passage does not exist” is used as the passage’s content.
orderthe order in which this passage was retrieved from the document’s storeArea div.  This is used to generate the passage’s id.  This parameter is optional, but should be included if el is specified.

render

Passage.prototype.render = function()

Renders the passage to a DOM element, including its title, toolbar, and content.  It’s up to the caller to add this to the DOM tree appropriately and animate its appearance.

Parameters

none

Returns

nothing

reset

Passage.prototype.reset = function()

Resets the passage’s text property to its initialText property.  This does not directly affect anything displayed on the page.

Parameters

none

Returns

nothing

unescapeLineBreaks

Passage.unescapeLineBreaks = function (text)

A static function used by the constructor to convert string literals used by TiddlyWiki to indicate newlines into actual newlines.

Parameters

texta string to unescape

Returns

a converted string

function Passage (title,
el,
order)
Initializes a new Passage object.
Passage.prototype.render = function()
Renders the passage to a DOM element, including its title, toolbar, and content.
Passage.prototype.reset = function()
Resets the passage’s text property to its initialText property.
The current text of the passage.
The initial text of the passage.
Passage.unescapeLineBreaks = function (text)
A static function used by the constructor to convert string literals used by TiddlyWiki to indicate newlines into actual newlines.
A class used to manage the state of the story -- displaying new passages and rewinding to the past.