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.
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.PortraitOrientation
or CF.LandscapeOrienation
)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 availableuniqueIdentifier
(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.machineName
(string): indicates the model type of the device. For iOS devices, this reports a manufacturers string such as iPad2,5
(iPad mini machine name). For Android, this reports the model name of the device, same as the model
property above.pushid
(string): The ID of the device for sending push notifications through our cloud. See the wiki for more documentation on push notifications.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