-
Notifications
You must be signed in to change notification settings - Fork 9
/
Ontology-Search-Template.html
388 lines (316 loc) · 10.8 KB
/
Ontology-Search-Template.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<style>
body,
html {
font-family: 'Roboto', sans-serif;
font-size: 14px;
color: #666666;
padding: 10px;
}
p {
margin: 0;
}
.branding-above {
padding: 0;
top: 0;
}
.sidebar {
width: 94%;
}
.hidden {
display: none;
}
.error {
padding-top: 10px;
color: #e74c3c;
}
.branding-below {
bottom: 56px;
position: fixed;
background-color: #fff;
top: 0;
}
.branding-text {
left: 7px;
position: relative;
font-size: .9em;
top: 3px;
}
.ontomaton-header {
padding-top: 5px;
height: 75px;
}
.col-contain {
overflow: hidden;
}
h3 {
margin-left: 5px;
margin-top: 0px;
margin-bottom: 0px;
text-align: left;
font-size: 1em;
padding: 5px 6px;
border-radius: 4px;
}
.col-one {
float: left;
width: 50%;
}
.logo {
vertical-align: middle;
}
.pull-left {
float: left;
}
.pull-right {
float: right;
}
.width-100 {
width: 100%;
}
#service {
width: 100%;
margin-bottom: 8px;
padding: 4px 6px;
border-radius: 4px;
border: 1px solid #2f3640;
}
.search-results ul {
list-style: none;
margin: 0px;
text-align: left;
}
.term-info {
float: left;
width: 70%;
margin: 3%;
}
.term-buttons {
float: right;
width: 21%;
}
.search-results ul li {
padding: 4px;
font-weight: bolder;
font-size: .9em;
}
.search-results ul li a {
color: #5A9C43;
text-decoration: none;
}
.ontology-abbr {
text-align: left;
font-weight: bolder;
font-size: 1em;
color: #414241;
}
.ontology-name {
text-align: left;
font-weight: bolder;
font-size: .8em;
color: #95A5A5;
}
.term-count {
text-align: right;
padding: 7px 5px;
background-color: #4FBA6F;
color: #fff;
border-radius: 50%;
font-size: .8em;
}
.btn-green {
text-align: center;
padding: 5px 8px;
border-radius: 4px;
border: none;
background-color: #5A9C43;
width: 100%;
color: white;
display: block;
cursor: pointer;
}
.bth-green:hover {
background-color: #4FBA6F;
}
ul {
-webkit-padding-start: 5px;
}
.term-button button {
background-color: #ecf0f1;
color: #414241;
padding: 5px 8px;
border: none;
cursor: pointer;
display: block;
}
.clearfix:after {
content: " ";
/* Older browser do not support empty content */
visibility: hidden;
display: block;
height: 0;
clear: both;
}
#spinner {
margin-top: 60px;
text-align: center;
}
#spinner p {
font-weight: bolder;
color: color: #414241;
}
#search-text {
border: 1px solid #2f3640;
padding: 5px 6px;
border-radius: 4px;
}
.footer {
text-align: center;
position: absolute;
width: 242px;
bottom: 12px;
}
</style>
</head>
<body>
<div class="ontomaton-header">
<img src="https://isa-tools.org/OntoMaton/figures/ontomaton-search.png" />
</div>
<form>
<div class="block col-contain" style="margin-top:20px">
<div class="col-two">
<div id="ontomaton-search-panel">
<label for="search-text" style="font-size: 1em; color: #414241">Search Term</label>
<input type="text" name="search-text" id="search-text" value="" placeholder="e.g. cy5">
</div>
<br />
<div class="col-two">
<select id="service" class="width-100">
<option value="bioportal" selected>Search BioPortal</option>
<option value="lov">Search LOV</option>
<option value="ols">Search OLS</option>
</select>
</div>
</div>
</div>
<div class="block" id="button-bar">
<button class="btn-green" id="run-search" style="width: 100%">Search</button>
</div>
<div id="search-results" class="block form-group search-results"
style="height:60vh; overflow: scroll; padding-top: 10px">
</div>
</form>
<div class="footer">
<img alt="Add-on logo" class="logo" src="//isa-tools.org/wp-content/themes/isatools-wp-theme/img/footer_logo.svg"><br />
<span class="gray branding-text">Created by the <a href="http://isa-tools.org" target="_blank">ISA tools</a>
team</span>
</div>
<script>
/**
* On document load, assign click handlers to each button and try to load the
* user's origin and destination language preferences if previously set.
*/
$(function () {
$('#run-search').click(runSearch);
});
/**
* Taken from http://www.mustbebuilt.co.uk/2012/04/20/replaceall-function-for-javascript-and-actionscript/
*/
function replaceAll(oldStr, removeStr, replaceStr, caseSenitivity) {
var cs = "gi"
if (caseSenitivity == 1) {
cs = "g";
}
var myPattern = new RegExp(removeStr, cs);
return oldStr.replace(myPattern, replaceStr);
}
/**
* Inserts the term in to the spreadsheet.
*/
function insertTerm(term_id) {
google.script.run
.withSuccessHandler(
function (result, element) {
console.log("success")
}).withFailureHandler(
function (msg, element) {
console.log("failure")
showError(msg, $('#button-bar'));
element.disabled = false;
})
.withUserObject(this)
.handleTermInsertion(term_id);
}
/**
* Runs a server-side function to translate the user-selected text and update
* the sidebar UI with the resulting translation.
*/
function runSearch() {
var term = $('input[name=search-text]').val();
if(term === "") {
showError('Please enter a search term.', $('#button-bar'));
return
}
this.disabled = true;
$('#search-results').html('<div id="spinner"><img src="//s-media-cache-ak0.pinimg.com/originals/0a/59/71/0a59718a5ee79a0558930ca9907c0659.gif" width="70px"/><p>Searching...</p></div>');
$('#error').remove();
var service = $('#service').val();
google.script.run
.withSuccessHandler(
function (result, element) {
// process results
var html = '<div id="accordion" class="accordion">';
console.log(result);
if (result) {
Object.keys(result).sort().forEach(function(ontology_abbr) {
var ontology = result[ontology_abbr];
html += '<h3><span class="ontology-abbr">' + ontology_abbr + '</span> - <span class="ontology-name">' + ontology["ontology-name"] + '</span></h3>' +
'<div><ul>'
Object.keys(ontology["terms"]).forEach(function(term_idx) {
var term = ontology["terms"][term_idx];
var label = term["label"];
html += '<li>' +
'<div class="term-info">' +
'<a href="' + term["url"] + '" target="_blank">' + term["label"] + '</a>' +
'</div>' +
'<div class="term-button"><button onclick="insertTerm(\'' + term["id"] + '\'); return false;">Insert</button></div>' +
'<div class="clearfix"></div>' +
'</li>';
});
html += '</ul></div>';
});
} else {
html += "<p>Sorry, no results were found matching your query...</p>";
}
html += "</div>";
$('#search-results').html(html);
element.disabled = false;
$('#spinner').addClass("hidden");
})
.withFailureHandler(
function (msg, element) {
$('#spinner').addClass("hidden");
showError(msg, $('#button-bar'));
element.disabled = false;
})
.withUserObject(this)
.runSearch(service, term);
return false;
}
/**
* Inserts a div that contains an error message after a given element.
*
* @param msg The error message to display.
* @param element The element after which to display the error.
*/
function showError(msg, element) {
var div = $('<div id="error" class="error">' + msg + '</div>');
$(element).after(div);
}
</script>
</body>
</html>