-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_subjects.html
73 lines (67 loc) · 2.21 KB
/
get_subjects.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Get Subject</title>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/gh/p2m2/[email protected]/dist/discovery-web.min.js">
</script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
>
<style>
.icon {
font-size: 2em;
}
</style>
<body>
<div id="icon-container">
<i id="status-icon" class="icon fas fa-spinner fa-spin"></i>
</div>
<div id="status-message">En attente...</div>
</body>
<script>
var config = SWDiscoveryConfiguration
.init()
.urlFile("https://raw.githubusercontent.com/p2m2/tp-discovery-websempilot/main/rdf/triples_assos_CID_MESH_sub.ttl");
SWDiscovery(config)
.prefix("mesh","http://id.nlm.nih.gov/mesh/")
.prefix("skos","http://www.w3.org/2004/02/skos/core#")
.something("some")
.set(URI("mesh:D000144"))
.isObjectOf(URI("skos:related"),"var_compounds")
.select("var_compounds")
.commit()
.raw()
.then((response) => {
message = "<p>termes mesh associés à chebi:133719 ->"+response.results.bindings.length + "</p><ul>" ;
for (const binding of response.results.bindings) {
message +=`<li> ${binding["var_compounds"].value} </li>`;
}
message += "</ul>"
isOK(message);
})
.catch( (error) => {
isKO(error)
} );
function isOK(message){
const iconElement = document.getElementById('status-icon');
const messageElement = document.getElementById('status-message');
iconElement.className = 'icon fas fa-check-circle';
iconElement.style.color = 'green';
messageElement.innerHTML = message;
messageElement.style.color = 'green';
}
function isKO(error){
const iconElement = document.getElementById('status-icon');
const messageElement = document.getElementById('status-message');
iconElement.className = 'icon fas fa-times-circle';
iconElement.style.color = 'red';
messageElement.textContent = error.message;
messageElement.style.color = 'red';
}
</script>
</html>