Global variables and objects
Appearance
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:
DEVICE_NAME- Contains the device name; it is set to "
[not defined]" in Elementi.
- Contains the device name; it is set to "
MULTI_SCREEN_ID- Contains the Multiscreen ID; it is set to "
fullscreen" in Elementi.
- Contains the Multiscreen ID; it is set to "
SERIAL_NUMBER- Contains the player serial number (i.e., its MAC address without the colon separator); it is set to "
[not defined]" in Elementi.
- Contains the player serial number (i.e., its MAC address without the colon separator); it is set to "
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 some 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
deviceInfoobject section below.
- Object with extended information about the device. See
document- An
SVGDocumentobject providing access to theSVGGlobalobject, to the root element from the DOM tree (document.documentElement) and to the document URI (document.documentURI).
- An
HID- Array of
HumanInterfaceDeviceobjects representing the interfaces exposed by all connected USB HID devices. See the USB I/O API page for more details.
- Array of
localStorage- Provides access to the
localStorageobject. See the Web Storage API page for more details.
- Provides access to the
sessionStorage- Provides access to the
sessionStorageobject. See the Web Storage API page for more details.
- Provides access to the
navigator- Navigator object containing the following information:
userAgent: set to “SpinetiX”spxDocumentTime: the document rendering timespxWallClock: the date and time of the contentspxNetworkClock: the date and time of the device/PCspxCloudStage: the cloud stage (e.g., “prod”) corresponding to the player/ElementispxLicenseFeatures: object containing details about the software features activated by the current license/Feature SetspxAudioPlayer: object containing details about the embedded audio player
- Navigator object containing the following information:
this- In the global execution context (outside any function),
thisrefers to the global object. See more aboutthiskeyword.
- In the global execution context (outside any function),
window- The
SVGGlobalobject 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 - seeWindowobject for more details.
- The
deviceInfo object
The deviceInfo global object contains extended information about the player, or the computer running Elementi. It is available since firmware 3.0.0.
Properties
| Property | Value |
|---|---|
deviceName
|
The player's device name or "[not defined]" in Elementi. It is identical to DEVICE_NAME global variable.
|
deviceType
|
The device hardware type, as following: |
multiScreenId
|
The player's multiscreen ID or "fullscreen" in Elementi. It is identical to MULTI_SCREEN_ID global variable.
|
serialNumber
|
The player serial number or "[not defined]" in Elementi. It is identical to SERIAL_NUMBER global variable.
|
userSerialNumber
|
The user player serial number of HMP400/W players or "null" otherwise.
|
boardSerialNumber
|
The board serial number or "null".
|
systemSerialNumber
|
The system serial number or "null".
|
chassisSerialNumber
|
The chassis serial number or "null".
|
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).
|
hostName
|
Contains the hostname of the player, respectively the PC name in Elementi. |
Functions
deviceInfo.getNetworkInterfaces()
- Function that returns an object mapping the network interfaces and their addresses. The returned object has a property for each interface (e.g., "
eth0", "eth1", etc.) whose value 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,wlanorwwan.
- Type of network interface, one of
physicalAddress- Physical address of the interface, typically a MAC address.
IPv4Addresses- Array of address objects listing all active IPv4 addresses on that interface. Each object has the following properties:
addressInterface addressnetmaskNetwork maskbroadcastBroadcast address (optional)destinationDestination address (only for modems)
- Array of address objects listing all active IPv4 addresses on that interface. Each object has the following properties:
IPv6Addresses- Array of address objects listing all active IPv6 addresses on that interface. Each object has the following properties:
addressInterface addressnetmaskNetwork mask
- Array of address objects listing all active IPv6 addresses on that interface. Each object has the following properties: