History |
HistoryA class used to manage the state of the story -- displaying new passages and rewinding to the past. Summary
HistoryAn array representing the state of the story. history[0] is the current state, history[1] is the state just before the present, and so on. Each entry in the history is an object with two properties: passage, which corresponds to the Passage just displayed, and variables. Variables is in itself an object. Each property is a variable set by the story via the <<set>> macro. init
This first attempts to restore the state of the story via the restore method. If that fails, it then either displays the passages linked in the StartPassages passage, or gives up and tries to display a passage named Start. Parametersnone Returnsnothing close
This removes a passage from display onscreen. This does not animate its disappearance. Parameters
Returnsnothing display
Displays a passage on the page. If a passage has previously been displayed, the browser window is scrolled so it is in view. Parameters
ReturnsThe DOM element containing the passage on the page. save
Returns a hash to append to the page’s URL that will be later read by the restore method. How this is generated is not guaranteed to remain constant in future releases -- but it is guaranteed to be understood by restore. Parameters
ReturnsA hash to append to the page’s URL. restore
Attempts to restore the state of the story as saved by save. Parametersnone ReturnsWhether this method actually restored anything. |
Initializes a History object.
function History()
This first attempts to restore the state of the story via the restore method.
History.prototype.init = function()
Attempts to restore the state of the story as saved by save.
History.prototype.restore = function ()
This removes a passage from display onscreen.
History.prototype.close = function ( passage )
Displays a passage on the page.
History.prototype.display = function ( title, link, render )
Restarts the story from the beginning.
History.prototype.restart = function()
Returns a hash to append to the page’s URL that will be later read by the restore method.
History.prototype.save = function ( passage )
Rewinds the state of the story to a particular Passage.
History.prototype.rewindTo = function ( passage )