SaletView class

A view object is available as salet.view. It's automatically initialized when Salet loads, so it's always available with the salet object. You can't create new instances of this class.

It's the only class that knows about what's jQuery, DOM and HTML. It encapsulates the DOM functions for the other classes.

These are all the assumptions Salet has about your game:

  • The game takes place inside a #page container. Everything outside the #page are non-game elements.
  • The game text is inside the #content container.
  • The interface can have a single button having a save ID.
  • The interface can have a single button to load the game. The button has a load ID.
  • The interface can have a single button to restart the game. The button has an erase ID.
  • The interface can have a #intro block for the introduction text present before Javascript is loaded.
  • The interface can have a block #ways containing a list of rooms available to go to.
  • The interface can have a block #ways_hint containing a hint text for the movement block.

This documentation doesn't list some system methods; see the sources if you need them.

SaletView doesn't have any properties.

Called automatically on Salet's initialization, declares the standard event handlers.

Disables the save button when called.

Enables the save button when called.

Enables the restart button when called.

Disables the restart button when called.

Enables the save button when called.

Disables the load button when called.

Slowly rewinds the page to the specified number of pixels from the top edge of the screen.

Regardless of the page height or rewind extent, the animation takes 500ms.

Argument: number of pixels from the top edge of the screen, an integer. Required.

Slowly scrolls the page to the specified number of pixels from the bottom edge of the screen.

Regardless of the page height or rewind extent, the animation takes 500ms.

Argument: number of pixels from the bottom edge of the screen, an integer. Required.

Slowly scrolls the page until the end.

The animation takes 500ms.

Clears the contents of the specified block.

Argument: a selector for the element that needs to be cleared; by default, it's #content. This argument is optional.

Converts the argument to text. If you pass a function, it will be run. If you pass a jQuery object, it will be converted into HTML code.

Argument: anything; mandatory argument.

A synonym for append but the selector is #current-room by default.

Appends the HTML provided to the text of the block provided.

The text is processed by prepareContent.

If the block is not found, the text would be appended to the #content block.

The function returns block's HTML after appending.

Argument 1: the text to append, anything. Mandatory argument.

Argument 2: a selector of a block to append the text into. By default, it's #content. Optional argument.

Replaces the text of a given block with given HTML.

The text is processed by prepareContent.

Argument 1: the text that replaces the original content, anything. Mandatory argument.

Argument 2: a selector of a block that would have its text replaced. Mandatory argument.

If the Argument 1 is present, then the function turns all HTML links leading to this address into text. If it's omitted, then the functions turns all links into text.

If the Argument 2 is present, then the function works only on the links inside that block. If it's omitted, then the functionw works inside the #page block.

Argument 1: link target. Optional parameter.

Argument 2: a selector of the block to work in. Optional parameter.

The function gets a list of room IDs and returns a regular list of choices linked to these rooms.

The list is not sorted but if a room has canChoose = false, the text optionText would be printed not as a link but as a <span> HTML. Therefore, you can make optionText something else, for example, a form or a special button.

Argument 1: a list of room IDs

Shows the specified block with a nice animation. If *Salet* is not in the interactive mode (loading a game), the animation is skipped.

Argument 1: block selector. Mandatory argument.

Hides the specified block with a nice animation. If *Salet* is not in the interactive mode (loading a game), the animation is skipped.

Argument 1: block selector. Mandatory argument.

Argument 2: removal flag. If true, then after the animation the block would be removed from DOM; if false then it will just be hidden. false by default, optional argument.

The function returns a code for the cycle link. With it you can make links that cycle their content.

  • en/api/view.txt
  • Last modified: 2021/01/24 10:42
  • by 127.0.0.1