-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatatype_endpoint.html
73 lines (65 loc) · 2.24 KB
/
datatype_endpoint.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>Datatype Endpoint</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()
.sparqlEndpoint("https://forum.semantic-metabolomics.fr/sparql/");
SWDiscovery(config)
.prefix("chebi","http://purl.obolibrary.org/obo/CHEBI_")
.something("var_study")
.set(URI("chebi:27732"))
.datatype(URI("http://purl.obolibrary.org/obo/chebi/formula"),"var_formula")
.datatype(URI("http://www.geneontology.org/formats/oboInOwl#hasExactSynonym"),"var_name")
.select("var_study", "var_formula", "var_name")
.commit()
.raw()
.then((response)=>{
let study=response.results.bindings[0]["var_study"].value;
let formula=response.results.datatypes["var_formula"][study][0].value;
let name = response.results.datatypes["var_name"][study][0].value;
isOK(`${name} : #Ref -> ${study} #Formula -> ${formula}`);
})
.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>