The GAIA API

This documentation is very incomplete...
gaia
A namespace (from
gaia.js) containing some basic GAIA variables and functions:
-
gaia.arrayIntersect((a, b, func) - test if two arrays (a and b) intersect, that is, if any of the contents are equal. An optional comparison function can be given, otherwise the normal comparison operator is used ("=="). Returns a boolean value.
-
gaia.arrayToObject() - convert an array to any object.
-
gaia.clone(a) - Deep-clone an object or array.
-
gaia.createQueryString() -
-
gaia.debug - a boolean value of the state of the debug mode, used by
debuglog(). Can be set from the JavaScript console to enable/disable debugging mode. If the query parameter debug is set to a true value in the URL then debug mode is also enabled.
-
gaia.debuglog() - if debugging mode is enabled certain debugging information is printed to the JavaScript console using
gaia.log().
-
gaia.error() - send error messages to the JavaScript console if
window.console.error() exists. $ getAbsoluteElementOffset():
- gaia.getQueryParameters()
- $
getStyle():
-
gaia.isArray() - test if an object is an array.
-
gaia.log() - send information messages to the JavaScript console if
window.console.log() exists. $ gaia.rot13(): $ gaia.unique(): $ gaia.unwrapCookies():
-
gaia.warn() - send warning messages to the JavaScript console if
window.console.warn() exists.
gaiaWS
The GAIA web services namespace (from
gaia.js) is responsible for downloading metadata using the GAIA web services and making it available to GAIA JavaScript functions. It contains a number of classes
gaiaWS.Channel
A class holding the details of a GAIA data channel. It has the following public accessor functions:
- getAttribution()
- getChannelType()
- getDataRequestUrls()
- getDbid()
- getEndTime()
- getKeogramDataLocations()
- getKeogramUrl()
- getLabel()
- getPalette()
- getProject()
- getProjectDbid()
- getStartTime()
- getStation()
- getStationDbid()
- getSummaryDataLocations()
- getSummaryDataUrl()
- getThumbnailDataLocations()
- getThumbnailUrl()
- getUrls()
- hasKeograms()
- hasSummaryData()
- hasThumbnails()
- toString()
- wasOperating()
Most of these functions are self-explanatory. URLs are
strftime() format strings.
gaiaWS.ChannelOrder
gaiaWS.ChannelType
gaiaWS.Contact
gaiaWS.Continent
gaiaWS.Country
gaiaWS.DataAvailability
gaiaWS.DataLocations
gaiaWS.Institute
gaiaWS.Location
A class holding the details of a location, as used by the
gaiaWS.Node and
gaiaWS.Station classes. It has the following public accessor functions:
* getCountry()
* getLatLon()
* getLatitude()
* getLongitude()
* getPlacename()
* getState()
* toString()
State is also used for provinces (e.g, for locations in Canada).
gaiaWS.Node
gaiaWS.Orientation
gaiaWS.Palette
gaiaWS.Project
A class holding the details of a GAIA project. A project has one of more stations, represented by the class
gaiaWS.Channel, from where data is recorded. It has the following public accessor functions:
gaiaWS.Station
A class holding the details of a GAIA station, each station belongs to one GAIA project, represented by the class
gaiaWS.Project. Within a given project stations and their abbreviations are unique, however stations belonging to different projects may have the same abbreviation and even identical coordinates. Each station has one or more data channels, represented by the class
gaiaWS.Channel. It has the following public accessor functions:
- getAbbreviation()
- getChannels()
- getDbid()
- getLatLon()
- getLatitude()
- getLocation()
- getLongitude()
- getProject()
- getProjectDbid()
- isStaticLocation()
- toString()
gaiaViewer
The
gaiaViewer namespace (from
gaia_viewer.js) is responsible for providing access to the functionality of the main viewer program. (Do not confuse it with the
viewer,js script which is responsible for initialising the viewer window.) The
gaiaViewer namespace contains a number of important variables relating to the viewer:
-
gaiaViewer.state - An object holding the current state of the viewer and its tool windows. Functions may read this object but must not change it directly, use
gaiaViewer.updateState() instead. The object contains a number of properties which are described in more detail below:
-
channelOrder - an object of the class
gaiaWS.ChannelOrder, indicating how the selected channels are ordered.
-
channels - an array of objects of the class
gaiaWS.Channel. The array is ordered according to channelOrder. Used in situations where multiple channels are displayed (e.g., when the main viewer window is in overview mode).
-
mode - A string indicating the display mode of the main viewer window. Valid modes are:
overview and detailedView.
-
orientation - an object of the class
gaiaWS.Orientation, indicating how images and keograms are to be displayed.
-
palette - an object of the class
gaiaWS.Palette, indicating the colour palette used for greyscale images. See also SummaryPlotRequirements#Colour_palettes
-
selectedChannel - an object of the class
gaiaWS.Channel. Used in situations where only one channel is displayed (e.g., when the main viewer window is in detailed view mode). selectedChannel must be in the channels array.
-
time - the time for which images are displayed. In overview mode keograms are displayed from the entire day, in detailed view mode thumbnail images are displayed for the selected time.
-
gaiaViewer.previousState - An object holding the previous state of the GAIA viewer, see
gaiaViewer.state for more information about the object properties.
-
gaiaViewer.toolboxWindow - A reference to the toolbox window. The reference may be null if the window has not be opened, otherwise it may refer to a window which has since been closed, use the
closed property to check.
The namespace also contains some important functions for interacting with the viewer:
-
gaiaViewer.doCallbacks() - This function should not be called directly by user programs. It is responsible for executing the callback functions in response to state changes.
-
gaiaViewer.openToolbox() - Open the toolbox window. Usually called in response to GUI events.
-
gaiaViewer.registerCallback(window, cbFunc, states, cbFuncName) - Register a callback function to be executed whenever selected state properties change. The function takes the following arguments:
- window
- reference to the window in which the callback should operate. If
window is closed the callback function is automatically unregistered.
- cbFunc
- reference to the callback function. The function should accept a single argument, an object whose property names are the state properties which changed, and the property values are the new values for those properties.
- states
- an array listing the state properties to be monitored for changes. See
gaiaViewer.state for a description of the properties. In addition, date may be specified to monitor only changes to time which result in a change of date.
- cbFuncName
- the name of the callback function. For anonymous callback functions pass a descriptive name. Used for debugging purposes.
-
gaiaViewer.updateState(obj) - Function to modify the current state. Its single argument is an object holding the state properties to be modified, where the object property names are the viewer state properties which should be altered and the object property values are the new values for those viewer properties. When calling
gaiaViewer.updateState() do not include unchanged state properties.