Skip to content

API methods

jxp edited this page Mar 16, 2012 · 4 revisions

PhoneGap desktop provides a number of methods to enable API functions to easily be simulated. They are divided up into three separate namespaces;

phonegapdesktop.utility

General helper methods that are not specific to phonegap desktop

mergeRecursive

Parameters; obj1 - object to copy to, obj2 - object to copy from
Perform a deep copy of properties from one object to another.

timedPopup

Parameters; left, top, width, height - %age dimensions of the popup, content - text to display in the popup, interval - length of time the message should be displayed, border - colour to use for the border, [callback] - optional function to call when message closes, [callbackParams] - parameters to pass to the callback function
Shows a simple popup message that closes after a short time.

clone

Parameters; obj - the object to clone
Creates a new object that is clone of the passed in parameter

phonegapdesktop.objects

Objects that should not be created manually in code

MediaFile

Parameters; data - object of media properties Returns a media object for use by the PhoneGap capture function

phonegapdesktop.internal

Internal function to enable PhoneGap api calls to be simulated

parseConfigFile

Parameters; fileName - the json data file to read
The file in question will be merged with the current configuration

getDebugValue

Parameters; nodeName - the section of the config file to use for this value, element - the element in the config file to use for this value
This function returns a value from the config file by use of section and element names.
If the found data is an array one value will be returned from it, otherwise the value itself will be returned. This allows API functions to return changing data (e.g. for accelerometer or gps readings)

fireEvent

Parameters; keyCode - the key pressed to trigger the event (e.g. 68 = D for Volume Down button)
Fires one of the PhoneGap phone events.

randomException

Parameters; sectionName - name of the section the exception relates to
Allows API functions to trigger random exceptions based on developer preference. e.g. gps function may regularly produce an error and this should be tested for. This can be configured globally or per section. See config page for more details.

setDynamicProperty

Parameters; obj - the object to add the property to, debugElement - section in the config file the property value should come from, debugNode - the element to read the value from in the config file. Also used as the property name on obj. Binds a dynamic property (one whose value can change) to an object.

intervalFunction

Parameters; successCallback - function to call when the interval elapses, errorCallback - function to call if an exception occurs, frequency - interval to use between each call, nodeName - section in the config file to read data from, elementName - element in the config file to read data for the successCallback, errorElement - element in the config file to read data for the errorCallback
Calls a function every x milliseconds. This returns an id for this interval function

cancelIntervalFunction

Parameters; functionID - the id for the interval function to cancel.