Difference between revisions of "XBio:D Javascript Library Reference"

From xBio:D Wiki
Jump to navigation Jump to search
(Search)
(Loading the xBio:D JavaScript Library)
 
(58 intermediate revisions by one other user not shown)
Line 9: Line 9:
 
== Example ==
 
== Example ==
  
An easy way to become familiar with the xBio:D JS library is to see a simple example of a web application which uses two xBio:D methods. The first is a Google Maps widget which takes data from the OJ_Break method [[OJ_Break API Reference#getLocalities|getLocalities]] for a specified [[OJ_Break API Data Type Glossary#tnuid_2|tnuid]] and displays the data onto an interactive map. Read more about the [https://developers.google.com/maps/documentation/javascript/tutorial Google Maps JavaScript API]. The second method used in the example is a listing of included taxa for a specified tnuid by using the OJ_Break method [[OJ_Break API Reference#getIncludedTaxa|getIncludedTaxa]]. When you click on any of the linked taxa, that taxon's localities will be shown on the map, however this feature will not be explained in this bare bones example, as only the basics will be covered.
+
An easy way to become familiar with the xBio:D JS library is to see a simple example of a web application which uses two xBio:D methods. The first is a Google Maps widget which takes data from the OJ_Break method [[OJ_Break API Reference#getLocalities|getLocalities]] for a specified [[OJ_Break API Data Type Glossary#tnuid_2|tnuid]] and displays the data onto an interactive map. Read more about the [https://developers.google.com/maps/documentation/javascript/tutorial Google Maps JavaScript API]. The second method used in the example is a listing of included taxa for a specified tnuid by using the OJ_Break method [[OJ_Break API Reference#getIncludedTaxa|getIncludedTaxa]].
  
<!--[[File:Xbiodjslib.png|alt=source code for a simple xBio:D web application.|Simple example of web application.]]-->
+
[[File:wiki-test.png|alt=source code for a simple xBio:D web application.|Simple example of web application.]]
  
  1 <span style="color:purple"><!DOCTYPE HTML></span>
+
<!--  1 <span style="color:purple"><!DOCTYPE HTML></span>
 
   2 <span style="color: blue"><html></span>
 
   2 <span style="color: blue"><html></span>
 
   3 <span style="color: blue"><head></span>
 
   3 <span style="color: blue"><head></span>
   4 <span style="color: blue"><meta </span><span style="color: purple">charset</span>=<span style="color: green">"UTF-8"</span><span style="color: blue">/></span>
+
   4   <span style="color: blue"><meta </span><span style="color: purple">charset</span>=<span style="color: green">"UTF-8"</span><span style="color: blue">/></span>
   5 <span style="color: blue"><title></span>xBio:D API test<span style="color: blue"></title></span>
+
   5   <span style="color: blue"><title></span>xBio:D API Test<span style="color: blue"></title></span>
   6 <span style="color: blue"><link </span><span style="color: purple">rel</span>=<span style="color: green">"stylesheet"</span><span style="color: purple"> type</span>=<span style="color: green">"text/css"</span><span style="color: purple"> href</span>=<span style="color: green">"xbiod.css"</span><span style="color: blue">></span>
+
   6   <span style="color: blue"><link </span><span style="color: purple">rel</span>=<span style="color: green">"stylesheet"</span><span style="color: purple"> type</span>=<span style="color: green">"text/css"</span><span style="color: purple"> href</span>=<span style="color: green">"xbiod.css"</span><span style="color: blue">></span>
   7 <span style="color: blue"><script </span><span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span><span style="color: purple"> src</span>=<span style="color: green">"<nowiki>http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js</nowiki>"</span><span style="color: blue">></script></span>
+
   7   <span style="color: blue"><script </span><span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span><span style="color: purple"> src</span>=<span style="color: green">"<nowiki>http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js</nowiki>"</span><span style="color: blue">></script></span>
   8 <span style="color: blue"><script </span><span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span><span style="color: purple"> src</span>=<span style="color: green">"<nowiki>https://maps.googleapis.com/maps/api/js?sensor=false</nowiki>"</span><span style="color: blue">></script></span>
+
   8   <span style="color: blue"><script </span><span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span><span style="color: purple"> src</span>=<span style="color: green">"<nowiki>http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js</nowiki>"</span><span style="color: blue">></script></span>
   9 <span style="color: blue"><script</span> <span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span><span style="color: purple"> src</span>=<span style="color: green">"<nowiki>http://osuc.biosci.ohio-state.edu/JSLib/xbiod_lib/xbiod.js</nowiki>"</span><span style="color: blue">></span><span style="color: blue"></script></span>
+
   9   <span style="color: blue"><script </span><span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span><span style="color: purple"> src</span>=<span style="color: green">"<nowiki>https://maps.googleapis.com/maps/api/js?sensor=false</nowiki>"</span><span style="color: blue">></script></span>
10 <span style="color: blue"><script></span>
+
10    <span style="color: blue"><script</span> <span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span><span style="color: purple"> src</span>=<span style="color: green">"<nowiki>http://osuc.biosci.ohio-state.edu/JSLib/xbiod_lib/xbiod.js</nowiki>"</span><span style="color: blue">></span><span style="color: blue"></script></span>
11 <span style="color:green">// Call the loader for the current page</span>
+
11    <span style="color: blue"><script></span>
12 $(document).ready(loader);
+
  12        <span style="color:green">// Call the loader for the current page</span>
13
+
13        $(document).ready(loader);
14 <span style="color: blue">function</span> loader() {
+
14
15
+
15            <span style="color: blue">function</span> loader() {
16 <span style="color: green">// Initialize xBio:D library</span>
+
  16
17 xbiod.init([<span style="color: green">'visual'</span>,<span style="color: green">'taxon'</span>], <span style="color: green; font-style: italic">'{API_KEY}'</span>, function() {
+
  17                <span style="color: green">// Initialize xBio:D library</span>
  18 <span style="color: blue">var</span> tnuid = <span style="color: pink">605</span>;
+
  18                xbiod.init([<span style="color: green">'visual'</span>,<span style="color: green">'taxon'</span>], <span style="color: green; font-style: italic">/*API_KEY*/</span>, function() {
  19
+
19                    <span style="color: blue">var</span> tnuid = <span style="color: DarkMagenta">605</span>;
  20 <span style="color:green">// Load xBio:D components</span>
+
20
  21 <span style="color: blue">var</span> visual = <span style="color: red">new</span> xbiod.visual();
+
  21                    <span style="color:green">// Load xBio:D components</span>
22 <span style="color: blue">var</span> taxon = <span style="color: red">new</span> xbiod.taxon();
+
  22                    <span style="color: blue">var</span> visual = <span style="color: red">new</span> xbiod.visual();
23
+
23                    <span style="color: blue">var</span> taxon = <span style="color: red">new</span> xbiod.taxon();
24 <span style="color:green">// Load map</span>
+
  24
  25 visual.showGoogleMap(<span style="color: green">'map_id'</span>, tnuid);
+
  25                    <span style="color:green">// Load map</span>
  26
+
  26                    visual.showGoogleMap(<span style="color: green">'map_id'</span>, tnuid);
27 <span style="color: green">// Load included taxa</span>
+
27
28 taxon.showIncludedTaxa(<span style="color: green">'included_id'</span>, tnuid, {show_num_spms: <span style="color: green">'Y'</span>,
+
28                    <span style="color: green">// Load included taxa</span>
29                                taxonFormat: <span style="color: green">'<a href="test.html?tnuid=%tnuid%">%taxon%</a> %author% - %num_spms%'</span>
+
29                    taxon.showIncludedTaxa(<span style="color: green">'included_id'</span>, tnuid, {show_num_spms: <span style="color: green">'Y'</span>});
30 });
+
31
  31 });
+
  32                });
32 }
+
33            }
  33 <span style="color: blue"></script></span>
+
34    <span style="color: blue"></script></span>
  34    <span style="color: blue"><style </span> <span style="color: purple">type</span>=<span style="color: green">"text/css"</span><span style="color: blue">></span>
+
  35    <span style="color: blue"><style </span><span style="color: purple">type</span>=<span style="color: green">"text/css"</span><span style="color: blue">></span>
  35 html { height: <span style="color: pink">100</span>% }
+
  36        html { height: <span style="color: DarkMagenta">100%</span> }
  36 body { height: <span style="color: pink">100</span>%; margin: <span style="color: pink">0</span>; padding: <span style="color: pink">0</span> }
+
  37        body { height: <span style="color: DarkMagenta">100%</span>; margin: <span style="color: DarkMagenta">0</span>; padding: <span style="color: DarkMagenta">0</span> }
37 #map_id { height: <span style="color: pink">50</span>% }
+
  38        #map_id { height: <span style="color: DarkMagenta">50%</span> }
  38 #included_id { height: <span style="color: pink">50</span>% }
+
  39        #included_id { height: <span style="color: DarkMagenta">100%</span> }
  39    <span style="color: blue"></style></span>
+
40    <span style="color: blue"></style></span>
40 <span style="color: blue"></head></span>
+
41 <span style="color: blue"></head></span>
  41 <span style="color: blue"><body></span>
+
42 <span style="color: blue"><body></span>
  42 <span style="color: blue"><div </span><span style="color: purple">id</span>=<span style="color: green">"map_id"</span><span style="color: blue">/></span>
+
  43   <span style="color: blue"><div </span><span style="color: purple">id</span>=<span style="color: green">"map_id"</span><span style="color: blue">/></span>
  43 <span style="color: blue"><div </span><span style="color: purple">id</span>=<span style="color: green">"included_id"</span><span style="color: blue">/></span>
+
  44   <span style="color: blue"><div </span><span style="color: purple">id</span>=<span style="color: green">"included_id"</span><span style="color: blue">/></span>
  44 <span style="color: blue"></body></span>
+
45 <span style="color: blue"></body></span>
45 <span style="color: blue"></html></span>
+
46 <span style="color: blue"></html></span>-->
 
 
[http://osuc.biosci.ohio-state.edu/JSLib/xbiod_lib/test.html View simple example here (test.html)]
 
  
  
Line 65: Line 63:
 
* The '''<!DOCTYPE html>''' tag is necessary for HTML 5 applications (line 1)
 
* The '''<!DOCTYPE html>''' tag is necessary for HTML 5 applications (line 1)
 
* Jquery 1.8 library is included with a '''<script>''' tag (line 7)  
 
* Jquery 1.8 library is included with a '''<script>''' tag (line 7)  
* The Google Map API JavaScript library is included with a '''<script>''' tag (line 8)
+
* Jquery UI 1.10.4 library is included with a '''<script>''' tag (line 8)
* The xBio:D JS library is included with a '''<script>''' tag (line 9)
+
* The Google Map API JavaScript library is included with a '''<script>''' tag (line 9)
* A function called ''loader'' intializes the xBio:D resources when the web page has finished loading (line 14)
+
* The xBio:D JS library is included with a '''<script>''' tag (line 10)
* Two objects where created to access the xBio:D components called ''visual'' and ''taxon'' (line 21 - 22)
+
* A function called ''loader'' intializes the xBio:D resources when the web page has finished loading (line 15)
* The applications are created by calling there respective methods via the xBio:D library components (line 25 & 28 - 29)
+
* Two objects where created to access the xBio:D components called ''visual'' and ''taxon'' (line 22 - 23)
* In the '''<body>''' there are two '''<nowiki><div></nowiki>''' elements which create areas to hold the widgets. The first is called ''map_id'' and the second is ''included_id''. (line 42 - 43)
+
* The applications are created by calling there respective methods via the xBio:D library components (line 26 & 29 - 30)
 +
* In the '''<body>''' there are two '''<nowiki><div></nowiki>''' elements which create areas to hold the widgets. The first is called ''map_id'' and the second is ''included_id''. (line 43 - 44)
  
  
Line 92: Line 91:
  
 
=== Loading the xBio:D JavaScript Library ===
 
=== Loading the xBio:D JavaScript Library ===
  <span style="color: blue"><script </span><span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span> <span style="color: purple">src</span>=<span style="color: green"><nowiki>"http://osuc.biosci.ohio-state.edu/JSLib/xbiod_lib/xbiod.js"</nowiki></span><span style="color: blue">></script></span>
+
  <span style="color: blue"><script </span><span style="color: purple">type</span>=<span style="color: green">"text/javascript"</span> <span style="color: purple">src</span>=<span style="color: green"><nowiki>"http://xbiod.osu.edu/xbiod_lib/xbiod.js"</nowiki></span><span style="color: blue">></script></span>
  
 
The URL in the '''<script>''' tage above is the location of the xBio:D JavaScript Library which is a required file for this simple example and any web application that will be using xBio:D applications.
 
The URL in the '''<script>''' tage above is the location of the xBio:D JavaScript Library which is a required file for this simple example and any web application that will be using xBio:D applications.
Line 102: Line 101:
 
         <span style="color: blue">function</span> loader() {<br>
 
         <span style="color: blue">function</span> loader() {<br>
 
             <span style="color: green">// Initialize xBio:D library</span>
 
             <span style="color: green">// Initialize xBio:D library</span>
             xbiod.init([<span style="color: green">'visual'</span>,<span style="color: green">'taxon'</span>], <span style="color: green; font-style: italic">'{API_KEY}'</span>, function(){
+
             xbiod.init([<span style="color: green">'visual'</span>,<span style="color: green">'taxon'</span>], <span style="color: green; font-style: italic">/*API_KEY*/</span>, function(){
  
 
To begin using the xBio:D library, first the components need to be loaded. This is done through the xBio:D ''init'' function which takes three parameters: an array of the components to be loaded, an API access key, and a callback function. In this example, the '''visual''' and '''taxon''' resources are passed to the ''init'' function for loading (all resources and their methods can be found in the [[XBio:D Javascript Library Reference#Reference|Reference]] section below). This example also shows where a user would provide an OJ_Break API access key. See [[OJ_Break API Access]] for more information on access keys. Lastly, a callback method needs to be provided which will create the component objects.
 
To begin using the xBio:D library, first the components need to be loaded. This is done through the xBio:D ''init'' function which takes three parameters: an array of the components to be loaded, an API access key, and a callback function. In this example, the '''visual''' and '''taxon''' resources are passed to the ''init'' function for loading (all resources and their methods can be found in the [[XBio:D Javascript Library Reference#Reference|Reference]] section below). This example also shows where a user would provide an OJ_Break API access key. See [[OJ_Break API Access]] for more information on access keys. Lastly, a callback method needs to be provided which will create the component objects.
Line 111: Line 110:
 
  <span style="color: blue">var</span> taxon = <span style="color: red">new</span> xbiod.taxon();
 
  <span style="color: blue">var</span> taxon = <span style="color: red">new</span> xbiod.taxon();
  
An object derived from a namespace is instatiated using the '''new''' keyword and a namespace's constructor. The JavaScript namespace that represents the xBio:D visual applications is the '''visual''' namespace/component and similarly the namespace that represents the xBio:D taxon applications is the '''taxon''' namespace/component. Access to functionality from either of these components requires an object with a reference to that component. These objects allow methods from each component to be called to the web page.
+
An object derived from a class is instatiated using the '''new''' keyword and a namespace's constructor. The JavaScript namespace that represents the xBio:D visual applications is the '''visual''' namespace/component and similarly the namespace that represents the xBio:D taxon applications is the '''taxon''' namespace/component. Access to functionality from either of these components requires an object with a reference to that component. These objects allow methods from each component to be called to the web page.
  
 
==== Calling Application Methods ====
 
==== Calling Application Methods ====
Line 122: Line 121:
 
Each application has a method associated with it which takes several parameters which will dictate what data it loads, where it will be contained, and options for how it should be presented. These methods and requirements can be found in the [[XBio:D Javascript Library Reference#Reference|Reference]] section.
 
Each application has a method associated with it which takes several parameters which will dictate what data it loads, where it will be contained, and options for how it should be presented. These methods and requirements can be found in the [[XBio:D Javascript Library Reference#Reference|Reference]] section.
  
In the above example, the '''visual''' method ''showGoogleMap'' gets passed a '''<nowiki><div></nowiki>''' element id string which decides where it will be contained and a tnuid which will dictate which taxon data the map will locate.
+
In the above example, the '''visual''' method ''showGoogleMap'' gets passed a '''<nowiki><div></nowiki>''' element ID string which decides where it will be contained and a tnuid which will dictate which taxon data the map will locate.
  
The '''taxon''' method ''showIncludedTaxa'' gets passed similar parameters (a specified '''<nowiki><div></nowiki>''' element id string and a tnuid) however it also gets additional options in the form of a [http://www.w3schools.com/js/js_objects.asp JavaScript object literal]. In this example, the option ''[[OJ_Break API Data Type Glossary#show_num_spms|show_num_spms]]'' is given the [[OJ Break API Data Type Glossary#Boolean_Flag| Boolean_flag]] 'Y' signifying that the application should display the number of specimens for that particular taxon and ''taxonFormat'' is assigned to present the data as links using the '''<a>''' tag.
+
The '''taxon''' method ''showIncludedTaxa'' gets passed similar parameters (a specified '''<nowiki><div></nowiki>''' element ID string and a tnuid) however it also gets additional options in the form of a [http://www.w3schools.com/js/js_objects.asp JavaScript object literal]. In this example, the option ''[[OJ_Break API Data Type Glossary#show_num_spms|show_num_spms]]'' is given the [[OJ Break API Data Type Glossary#Boolean_Flag| Boolean_flag]] 'Y' signifying that the application should display the number of specimens for that particular taxon and ''taxonFormat'' is assigned to present the data as links using the '''<a>''' tag.
  
 
==== Element Containers ====
 
==== Element Containers ====
Each method requires one or more unique '''<nowiki><div></nowiki>''' tag ids as string parameters (seen in the example '''<body>''' below). This will be used to specify where the resource will be contained in the web page.
+
Each method requires one or more unique '''<nowiki><div></nowiki>''' tag IDs as string parameters (seen in the example '''<body>''' below). This will be used to specify where the resource will be contained in the web page.
  
 
  <span style="color: blue"><body></span>
 
  <span style="color: blue"><body></span>
Line 135: Line 134:
  
 
== Reference ==
 
== Reference ==
=== Person ===
+
=== Agent ===
==== showCollectingTripLocalityInfo ====
+
==== showAgentInfo ====
 
===== Description =====
 
===== Description =====
Displays the locality info for a certain person's collecting trip.
+
Displays information about an agent, including name, contact information, and a short biography.
 
===== Parameters =====
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
* loc_id ([[OJ_Break API Data Type Glossary#loc_id_2|?]])
+
* [[OJ_Break v2 Agent Reference#agent_id|agent_id]]
* per_id ([[OJ_Break API Data Type Glossary#per_id_2|?]])
 
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* widget_options - Object
* inst_id ([[OJ_Break API Data Type Glossary#inst_id_2|?]])
 
* pnid ([[OJ_Break API Data Type Glossary#pnid_2|?]])
 
* showChildren ([[OJ_Break API Data Type Glossary#showChildren|?]])
 
* completeSpmInfo - Boolean_flag
 
* generalFormat - string
 
  
==== showCollectingTrips ====
+
==== showAgentOccurrences ====
 
===== Description =====
 
===== Description =====
Displays collecting trips for a specified collector.
+
Displays collected occurrences for a specified agent on a Google Map. Creates two windows.
 
===== Parameters =====
 
===== Parameters =====
* trips_element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
* map_element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* agent_id ([[OJ_Break API Data Type Glossary#collector_id_2|?]])
* collector_id ([[OJ_Break API Data Type Glossary#collector_id_2|?]])
 
 
* options
 
* options
  
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* info_element_id - ID String (defaults to element_id parameter)
 +
* generalFormat - HTML String
 +
* markers - String ('spiderfy' or undefined). Requires additional dependencies (see below).
 +
* offset - Number
 +
* limit - Number
 +
* icons - Object
 +
* widget_options
 +
 
 
===== Additional Requirements =====
 
===== Additional Requirements =====
 
* [https://developers.google.com/maps/documentation/javascript/ Google Maps API v3]
 
* [https://developers.google.com/maps/documentation/javascript/ Google Maps API v3]
* [http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/reference.html MarkerClusterer]
+
* [https://github.com/jawj/OverlappingMarkerSpiderfier Overlapping Marker Spiderfier]
 +
 
 +
==== showAgentOccurrenceLocalityInfo ====
 +
===== Description =====
 +
Displays locality information for a certain agent's collecting occurrence.
 +
===== Parameters =====
 +
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 +
* loc_id ([[OJ_Break API Data Type Glossary#loc_id_2|?]])
 +
* options
 +
===== Options =====
 +
None
  
 
==== showDescribedTaxa ====
 
==== showDescribedTaxa ====
 
===== Description =====
 
===== Description =====
Displays all taxa described by the specified author.
+
Displays all taxa described by the specified agent.
 
===== Parameters =====
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
Line 175: Line 184:
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* taxonFormat - string
+
* taxonFormat - String
 +
* useTaxonItalics - Boolean
 +
* limit - Number
 +
* offset - Number
 +
* widget_options - Object
  
 
==== showPublications ====
 
==== showPublications ====
 
===== Description =====
 
===== Description =====
Displays all publications for a particular author.
+
Displays all publications for a specified agent.
 
===== Parameters =====
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
Line 185: Line 198:
 
* options
 
* options
 
===== Options =====
 
===== Options =====
None
+
* limit - Number
 
+
* offset - Number
 +
* widget_options - Object
  
=== Record ===
+
=== Occurrence ===
 
==== showBiologicalInfo ====
 
==== showBiologicalInfo ====
 
===== Description =====
 
===== Description =====
Displays both the habitat and associations for a selected occurrence identifier (cuid).
+
Displays both the habitat and associations for a selected occurrence identifier.
  
 
===== Parameters =====
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
* cuid ([[OJ_Break API Data Type Glossary#cuid_2|?]])
+
* occurrence_id ([[OJ_Break API Data Type Glossary#occurrence_id|?]])
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* widget_options - Object
  
==== showCollectingTripsInfo ====
+
==== showOccurrenceInfo ====
 
===== Description =====
 
===== Description =====
 
Displays collecting trip info for a specified occurrence.
 
Displays collecting trip info for a specified occurrence.
 
===== Parameters =====
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
* cuid ([[OJ_Break API Data Type Glossary#cuid_2|?]])
+
* occurrence_id ([[OJ_Break API Data Type Glossary#occurrence_id|?]])
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* widget_options - Object
  
 
==== showDeterminations ====
 
==== showDeterminations ====
Line 215: Line 229:
 
===== Parameters =====
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
* cuid ([[OJ_Break API Data Type Glossary#cuid_2|?]])
+
* occurrence_id ([[OJ_Break API Data Type Glossary#occurrence_id|?]])
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* widget_options - Object
  
 
==== showLocalityInfo ====
 
==== showLocalityInfo ====
Line 225: Line 239:
 
===== Parameters =====
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
* cuid ([[OJ_Break API Data Type Glossary#cuid_2|?]])
+
* occurrence_id ([[OJ_Break API Data Type Glossary#occurrence_id|?]])
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* widget_options - Object
  
 
==== showSpecimenInfo ====
 
==== showSpecimenInfo ====
Line 235: Line 249:
 
===== Parameters =====
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
* cuid ([[OJ_Break API Data Type Glossary#cuid_2|?]])
+
* occurrence_id ([[OJ_Break API Data Type Glossary#occurrence_id|?]])
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* widget_options - Object
 
 
  
 
=== Search ===
 
=== Search ===
 
==== showSearch ====
 
==== showSearch ====
 
===== Description =====
 
===== Description =====
A JQuery UI autocomplete search bar which can search for taxa, cuids, institutions, agents, journals, organizations, collecting methods, localities, and places.
+
A JQuery UI autocomplete search bar which can search for taxa, occurrences, institutions, agents, journals, localities, and places.
 +
 
 
===== Parameters =====
 
===== Parameters =====
 
* element_id
 
* element_id
Line 250: Line 264:
  
 
===== Options =====
 
===== Options =====
* category - array of string (NOTE: will need to add a handler option for each category; need to change the form to -> ''type:'taxon', handler_url:'http://blah' '' for each category)
+
* search - the type of search to execute. Controls the passing of URL parameters to methods. Can be specified a either 'id' or 'name'. Defaults to 'id'
* handler_url - a URL that will be passed the ID of the selected search option
+
* domains - array of the below object elements
 +
** type - a domain keyword for which data gets searched for
 +
** handler_url - a URL that will be passed the ID of the selected type option
  
===== Additional Requirements =====
+
===== Additional Information =====
* [http://jqueryui.com/ JQuery UI v1.10.4+]
+
====== Category Options Formatting ======
 +
Below is an example of how the categories should be input:
  
===== Additional Information =====
+
<span style="color:green;">// Load search</span>
Below is a list of available category keywords that the ''category'' array option can take (Note: the keyword spelling must match exactly what is seen below):
+
search.showSearch(<span style="color:green">'search_id'</span>, {domains: [{type: <span style="color: green">'taxon'</span>, handler_url: <span style="color: green">'<nowiki>http://domain.url/index.html</nowiki>'</span>}, {type: <span style="color: green">'occurrence'</span>, handler_url: <span style="color: green">'<nowiki>http://domain.url/occurrence.html</nowiki>'</span>}]});
* all - (if 'all' is chosen, it must be the only keyword chosen)
 
* taxa
 
* cuids
 
* inst
 
* agents
 
* journals
 
* orgs
 
* coll_methods
 
* locs
 
* places
 
  
 
=== Taxon ===
 
=== Taxon ===
Line 274: Line 281:
 
Displays all associations for a specified taxon.
 
Displays all associations for a specified taxon.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* rank_grouping - string
+
* basic_only - Boolean_flag
* taxonFormat - string
+
* limit - Number
 +
* offset - Number
 +
* widget_options
  
==== showCollections ====
+
==== showInstitutions ====
 
===== Description =====
 
===== Description =====
Displays all collections for which specimen of the selected taxon belong.
+
Displays institutions for which specimens of the selected taxon level belong.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* limit - Number
 
+
* offset - Number
==== showCollectingMethods ====
+
* widget_options - Object
===== Description =====
 
Displays all the collecting methods performed to collect a specified taxon.
 
===== Parameters =====
 
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
 
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
 
* options
 
===== Options =====
 
* generalFormat - string
 
  
 
==== showContributors ====
 
==== showContributors ====
 
===== Description =====
 
===== Description =====
Displays all contributors related to the occurrence, taxonomy, literature, and media of a taxon.
+
Displays all contributing agents related to the occurrence, taxonomy, literature, and media of a taxon.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* inst_id ([[OJ_Break API Data Type Glossary#inst_id_2|?]])
+
* inst_id
* generalFormat - string
+
* widget_options
  
 
==== showDeterminers ====
 
==== showDeterminers ====
Line 316: Line 317:
 
Displays determiners for a specified taxon.
 
Displays determiners for a specified taxon.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* limit - Number
 +
* offset - Number
 +
* inst_id
 +
* widget_options
  
 
==== showHabitats ====
 
==== showHabitats ====
Line 326: Line 330:
 
Displays all identified habitats for a selected taxon.
 
Displays all identified habitats for a selected taxon.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* generalFormat - string
+
* limit - Number
 +
* offset - Number
 +
* widget_options
  
 
==== showIncludedTaxa ====
 
==== showIncludedTaxa ====
Line 336: Line 342:
 
Displays taxa directly included within a taxon but not synonymous with it.
 
Displays taxa directly included within a taxon but not synonymous with it.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* inst_id ([[OJ_Break API Data Type Glossary#inst_id|?]])
+
* inst_id
* showSyns ([[OJ_Break API Data Type Glossary#showSyns|?]])
+
* show_syns
* showFossils ([[OJ_Break API Data Type Glossary#showFossils|?]])
+
* show_fossiles
* types_only ([[OJ_Break API Data Type Glossary#types_only|?]])
+
* types_only
* show_num_spms ([[OJ_Break API Data Type Glossary#show_num_spms|?]])
+
* useTaxonItalics - Boolean
* taxonFormat - string
+
* limit - Number
* useTaxonItalics - boolean
+
* offset - Number
 +
* widget_options
  
 
==== showLiterature ====
 
==== showLiterature ====
Line 352: Line 359:
 
Displays relevent publications for a specified taxon with links to the literature when available.
 
Displays relevent publications for a specified taxon with links to the literature when available.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* showSyns ([[OJ_Break API Data Type Glossary#showSyns|?]])
+
* show_children - Boolean_flag
* taxonFormat - string
+
* show_bib - Boolean_flag
* useTaxonItalics - boolean
+
* useTaxonItalics - Boolean
 +
* limit - Number
 +
* offset - Number
 +
* widget_options
  
 
==== showSubordinateTaxa ====
 
==== showSubordinateTaxa ====
 
===== Description =====
 
===== Description =====
Displays the count of valid taxa groups available below the current taxon rank.
+
Displays the count of valid taxa levels available below the current taxon rank.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* inst_id ([[OJ_Break API Data Type Glossary#inst_id_2|?]])
+
* inst_id
* generalFormat - string
+
* widget_options
  
 
==== showSynonyms ====
 
==== showSynonyms ====
Line 375: Line 385:
 
Displays all taxa which are objectively or subjectively synonymous with a selected taxon.
 
Displays all taxa which are objectively or subjectively synonymous with a selected taxon.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* showFossils ([[OJ_Break API Data Type Glossary#showFossils|?]])
+
* show_fossils
* taxonFormat - string
 
 
* useTaxonItalics - boolean
 
* useTaxonItalics - boolean
 +
* limit - Number
 +
* offset - Number
 +
* widget_options
  
==== showTaxonImages ====
+
==== showTaxonMedia ====
 
===== Description =====
 
===== Description =====
Displays a table of all images associated to a specific taxon.
+
Displays a table of all media associated to a specific taxon rank.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* type - string
+
* inst_id
* taxonFormat - string
+
* row_count - Number
 +
* media_type
 +
* limit - Number
 +
* offset - Number
 +
* widget_options
  
 
==== showTypes ====
 
==== showTypes ====
Line 398: Line 414:
 
Displays information and specimen types for a specified taxon.
 
Displays information and specimen types for a specified taxon.
 
===== Parameters =====
 
===== Parameters =====
* element_id ([[xBio:D Javascript Library Reference#Element_Containers|?]])
+
* [[xBio:D Javascript Library Reference#Element_Containers|element_id]]
* tnuid ([[OJ_Break API Data Type Glossary#tnuid_2|?]])
+
* tnuid
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* showSyns ([[OJ_Break API Data Type Glossary#showSyns|?]])
+
* show_children
* inst_id ([[OJ_Break API Data Type Glossary#inst_id|?]])
+
* inst_id
 
* primary_only - Boolean_flag
 
* primary_only - Boolean_flag
* taxon_author_search - string
+
* basic_only - Boolean_flag
 
* offset - number
 
* offset - number
 
* limit - number
 
* limit - number
 
* useTaxonItalics - boolean
 
* useTaxonItalics - boolean
* taxonFormat - string
+
* widget_options
 
 
  
 
=== Visual ===
 
=== Visual ===
Line 421: Line 436:
 
* options
 
* options
 
===== Options =====
 
===== Options =====
* pnids ([[OJ_Break API Data Type Glossary#pnid_2|?]]) - array of number
+
* place_id - Number
* inst_id ([[OJ_Break API Data Type Glossary#inst_id_2|?]])
+
* inst_id - Number
* precDecimals ([[OJ_Break API Data Type Glossary#precDecimals|?]])
+
* use_sex_icons - Boolean_flag
* showChildren ([[OJ_Break API Data Type Glossary#showChildren|?]])
+
* show_children - Boolean_flag
 +
* limit - Number
 +
* offset - Number
 +
* markers - Number
 +
* widget_options - Object
  
 
===== Additional Requirements =====
 
===== Additional Requirements =====
 
* [https://developers.google.com/maps/documentation/javascript/ Google Maps API v3]
 
* [https://developers.google.com/maps/documentation/javascript/ Google Maps API v3]
 +
* [https://github.com/jawj/OverlappingMarkerSpiderfier Overlapping Marker Spiderfier]
  
 
==== showTaxonHierarchy ====
 
==== showTaxonHierarchy ====
Line 439: Line 459:
  
 
===== Options =====
 
===== Options =====
* show_num_spms ([[OJ_Break API Data Type Glossary#show_num_spms|?]])
+
* show_num_spms - Boolean_flag
* inst_id ([[OJ_Break API Data Type Glossary#inst_id_2|?]])
+
* inst_id - Number
* showSyns ([[OJ_Break API Data Type Glossary#showSyns|?]])
+
* show_syns - Boolean_flag
* showFossils ([[OJ_Break API Data Type Glossary#showFossils|?]])
+
* show_fossils - Boolean_flag
* typesOnly ([[OJ_Break API Data Type Glossary#typesOnly|?]])
+
* types_only - Boolean_flag
* node_color - string or hexadecimal number
+
* nodeColor - string or hexadecimal number
* background_color - string or hexadecimal number
+
* backgroundColor - string or hexadecimal number
* handler_url - URL string
+
* handler_url - File path string/URL
 +
* size - JavaScript object with two string properties:
 +
** width - either a number or string in pixels
 +
** height - either a number of string in pixels
 +
* imagePath - string of relative path to a folder containing necessary images.
 +
* widget_options - Object
  
 
===== Additional Requirements =====
 
===== Additional Requirements =====
Line 452: Line 477:
 
* Pass requestedNode parameter a value of '''null''' when calling function. See below:
 
* Pass requestedNode parameter a value of '''null''' when calling function. See below:
 
  <span style="color:green;">// Load taxon hierarchy</span>
 
  <span style="color:green;">// Load taxon hierarchy</span>
  visual.showTaxonHierarchy(<span style="color:green">'canvas_id'</span>, tnuid, <span style="color: red;">null</span>, {backgroundColor: <span style="color: green">'black'</span>});
+
  visual.showTaxonHierarchy(<span style="color:green">'canvas_id'</span>, tnuid, <span style="color: red;">null</span>, {<span style="color: green;"> /*options*/ </span>});
  
 
===== Additional Information =====
 
===== Additional Information =====
====== Valid Color Options ======  
+
====== URL Handler Option ======
Below is a list of the available colors that can be used as the background or node color:
+
The ''handler_url'' option can be used to allow the nodes to have links attached to them, so that a user may follow the link for more information on that specific taxon.
* red
 
* scarlet
 
* orange
 
* yellow
 
* green
 
* blue
 
* cyan
 
* violet
 
* purple
 
* grey/gray
 
* white
 
* black
 
  
====== URL Handler ======
+
<span style="color:green;">// Load taxon hierarchy</span>
The ''handler_url'' option can be used to allow the nodes to have links attached to them, so that a user may follow the link for more information on that specific taxon.
+
visual.showTaxonHierarchy(<span style="color:green">'canvas_id'</span>, tnuid, <span style="color: red;">null</span>, {nodeColor: <span style="color: green">'cyan'</span>, backgroundColor: <span style="color: green">'#FFFFFF'</span>, handler_url: <span style="color: green">'<nowiki>http://hol.osu.edu/index.html</nowiki>'</span>});
 +
 
 +
In this example, a default web page URL is given (note the use of http:// at the beginning). When provided a URL, the taxon hierachy animation will present a link button to the top right of the node that is currently being highlighted (see image below). This link will not be present if a URL is not specified. If this button is clicked, the ''handler_url'' link will be followed.
 +
 
 +
====== Size Option ======
 +
The taxon hierarchy application can be resized in one of two ways: via [http://en.wikipedia.org/wiki/Cascading_Style_Sheets CSS] (preferred) or by inputting the dimensions of the HTML canvas into the API method call as options. One way this can be done is by specifying the width and height as numbers:
 +
 
 +
<span style="color:green;">// Load taxon hierarchy</span>
 +
visual.showTaxonHierarchy(<span style="color:green">'canvas_id'</span>, tnuid, <span style="color: red;">null</span>, {size: {width: <span style="color:purple;">300</span>, height: <span style="color:purple;">900</span>}});
 +
 
 +
The dimensions of the canvas can also be input as pixels:
  
 
  <span style="color:green;">// Load taxon hierarchy</span>
 
  <span style="color:green;">// Load taxon hierarchy</span>
  visual.showTaxonHierarchy(<span style="color:green">'canvas_id'</span>, tnuid, <span style="color: red;">null</span>, {backgroundColor: <span style="color: green">'black'</span>, handler_url: <span style="color: green">'<nowiki>http://hol.osu.edu/index.html</nowiki>'</span>});
+
  visual.showTaxonHierarchy(<span style="color:green">'canvas_id'</span>, tnuid, <span style="color: red;">null</span>, {size: {width: <span style="color:green;">"300px"</span>, height: <span style="color:green;">"900px"</span>}});
  
In this example, a default web page URL is given (note the use of http:// at the beginning). Once provided a URL, the taxon hierachy animation will present a link button to the top right of the node that is currently being highlighted (see image below).  
+
Both of these methods (CSS and parameter passing) are valid, but they should never both be used at the same time since unexpected errors may occur.
  
[[File:link_button_tut.png]]
+
====== Image Path Option ======
 +
Due to security restrictions, Processingjs is limited in its function to request images. As a consequence, any user wishing to use the animation must have copies of the required images available locally on their server. To access these images, a relative directory path must be input in the form of a optional parameter. The call may look something like this:
  
If this button is clicked, the ''tnuid'' of the taxon will be appended to the ''handler_url'' and will be followed.
+
<span style="color:green;">// Load taxon hierarchy</span>
 +
visual.showTaxonHierarchy(<span style="color:green">'canvas_id'</span>, tnuid, <span style="color: red;">null</span>, {imagePath: <span style="color:green">"media/images/"</span>});
  
 
<hr>
 
<hr>

Latest revision as of 19:33, 22 July 2015

Introduction

The xBio:D JavaScript library offers the functionality to create rich, dynamic, and interactive features for use with the OJ_Break API. The OJ_Break API provides procedures to retrieve data within the xBio:D database, and the xBio:D JS library is how that data gets presented. Users planning on working with the xBio:D JS library should be familiar with JavaScript programming and object-oriented programming.

Contents

API Access

All functionality in the xBio:D JS library depends on access of data from the OJ_Break API. See OJ_Break API Access for an overview of the API and how to obtain an API access key.

Example

An easy way to become familiar with the xBio:D JS library is to see a simple example of a web application which uses two xBio:D methods. The first is a Google Maps widget which takes data from the OJ_Break method getLocalities for a specified tnuid and displays the data onto an interactive map. Read more about the Google Maps JavaScript API. The second method used in the example is a listing of included taxa for a specified tnuid by using the OJ_Break method getIncludedTaxa.

Simple example of web application.


There are a few things to note about this example:

  • The <!DOCTYPE html> tag is necessary for HTML 5 applications (line 1)
  • Jquery 1.8 library is included with a <script> tag (line 7)
  • Jquery UI 1.10.4 library is included with a <script> tag (line 8)
  • The Google Map API JavaScript library is included with a <script> tag (line 9)
  • The xBio:D JS library is included with a <script> tag (line 10)
  • A function called loader intializes the xBio:D resources when the web page has finished loading (line 15)
  • Two objects where created to access the xBio:D components called visual and taxon (line 22 - 23)
  • The applications are created by calling there respective methods via the xBio:D library components (line 26 & 29 - 30)
  • In the <body> there are two <div> elements which create areas to hold the widgets. The first is called map_id and the second is included_id. (line 43 - 44)


These steps will be explained below.


Declaring Application as HTML 5

It is recommended for any web application to be declared as a true DOCTYPE. This can easily be done by using the HTML 5 DOCTYPE as seen below. This allows the application to be more cross-browser compliant. Please refer to the Google Maps Documentation on HTML 5 for more info.

<!DOCTYPE html>

Loading JQuery Library

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>

The URL in the <script> tag above is the location of the JavaScript file which allows JQuery 1.8 to run on the web application. JQuery is used in the xBio:D JS library to get methods from the OJ_Break API and other scripts. It is a necessary component of any web app that intends to use xBio:D functionality.

Loading the Google Maps API

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>

The URL in the <script> tag above is the location of the JavaScript file which will load all the necessary defintions to allow access to the Maps API. Normally, an access key would need to be provided in order to use the Maps library. See Loading the Maps API for more info. This script file is necessary for web apps that use Google Maps as part of the application. It is a necessary file to have in this simple example, but is not required for all xBio:D applications.

Loading the xBio:D JavaScript Library

<script type="text/javascript" src="http://xbiod.osu.edu/xbiod_lib/xbiod.js"></script>

The URL in the <script> tage above is the location of the xBio:D JavaScript Library which is a required file for this simple example and any web application that will be using xBio:D applications.

Initializing the xBio:D JS Library

<script>
    // Call the loader for the current page
    $(document).ready(loader);
function loader() {
// Initialize xBio:D library xbiod.init(['visual','taxon'], /*API_KEY*/, function(){

To begin using the xBio:D library, first the components need to be loaded. This is done through the xBio:D init function which takes three parameters: an array of the components to be loaded, an API access key, and a callback function. In this example, the visual and taxon resources are passed to the init function for loading (all resources and their methods can be found in the Reference section below). This example also shows where a user would provide an OJ_Break API access key. See OJ_Break API Access for more information on access keys. Lastly, a callback method needs to be provided which will create the component objects.

Component Objects

// Load xBio:D components
var visual = new xbiod.visual();
var taxon = new xbiod.taxon();

An object derived from a class is instatiated using the new keyword and a namespace's constructor. The JavaScript namespace that represents the xBio:D visual applications is the visual namespace/component and similarly the namespace that represents the xBio:D taxon applications is the taxon namespace/component. Access to functionality from either of these components requires an object with a reference to that component. These objects allow methods from each component to be called to the web page.

Calling Application Methods

// Load map
visual.showGoogleMap('map_id', tnuid);
		
// Load included taxa
taxon.showIncludedTaxa('included_id', tnuid, {show_num_spms: 'Y', taxonFormat: '<a href="test.html?tnuid=%tnuid%">%taxon%</a> %author% - %num_spms%'});

Each application has a method associated with it which takes several parameters which will dictate what data it loads, where it will be contained, and options for how it should be presented. These methods and requirements can be found in the Reference section.

In the above example, the visual method showGoogleMap gets passed a <div> element ID string which decides where it will be contained and a tnuid which will dictate which taxon data the map will locate.

The taxon method showIncludedTaxa gets passed similar parameters (a specified <div> element ID string and a tnuid) however it also gets additional options in the form of a JavaScript object literal. In this example, the option show_num_spms is given the Boolean_flag 'Y' signifying that the application should display the number of specimens for that particular taxon and taxonFormat is assigned to present the data as links using the <a> tag.

Element Containers

Each method requires one or more unique <div> tag IDs as string parameters (seen in the example <body> below). This will be used to specify where the resource will be contained in the web page.

<body>
    <div id="map_id"/>
    <div id="included_id"/>
</body>

Reference

Agent

showAgentInfo

Description

Displays information about an agent, including name, contact information, and a short biography.

Parameters
Options
  • widget_options - Object

showAgentOccurrences

Description

Displays collected occurrences for a specified agent on a Google Map. Creates two windows.

Parameters
  • element_id (?)
  • agent_id (?)
  • options
Options
  • info_element_id - ID String (defaults to element_id parameter)
  • generalFormat - HTML String
  • markers - String ('spiderfy' or undefined). Requires additional dependencies (see below).
  • offset - Number
  • limit - Number
  • icons - Object
  • widget_options
Additional Requirements

showAgentOccurrenceLocalityInfo

Description

Displays locality information for a certain agent's collecting occurrence.

Parameters
  • element_id (?)
  • loc_id (?)
  • options
Options

None

showDescribedTaxa

Description

Displays all taxa described by the specified agent.

Parameters
  • element_id (?)
  • author_id (?)
  • options
Options
  • taxonFormat - String
  • useTaxonItalics - Boolean
  • limit - Number
  • offset - Number
  • widget_options - Object

showPublications

Description

Displays all publications for a specified agent.

Parameters
  • element_id (?)
  • author_id (?)
  • options
Options
  • limit - Number
  • offset - Number
  • widget_options - Object

Occurrence

showBiologicalInfo

Description

Displays both the habitat and associations for a selected occurrence identifier.

Parameters
  • element_id (?)
  • occurrence_id (?)
  • options
Options
  • widget_options - Object

showOccurrenceInfo

Description

Displays collecting trip info for a specified occurrence.

Parameters
  • element_id (?)
  • occurrence_id (?)
  • options
Options
  • widget_options - Object

showDeterminations

Description

Displays determinations for a specified occurence.

Parameters
  • element_id (?)
  • occurrence_id (?)
  • options
Options
  • widget_options - Object

showLocalityInfo

Description

Displays locality info for a specified occurrence.

Parameters
  • element_id (?)
  • occurrence_id (?)
  • options
Options
  • widget_options - Object

showSpecimenInfo

Description

Displays specimen info for a specified occurrence.

Parameters
  • element_id (?)
  • occurrence_id (?)
  • options
Options
  • widget_options - Object

Search

showSearch

Description

A JQuery UI autocomplete search bar which can search for taxa, occurrences, institutions, agents, journals, localities, and places.

Parameters
  • element_id
  • options
Options
  • search - the type of search to execute. Controls the passing of URL parameters to methods. Can be specified a either 'id' or 'name'. Defaults to 'id'
  • domains - array of the below object elements
    • type - a domain keyword for which data gets searched for
    • handler_url - a URL that will be passed the ID of the selected type option
Additional Information
Category Options Formatting

Below is an example of how the categories should be input:

// Load search
search.showSearch('search_id', {domains: [{type: 'taxon', handler_url: 'http://domain.url/index.html'}, {type: 'occurrence', handler_url: 'http://domain.url/occurrence.html'}]});

Taxon

showAssociations

Description

Displays all associations for a specified taxon.

Parameters
Options
  • basic_only - Boolean_flag
  • limit - Number
  • offset - Number
  • widget_options

showInstitutions

Description

Displays institutions for which specimens of the selected taxon level belong.

Parameters
Options
  • limit - Number
  • offset - Number
  • widget_options - Object

showContributors

Description

Displays all contributing agents related to the occurrence, taxonomy, literature, and media of a taxon.

Parameters
Options
  • inst_id
  • widget_options

showDeterminers

Description

Displays determiners for a specified taxon.

Parameters
Options
  • limit - Number
  • offset - Number
  • inst_id
  • widget_options

showHabitats

Description

Displays all identified habitats for a selected taxon.

Parameters
Options
  • limit - Number
  • offset - Number
  • widget_options

showIncludedTaxa

Description

Displays taxa directly included within a taxon but not synonymous with it.

Parameters
Options
  • inst_id
  • show_syns
  • show_fossiles
  • types_only
  • useTaxonItalics - Boolean
  • limit - Number
  • offset - Number
  • widget_options

showLiterature

Description

Displays relevent publications for a specified taxon with links to the literature when available.

Parameters
Options
  • show_children - Boolean_flag
  • show_bib - Boolean_flag
  • useTaxonItalics - Boolean
  • limit - Number
  • offset - Number
  • widget_options

showSubordinateTaxa

Description

Displays the count of valid taxa levels available below the current taxon rank.

Parameters
Options
  • inst_id
  • widget_options

showSynonyms

Description

Displays all taxa which are objectively or subjectively synonymous with a selected taxon.

Parameters
Options
  • show_fossils
  • useTaxonItalics - boolean
  • limit - Number
  • offset - Number
  • widget_options

showTaxonMedia

Description

Displays a table of all media associated to a specific taxon rank.

Parameters
Options
  • inst_id
  • row_count - Number
  • media_type
  • limit - Number
  • offset - Number
  • widget_options

showTypes

Description

Displays information and specimen types for a specified taxon.

Parameters
Options
  • show_children
  • inst_id
  • primary_only - Boolean_flag
  • basic_only - Boolean_flag
  • offset - number
  • limit - number
  • useTaxonItalics - boolean
  • widget_options

Visual

showGoogleMap

Description

A Google map which displays locality markers for a specified taxon.

Parameters
  • element_id (?)
  • tnuid (?)
  • options
Options
  • place_id - Number
  • inst_id - Number
  • use_sex_icons - Boolean_flag
  • show_children - Boolean_flag
  • limit - Number
  • offset - Number
  • markers - Number
  • widget_options - Object
Additional Requirements

showTaxonHierarchy

Description

An interactive, tree-based animation which allows a user to navigate through a selected taxon's hierarchy and all taxa available through the OJ_Break API.

Parameters
  • element_id (?)
  • tnuid (?)
  • requestedNode
  • options
Options
  • show_num_spms - Boolean_flag
  • inst_id - Number
  • show_syns - Boolean_flag
  • show_fossils - Boolean_flag
  • types_only - Boolean_flag
  • nodeColor - string or hexadecimal number
  • backgroundColor - string or hexadecimal number
  • handler_url - File path string/URL
  • size - JavaScript object with two string properties:
    • width - either a number or string in pixels
    • height - either a number of string in pixels
  • imagePath - string of relative path to a folder containing necessary images.
  • widget_options - Object
Additional Requirements
  • Processing.js 1.4.1+
  • Pass requestedNode parameter a value of null when calling function. See below:
// Load taxon hierarchy
visual.showTaxonHierarchy('canvas_id', tnuid, null, { /*options*/ });
Additional Information
URL Handler Option

The handler_url option can be used to allow the nodes to have links attached to them, so that a user may follow the link for more information on that specific taxon.

// Load taxon hierarchy
visual.showTaxonHierarchy('canvas_id', tnuid, null, {nodeColor: 'cyan', backgroundColor: '#FFFFFF', handler_url: 'http://hol.osu.edu/index.html'});

In this example, a default web page URL is given (note the use of http:// at the beginning). When provided a URL, the taxon hierachy animation will present a link button to the top right of the node that is currently being highlighted (see image below). This link will not be present if a URL is not specified. If this button is clicked, the handler_url link will be followed.

Size Option

The taxon hierarchy application can be resized in one of two ways: via CSS (preferred) or by inputting the dimensions of the HTML canvas into the API method call as options. One way this can be done is by specifying the width and height as numbers:

// Load taxon hierarchy
visual.showTaxonHierarchy('canvas_id', tnuid, null, {size: {width: 300, height: 900}});

The dimensions of the canvas can also be input as pixels:

// Load taxon hierarchy
visual.showTaxonHierarchy('canvas_id', tnuid, null, {size: {width: "300px", height: "900px"}});

Both of these methods (CSS and parameter passing) are valid, but they should never both be used at the same time since unexpected errors may occur.

Image Path Option

Due to security restrictions, Processingjs is limited in its function to request images. As a consequence, any user wishing to use the animation must have copies of the required images available locally on their server. To access these images, a relative directory path must be input in the form of a optional parameter. The call may look something like this:

// Load taxon hierarchy
visual.showTaxonHierarchy('canvas_id', tnuid, null, {imagePath: "media/images/"});


Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.