User Tools

Site Tools


viziapps_javascript_function_reference

ViziApps JavaScript Function Reference

This is a reference to javascript functions that can be used to enhance the operation of your app.

The Javascript namespace for all ViziApps funtions is: v. Here is the list of javascript functions that you can refer to in the Custom HTML Header or in the various places within field properties and data management where lines of JavaScript can be inserted.

v.getFieldType('field_name') Returns the field type for field_name: button, image_button, label, text_field, text_area, image, audio, table, picker, slider, alert, switch, hidden_field, photo, gps, html_panel
v.getFieldValue('field_name') Returns the string value for field_name
v.setFieldValue('field_name', field_value) Sets field_name to the given value
v.getFieldArray('field_name') Returns the array of string values for field_name. This is used with Table and Picker fields.
v.setFieldArray('field_name', array_values) Sets field_name to the given array of string values. This is used with Table and Picker fields.
v.gotoPage('page_name') Performs a page transition to page_name
v.setPickerSelectedIndex('field_name',index) Sets field_name picker to the selected index, starting with a 0 index
v.showAlert('field_name','Title…','Message…') Pops up field_name alert with a Title and a Message
v.isMobileDevice() Returns true if the app is running on a mobile device. This works for Web Apps as well as Hybrid Mobile Apps. Returns false if the app is running on a desktop such as App Preview mode.
v.getDeviceType() Returns 'android', 'iphone', 'ipod', 'ipad', or 'blackberry' if the app is running on a mobile device. This works for Web Apps as well as Hybrid Mobile Apps. Returns 'unknown' if the app is running on a desktop such as App Preview mode.
v.showField(‘field_name’) Causes the field field_name to become visible to the user.
v.hideField(‘field_name’) The field field_name will not be visible to the user.
v.showLoading() Displays a user indication of continuous loading cycle
v.hideLoading() Stops the display of continuous loading cycle
v.getGPS('lat_field_name','lng_field_name') starts GPS, puts location values into lat_field_name and lat_field_name, and continues to change the field values as location changes
v.stopGPS() Stops GPS continuous measurement reporting (which saves battery power)
v.httpRequest('url','method',params,win,fail) Calls web service url across domains: method is 'get' or 'post', params are json params, win is the success response function and fail is the error response function. The win and fail functions are called back with the response string parameter. For an example, see: In Case of CORS Errors from Mobile Devices
v.setKeychainValueForKey('key_field','value_field') Sets the value for the key in the device keychain
v.getKeychainValueForKey('key_field','value_field') Gets the value for the key in the device keychain
v.removeKeychainKey('key_field') Removes the key-value pair in the device keychain
v. isNetworkConnected() Returns true if the mobile device has a network connection, otherwise false
v.getNetworkConnectionState() Returns the device network connection state, one of: • Unknown connection • Ethernet connection • WiFi connection • Cell 2G connection • Cell 3G connection • Cell 4G connection • No network connection