forked from edamontology/edam-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
156 lines (155 loc) · 8.83 KB
/
demo.html
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" >
<head>
<title>EDAM ontology browser</title>
<link rel="icon" type="image/png" href="favicon.ico" />
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-115521967-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-115521967-1');
</script>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"/>
<script
src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.min.js"
integrity="sha256-hYXbQJK4qdJiAeDVjjQ9G0D6A0xLnDQ4eJI9dkm7Fpk=" crossorigin="anonymous"></script>
<script src="js/tree-reusable-d3.js"></script>
<script type="text/javascript">
var my_tree;
function demo(){
delay=0;
step=2500;
delay+=step;
setTimeout(function() {
my_tree.cmd.selectElement("http://edamontology.org/topic_3174",true);
$("#simple-pre").append($('<p>Add Metagenomics:</p><pre>my_tree.cmd.selectElement("http://edamontology.org/topic_3174",true);</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
delay+=step;
setTimeout(function() {
my_tree.cmd.selectElement("http://edamontology.org/topic_0091",false);
$("#simple-pre").append($('<p>Remove Bioinformatics:</p><pre>my_tree.cmd.selectElement("http://edamontology.org/topic_0091",false);</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
delay+=step;
setTimeout(function() {
my_tree.cmd.expandElement("http://edamontology.org/topic_3065");
$("#simple-pre").append($('<p>Expand to Embriology:</p><pre>my_tree.cmd.expandElement("http://edamontology.org/topic_3065");</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
delay+=step;
setTimeout(function() {
my_tree.cmd.selectElement("http://edamontology.org/topic_3174",false);
$("#simple-pre").append($('<p>Remove Metagenomics:</p><pre>my_tree.cmd.selectElement("http://edamontology.org/topic_3174",false);</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
delay+=step;
setTimeout(function() {
my_tree.cmd.selectElement("http://edamontology.org/topic_3401",true);
$("#simple-pre").append($('<p>Add Pain medecine:</p><pre>my_tree.cmd.selectElement("http://edamontology.org/topic_3401",true);</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
delay+=step;
setTimeout(function() {
my_tree.cmd.collapseNotSelectedElement();
$("#simple-pre").append($('<p>Collapse not selected node:</p><pre>my_tree.cmd.collapseNotSelectedElement();</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
setTimeout(function() {
my_tree.cmd.collapseElement("http://edamontology.org/topic_3303");
$("#simple-pre").append($('<p>Collapse Medecine:</p><pre>my_tree.cmd.collapseElement("http://edamontology.org/topic_3303");</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
delay+=step;
setTimeout(function() {
my_tree.cmd.selectElement("http://edamontology.org/topic_3065",true,false);
$("#simple-pre").append($('<p>Add Embriology without expanding to it:</p><pre>my_tree.cmd.selectElement("http://edamontology.org/topic_3065",true,false);</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
delay+=step;
setTimeout(function() {
my_tree.cmd.expandSelectedElement();
$("#simple-pre").append($('<p>Expand to selected elements:</p><pre>my_tree.cmd.expandSelectedElement();</pre>'));
$('#simple-pre').stop().animate({scrollTop: $('#simple-pre')[0].scrollHeight}, 800);
;}, delay);
delay+=step;
}
window.onload = function() {
my_tree = interactive_tree()
.identifierAccessor(function(d){return d.data.data.uri;})
.debug(true)
.duration(1000)
.tooltipEnabled(true)
.initiallySelectedElementHandler(function(d){return d.data.data.uri==="http://edamontology.org/topic_0091"})
.openElementHandler(function(d){alert(d.data.data.uri);})
.loadingDoneHandler(demo)
;
d3.select("#tree").call(my_tree); // draw chart in div
my_tree.data_url("media/edam_extended.biotools.min.json");
$("#simple-pre").append($(`<p>Starting from this minimal working example: </p><pre>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.min.js"></script>
<script src="js/tree-reusable-d3.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"/>
<link href="css/tree-reusable-d3.css" rel="stylesheet">
<script type="text/javascript">
var my_tree;
window.onload = function() {
my_tree = interactive_tree()
//overriding as the identifier by default consider d.data.id
.identifierAccessor(function(d){return d.data.data.uri;})
.debug(true)
.duration(1000)
.tooltipEnabled(true)
//at first Bioinformatics should be selected
.initiallySelectedElementHandler(function(d){
return d.data.data.uri==="http://edamontology.org/topic_0091"
})
//Show a JS alert when you ctrl-click on a node
.openElementHandler(function(d){
alert("Ctrl-clicked (Open action) on "+d.data.data.uri);
})
;
// pre-draw/build chart in div
d3.select("#tree").call(my_tree);
//indicated where the data can be found
my_tree.data_url("media/edam_extended.biotools.min.json");
}
</script>
</head>
<body>
<div id="tree" style="height:99vh"></div>
</body></pre>`));
}
</script>
<link href="css/tree-reusable-d3.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row"></div>
<div class="col-xs-12 col-md-6 col-lg-7 col-xl-8">
<div id="tree" style="height:99vh"></div>
</div>
<div class="col-xs-12 col-md-6 col-lg-5 col-xl-4">
<div class="bs-example" style="height:99vh;overflow:auto" id="simple-pre">
</div>
</div>
</div>
</body>