Jump to content

Global variables and objects

From SpinetiX Wiki
Note  
This page is related to JavaScript.

Introduction

The global variables and the global objects detailed below are particular to SpinetiX platform. They can be used within the JavaScript code (<script> elements, JS files) for different purposes, like:

  • to display the device information on the screen;
  • to change the content or behavior based on a global variable value – for instance when the device name is x, display image y;
  • to access the web storage content.

For instance, the following widgets were build using the global variables:

Global variables

The following JavaScript global variables are available:

Here are some JavaScript examples, using the global variables:

 document.getElementById("MySerialNumberTextBox").textContent = SERIAL_NUMBER;
var uri = document.getElementById( "rss_uri" ).textContent + DEVICE_NAME;
 if ( MULTI_SCREEN_ID=='Tokio' ) {
   // show one type of content
 } else {
   // Show another type of content
 }

Global objects

The following JavaScript global objects are available:

  • deviceInfo
    Object with extended information about the device. See deviceInfo object section below.
  • document
    An SVGDocument object providing access to the SVGGlobal object, to the root element from the DOM tree (document.documentElement) and to the document URI (document.documentURI).
  • HID
    Array of HumanInterfaceDevice objects representing the interfaces exposed by all connected USB HID devices. See the USB I/O API page for more details.
  • localStorage
    Provides access to the localStorage object. See the Web Storage API page for more details.
  • navigator
    Navigator object containing the following information:
    • userAgent: set to “SpinetiX
    • spxDocumentTime: the document rendering time
    • spxWallClock: the date and time of the content
    • spxNetworkClock: the date and time of the device/PC
    • spxCloudStage: the cloud stage (e.g., “prod”) corresponding to the player/Elementi
    • spxLicenseFeatures: object containing details about the software features activated by the current license/Feature Set
    • spxAudioPlayer: object containing details about the embedded audio player
  • sessionStorage
    Provides access to the sessionStorage object. See the Web Storage API page for more details.
  • this
    In the global execution context (outside any function), this refers to the global object. See more about this keyword.
  • window
    The SVGGlobal object containing all the global variables mentioned on this page. When the code is run in a browser, this object may have other properties as well - see Window object for more details.

deviceInfo object

Available since 3.0.0 release.

The deviceInfo is a global object with extended information about the player, or the computer running Elementi.

It contains the following properties:

  • deviceInfo.deviceName
    Contains the device name; it is set to "[not defined]" in Elementi. It is identical to DEVICE_NAME global variable.
  • deviceInfo.deviceType
    Contains the device hardware type, which could be one of the following:
    • "ikebana" for HMP300 and HMP350
    • "Sakura" for HMP200
    • "Bonsai" for HMP130 and HMP100
    • "windows" for Elementi.
  • deviceInfo.firmwareVersion
    Contains the player's firmware or Elementi software version. It is formatted as major.minor.update-releaseBuild.number.internalBuild (where releaseBuild is 0 for betas and 1,2,3... for stable releases).
  • deviceInfo.multiScreenId
    Contains the Multiscreen ID; it is set to "fullscreen" in Elementi. It is identical to MULTI_SCREEN_ID global variable.
  • deviceInfo.serialNumber
    Contains the player serial number; it is set to "[not defined]" in Elementi. It is identical to SERIAL_NUMBER global variable.
  • deviceInfo.getNetworkInterfaces()
    Function that returns a map of all network interfaces and their addresses. The returned object has a property for each interface (e.g., "eth0", "eth1" etc.), which is an object with the following information:
    • running
      Boolean set to true when the interface's link is running
    • type
      Type of network interface, one of ethernet, modem, wlan or wwan.
    • physicalAddress
      Physical address of the interface, typically a MAC address for the form xx:xx:xx:xx:xx:xx.
    • IPv4Addresses
      Array of address objects listing all active IPv4 addresses on that interface. Each object has the following properties:
      • address Interface address
      • netmask Network mask
      • broadcast Broadcast address (optional)
      • destination Destination address (only for modems)
    • IPv6Addresses
      Array of address objects listing all active IPv6 addresses on that interface. Each object has the following properties:
      • address Interface address
      • netmask Network mask