Global variables and constants

iViewer defines one global variable (CF) which itselfs holds a number of variables that you can use in your script. CF also contains a number of constants to be used with several of the iViewer APIs.

CF variables summary

The Javascript interface to iViewer defines a single object: CF. All functions and variables exposed by iViewer exist in this object, so as to completely encapsulate the iViewer interface into a single object.

You are strongly advised not to change anything in the CF object. Variables are updated automatically by iViewer itself, any manual change you make to the documented variables will be overwritten. Moreover, any change you make to undocumented variables may break the interface between JavaScript and iViewer.

The CF object exposes a number of variables:

  • CF.device details about the device currently running your code
  • CF.currentPage (string) the current page name
  • CF.currentOrientation the current device orientation (CF.PortraitOrientation or CF.LandscapeOrienation)
  • CF.ipv4address (string) the device's IPv4 address
  • CF.ipv4netmask (string) the device's IPv4 subnet mask
  • CF.ipv6address (string) the device's IPv6 address
  • CF.ipv6netmask (string) the device's IPv6 subnet mask
  • CF.MACaddress (string) the device's network adapter MAC address
  • CF.networkType (string) the device's connection type
  • CF.networkSSID (string) the device's current connected network SSID when applicable
  • CF.systems (object) a object listing all the external systems listed in your GUI
  • CF.guiURL (string) the original download URL (even when GUI has been cached) for the current GUI

CF.device

Information about the current device if available in the CF.device object, which exposes the following properties:

  • platform (string): the device OS platform (i.e. "iOS")
  • version (string): the OS version (i.e. "4.3")
  • model (string): the device model (i.e. "iPad")
  • uuid (string): the device's unique ID string. On some iOS devices where the legacy unique identifier can still be retrieved, this property will contain either the legacy unique identifier (Apple's) or the iViewer-generated unique identifier, depending on against which one the license matched.
  • legacyUniqueIdentifier (string): on iOS devices only, Apple's unique device identifier if it is available
  • uniqueIdentifier (string): a unique identifier for this device, generated once by iViewer. On non-iOS devices, this is the same as the uuid property.
  • name (string): the device name. For iOS devices, the is the name set in iTunes for this device.
  • screenBrightness (number): the device's current screen brightness, a value between 0.0 and 1.0. Note that this property is always equal to 1.0 on iOS 4 as it is only supported on iOS 5 and later, and on Android platforms.
  • soundOutputVolume (number): the device's sound output volume, a number between 0.0 (muted) and 1.0 (full volume)
  • batteryLevel (number): the device battery charge level, a number between 0.0 (empty) and 1.0 (full)
  • batteryChargeStatus (enum): the device charge status. See the battery charge constants for possible values.
  • hasSensors (object): an object with boolean values for each sensor (CF.Gyroscope, CF.Accelerometer) indicating whether the sensor is supported on the current device. See the Sensors API introduction for code that detects sensor support.
  • displayDensity (number): indicates the density of the display compared to a regular display. This allows detection of Retina displays on iOS: 1.0 is standard density, 2.0 is a retina display. On Android, this value is always 1.0 for current versions of the OS and line of devices.

CF constants summary

A number of constants are defined for convenience. You use them in API calls and for comparison with current CF variables values:

Hash type constants for CF.hash():

CRC type constants for CF.crc():

Output format constants for CF.crc():

Special item index values for CF.listUpdate()

List scroll position constants for CF.listScroll()

Sensor constants - see Sensors for more info