Finnish English

How to integrate ONKI Mash-Up component into your own application

The ONKI Mash-Up component can be integrated into your own application by adding the following two lines of HTML/Javascript code to the HTML source file of the application:

<script type="text/Javascript" src="http://www.yso.fi/onki.js"><script> (typically inside the head element)

<input onkeyup="onki['X'].search(Y)" id="Z"/> (inside the body element in the location of the page where the search field is desired)

Multiple search fields can be integrated into one single page. For every search field an input element described above is needed.

If the search fields are created dynamically in your application, in other words, if the search fields are not on the page when the page is loaded for the first time, a Javascript function initOnki() should be called after a search field is added (can be called multiple times).

The appearance of the ONKI Mash-Up component can be modified by defining CSS rules, e.g. using class attributes of the elements of the component.


The optional parameters of method onki['X'].search():

ParameterTypeDescriptionDefault value
lang String Search is limited to the labels of this language "fi"
maxHits int Maximum amount of search results 0 (unlimited)
parentRestriction String Search is limited to the sub tree of this concept null (no limitation)
typeRestriction String Search is limited to the concepts of this type null (no limitation unless the ONKI instance used in search contains some default value (e.g. YSO: yso-meta:Class))
autocompletionSearch boolean Is the autocompletion search field in use true
languageMenu boolean Is the language selection menu in use true
openonkibutton boolean Is the "Open ONKI Browser" button in use true
openonkilabel String The label of the "Open ONKI Browser" button "Open ONKI Browser"
onkimenu boolean Is the ONKI instance (ontology) selection menu in use true
prefix boolean Is the namespace prefix of the concepts shown as part of the labels of concepts selected from search results true
addConceptFunction reference to a function A javacript function defined by you to add concepts from search results to your application; the function gets parameters (uri, label, url); URL is a link to concept's HTML representation, unless it's the same as the URI, in that case URL isn't defined; using of this is an alternative to conceptCollector ONKI's own implementation is used
onkiFinder reference to a function (constructor) A Javascript component for showing the search results (further specifications will be documented later) ONKI's own implementation is used
conceptCollector reference to a function (constructor) A Javascript component for adding concepts from search results (further specifications will be documented later) ONKI's own implementation is used
maxSelect int The maximum amount of concepts that can be selected from search results; conceptCollector is required for this to work (doesn't work when function addConceptFunction defined by you is used) 0 (unlimited)
returnType string The type of the search result; at the moment it's used only in ONKI-Paikka ("uri" / "polygon"), return type in other ONKI instances is always URI null (the default value defined in the ONKI instance used in search)
termsNotUris boolean Fetch terms instead of URIs false
fieldName String The name of the hidden input fields used for storing the selected concepts "uri" for URIs, "term" for terms (based on the previous parameter)

The parameters are given in the JSON form: {'parameter1-name' : parameter1-value, 'parameter2-name' : parameter2-value}.