Global variables and objects
From SpinetiX Support Wiki
(Redirected from Global variables)
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.
Some widgets were build using the global variables, like:
Global variables
The following JavaScript global variables are available:
-
DEVICE_NAME
- Contains the HMP device name or to "
[not defined]
" in Elementi / HMD.
- Contains the HMP device name or to "
-
MULTI_SCREEN_ID
- Contains the Multiscreen ID or to "
fullscreen
" in Elementi / HMD.
- Contains the Multiscreen ID or to "
-
SERIAL_NUMBER
- Contains the HMP serial number or to "
[not defined]
" in Elementi / HMD.
- Contains the HMP serial number or 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 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 HMP device. See
deviceInfo
object below.
- Object with extended information about the HMP device. See
-
document
- An
SVGDocument
object providing access to theSVGGlobal
object, to the root element from the DOM tree (document.documentElement
) and to the document URI (document.documentURI
).
- An
-
HID
- Array of
HumanInterfaceDevice
objects representing the interfaces exposed by all connected USB HID devices. See USB I/O API for more details.
- Array of
-
localStorage
- Provides access to the
localStorage
object.
- Provides access to the
-
navigator
- Navigator object with information about the state and the identity of the user agent. When the code is not run in a browser, the
userAgent
is set to'Spinetix'
.
- Navigator object with information about the state and the identity of the user agent. When the code is not run in a browser, the
-
sessionStorage
- Provides access to the
sessionStorage
object.
- Provides access to the
-
this
- In the global execution context (outside of any function),
this
refers to the global object. See more aboutthis
keyword.
- In the global execution context (outside of any function),
-
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 - seeWindow
object for more details.
- The
deviceInfo
object
Available since 3.0.0 release.
The deviceInfo
is an global object with extended information about the HMP device, or the computer running Elementi.
It contains the following properties:
-
deviceInfo.deviceName
- Contains the HMP device name or to "
[not defined]
" in Elementi. It is identical toDEVICE_NAME
global variable.
- Contains the HMP device name or to "
-
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.
- "
- Contains the device hardware type, which could be one of the following:
-
deviceInfo.firmwareVersion
-
deviceInfo.hostName
- Contains the HMP hostname, respectively the PC name for Elementi.
-
deviceInfo.multiScreenId
- Contains the Multiscreen ID or to "
fullscreen
" in Elementi. It is identical toMULTI_SCREEN_ID
global variable.
- Contains the Multiscreen ID or to "
-
deviceInfo.serialNumber
- Contains the HMP serial number or to "
[not defined]
" in Elementi / HMD. It is identical toSERIAL_NUMBER
global variable.
- Contains the HMP serial number or to "
-
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
orwwan
.
- Type of network interface, one of
-
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)
-
- 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:
-
address
Interface address -
netmask
Network mask
-
- Array of address objects listing all active IPv6 addresses on that interface. Each object has the following properties:
-
- 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: