forked from marieALaporte/prototypeAutocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautocomplete.html
More file actions
98 lines (85 loc) · 2.64 KB
/
autocomplete.html
File metadata and controls
98 lines (85 loc) · 2.64 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Keyword Autocomplete</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="css/styles.css">
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
var agrovoc;
var agrovoc = (function () {
var json = null;
$.ajax({
'async': false,
'global': false,
'url': "data/agrovoc.json",
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
})();
var arrAgrovoc = $.map(agrovoc["results"]["bindings"], function(el) {
return el["label"]["value"] + " - " + el["uri"]["value"].split("http://aims.fao.org/aos/agrovoc/")[1];
});
//console.log(arrAgrovoc)
//http://www.cropontology.org/brapi/v1/traits/CO_321?pageSize=334
var co;
var co = (function () {
var json = null;
$.ajax({
'async': false,
'global': false,
'url': "data/CO_321.json",
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
})();
var arrCO = $.map(co["result"], function(el) {
return el["name"] +" - "+ el["traitId"];
});
//console.log(arrCO)
var arr = arrAgrovoc.concat(arrCO)
$( "#tags" ).autocomplete({
max:10,
minLength:3,
source: arr,
select: function (e, ui) {
var id = ui.item.value.split(" - ")[1];
if(id.match(/CO_\d{3}:\d{7}/)){
//alert(ui.item.value.split(" - ")[1]);
$('#frame').attr('src', 'http://www.cropontology.org/terms/'+id+'/static-html?language=english');
}else{
$('#frame').attr('src', 'http://artemide.art.uniroma2.it:8081/agrovoc/agrovoc/en/page/'+id);
}
}
});
} );
</script>
</head>
<body>
<div class="body-wrapper">
<div class="top-box clearfix">
<img src="https://cgspace.cgiar.org/bitstream/handle/10947/2622/CGIAR%20green%20logo.jpg?sequence=1" alt="CGIAR logo">
<h1> Ontology lookup service for Dataverse </h1>
</div>
<div class="ui-widget keyword-hints" >
<label for="tags">Keyword: </label>
<input id="tags">
</div>
<div>
<iframe frameborder="0" id="frame" height="700px"></iframe>
</div>
</div>
<!-- end .body-wrapper -->
</body>
</html>