|
@@ -0,0 +1,90 @@
|
|
|
+// Raccatto i parametri dall'URL -- mi aspetto un parametro di nome 'link'!
|
|
|
+thisUrlParams = {};
|
|
|
+window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
|
|
|
+ thisUrlParams[key] = value;
|
|
|
+});
|
|
|
+console.log('URL get params: ', thisUrlParams);
|
|
|
+
|
|
|
+// Funzioni per eseguire le queries
|
|
|
+function prepareQueryURL(query){
|
|
|
+ sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
|
|
|
+ sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
|
|
|
+ return sparqlEndpoint + sparqlUrlParams;
|
|
|
+}
|
|
|
+
|
|
|
+function doJsonQuery(query){
|
|
|
+
|
|
|
+ queryURL = prepareQueryURL(query);
|
|
|
+
|
|
|
+ response = $.ajax({//OGGETTO
|
|
|
+
|
|
|
+ url: queryURL,
|
|
|
+ dataType: "json",
|
|
|
+ success: function (data){},
|
|
|
+ error: function (e) {}
|
|
|
+ });
|
|
|
+
|
|
|
+ return response;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// Funzioni per raccattare + stringhificare l'output
|
|
|
+queryStringOutput = "";
|
|
|
+function stringifyResponse(val){
|
|
|
+ resultArray = val['results']['bindings'];
|
|
|
+ out = "";
|
|
|
+ for(i = 0; i < resultArray.length; i++){
|
|
|
+ out = out + JSON.stringify(resultArray[i])
|
|
|
+ }
|
|
|
+ queryStringOutput = (queryStringOutput + out).replace("}{",",");
|
|
|
+}
|
|
|
+
|
|
|
+queryTopoOutput = "";
|
|
|
+function stringifyTopo(val){
|
|
|
+ resultArray = val['results']['bindings'];
|
|
|
+ out = "";
|
|
|
+ for(i = 0; i < resultArray.length; i++){
|
|
|
+ out = out + JSON.stringify(resultArray[i])
|
|
|
+ }
|
|
|
+ queryStringOutput = (queryStringOutput + out).replace("}{",",");
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////
|
|
|
+// TESTI DELLE QUERY
|
|
|
+////////////////////
|
|
|
+
|
|
|
+prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
|
|
|
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
|
|
|
+PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
|
|
|
+PREFIX dat: <http://datini.archiviodistato.prato.it/la-ricerca/scheda/> \
|
|
|
+PREFIX mpp: <http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/> \
|
|
|
+PREFIX aut: <http://palazzopretorio.comune.prato.it/it/opere/autori/>"
|
|
|
+
|
|
|
+queryTesto = prefixes + " SELECT DISTINCT ?titolo ?testo WHERE {?subject crm:P128_carries <" + thisUrlParams.link + ">;\
|
|
|
+crm:P128_carries ?object .\
|
|
|
+?object rdf:type crm:E33_Linguistic_Object;\
|
|
|
+crm:P190_has_symbolic_content ?testo;\
|
|
|
+rdfs:label ?titolo .}"
|
|
|
+
|
|
|
+async function fillPageContents(){
|
|
|
+ val = await doJsonQuery(queryTesto);
|
|
|
+ stringifyResponse(val);
|
|
|
+ putValuesInHTML();
|
|
|
+}
|
|
|
+
|
|
|
+function putValuesInHTML(){
|
|
|
+ queryString = queryStringOutput.replaceAll("}}{", "},")
|
|
|
+ console.log("Stringified Response:", queryString);
|
|
|
+ queryOutput = JSON.parse(queryString);
|
|
|
+ //
|
|
|
+
|
|
|
+ testo = "<p>" + queryOutput.testo.value + "</p>";
|
|
|
+
|
|
|
+ document.getElementById("testo_OVI").innerHTML = testo;
|
|
|
+ document.getElementById("titolo_lettera").innerHTML = queryOutput.titolo.value;
|
|
|
+ //
|
|
|
+ // Query ancora farlocche
|
|
|
+}
|
|
|
+
|
|
|
+// Dà il via alle queries + riempimento HTML
|
|
|
+fillPageContents();
|