-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
103 lines (94 loc) · 2.94 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Test RDF</title>
<script src="js/rdflib.js"></script>
<script src="js/jquery-3.7.1.min.js"></script>
</head>
<body>
<form id="fileForm">
<input type="text" id="textInput"> </input>
<button type="submit">Graph laden</button>
</form>
<div id="rdfDiv">
<p id="paragraphText"></p>
</div>
</body>
<script>
//let podUrl = "https://leiza-rse.solidweb.org/tiger/CA2MapBritannia.ttl";
let podUrl = "https://restaurierungsvokabular.solidweb.org/wuerste/krakauer.ttl";
/*
let loadOntology = (input) => {
var store = $rdf.graph()
var timeout = 5000
var url = input
var fetcher = new $rdf.Fetcher(store, timeout)
fetcher.nowOrWhenFetched(url, function(ok, body, response) {
if (!ok) {
console.log("Oops, something happened and couldn't fetch data " + body);
} else if (response.onErrorWasCalled || response.status !== 200) {
console.log(' Non-HTTP error reloading data! onErrorWasCalled=' + response.onErrorWasCalled + ' status: ' + response.status)
} else {
console.log("---data loaded---")
console.log(response)
}
})
}
*/
let formFunction = () => {
event.preventDefault();
const input = document.getElementById('textInput');
const text = input.value;
loadOntology(text);
}
const fileForm = document.getElementById('fileForm');
fileForm.addEventListener('submit', formFunction);
let writeTtlToDiv = (ttl) => {
//$('#rdfDiv').empty();
console.log(ttl);
//$('#rdfDiv').append(ttl);
$('#paragraphText').text(ttl);
}
// https://github.com/SolidOS/solid-tutorial-rdflib.js?files=1
let writeToStore2 = (data) => {
var uri = 'example.org/resource.ttl' // https://
var body = '<a> <b> <c> .'
var mimeType = 'text/turtle'
var store = $rdf.graph()
try {
var a = $rdf.parse(body, store, uri, mimeType);
console.log(a);
} catch (err) {
console.log(err)
}
}
//https://linkeddata.github.io/rdflib.js/Documentation/webapp-intro.html
let writeToStore = (rdfString, rdfUri, rdfStore, callbackFunction) => {
//let text = data;
rdfStore = $rdf.parse(rdfString, rdfStore, rdfUri.uri, "text/turtle");
console.log(rdfStore);
callbackFunction; //encodeURIComponent()
}
let readFromPod = (podUrl, callbackFunction) =>{
$.ajax({
url: podUrl,
type: 'GET',
contentType: 'text/turtle',
//async: false,
success: function(result) {
console.log(result);
//document.getElementById('podText').value = data;
callbackFunction(result);
},
error: function(result) {
console.log('Error:', result);
}
});
}
//readFromPod(podUrl, writeToStore);
let rdfString = '<#this> a <#Example> .';
let rdfUri = $rdf.sym("https://example.com/alice/card");
let rdfStore = $rdf.graph();
writeToStore(rdfString, rdfUri, rdfStore, writeTtlToDiv(rdfStore.toNT()));
</script>
</html>