Reference
ProsePlay(el: HTMLElement): ProsePlayCreate a new ProsePlay instance, which will operate in the given HTML element.
ProsePlay.parse(str: string): ProsePlayParse the given string and creates the interactive components.
static ProsePlay.parse(str: string): ProsePlaySame 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"): ProsePlayLoad one of the three available samples and creates the interactive components.
static ProsePlay.load(name: "homophones" | "hypothetically" | "dickinson"): ProsePlaySame 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[]): voidSlide each window to a random choice. If windows are linked, they will move to the same choice index together. If no
windowIndexesis specified, all windows will be randomised.ProsePlay.randomize(windowIndexes?: number[]): voidAlias for
randomise().ProsePlay.slideWindow(windowIndex: number, choiceIndex: number): voidSlide 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): voidAttach 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 timechoice1is activated.ProsePlay.expand(): voidExpand 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(): voidCollapse all choices across windows, allowing windows to be moved and the
randomise()function to be called.ProsePlay.isExpanded: booleanReturn a boolean describing whether the windows are expanded (
true) or collapsed (false).