{{response.title=T('Embedding') + ' ' + base_title}} {{response.files.append(URL('static', 'css/content_pages.css'))}} {{extend 'uikit_layout.html'}} {{block masthead}}

{{=T('Embed OneZoom in your website')}}

{{=T('Configure a OneZoom embeddable widget for your website')}}

{{end block}}

{{=T('Embed a customised OneZoom tree in your website')}}

{{=T("Without downloading or installing any software you can still use our embed and link tool if you want to embed custom versions of a tree that's already on OneZoom. After selecting the settings you want the page will e-mail you a short piece of code that you can copy any paste into your website to give you a OneZoom visualisation.")}}

{{=XML(T('The embed editor can be accessed here.') % {'slot0': (xmlescape(URL('embed_edit')))})}}

{{=T('Bulk-embedding OneZoom in many pages')}}

{{=XML(T('If embedding in many pages, it may be useful to check that a species / node exists before importing the entirety of OneZoom. To do this you can use the getOTT API that finds a matching OTT identifier if available. Once you have an OTT you can load OneZoom using the an embed URL as generated using the embed editor.') % {'slot0': (xmlescape(URL('API', 'index'))), 'slot1': (xmlescape(URL('embed_edit')))})}}

{{=XML(T('getOTT can search by several different identifiers. For example, the code below will search based on a GBIF ID and, if available in OneZoom, update the iframe to load the OneZoom tree.') % {'slot0': (xmlescape(URL('API', 'index')))})}}

const oz_origin = 'https://onezoom.org';
const oz_embed_url = ott => `${oz_origin}/life/@${ott}?otthome=${ott}&embedkey=...`;

// Fetch a GBIF ID from the URL
let gbif_code = parseInt(window.location.search.match(/gbif=([0-9]+)/)[1]);

window.fetch(`${oz_origin}/API/getOTT.json?gbif=${gbif_code}`).then(x=>x.json()).then(function (data) {
    let ott = data.gbif[gbif_code];

    document.getElementById('oz_iframe').src = ott ? oz_embed_url(ott) : '';
});

{{=T('OneZoom treeviewer variants')}}

{{=T('There are several variations on the main OneZoom')}} /life/ {{=T('page:')}}

{{=T('Remote-control of OneZoom')}}

{{=T('Many aspects of OneZoom treeviewer can be configured by URL. There are 2 relevant bits of documentation:')}}

{{=XML(T('Anything that can be set via. the URL can be changed at run time by giving a querystring to onezoom.controller.set_treestate(). For example:'))}}

onezoom.controller.set_treestate('?lang=fr')
onezoom.controller.set_treestate('?lang=fr&cols=AT')
// NB: An empty URL section resets to default
onezoom.controller.set_treestate('?lang=&cols=')

{{=T('Zooming around')}}

{{=T('This can also be done with')}} set_treestate():
onezoom.controller.set_treestate('@Aves')
// Instant jump to Elephants
onezoom.controller.set_treestate('@Loxodonta_africana?anim=jump')
// Slow direct flight to Rodents
onezoom.controller.set_treestate('@RODENTIA?anim=straight-0.2')
// Quick Flight to blackbird
onezoom.controller.set_treestate('@Turdus_merula?anim=flight-4')
// Reset flights back to normal
onezoom.controller.set_treestate('?anim=')

{{=T('Highlighting')}}

{{=T('Highlights can be enabled by providing a highlight string to')}} set_treestate():
onezoom.controller.set_treestate('?highlight=path:@tetrapoda@aves&highlight=fan:@aves@GALLOANSERAE')
// Turn highlights off again
onezoom.controller.set_treestate('?highlight=')

{{=XML(T('See the the highlight documentation for more information on syntax.'))}}

{{=T('Playing a tour')}}

{{=T('Tours can be played using the')}} tour {{=T('querystring option:')}}
onezoom.controller.set_treestate('?tour=/tour/data.html/superpowers');