-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgfbio_search_visualization.xml
More file actions
57 lines (53 loc) · 2.06 KB
/
gfbio_search_visualization.xml
File metadata and controls
57 lines (53 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Search Visualization" author="Database Research Group of Uni Marburg" height="300">
<Require feature="pubsub-2">
<Param name="topics">
<![CDATA[
<Topic title="GFBio Listener" name="gfbio.search.selectedData.listener"
description="Listens to GFBio Search data" type="string" subscribe="true" />
]]>
</Param>
</Require>
</ModulePrefs>
<UserPref
name="visualization_html"
display_name="URL to the gfbio_search_visualization.html"
required="true"
default_value="https://vat.gfbio.org/search-widget/gfbio_search_visualization.html"
/>
<Content type="html">
<![CDATA[
<script type="text/javascript">
const userPrefs = new gadgets.Prefs();
const visualizationHtml = userPrefs.getString('visualization_html');
let iframe = undefined;
/**
* Receive Liferay event an pass it to the iframe's window.
* @param topic
* @param data
* @param subscriberData
*/
function receiveVisualizationRequest(topic, data, subscriberData) {
iframe.contentWindow.postMessage(data, '*');
}
// subscribe to the channel as soon as the message hub is ready
gadgets.HubSettings.onConnect = function(hub, suc, err) {
gadgets.Hub.subscribe('gfbio.search.selectedData', receiveVisualizationRequest);
};
// create iframe
(function() {
iframe = document.createElement('iframe');
iframe.id = 'searchVisualizationFrame';
iframe.src = visualizationHtml;
iframe.style.border = 'none';
iframe.style.margin = 0;
iframe.style.padding = 0;
iframe.style.height = '100%';
iframe.style.width = '100%';
document.getElementsByTagName('body')[0].appendChild(iframe);
})();
</script>
]]>
</Content>
</Module>