Options
All
  • Public
  • Public/Protected
  • All
Menu

Module ui

Thin wrapper library for general ui operations, and easy ways to add event listeners to specific elements.

Basically this means you don't need to use the xAPI commands yourself, eg:

import ui from './ui';
ui.alert('Hello World!');

// instead of
xapi.Command.UserInterface.Message.Alert.Display({ Text: 'Hello World!' });

Also, event handling is made easier with dedicated methods, in a jquery-like fashion:

ui('my-button').onButtonClicked(() => console.log('button clicked'));

// instead of
xapi.Event.UserInterface.Extensions.Widget.Action.on((e) => {
  if (e.WidgetId === 'my-button' && e.Type === 'clicked') {
    console.log('button clicked');
  }
});

An added benefit with the event handling is that behind the scenes, only one single catch-all event listener is registered for the library. This means you don't need to worry about getting close to the system's max number of listeners.

Main parts:

This library is inspired by jQuery and https://github.com/valgaze/sugar

Index

Namespaces

Interfaces

Type aliases

Functions

Type aliases

XapiResult

XapiResult: Promise<{ result: string }>

Most api calls return a promise (except when you register for feedback)

Xml

Xml: string | { toString: any }

UI extension xml string. Can either be a string or an object with a toString() method

Device expects something looking like:

<Extensions>
  <Version>1.8</Version>
  <Panel>
  <PanelId>end-call</PanelId>
    <Type>InCall</Type>
    <Icon>Handset</Icon>
    <Color>#FF503C</Color>
    <Name>End call</Name>
    <Page>
      <Name>End call</Name>
      <Row>
      ...

Functions

ui

  • Instantiates an element that can provide event listener, eg:

    const ui = require('./ui');
    ui('my-toggle').onButtonClicked(() => console.log('clicked my button));
    

    Parameters

    • id: string

      Id (widget id, panel id, page id, etc) whichever id is relevant for the event you want to listen for.

    Returns uiElement

Generated using TypeDoc