JSAPI page » History » Version 21

Version 20 (eddy ed, 06/04/2017 11:18 AM) → Version 21/33 (eddy ed, 06/04/2017 11:19 AM)

h1. The page object

h1. Properties

h2. type

* directory
* item
* video

h2. contents

If type is 'directory' this can be used to hint the UI what type of items is being displayed so the UI can chose a way to layout the items.

It can be set like this:

@page.model.contents = 'yourType';@

_yourType_ can be one from the list:

> grid : preffer to represent the page as a grid
> list : (mostly default) preffer to represent the page as a list

h2. loading

Set to true if the page is loading. This is the default value. When set to true the user interface will display a throbber or similar animation telling the user that loading is in progress. Should be set to false by the plugin once the page have been filled with data.

h2. source

Source URL for video content. Only relevant if page.type is set to "video"

h2. metadata

Metadata of the current page.

Some keys most used are:
> title: Title of the current page
> logo: Image that identifies the current page
> glwview: Path to a view file that defines the UI for the current page
> background: Background of the current page
> backgroundAlpha: You can set background's alpha channel (on platforms where it's available) eg backgroundAlpha = 0.5
> backgroundAvailable: You can disable/enable background. eg backgroundAvailable=true
> font: You can change font of the items on the page

h2. options

Gives access to the object which has functions to add options to the page menu. For the functions list refer to the Settings object.

h2. entries

Number of total entries on the page when all items have been inserted. This is a must to be set in addSearcher or it will return no results even if you append items to the page by appendItem. Also it should be initialised on searcher entry as not on all platforms value is 0 on loading.

Note: A positive value in a Searcher means there are results, while 0 means there are no search results and so Movian should not add the Searcher.

h2. paginator

If a function is assigned to this property, that function will be invoked when Movian wants more items appended to the data model for, so called, paginated loading. If this property is not set Movian will assume that the plugin populates the entire model during the initial page load.

h2. asyncPaginator

Available since 4.9.105.

h2. reorderer

If a function is assigned to this property, that function will be invoked whenever an item of the pages changes position.

h1. Functions

h2. redirect(String URI);

Redirects URI call to another URI.

h2. appendItem(String URI, [String type], [Object metadata])

Append an item to the page. This should be used to populate data when page.type == 'directory'

* URI - URI to be opened when the item is activated (clicked)

* type - Type of the item

> * directory - Directory that can be browsed
> * file - Any type of file or unknown file format
> * video - Video file
> * audio - Audio track
> * image - Image that can be displayed
> * album - Collection of audio tracks
> * station - Icecast/shoutcast music station (see di.fm plugin for example)

* metadata - Additional information about the item

> Depending on the type of item, different information will be visible:

>*video* *video* : following properties are displayed
>> > * title
>> > * icon
>> > * description

>*directory* *directory* : following properties are displayed
>> > * title
>> > * icon

>*item* *item* : following properties are displayed
>> > * title
>> > * description

Returns the item object

h2. appendPassiveItem(String type, [Variable data], [Object metadata])

Appends so called, passive item to the page. These items are only used for informational purposes.

h2. appendAction(String type, String data, [Boolean enabled], [Object metadata])

Appends so called action item to the page. To display properly, do page.type = 'items'.
If 'type' == 'navopen' then data == URI (it opens URI this way. If 'type' == 'pageevent' then 'data' is event name and it is used together with page.onEvent function.

h2. onEvent(String Event, Function Handler)

Install an event handler for the current page. If event is 'null' all events will be passed to the handler. The first argument to the handler is a string with the event name.

* Event - Name of the event to associate to the handler.
* Handler - Function to be executed when event is called.

h2. flush()

Removes all items of the current page.

h2. error(String errorMessage)

A helper to switch the page in error mode and display the supplied error message.

h2. dump()

Prints dump of the property tree representing the page to the console (used while debugging plugins).

h2. getItems()

Returns object via which you can manipulate by items residing on the page.

Some properties are:
> id: id of the item