Reference
ProsePlay(el: HTMLElement): ProsePlay
Create a new ProsePlay instance, which will operate in the given HTML element.
ProsePlay.parse(str: string): ProsePlay
Parse the given string and creates the interactive components.
static ProsePlay.parse(str: string): ProsePlay
Same as above, but without first creating a ProsePlay instance and providing an existing HTML element. This will insert a new
<div>
into the body of the page.ProsePlay.load(name: "homophones" | "hypothetically" | "dickinson"): ProsePlay
Load one of the three available samples and creates the interactive components.
static ProsePlay.load(name: "homophones" | "hypothetically" | "dickinson"): ProsePlay
Same as above, but without first creating a ProsePlay instance and providing an existing HTML element. This will insert a new
<div>
into the body of the page.ProsePlay.randomise(windowIndexes?: number[]): void
Slide each window to a random choice. If windows are linked, they will move to the same choice index together. If no
windowIndexes
is specified, all windows will be randomised.ProsePlay.randomize(windowIndexes?: number[]): void
Alias for
randomise()
.ProsePlay.slideWindow(windowIndex: number, choiceIndex: number): void
Slide a specified window to a specified choice index.
ProsePlay.choices: string[][]
Return a nested list consisting of, for each window, the list of choices in that window.
ProsePlay.currentIndexes: number[]
Return a list consisting of, for each window, the current choice index.
ProsePlay.setFunction(name: string, fnc: Function): void
Attach a custom function to the ProsePlay instance. If the poem has the syntax
(choice1->myFunc|choice2)
andmyFunc()
is a custom function that exists in the code, the function can be passed into the ProsePlay instance usingsetFunction("myFunc", myFunc)
. After the function is set,myFunc()
will be called each timechoice1
is activated.ProsePlay.expand(): void
Expand all choices across windows. When the poem is in this state, no windows can be moved and the
randomise()
function cannot be called.ProsePlay.collapse(): void
Collapse all choices across windows, allowing windows to be moved and the
randomise()
function to be called.ProsePlay.isExpanded: boolean
Return a boolean describing whether the windows are expanded (
true
) or collapsed (false
).