Apps and slots

There are two ways to start a CloudWall app programmatically: changing page URL hash using window.location.hash = URLhash, and calling cw.state.set(URLhash)

CloudWall apps are started inside slots, which are children of a DOM node, defined in config.$slots global CW config. 

Each slot also carries additional properties, describing slot app.

cw.state object

Collection of basic slot manager methods.

state.get()

Returns Slot object for current active slot.

state.set( url )

Decodes URL hash and starts app with init params passed through URL. If app is already running, switches to the running app instance.

Returns Promise resolved with Slot object.

state.slots()

Returns list of all running slots.

state.url()

Returns current state URL.

Slot object

Slot object represents running CloudWall app. Slot objects are returned on app start/switch, also cw.state.slots() returns list of Slot objects for all running apps.

slot.$app

Returns jQuery object, pointing to the app container DOM node.

slot.domid

String, id attribute of the slot DOM node.

slot.db

Points to app-bound bucket methods collection object. Methods are described more detailed in App runtime section.

slot.name

String, app name, in most cases the name is a second part of URL hash.

slot.title

String, slot title for display.

slot.busy

Boolean, value is true if slot is busy (can’t receive user interactions).

slot.initstate

Part of URL hash string, params the app was started with. In most cases is base64-encoded and may be decoded using cw.lib.fromurl64(slot.initstate).

slot.initurl

String, URL hash the app was started with.

slot.isEditor

Boolean, value is true if the app is an editor.

slot.notify( msg )

Sends a message to slot app. To receive a message an app should use 

slot.started

Number, timestamp of the moment the slot was started.

slot.url

Current URL hash of the slot. Slot URL hash generally consists of 3 parts, delimited by slash:

lab/Inliner/!WyJlZGl0IiwiMTUzNjUwMDc4MDg0eHozMnA1MWsiXQ--

Here the first part lab is the bucket. Second part Inliner is the app name. Third part is app state shortcut, it’s has fixed hard-coded format for editors and is more or less freeform for non-editors.

For editors:

 Fon non-editors: