Bladeren bron

Carica file su 'js'

Alessia 2 jaren geleden
bovenliggende
commit
6b53d14521
5 gewijzigde bestanden met toevoegingen van 2151 en 0 verwijderingen
  1. 120 0
      js/lettera.js
  2. 167 0
      js/lettera_query.js
  3. 710 0
      js/map.js
  4. 490 0
      js/people.js
  5. 664 0
      js/search.js

+ 120 - 0
js/lettera.js

@@ -0,0 +1,120 @@
+
+// Oggetto che raccoglie le info necessarie per la pagina
+pageInfo = {};
+
+// Inizializzazione della pagina
+initPage();
+
+
+// Def. funzione di inizializzazione
+async function initPage(){
+	pageInfo = await getPageInfo();
+	updatePage();
+}
+
+// Esegue le queries, restituisce un oggetto con tutte le info per completare la pagina
+async function getPageInfo(){
+	var out = {};
+
+	try{
+		out.query1 = await doJsonQuery(query1, true);
+		out.titolo = await doJsonQuery(queryTitolo, true);
+		out.segnatura = await doJsonQuery(querySegnatura, true);
+		out.areaLinguistica = await doJsonQuery(queryAreaLinguistica, true);
+		out.descrizione = await doJsonQuery(queryDescrizione, true);
+		out.testo = await doJsonQuery(queryTestoLemmatizzato, true);
+		out.edizione = await doJsonQuery(queryEdizione, true);
+		out.toponimi = await doJsonQuery(queryToponimi);
+		out.antroponimi = await doJsonQuery(queryAntroponimi);
+
+		// out.tipo = await doJsonQuery(queryTipo);
+		// out.siglaOVI = await doJsonQuery(querySiglaOVI);
+		// out.raccolta = await doJsonQuery(queryRaccolta);
+	} catch(err){
+		console.log(err);
+	}
+
+	console.log('out', out)
+	return out;
+}
+
+
+// Aggiorna la pagina usando l'oggetto-info passato come parametro
+function updatePage(){
+
+	if(pageInfo.titolo) document.getElementById("title").innerHTML = pageInfo.titolo.titolo.value;
+	if(pageInfo.query1){
+		document.getElementById("mittente_id").innerHTML = pageInfo.query1.mittente.value;
+		document.getElementById("mittente_btn").innerHTML = createButton("fa fa-user", "Scheda persona", "schedaPersona('PERS')".replace("PERS", pageInfo.query1.mittente.value));
+	}
+	if(pageInfo.query1){
+		document.getElementById("destinatario_id").innerHTML = pageInfo.query1.destinatario.value;
+		document.getElementById("destinatario_btn").innerHTML = createButton("fa fa-user", "Scheda persona", "schedaPersona('PERS')".replace("PERS", pageInfo.query1.destinatario.value));
+	}
+	if(pageInfo.query1){
+		document.getElementById("luogo_partenza_id").innerHTML = pageInfo.query1.luogo_partenza.value;
+		document.getElementById("luogo_partenza_btn").innerHTML = createButton("fa fa-map", "Vedi mappa", "schedaMappa('LUOGO')".replace("LUOGO", pageInfo.query1.luogo_partenza.value));
+	}
+	if(pageInfo.query1){
+		document.getElementById("luogo_arrivo_id").innerHTML = pageInfo.query1.luogo_arrivo.value;
+		document.getElementById("luogo_arrivo_btn").innerHTML = createButton("fa fa-map", "Vedi mappa", "schedaMappa('LUOGO')".replace("LUOGO", pageInfo.query1.luogo_arrivo.value));
+	}
+	if(pageInfo.query1) document.getElementById("data_partenza_id").innerHTML = pageInfo.query1.data_partenza.value;
+	if(pageInfo.query1) document.getElementById("data_arrivo_id").innerHTML = pageInfo.query1.data_arrivo.value;
+	if(pageInfo.descrizione) document.getElementById("descrizione_id").innerHTML = pageInfo.descrizione.descrizione.value;
+	if(pageInfo.areaLinguistica) document.getElementById("lingua_id").innerHTML = pageInfo.areaLinguistica.lingua.value;
+	if(pageInfo.areaLinguistica) document.getElementById("area_linguistica_id").innerHTML = pageInfo.areaLinguistica.area_linguistica.value;
+	if(pageInfo.segnatura){
+		document.getElementById("segnatura_id").innerHTML = pageInfo.segnatura.segnatura_OVI.value;
+		document.getElementById("segnatura_btn").innerHTML = createButton("fa fa-link", "Link ASPO", "schedaASPO('SEGN')".replace("SEGN", thisUrlParams.link));
+	}
+	if(pageInfo.edizione){
+		document.getElementById("edizione_id").innerHTML = pageInfo.edizione.edizione.value;
+		document.getElementById("edizione_btn").innerHTML = createButton("fa fa-comments", "Cita Edizione", "schedaEdizione('EDIZ')".replace("EDIZ", pageInfo.edizione.edizione.value));
+	}
+	if(pageInfo.testo) document.getElementById("trascrizione_id").innerHTML = pageInfo.testo.testo_lemmatizzato.value;
+	//
+	if(pageInfo.antroponimi && pageInfo.antroponimi.length){
+		const listaAntroponimi = pageInfo.antroponimi.map(elem => elem.antroponimo.value);
+		document.getElementById("antroponimi").innerHTML = formatListAsLi(listaAntroponimi);
+	}
+	if(pageInfo.toponimi && pageInfo.toponimi.length){
+		const listaToponimi = pageInfo.toponimi.map(elem => elem.toponimo.value);
+		document.getElementById("toponimi").innerHTML = formatListAsLi(listaToponimi);
+	}
+}
+
+// Mini-utility per formattare liste
+function formatListAsLi(thisList){
+	toRet = "";
+	thisList.forEach(value => toRet += "<li>" + value + "</li>");
+	return toRet;
+}
+
+// Buttons
+function createButton(buttonClass, text, onClickFunction){
+	htmlCode = '\
+		<button class="btn btn-default" type="button" onclick="<FUNCTION>">\
+		<i class="<CLASS>" aria-hidden="true">\
+			<p class="btn-text"><TEXT></p>\
+		</i>\
+		</button>\
+		'.replace("<CLASS>", buttonClass).replace("<TEXT>", text).replace("<FUNCTION>", onClickFunction);
+	return htmlCode;
+}
+
+function schedaPersona(info){
+	alert("Hi! I've been clicked.\n I've been passed: '" + info + "' as a paramater");
+}
+
+function schedaMappa(info){
+	alert("Hi! I've been clicked.\n I've been passed: '" + info + "' as a paramater");
+}
+
+function schedaASPO(info){
+	window.open(info);
+}
+
+function schedaEdizione(info){
+	alert("Hi! I've been clicked.\n I've been passed: '" + info + "' as a paramater");
+}

+ 167 - 0
js/lettera_query.js

@@ -0,0 +1,167 @@
+
+// Recupero 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;
+}
+
+// Esegue una query sull'endpoint SPARQL il cui testo completo deve essere fornito nel parametro-stringa 'query'
+// Restituisce una lista di oggetti json nel formato di Virtuoso
+// Il parametro opzionale 'isUnique', se messo a 'true' controlla che ci sia un unico risultato (un array di
+// lunghezza 1) e se non è così restituisce un errore.
+async function doJsonQuery(query, isUnique = false){
+
+    queryURL = prepareQueryURL(query);
+
+    response = await $.ajax({//OGGETTO
+
+        url: queryURL,
+        dataType: "json",
+        success: function (data){},
+        error: function (e) {
+            console.log("Exception in query:", e);
+        }
+    });
+
+    let out = response['results']['bindings'];
+    if(!isUnique) return out;
+    if(!out.length) throw "ERROR: Letter not found";
+    if(out.length>1) throw "ERROR: ambiguity in search -- multiple letters matching search parameters";
+    return out[0];
+
+}
+
+// Nuova funzione per l'NLP
+function loadPageNLP()
+{
+     window.location="nlp.html?link=" + thisUrlParams.link;
+}
+
+// Nuova funzione per Button EVT
+function loadPageEVT()
+{
+     window.location="http://restore.ovi.cnr.it/mockup/evt/index.html";
+}
+
+// Nuova funzione per Button LOD
+function loadPageLOD()
+{
+     window.location="http://dev.restore.ovi.cnr.it/lodlive/?" + thisUrlParams.link;
+}
+
+
+////////////////////
+// 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/>"
+
+query1 = prefixes + " SELECT DISTINCT ?mittente ?destinatario ?data_partenza ?data_arrivo ?luogo_partenza ?luogo_arrivo \
+WHERE {?subject crm:P128_carries <" + thisUrlParams.link + "> \
+GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?subject crm:P25i_moved_by ?mov_ev .} \
+?send rdfs:subClassOf ?mov_ev ; \
+rdf:type crm:EL2_Send_Letter ; \
+crm:P4_has_time-span ?time_spanA; \
+crm:P27_moved_from ?placeA; \
+crm:P01_has_domain ?sender . \
+\
+?time_spanA rdfs:label ?data_partenza . \
+?placeA rdfs:label ?luogo_partenza . \
+?sender crm:P02_has_range ?mittente . \
+ \
+?receive rdfs:subClassOf ?mov_ev; \
+rdf:type crm:EL3_Receive_Letter ; \
+crm:P4_has_time-span ?time_spanB; \
+crm:P26_moved_to ?placeB; \
+crm:P01_has_domain ?receiver . \
+ \
+?time_spanB rdfs:label ?data_arrivo . \
+?placeB rdfs:label ?luogo_arrivo . \
+?receiver crm:P02_has_range ?destinatario . \
+}"
+
+querySegnatura = prefixes + "SELECT DISTINCT ?segnatura_OVI \
+WHERE {?subject crm:P128_carries <" + thisUrlParams.link + ">; \
+crm:P1_is_identified_by ?segnatura_ASPO . \
+?segnatura_ASPO crm:P139_has_alternative_form ?segnatura . \
+?segnatura crm:P2_has_type ?tipo_segnatura; \
+rdfs:label ?segnatura_OVI . \
+?tipo_segnatura rdfs:label \"Segnatura OVI\"}"
+
+queryAreaLinguistica = prefixes + " SELECT DISTINCT ?lingua ?area_linguistica \
+WHERE {<" + thisUrlParams.link + "> crm:P72_has_language ?language . \
+?language crm:P3_has_note ?area ; \
+rdfs:label ?lingua . \
+?area rdfs:label ?area_linguistica \
+}"
+
+
+queryDescrizione = prefixes + " SELECT DISTINCT ?descrizione \
+WHERE {<" + thisUrlParams.link + "> crm:P3_has_note ?description . \
+?description rdfs:label ?descrizione \
+}"
+
+queryTipo = prefixes + " SELECT DISTINCT ?tipologia \
+WHERE {<" + thisUrlParams.link + "> crm:P2_has_type ?type . \
+?type rdf:type crm:E55_Type; \
+rdfs:label ?tipologia . \
+}"
+
+querySiglaOVI = prefixes + " SELECT DISTINCT ?sigla_OVI \
+WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?id . \
+?id rdf:type crm:E42_Identifier; \
+crm:P2_has_type ?type ; \
+rdfs:label ?sigla_OVI . \
+?type rdfs:label 'Sigla OVI'. \
+}"
+
+queryTitolo = prefixes + " SELECT DISTINCT ?titolo \
+WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?title . \
+?title rdf:type crm:E35_Title; \
+rdfs:label ?titolo . \
+}"
+
+queryTestoLemmatizzato = prefixes + " SELECT DISTINCT ?testo_lemmatizzato \
+WHERE {<" + thisUrlParams.link + "> crm:P190_has_symbolic_content ?testo_lemmatizzato . \
+}"
+
+queryEdizione = prefixes + " SELECT DISTINCT ?edizione ?edizione_abbreviata \
+WHERE {?edition crm:P70_documents <" + thisUrlParams.link + "> ; \
+crm:P1_is_identified_by ?edition_id . \
+?edition_id rdfs:label ?edizione; \
+crm:P139_has_alternative_form ?ed_abbr . \
+?ed_abbr rdfs:label ?edizione_abbreviata \
+}"
+
+queryRaccolta = prefixes + " SELECT DISTINCT ?raccolta \
+WHERE {?racc crm:P148_has_component <" + thisUrlParams.link + "> ; \
+crm:P2_has_type ?racc_type ; \
+rdfs:label ?raccolta . \
+?racc_type rdfs:label 'Raccolta'. \
+}"
+
+queryToponimi = prefixes + "SELECT DISTINCT ?link_toponimo ?toponimo \
+WHERE {<" + thisUrlParams.link + "> crm:P67_refers_to ?link_toponimo . \
+?link_toponimo rdfs:label ?toponimo ; \
+crm:P2_has_type 'Toponimo' . \
+}"
+
+queryAntroponimi = prefixes + "SELECT DISTINCT * \
+WHERE {<" + thisUrlParams.link + "> crm:P67_refers_to ?link_antroponimo . \
+?link_antroponimo rdfs:label ?antroponimo; \
+crm:P2_has_type 'Antroponimo'}"

+ 710 - 0
js/map.js

@@ -0,0 +1,710 @@
+// 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("}{",",");
+}
+
+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 owl: <http://www.w3.org/2002/07/owl#>"
+
+query = prefixes + " SELECT DISTINCT ?graph ?name_place ?coordinates {\
+GRAPH ?graph {<" + thisUrlParams.link + "> crm:P168_place_is_defined_by ?coordinates;\
+rdfs:label ?name_place .\
+}\
+}"
+
+queryRiferimenti = prefixes + " SELECT DISTINCT ?references {\
+<" + thisUrlParams.link + "> owl:sameAs ?references\
+}"
+
+queryToponimi = prefixes + " SELECT DISTINCT ?toponimi {\
+<" + thisUrlParams.link + "> crm:P1_is_identified_by ?uri_toponym .\
+?uri_toponym rdfs:label ?toponimi\
+}"
+
+queryRicezione = prefixes + " SELECT DISTINCT ?object ?label {\
+<" + thisUrlParams.link + "> owl:sameAs ?place .\
+?event_to crm:P26_moved_to ?place ;\
+rdf:type crm:EL3_Receive_Letter ;\
+rdfs:subClassOf ?event .\
+?object crm:P25i_moved_by ?event ; \
+rdfs:label ?label .\
+} "
+
+queryInvio = prefixes + " SELECT DISTINCT ?object ?label {\
+<" + thisUrlParams.link + "> owl:sameAs ?place .\
+?event_to crm:P27_moved_from ?place ;\
+rdf:type crm:EL2_Send_Letter ;\
+rdfs:subClassOf ?event .\
+?object crm:P25i_moved_by ?event ; \
+rdfs:label ?label .\
+}"
+
+queryCitazione = prefixes + " SELECT DISTINCT ?object ?label\
+{<" + thisUrlParams.link + "> crm:P1_is_identified_by ?toponym .\
+?object crm:P67_refers_to ?toponym ;\
+rdfs:label ?label\
+}"
+
+queryPersone = prefixes + " SELECT DISTINCT ?range ?label \
+WHERE{ \
+  {?place owl:sameAs <" + thisUrlParams.link + "> .\
+  ?event_to crm:P26_moved_to ?place ;\
+  rdf:type crm:EL3_Receive_Letter ;\
+  crm:P01_has_domain ?domain .\
+  ?domain crm:P02_has_range ?range .\
+  ?range rdfs:label ?label .\
+} UNION {\
+  ?place owl:sameAs <" + thisUrlParams.link + "> .\
+  ?event_to crm:P27_moved_from ?place ;\
+  rdf:type crm:EL2_Send_Letter ;\
+  crm:P01_has_domain ?domain .\
+  ?domain crm:P02_has_range ?range .\
+  ?range rdfs:label ?label .\
+  }\
+}"
+
+queryCount = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
+WHERE{ \
+?place_to owl:sameAs <" + thisUrlParams.link + "> . \
+?event_to crm:P26_moved_to ?place_to ; \
+rdf:type crm:EL3_Receive_Letter ; \
+rdfs:subClassOf ?event . \
+?event_from rdfs:subClassOf ?event ; \
+rdf:type crm:EL2_Send_Letter ; \
+crm:P27_moved_from ?place . \
+?place rdfs:label ?label \
+} \
+ORDER BY DESC (?Count)"
+
+queryCount2 = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
+WHERE{ \
+?place_from owl:sameAs <" + thisUrlParams.link + "> . \
+?event_from crm:P27_moved_from ?place_from ; \
+rdf:type crm:EL2_Send_Letter ; \
+rdfs:subClassOf ?event . \
+?event_to rdfs:subClassOf ?event ; \
+rdf:type crm:EL2_Send_Letter ; \
+crm:P27_moved_from ?place . \
+?place rdfs:label ?label . \
+} \
+ORDER BY DESC (?Count) "
+
+
+
+queryURL = prepareQueryURL(query);
+
+queryRef = prepareQueryURL(queryRiferimenti);
+
+queryTopo = prepareQueryURL(queryToponimi);
+
+queryRec = prepareQueryURL(queryRicezione);
+
+querySend = prepareQueryURL(queryInvio);
+
+queryCit = prepareQueryURL(queryCitazione);
+
+queryPer = prepareQueryURL(queryPersone);
+
+queryCon1 = prepareQueryURL(queryCount);
+
+queryCon2 = prepareQueryURL(queryCount2);
+
+
+response = $.ajax({//OGGETTO
+
+    url: queryURL,
+    dataType: "json",
+    success: function (data){
+    	handle_data(data);
+    },
+    error: function (e) {}
+});
+
+
+response_ref = $.ajax({//OGGETTO
+
+    url: queryRef,
+    dataType: "json",
+    success: function (data){
+      handle_ref(data);
+    },
+    error: function (e) {}
+});
+
+response_top = $.ajax({//OGGETTO
+
+    url: queryTopo,
+    dataType: "json",
+    success: function (data){
+      handle_toponym(data);
+    },
+    error: function (e) {}
+});
+
+response_receive = $.ajax({//OGGETTO
+
+    url: queryRec,
+    dataType: "json",
+    success: function (data){
+      handle_receive(data);
+    },
+    error: function (e) {}
+});
+
+response_send = $.ajax({//OGGETTO
+
+    url: querySend,
+    dataType: "json",
+    success: function (data){
+      handle_send(data);
+    },
+    error: function (e) {}
+});
+
+response_cit = $.ajax({//OGGETTO
+
+    url: queryCit,
+    dataType: "json",
+    success: function (data){
+      handle_cit(data);
+    },
+    error: function (e) {}
+});
+
+response_per = $.ajax({//OGGETTO
+
+    url: queryPer,
+    dataType: "json",
+    success: function (data){
+      handle_persons(data);
+    },
+    error: function (e) {}
+});
+
+responseCountA = $.ajax({//OGGETTO
+
+    url: queryCon1,
+    dataType: "json",
+    success: function (data){
+      handle_count(data);
+    },
+    error: function (e) {}
+});
+
+responseCountP = $.ajax({//OGGETTO
+
+    url: queryCon2,
+    dataType: "json",
+    success: function (data){
+      handle_count2(data);
+    },
+    error: function (e) {}
+});
+
+function handle_data(json) {
+	console.log(json);
+
+	const locations = [];
+
+	$.each(
+			json['results']['bindings'],
+			function (index, value) {
+				const loc = []
+				var graph = value['graph']['value'];
+				var label = value['name_place']['value'];
+				var coord = value['coordinates']['value'];
+				const coordinates = coord.split(", ");
+				loc.push(label);
+				loc.push(coordinates[0]);
+				loc.push(coordinates[1]);
+				locations.push(loc);
+
+        document.getElementById("grafo").innerHTML = graph;
+        document.getElementById("nome_luogo").innerHTML = label;
+        document.getElementById("nome_lu").innerHTML = label;
+        document.getElementById("nome_lp").innerHTML = label;
+        document.getElementById("nome_ll").innerHTML = label;
+        document.getElementById("nome_lg").innerHTML = label;
+        document.getElementById("nome_st1").innerHTML = label;
+        document.getElementById("nome_st2").innerHTML = label;
+				
+			});
+
+	var map = L.map('map').setView([locations[0][1], locations[0][2]], 7);
+	mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
+
+	L.tileLayer(
+	  'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+	    attribution: '&copy; ' + mapLink + ' Contributors',
+	    maxZoom: 18,
+	  }).addTo(map);
+
+	for (var i = 0; i < locations.length; i++) {
+	  marker = new L.marker([locations[i][1], locations[i][2]])
+	    .bindPopup(locations[i][0])
+	    .addTo(map);
+	}
+}
+
+
+function handle_ref(json) {
+
+  console.log(json);
+
+  const references = [];
+
+  var list_ref = "";
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        var ref = value['references']['value'];
+        references.push(ref);        
+      });
+
+  
+  for (i=0; i<references.length; i++) {
+      list_ref += "<div class='row'><div class='col'><a href='" + references[i] + "'>" + references[i] + "</a></div></div>";
+  }
+  
+  document.getElementById("riferimenti").innerHTML = list_ref;
+  
+}
+
+function handle_toponym(json) {
+
+  console.log(json);
+
+  const toponym = [];
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        var topo = value['toponimi']['value'];
+        toponym.push(" " + topo);        
+      });
+  
+  document.getElementById("toponimi").innerHTML = toponym;
+
+}
+
+function handle_receive(json) {
+
+  console.log(json);
+
+  const received = {};
+
+  var i=0;
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        key = value['object']['value'];
+        data = value['label']['value'];   
+        received[key] = data;  
+        i++;   
+      });
+
+  var myArray = "";
+
+  for (var key in received) {
+    myArray += "<div class='row'><div class='col-10'>" + received[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
+  }
+
+  document.getElementById("n_receive").innerHTML = i;
+  document.getElementById("object_receive").innerHTML = myArray;
+
+  if (i==0) {
+    var messaggio = "<p>Nessun risultato trovato</p>";
+    document.getElementById("object_receive").innerHTML = messaggio;
+  }
+
+}
+
+
+function handle_send(json) {
+
+  console.log(json);
+
+  const sent = {};
+
+  var i=0;
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        key = value['object']['value'];
+        data = value['label']['value'];   
+        sent[key] = data;   
+        i++;  
+      });
+
+  var myArray = "";
+
+  for (var key in sent) {
+    myArray += "<div class='row'><div class='col-10'>" + sent[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
+  }
+
+  document.getElementById("n_send").innerHTML = i;
+  document.getElementById("object_send").innerHTML = myArray;
+
+  if (i==0) {
+    var messaggio = "<p>Nessun risultato trovato</p>";
+    document.getElementById("object_send").innerHTML = messaggio;
+  }
+
+}
+
+function handle_cit(json) {
+
+  console.log(json);
+
+  const citations = {};
+
+  var i=0;
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        key = value['object']['value'];
+        data = value['label']['value'];   
+        citations[key] = data;  
+        i++;   
+      });
+
+  var myArray = "";
+
+  for (var key in citations) {
+    myArray += "<div class='row'><div class='col-10'>" + citations[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
+  }
+
+  document.getElementById("n_cit").innerHTML = i;
+  document.getElementById("object_cit").innerHTML = myArray;
+
+  if (i==0) {
+    var messaggio = "<p>Nessun risultato trovato</p>";
+    document.getElementById("object_cit").innerHTML = messaggio;
+  }
+
+}
+
+function handle_persons(json) {
+
+  console.log(json);
+
+  const people = {};
+
+  var i=0;
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        key = value['range']['value'];
+        data = value['label']['value'];   
+        people[key] = data;  
+        i++;   
+      });
+
+  var myArray = "";
+
+  for (var key in people) {
+    myArray += "<div class='row'><div class='col-10'>" + people[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
+  }
+
+  document.getElementById("n_per").innerHTML = i;
+  document.getElementById("object_per").innerHTML = myArray;
+
+  if (i==0) {
+    var messaggio = "<p>Nessun risultato trovato</p>";
+    document.getElementById("object_per").innerHTML = messaggio;
+  }
+
+}
+
+function handle_count(json) {
+  console.log(json);
+
+  const toponimi = [];
+
+  const dataToponimi = [];
+
+  var max = 0;
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        const topo = [];
+
+        var toponimo = value['label']['value'];
+        var count = value['Count']['value'];
+        var temp = parseInt(count);
+        toponimi.push(toponimo);
+        dataToponimi.push([toponimo, count]);
+
+        if (temp>max) {
+          max = temp;
+        }
+        
+      });
+
+  // set the dimensions and margins of the graph
+      var margin = {top: 20, right: 30, bottom: 40, left: 90},
+          width = 460 - margin.left - margin.right,
+          height = 400 - margin.top - margin.bottom;
+
+      // append the svg object to the body of the page
+      var svg = d3.select("#my_dataviz")
+        .append("svg")
+          .attr("width", width + margin.left + margin.right)
+          .attr("height", height + margin.top + margin.bottom)
+        .append("g")
+          .attr("transform",
+                "translate(" + margin.left + "," + margin.top + ")");
+
+      // Parse the Data
+      //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
+        // Add X axis
+        var x = d3.scaleLinear()
+          .domain([0, max])
+          .range([ 0, width]);
+        svg.append("g")
+          .attr("transform", "translate(0," + height + ")")
+          .call(d3.axisBottom(x))
+          .selectAll("text")
+            .attr("transform", "translate(-10,0)rotate(-45)")
+            .style("text-anchor", "end");
+
+        // Y axis
+        var y = d3.scaleBand()
+          .range([ 0, height ])
+          .domain(toponimi)
+          .padding(.1);
+        svg.append("g")
+          .call(d3.axisLeft(y))
+
+        //Bars
+        svg.selectAll("myRect")
+          .data(dataToponimi)
+          .enter()
+          .append("rect")
+          .attr("x", x(0) )
+          .attr("y", function(d) { return y(d[0]); })
+          .attr("width", function(d) { return x(d[1]); })
+          .attr("height", y.bandwidth() )
+          .attr("fill", "#69b3a2")
+
+
+  /*var texts = svg.selectAll("myRect")
+    .data(dataToponimi)
+    .enter()
+    .append("text");
+
+  texts.attr("x", function(d){ return d[1] / 4 - 20})
+      .attr("y", function(d,i){ return 22.26*i +20})
+      .attr("text-anchor", "middle")
+      .attr("fill", "#fff")
+      .text(function(d){ return d[1]});*/
+
+}
+
+
+function handle_count2(json) {
+  console.log(json);
+
+  const toponimi = [];
+
+  const dataToponimi = [];
+
+  const values = [];
+
+  var max = 0;
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        const topo = [];
+
+        var toponimo = value['label']['value'];
+        var count = value['Count']['value'];
+        var temp = parseInt(count);
+        toponimi.push(toponimo);
+        dataToponimi.push([toponimo, count]);
+
+        if (temp>max) {
+          max = temp;
+        }
+        
+      });
+
+  // set the dimensions and margins of the graph
+      var margin = {top: 20, right: 30, bottom: 40, left: 90},
+          width = 460 - margin.left - margin.right,
+          height = 400 - margin.top - margin.bottom;
+
+      // append the svg object to the body of the page
+      var svg = d3.select("#my_dataviz2")
+        .append("svg")
+          .attr("width", width + margin.left + margin.right)
+          .attr("height", height + margin.top + margin.bottom)
+        .append("g")
+          .attr("transform",
+                "translate(" + margin.left + "," + margin.top + ")");
+
+      // Parse the Data
+      //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
+        // Add X axis
+        var x = d3.scaleLinear()
+          .domain([0, max])
+          .range([ 0, width]);
+        
+        svg.append("g")
+          .attr("transform", "translate(0," + height + ")")
+          .call(d3.axisBottom(x))
+          .selectAll("text")
+            .attr("transform", "translate(-10,0)rotate(-45)")
+            .style("text-anchor", "end");
+
+        // Y axis
+        var y = d3.scaleBand()
+          .range([ 0, height ])
+          .domain(toponimi)
+          .padding(.1);
+
+        svg.append("g")
+          .call(d3.axisLeft(y))
+
+        //Bars
+        svg.selectAll("myRect")
+          .data(dataToponimi)
+          .enter()
+          .append("rect")
+          .attr("x", x(0) )
+          .attr("y", function(d) { return y(d[0]); })
+          .attr("width", function(d) { return x(d[1]); })
+          .attr("height", y.bandwidth() )
+          .attr("fill", "#69b3a2")
+
+        svg.selectAll("text2")
+          .data(dataToponimi)
+          .enter().append("text2")
+          .text(function(d) {return d[1]})
+          .attr("class", "text")
+}
+
+
+function open_info() {
+
+    document.getElementById("info_luogo").style.display = "block";
+    document.getElementById("place_info").style.display = "block";
+    document.getElementById("topo").style.display = "none";
+    document.getElementById("rif").style.display = "none";
+}
+
+function open_toponimi() {
+
+    document.getElementById("info_luogo").style.display = "block";
+    document.getElementById("place_info").style.display = "none";
+    document.getElementById("topo").style.display = "block";
+    document.getElementById("rif").style.display = "none";
+}
+
+function open_riferimenti() {
+
+    document.getElementById("info_luogo").style.display = "block";
+    document.getElementById("place_info").style.display = "none";
+    document.getElementById("topo").style.display = "none";
+    document.getElementById("rif").style.display = "block";
+}
+
+function open_collegamenti() {
+
+    document.getElementById("references").style.display = "flex";
+    document.getElementById("statistiche").style.display = "none";
+}
+
+function open_statistiche() {
+
+    document.getElementById("references").style.display = "none";
+    document.getElementById("statistiche").style.display = "flex";
+}
+
+var header = document.getElementById("ref_buttons");
+var btns = header.getElementsByClassName("btn");
+for (var i = 0; i < btns.length; i++) {
+  btns[i].addEventListener("click", function() {
+  var current = document.getElementsByClassName("active");
+  current[0].className = current[0].className.replace(" active", "");
+  this.className += " active";
+  });
+}
+
+//out = "";
+//for(i = 0; i < resultArray.length; i++){
+ //   out = out + JSON.stringify(resultArray[i])
+//}
+//queryStringOutput = (queryStringOutput + out).replace("}{",",");
+
+
+/*
+
+var locations = [
+  ["LOCATION_1", 11.8166, 122.0942],
+  ["LOCATION_2", 11.9804, 121.9189],
+  ["LOCATION_3", 10.7202, 122.5621],
+  ["LOCATION_4", 11.3889, 122.6277],
+  ["LOCATION_5", 10.5929, 122.6325]
+];
+
+var map = L.map('map').setView([11.206051, 122.447886], 8);
+mapLink =
+  '<a href="http://openstreetmap.org">OpenStreetMap</a>';
+L.tileLayer(
+  'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+    attribution: '&copy; ' + mapLink + ' Contributors',
+    maxZoom: 18,
+  }).addTo(map);
+
+for (var i = 0; i < locations.length; i++) {
+  marker = new L.marker([locations[i][1], locations[i][2]])
+    .bindPopup(locations[i][0])
+    .addTo(map);
+}
+*/

+ 490 - 0
js/people.js

@@ -0,0 +1,490 @@
+// 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("}{",",");
+}
+
+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 owl: <http://www.w3.org/2002/07/owl#>"
+
+query = prefixes + " SELECT DISTINCT ?place ?label ?coordinates \
+WHERE { \
+{?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
+?event_from crm:P01_has_domain ?pc ; \
+rdf:type crm:EL3_Receive_Letter; \
+crm:P26_moved_to ?place_from . \
+?place_from rdf:type crm:E53_Place ; \
+owl:sameAs ?place . \
+?place rdfs:label ?label ; \
+crm:P168_place_is_defined_by ?coordinates . \
+} UNION { \
+?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
+?event_from crm:P01_has_domain ?pc ; \
+rdf:type crm:EL2_Send_Letter; \
+crm:P27_moved_from ?place_from . \
+?place_from rdf:type crm:E53_Place ; \
+owl:sameAs ?place . \
+?place rdfs:label ?label ; \
+crm:P168_place_is_defined_by ?coordinates . \
+} \
+}"
+
+queryInfo = prefixes + " SELECT DISTINCT ?graph ?label \
+WHERE { \
+GRAPH ?graph {<" + thisUrlParams.link + "> rdfs:label ?label} \
+}"
+
+queryLetters = prefixes + " SELECT DISTINCT ?type ?document_uri ?document_name \
+WHERE {?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
+?ev_send crm:P01_has_domain ?pc ; \
+rdfs:label ?type ; \
+rdfs:subClassOf ?event . \
+?document_uri crm:P25i_moved_by ?event ; \
+rdfs:label ?document_name . \
+}"
+
+queryNetwork = prefixes + " SELECT DISTINCT ?uri ?label ?uri2 ?label2 \
+WHERE { \
+{?event rdf:type crm:EL1_Exchange_Letters . \
+?event_to rdfs:subClassOf ?event; \
+rdf:type crm:EL2_Send_Letter ; \
+crm:P01_has_domain ?pc_to . \
+?pc_to crm:P02_has_range ?uri . \
+?uri rdfs:label ?label . \
+?event_from rdfs:subClassOf ?event; \
+rdf:type crm:EL3_Receive_Letter; \
+crm:P01_has_domain ?pc_from . \
+?pc_from crm:P02_has_range ?uri2 . \
+?uri2 rdfs:label ?label2 . \
+FILTER (?uri = <" + thisUrlParams.link + ">) \
+} UNION { \
+?event rdf:type crm:EL1_Exchange_Letters . \
+?event_to rdfs:subClassOf ?event; \
+rdf:type crm:EL2_Send_Letter ; \
+crm:P01_has_domain ?pc_to . \
+?pc_to crm:P02_has_range <" + thisUrlParams.link + "> . \
+?event_from rdfs:subClassOf ?event; \
+rdf:type crm:EL3_Receive_Letter; \
+crm:P01_has_domain ?pc_from . \
+?pc_from crm:P02_has_range ?uri . \
+?uri rdfs:label ?label . \
+?pc_new crm:P02_has_range ?uri . \
+?event_new crm:P01_has_domain ?pc_new ; \
+rdfs:label ?event_label; \
+rdfs:subClassOf ?exchange . \
+?event3 rdfs:subClassOf ?exchange; \
+rdfs:label ?event_label2; \
+crm:P01_has_domain ?pc3 . \
+?pc3 crm:P02_has_range ?uri2 . \
+?uri2 rdfs:label ?label2 .  \
+FILTER (?event_label != ?event_label2)\
+} \
+} limit 50 "
+
+queryURL = prepareQueryURL(query);
+
+queryNet = prepareQueryURL(queryNetwork);
+
+query = prepareQueryURL(queryInfo);
+
+queryEx = prepareQueryURL(queryLetters);
+
+response = $.ajax({
+
+    url: query,
+    dataType: "json",
+    success: function (data){
+      handle_data(data);
+    },
+    error: function (e) {}
+});
+
+response = $.ajax({
+
+    url: queryURL,
+    dataType: "json",
+    success: function (data){
+    	handle_map(data);
+    },
+    error: function (e) {}
+});
+
+responseNet = $.ajax({
+
+    url: queryNet,
+    dataType: "json",
+    success: function (data){
+      handle_network(data);
+    },
+    error: function (e) {}
+});
+
+responseLet = $.ajax({
+
+    url: queryEx,
+    dataType: "json",
+    success: function (data){
+      handle_Letters(data);
+    },
+    error: function (e) {}
+});
+
+
+
+function handle_data(json) {
+
+  console.log(json);
+
+  var graph = "";
+  var label = "";
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        var graph = value['graph']['value'];
+        var label = value['label']['value'];
+
+        document.getElementById("grafo").innerHTML = graph;
+        document.getElementById("nome_persona").innerHTML = label;
+        document.getElementById("nome1").innerHTML = label;
+        document.getElementById("nome2").innerHTML = label;
+        document.getElementById("nome_au").innerHTML = label;
+        document.getElementById("nome_ap").innerHTML = label;
+        document.getElementById("nome_al").innerHTML = label;
+        
+      });
+  
+}
+
+
+function handle_Letters(json) {
+
+  console.log(json);
+
+  const send = {};
+  const receive = {};
+
+  var i=0;
+  var j=0;
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        type = value['type']['value'];
+        uri = value['document_uri']['value'];
+        title = value['document_name']['value'];
+        if (type == "Invio") {
+          send[uri] = title;
+          i++;
+        } else {
+          receive[uri] = title;
+          j++;
+        }   
+      });
+
+  var Send_Letters = "";
+  var Receive_Letters = "";
+
+  for (var key in send) {
+    Send_Letters += "<div class='row'><div class='col-10'>" + send[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
+  }
+
+  for (var key in receive) {
+    Receive_Letters += "<div class='row'><div class='col-10'>" + receive[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
+  }
+
+  document.getElementById("l_send").innerHTML = i;
+  document.getElementById("l_receive").innerHTML = j;
+  document.getElementById("letters_send").innerHTML = Send_Letters;
+  document.getElementById("letters_receive").innerHTML = Receive_Letters;
+
+  if (i==0) {
+    var messaggio = "<p>Nessun risultato trovato</p>";
+    document.getElementById("letters_send").innerHTML = messaggio;
+  }
+
+  if (j==0) {
+    var messaggio = "<p>Nessun risultato trovato</p>";
+    document.getElementById("letters_receive").innerHTML = messaggio;
+  }
+
+}
+
+
+function handle_map(json) {
+  console.log(json);
+
+  const locations = [];
+  const place_names = [];
+
+  var lat = 0;
+  var long = 0;
+  var i=0;
+  var myPlaces = "";
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        const loc = []
+        var graph = value['place']['value'];
+        var label = value['label']['value'];
+        var coord = value['coordinates']['value'];
+        const coordinates = coord.split(", ");
+        loc.push(label);
+        myPlaces += "<div class='row'><div class='col-10'>" + label + "</div></div>";
+        loc.push(coordinates[0]);
+        lat += parseInt(coordinates[0]);
+        loc.push(coordinates[1]);
+        long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
+        locations.push(loc);
+        i++;
+        
+      });
+
+  var latitude = lat/i;
+  var longitude = long/i;
+
+  document.getElementById("list_places_person").innerHTML = myPlaces;
+
+
+  var map = L.map('map').setView([locations[0][1], locations[0][2]], 5);
+  mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
+
+  L.tileLayer(
+    'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+      attribution: '&copy; ' + mapLink + ' Contributors',
+      maxZoom: 18,
+    }).addTo(map);
+
+  for (var i = 0; i < locations.length; i++) {
+    marker = new L.marker([locations[i][1], locations[i][2]])
+      .bindPopup(locations[i][0])
+      .addTo(map);
+  }
+}
+
+//out = "";
+//for(i = 0; i < resultArray.length; i++){
+ //   out = out + JSON.stringify(resultArray[i])
+//}
+//queryStringOutput = (queryStringOutput + out).replace("}{",",");
+
+
+/*
+
+var locations = [
+  ["LOCATION_1", 11.8166, 122.0942],
+  ["LOCATION_2", 11.9804, 121.9189],
+  ["LOCATION_3", 10.7202, 122.5621],
+  ["LOCATION_4", 11.3889, 122.6277],
+  ["LOCATION_5", 10.5929, 122.6325]
+];
+
+var map = L.map('map').setView([11.206051, 122.447886], 8);
+mapLink =
+  '<a href="http://openstreetmap.org">OpenStreetMap</a>';
+L.tileLayer(
+  'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+    attribution: '&copy; ' + mapLink + ' Contributors',
+    maxZoom: 18,
+  }).addTo(map);
+
+for (var i = 0; i < locations.length; i++) {
+  marker = new L.marker([locations[i][1], locations[i][2]])
+    .bindPopup(locations[i][0])
+    .addTo(map);
+}
+*/
+
+function handle_network(json) {
+  console.log(json);
+
+  const  myArray = {};
+  const  myLinks = [];
+  var listNodes = "";
+  var listLinks = "";
+  var ArrayNames = "";
+
+  var max = 0;
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        const topo = [];
+
+        var id = value['uri']['value'];
+        var name = value['label']['value'];
+        var id2 = value['uri2']['value'];
+        var name2 = value['label2']['value'];
+        ArrayNames += "<div class='row'><div class='col-10'>" + name2 + "</div><div class='col'><a target='_blank' href='" + id2 + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
+        myArray[id] = name;
+        myArray[id2] = name2;
+        myLinks.push([id, id2]);
+        
+      });
+
+  document.getElementById("list_person_network").innerHTML = ArrayNames;
+
+  for (var key in myArray) {
+      listNodes += '{ "id": \"' + key + '\", "name": \"' + myArray[key] + '\"},';
+  }
+
+  for (var i in myLinks) {
+    var source = myLinks[i][0]
+    var target = myLinks[i][1]
+    listLinks += '{ "source": \"' + source + '\", "target": \"' + target + '\"},';
+  }
+
+  console.log(myLinks);
+
+  let listN = ('[' + listNodes + ']').replace(',]', ']');
+  let listL = ('[' + listLinks + ']').replace(',]', ']');
+
+
+  const nodes = JSON.parse(listN);
+  const links = JSON.parse(listL);
+
+  console.log(nodes);
+  console.log(links);
+
+
+  var svg = d3.select("svg"),
+      width = +svg.attr("width"),
+      height = +svg.attr("height");
+
+  var simulation = d3.forceSimulation()
+      .force("link", d3.forceLink().id(function(d) { return d.id; }))
+      //.force("charge", d3.forceManyBody().strength(-200))
+      .force('charge', d3.forceManyBody()
+        .strength(-500)
+        .theta(0.8)
+        .distanceMax(250)
+      )
+  //    .force('collide', d3.forceCollide()
+  //       .radius(d => 40)
+  //       .iterations(2)
+  //     )
+      .force("center", d3.forceCenter(width / 4, height / 3));
+
+  
+  links.forEach(function(d){
+//     d.source = d.source_id;    
+//     d.target = d.target_id;
+  });           
+
+  var link = svg.append("g")
+                .style("stroke", "#aaa")
+                .selectAll("line")
+                .data(links)
+                .enter().append("line");
+
+  var node = svg.append("g")
+            .attr("class", "nodes")
+  .selectAll("circle")
+            .data(nodes)
+  .enter().append("circle")
+          .attr("r", 2)
+          .attr("id", function (d) { return d.id; })
+          .call(d3.drag()
+              .on("start", dragstarted)
+              .on("drag", dragged)
+              .on("end", dragended));
+  
+  var label = svg.append("g")
+      .attr("class", "labels")
+      .selectAll("text")
+      .data(nodes)
+      .enter().append("text")
+        .attr("class", "label")
+        .call(d3.drag()
+              .on("start", dragstarted)
+              .on("drag", dragged)
+              .on("end", dragended))
+        .text(function(d) { return d.name; });
+
+  simulation
+      .nodes(nodes)
+      .on("tick", ticked);
+
+  simulation.force("link")
+      .links(links);
+
+  function ticked() {
+    link
+        .attr("x1", function(d) { return d.source.x; })
+        .attr("y1", function(d) { return d.source.y; })
+        .attr("x2", function(d) { return d.target.x; })
+        .attr("y2", function(d) { return d.target.y; });
+
+    node
+         .attr("r", 5)
+         .style("fill", "#efefef")
+         .style("stroke", "#424242")
+         .style("stroke-width", "1px")
+         .attr("cx", function (d) { return d.x+5; })
+         .attr("cy", function(d) { return d.y-3; });
+    
+    label
+        .attr("x", function(d) { return d.x+12; })
+            .attr("y", function (d) { return d.y+1; })
+            .style("font-size", "10px").style("fill", "#333");
+
+  }
+
+  function dragstarted(d) {
+    if (!d3.event.active) simulation.alphaTarget(0.3).restart()
+    d.fx = d.x
+    d.fy = d.y
+  //  simulation.fix(d);
+  }
+
+  function dragged(d) {
+    d.fx = d3.event.x
+    d.fy = d3.event.y
+  //  simulation.fix(d, d3.event.x, d3.event.y);
+  }
+
+  function dragended(d) {
+    d.fx = d3.event.x
+    d.fy = d3.event.y
+    if (!d3.event.active) simulation.alphaTarget(0);
+    //simulation.unfix(d);
+  }
+}

+ 664 - 0
js/search.js

@@ -0,0 +1,664 @@
+$(document).ready(function () {
+	//#######################################
+
+	const graphArray = [
+	["ASPO - Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/datini"], 
+	["ASPO - Ospedale", "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale"],
+	["ASPO - Marcovaldi", "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi"],
+	["ASPO - Gettatelli", "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli"],
+	["ASPO - Autori ASPO", "http://dev.restore.ovi.cnr.it:8890/aspo/actors"],
+	["MPP - Collezione Martini", "http://dev.restore.ovi.cnr.it:8890/mpp/martini"],
+	["MPP - Collezione Ospedale", "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale"],
+	["MPP - Collezione Datini", "http://dev.restore.ovi.cnr.it:8890/mpp/datini"],
+	["MPP - Autori MPP", "http://dev.restore.ovi.cnr.it:8890/mpp/authors"],
+	["OVI - Lettere", "http://dev.restore.ovi.cnr.it:8890/ovi/datini"],
+	["Luoghi", "http://dev.restore.ovi.cnr.it:8890/mpp/places"]
+	];
+
+	var graph_selector = document.getElementById("graph_selector");
+
+	let x = graphArray.length;
+
+	for(var i=0; i<x; i++) {
+		   var opt = document.createElement("option");
+		   opt.value= graphArray[i][1];
+		   opt.innerHTML = graphArray[i][0]; // whatever property it has
+
+		   // then append it to the select element
+		   graph_selector.add(opt);
+		}
+
+	var search_name = "";
+	var testo = "";
+
+	function results_retrieveData() {
+
+		search_name = testo;
+
+		var g = document.getElementById("graph_selector");
+		var graph = g.value;
+
+		var search_graph = "?g";
+		var gg = "?g";
+
+		if (graph != "") {
+			search_graph = '<' + graph + '>';
+			gg = "";
+		} 
+
+
+		//var query='SELECT DISTINCT ?nome WHERE {  ?autore <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.cidoc-crm.org/cidoc-crm/E39_Actor> .   ?autore <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by> ?nomeid.   ?nomeid <http://www.w3.org/2000/01/rdf-schema#label> ?nome . FILTER regex(?nome, "'+ search_name +'") }' ;
+		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/>"
+
+		queryMMO = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label ?object\
+		WHERE {GRAPH "+ search_graph +" { ?subject ?property ?object }\
+		?subject rdf:type crm:E22_Man-Made_Object ;\
+		rdfs:label ?label ;\
+		?property ?object .\
+		?object bif:contains \"\' "+ search_name + " \'\"  .\
+		}"
+
+		queryInfObj = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph (SAMPLE(?type) AS ?typeName) ?subject ?label ?object \
+		WHERE {GRAPH "+ search_graph +" { ?subject ?property ?object }\
+		?subject rdf:type crm:E73_Information_Object ;\
+		rdfs:label ?label ;\
+		?property ?object .\
+		?object bif:contains \"\' "+ search_name + " \'\"  .\
+		OPTIONAL {?subject crm:P2_has_type ?entity_type . \
+		?entity_type rdfs:label ?type .}\
+		} \
+		GROUP BY ?subject ?object ?label "+ gg + ""
+
+		queryPerson = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label \
+		WHERE {GRAPH "+ search_graph +" { ?subject rdfs:label ?label ;\
+		rdf:type crm:E21_Person .\
+		?label bif:contains \"\' "+ search_name + " \'\"  .}\
+		}"
+
+		queryPlace = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label \
+		WHERE {GRAPH "+ search_graph +" { ?subject rdfs:label ?label ;\
+		rdf:type crm:E53_Place .\
+		?label bif:contains \"\' "+ search_name + " \'\"  .}\
+		}"
+
+
+		//query = 'SELECT DISTINCT '+ search_graph +' AS ?graph ?link ?label ?entity ?object ?objLab WHERE { GRAPH '+ search_graph +' { ?link <http://www.w3.org/2000/01/rdf-schema#label> ?label ; <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> '+ search_entity +' . ?label bif:contains "\'' + search_name + '\'" .} '+ search_entity +' <http://www.w3.org/2000/01/rdf-schema#label> ?entity . FILTER (langMatches( lang(?entity), "en" )) OPTIONAL {?link <http://www.cidoc-crm.org/cidoc-crm/P2_has_type> ?object } OPTIONAL {?link <http://www.cidoc-crm.org/cidoc-crm/P2_has_type> ?link_object . ?link_object <http://www.w3.org/2000/01/rdf-schema#label> ?objLab }} limit 100';
+       
+		var ManMadeObject_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryMMO) + '&output=json';
+
+		var InformationObject_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryInfObj) + '&output=json';
+
+		var Persons_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryPerson) + '&output=json';
+
+		var Places_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryPlace) + '&output=json';
+
+		$.ajax({
+
+			url: ManMadeObject_url + '&callback=?',
+			dataType: "json",
+			success: function (data) {
+				MMO_handle_json(data);
+			},
+			error: function (e) {}
+		});
+
+		$.ajax({
+
+			url: InformationObject_url + '&callback=?',
+			dataType: "json",
+			success: function (data) {
+				InfObj_handle_json(data);
+			},
+			error: function (e) {}
+		});
+
+		$.ajax({
+
+			url: Persons_url + '&callback=?',
+			dataType: "json",
+			success: function (data) {
+				Person_handle_json(data);
+			},
+			error: function (e) {}
+		});
+
+		$.ajax({
+
+			url: Places_url + '&callback=?',
+			dataType: "json",
+			success: function (data) {
+				Place_handle_json(data);
+			},
+			error: function (e) {}
+		});
+
+	}
+
+	function rewrite_graph(graph) {
+
+		var graph_name = ""
+
+		if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/datini") {
+			graph_name = "Archivio di Stato di Prato"; 
+		}
+		else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") {
+			graph_name = "Archivio di Stato di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") {
+			graph_name = "Archivio di Stato di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") {
+			graph_name = "Archivio di Stato di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/aspo/actors") {
+			graph_name = "Archivio di Stato di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/mpp/martini") {
+			graph_name = "Museo di Palazzo Pretorio di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale") {
+			graph_name = "Museo di Palazzo Pretorio di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/mpp/datini") {
+			graph_name = "Museo di Palazzo Pretorio di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/mpp/authors") {
+			graph_name = "Museo di Palazzo Pretorio di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/ovi/datini") {
+			graph_name = "Opera del Vocabolario Italiano";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/ovi/datini/trascr") {
+			graph_name = "Opera del Vocabolario Italiano";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/places") {
+			graph_name = "Luoghi";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/mpp/places") {
+			graph_name = "Museo di Palazzo Pretorio di Prato";
+		}
+		else if (graph ==  "http://dev.restore.ovi.cnr.it:8890/label/toponimi") {
+			graph_name = "Toponimi Archivio di Stato di Prato";
+		}
+		else {graph_name = graph;
+		}
+
+		return graph_name;
+	}
+
+	function MMO_handle_json(json) {
+
+		console.log(json); 
+
+		$('#wb_Shape1').text("");
+		$('#wb_Image1').text("");
+		$('#Man-Made_Object').text("");
+		$(".results").css("display", "block");
+		$('#n_mmo').text("");
+
+		var i = 0;
+
+		$.each(
+			json['results']['bindings'],
+			function (index, value) {
+				var object = ""; /*Inserisci VALUE TIPOLOGIA*/
+
+				var graph = value['graph']['value'];
+				var graph_name = rewrite_graph(graph);
+
+				object += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
+				'<a href=' + value['subject']['value'] + '>' + value['label']['value'] + '</a></div>' +
+				'<div class="col"></div>' +
+				'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button></div>' +
+				/*DA QUI HYPERLINK ->*/'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button></div>' +
+				/*DA QUI LOD ->*/'<div class="col"><a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>'; 
+
+				i++;
+
+				/*onclick=copy__Text("' + value['link']['value'] + '")*/
+
+				$('#Man-Made_Object').append(object);
+
+			});
+
+		$('#n_mmo').append(i);
+
+		if (i==0) {
+			var message = '<p>Nessun Oggetto Fisico trovato</p>';
+			$('#Man-Made_Object').append(message);
+		}
+
+	}
+
+	function InfObj_handle_json(json) {
+
+		console.log(json); 
+
+		$('#Information_Object').text("");
+		$('#n_io').text("");
+
+		var i = 0;
+
+		$.each(
+			json['results']['bindings'],
+			function (index, value) {
+				var information = ""; /*Inserisci VALUE TIPOLOGIA*/
+
+				var graph = value['graph']['value'];
+				var graph_name = rewrite_graph(graph);
+
+				var tipo = "";
+				var envelope_button = "";
+
+				if (value.hasOwnProperty('typeName')) {
+						tipo = value['typeName']['value'];
+					}
+				
+				if (tipo == "lettera" || tipo == "Testo annotato OVI") {
+					envelope_button  += '<button type="button" id="' + value['subject']['value'] + 
+					'" class="lettera btn btn-default" alt="lettera" title="' + value['label']['value'] + 
+					'"><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
+				}
+
+				information += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
+				'<a href=' + value['subject']['value'] + '>' + value['label']['value'] + '</a></div>' + 
+				'<div class="col">' + envelope_button + '</div>' +
+				'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button></div>' +
+				/*DA QUI HYPERLINK ->*/'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button></div>' +
+				/*DA QUI LOD ->*/'<div class="col"><a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>'; 
+
+				i++;
+
+				/*onclick=copy__Text("' + value['link']['value'] + '")*/
+
+				$('#Information_Object').append(information);
+
+			});
+
+		$('#n_io').append(i);
+
+		if (i==0) {
+			var message = '<p>Nessun Oggetto Informativo trovato</p>';
+			$('#Information_Object').append(message);
+		}
+
+	}
+
+	function Person_handle_json(json) {
+
+		console.log(json); 
+
+		$('#Person').text("");
+		$('#n_ps').text("");
+		
+		var i = 0;
+
+		$.each(
+			json['results']['bindings'],
+			function (index, value) {
+				var person = ""; /*Inserisci VALUE TIPOLOGIA*/
+				var graph = value['graph']['value'];
+				var graph_name = rewrite_graph(graph);
+
+				person += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
+				'<a href=' + value['subject']['value'] + '>' + value['label']['value'] + '</a></div>' +
+				'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="persona btn btn-default" alt="persona" title="' + 
+				value['label']['value'] + '"><i class="fa fa-user"></i><p class="btn-text">Scheda Persona</p></button></div>' +
+				'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button></div>' +
+				/*DA QUI HYPERLINK ->*/'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button></div>' +
+				/*DA QUI LOD ->*/'<div class="col"><a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>'; 
+
+				i++;
+
+				/*onclick=copy__Text("' + value['link']['value'] + '")*/
+
+				$('#Person').append(person);
+
+			});
+
+		$('#n_ps').append(i);
+
+		if (i==0) {
+			var message = '<p>Nessuna Persona trovata</p>';
+			$('#Person').append(message);
+		}
+
+	}
+
+	function Place_handle_json(json) {
+
+		console.log(json); 
+
+		$('#Place').text("");
+		$('#n_pl').text("");
+		
+		var i = 0;
+
+		$.each(
+			json['results']['bindings'],
+			function (index, value) {
+				var place = ""; /*Inserisci VALUE TIPOLOGIA*/
+				var graph = value['graph']['value'];
+				var graph_name = rewrite_graph(graph);
+
+				place += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
+				'<a href=' + value['subject']['value'] + '>' + value['label']['value'] + '</a></div>' +
+				'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="luogo btn btn-default" alt="luogo" title="' + 
+				value['label']['value'] + '"><i class="fa fa-map"></i><p class="btn-text">Scheda Luogo</p></button></div>' +
+				'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button></div>' +
+				/*DA QUI HYPERLINK ->*/'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button></div>' +
+				/*DA QUI LOD ->*/'<div class="col"><a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>'; 
+
+				i++;
+
+				/*onclick=copy__Text("' + value['link']['value'] + '")*/
+
+				$('#Place').append(place);
+
+			});
+
+		$('#n_pl').append(i);
+
+		if (i==0) {
+			var message = '<p>Nessun Luogo trovato</p>';
+			$('#Place').append(message);
+		}
+
+	}
+
+	$('#ClipArt1').click(function () {
+		testo = $('input#TextArea1').val();
+		results_retrieveData();
+		search_name = "";
+	});
+  
+    $('input#TextArea1').keypress(function(e) {
+      var key = e.which;
+      if (key == 13) // the enter key code
+          {
+            $('#ClipArt1').click();
+            return false;
+          }
+    });
+
+	//onlick hyperlink button
+
+	$(document).on("click", ".hyp", function (ev) {
+
+		var link = this.id;
+		//alert(nome_autore);
+		//$('#myModal').text("");
+		$("#myModal").empty();
+		$("#myModal").css("display", "block");
+		$('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
+			link + "</div><button id='copy_btn' class='btn btn-primary btn-lg' onclick='myFunction()'>Copia</button>");
+
+		
+
+	});
+
+	$(document).on("click", ".lettera", function (ev) {
+
+		var link = this.id;
+		//alert(nome_autore);
+		//$('#myModal').text("");
+		window.open("lettera.html?link="+this.id);
+		
+
+	});
+
+	$(document).on("click", ".persona", function (ev) {
+
+		var link = this.id;
+		//alert(nome_autore);
+		//$('#myModal').text("");
+		window.open("Persona.html?link="+this.id);
+		
+
+	});
+
+	$(document).on("click", ".luogo", function (ev) {
+
+		var link = this.id;
+		//alert(nome_autore);
+		//$('#myModal').text("");
+		window.open("Luogo.html?link="+this.id);
+		
+
+	});
+
+	$(document).on("click", ".close", function (ev) {
+
+		var link = this.id;
+		//alert(nome_autore);
+		//$('#myModal').text("");
+		$("#myModal").css("display", "none");
+
+	});
+
+	$(document).on("click", ".back", function (ev) {
+
+		$("#myTab").css("display", "none");
+
+	});
+
+	$(document).on("click", ".cit", function (ev) {
+		
+		var author ="RESTORE. smart access to digital heritage and memory"
+
+		var year = new Date().getFullYear()
+
+		var today = new Date();
+		var dd = String(today.getDate()).padStart(2, '0');
+		var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
+		var yyyy = today.getFullYear();
+
+		today = dd + '/' + mm + '/' + yyyy;
+
+		var link = this.id;
+		//alert(nome_autore);
+		//$('#myModal').text("");
+		$("#myModal").empty();
+		$("#myModal").css("display", "block");
+		$('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" + 
+			author + " " + year + ", accesso effettuato: " + today + ", &lt;" + link + "&gt;</div><button id='copy_btn' class='btn btn-primary btn-lg' onclick='myFunction()'>Copia</button>");
+
+		
+
+	});
+
+	$(document).on("click", ".scheda", function (ev) {
+
+		var link = this.id;
+		var title = this.title;
+
+		//alert(nome_autore);
+		$("#myTab").empty();
+		$("#myTab").css("display", "block");
+		$('#myTab').append("<div class='tab-content'><span class='back'>&lt; Indietro</span><br /><h2><a href='" + link + "' target='_blank'>" + title + "</a></h2><div id='tab_container'><h3>Relazioni dirette</h3><br /><table id='info_link' class='table table-hover'></table><br /><table id='info_ico' class='table table-hover'></table><br /><h3>Relazioni inverse</h3><br /><table id='info_obj' class='table table-hover'></table></div></div>");
+
+		/*var query_a = 'SELECT DISTINCT ?label WHERE { {<' + link +
+		 '> ?p ?object. OPTIONAL {?object ?property ?label . FILTER(?property = <http://www.w3.org/2004/02/skos/core#prefLabel> || ?property = <http://www.w3.org/2000/01/rdf-schema#label>) FILTER (langMatches( lang(?label), "en" )) } } UNION {<'+ link +
+		 '> ?p ?object. OPTIONAL {?p <http://www.w3.org/2000/01/rdf-schema#label> ?propertyLabel .?object <http://www.w3.org/2000/01/rdf-schema#label> ?label } FILTER (?p != <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>) FILTER (langMatches( lang(?propertyLabel), "en" ))  }}';
+		*/
+		var query_a = 'SELECT DISTINCT ?propLab ?object ?label WHERE {{<' + link + 
+		'> ?property ?object. ?property <http://www.w3.org/2000/01/rdf-schema#label> ?propLab . OPTIONAL {?object <http://www.w3.org/2000/01/rdf-schema#label> ?label . } FILTER (?property != <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?property != <http://www.cidoc-crm.org/cidoc-crm/P62_depicts>) FILTER (langMatches( lang(?propLab), "en" ))} UNION {<' + link + 
+		'> ?property ?object. ?property <http://www.w3.org/2000/01/rdf-schema#label> ?propLab . OPTIONAL {?object <http://www.w3.org/2000/01/rdf-schema#label> ?label . } FILTER (?property != <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?property != <http://www.w3.org/2000/01/rdf-schema#label>) FILTER(!regex(?property, "cidoc"))}}';
+		var object_url_a = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query_a) + '&output=json';
+
+		var query_b = 'SELECT DISTINCT ?subject ?label ?property ?propertyLabel WHERE {?subject ?property <' + link + 
+		'> ; <http://www.w3.org/2000/01/rdf-schema#label> ?label . ?property <http://www.w3.org/2000/01/rdf-schema#label> ?propertyLabel . FILTER (langMatches( lang(?propertyLabel), "en" ))}';
+		var object_url_b = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query_b) + '&output=json';
+
+		var query_c = 'SELECT DISTINCT ?object ?label WHERE {{<' + link + '> <http://www.cidoc-crm.org/cidoc-crm/P62_depicts> ?object . ?object <http://www.w3.org/2000/01/rdf-schema#label> ?label .} UNION {<' + link + 
+		'> <http://www.cidoc-crm.org/cidoc-crm/P62_depicts> ?object . ?object <http://www.w3.org/2004/02/skos/core#prefLabel> ?label . FILTER (langMatches(lang(?label), "it" )) }}';
+		var object_url_c = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query_c) + '&output=json';
+
+
+		$.ajax({//SOGGETTO
+
+			url: object_url_a + '&callback=?',
+			dataType: "json",
+			success: function (data_a) {
+				object_info_a(data_a);
+			},
+			error: function (e) {}
+		});
+
+		$.ajax({//OGGETTO
+
+			url: object_url_b + '&callback=?',
+			dataType: "json",
+			success: function (data_b) {
+				object_info_b(data_b);
+			},
+			error: function (e) {}
+		});
+
+		$.ajax({//ICONCLASS
+
+			url: object_url_c + '&callback=?',
+			dataType: "json",
+			success: function (data_c) {
+				object_info_c(data_c);
+			},
+			error: function (e) {}
+		});
+		
+	});
+
+	function object_info_a(json) {
+
+		console.log(json); 
+
+		var j = 0;
+
+		$('#info_link').text("");
+
+		$.each(
+			json['results']['bindings'],
+			function (index, value) {
+				var autore_a = "";
+				var object = "";
+				var object_type = value['object']['type'];
+				if (object_type == "typed-literal" || object_type == "literal"){
+					object = '<td>'+ value['object']['value'] + '</td>';
+				}
+				else{
+					object = '<td style="width:60%;"><a href="'+ value['object']['value'] +'" target="_blank">'+ value['label']['value'] +'</a></td><td>' +
+					'<button type="button" id="' + value['object']['value'] + '" class="scheda btn btn-default" alt="scheda" title="' + value['label']['value'] + '"><i class="fa fa-bars"></i><p class="btn-text">Scheda</p></button></td><td>' +
+					'<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['object']['value'] + '" target="_blank"><button type="button" id="lod " class="btn btn-default info" alt="scheda" title="Info"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></td>';
+				}
+
+				autore_a += /*INIZIO DIV*/ '<tr><td style="width:25%;">' + value['propLab']['value'] + '</td>' + object + '</tr>';/*FINE DIV*/ 
+
+				/*onclick=copy__Text("' + value['link']['value'] + '")*/
+				j++;
+
+				$('#info_link').append(autore_a);
+
+			});
+
+		if (j==0) {
+			var message_a = '<tr id="error"><td><p>Non sono presenti relazioni dirette per questa risorsa</p></td></tr>';
+			$('#info_link').append(message_a);
+		}
+
+	}
+	
+	function object_info_b(json) {
+
+		console.log(json); 
+
+		var k = 0;
+
+		$('#info_obj').text("");
+
+		$.each(
+			json['results']['bindings'],
+			function (index, value) {
+
+				var autore_b = "";
+
+				autore_b += /*INIZIO DIV*/ '<tr><td style="width:60%;"><a href="' + value['subject']['value'] + '" target="_blank">' + value['label']['value'] + '</a></td><td style="width:25%;">' + value['propertyLabel']['value'] + '</td><td>' + 
+				'<button type="button" id="' + value['subject']['value'] + '" class="scheda btn btn-default" alt="scheda" title="' + value['label']['value'] + '"><i class="fa fa-bars"></i><p class="btn-text">Scheda</p></button></td><td>' +
+				'<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" id="lod " class="btn btn-default info" alt="scheda" title="Info"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></td></tr>';
+				/*FINE DIV*/ 
+
+				k++;
+				/*onclick=copy__Text("' + value['link']['value'] + '")*/
+
+				$('#info_obj').append(autore_b);
+
+			});
+
+		if (k==0) {
+			var message_b = '<tr id="error"><td><p>Non sono presenti relazioni inverse per questa risorsa</p></td></tr>';
+			$('#info_obj').append(message_b);
+		}
+
+	}
+
+	function object_info_c(json) {
+
+		console.log(json); 
+
+		$('#info_ico').text("");
+
+		$.each(
+			json['results']['bindings'],
+			function (index, value) {
+
+				var autore_c = "";
+
+				autore_c += /*INIZIO DIV*/ '<tr><td style="width:25%;">depicts</td><td style="width:60%;"><a href="' + value['object']['value'] + '">' + value['label']['value'] + '</a></td><td>' + 
+				'<button type="button" id="' + value['object']['value'] + '" class="scheda btn btn-default" alt="scheda" title="' + value['label']['value'] + '"><i class="fa fa-bars"></i><p class="btn-text">Scheda</p></button></td><td>' +
+				'<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['object']['value'] + '" target="_blank"><button type="button" id="lod " class="btn btn-default info" alt="scheda" title="Info"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></td></tr>';
+				/*FINE DIV*/ 
+
+				/*onclick=copy__Text("' + value['link']['value'] + '")*/
+
+				$('#info_ico').append(autore_c);
+
+			});
+
+	}
+
+	//VISUALIZZAZIONI DATI DELL'AUTORE
+	
+
+	//FUNZIONE LETTURA LUNGHEZZA FILE JSON
+	/*
+	function objLength(obj){
+		var i=0;
+		for (var x in obj){
+		if(obj.hasOwnProperty(x)){
+		  i++;
+		}
+		} 
+		return i;
+	}
+	*/
+
+	//#######################################
+});
+
+function copyToClipboard(text) {
+    var sampleTextarea = document.createElement("textarea");
+    document.body.appendChild(sampleTextarea);
+    sampleTextarea.value = text; //save main text in it
+    sampleTextarea.select(); //select textarea contenrs
+    document.execCommand("copy");
+    document.body.removeChild(sampleTextarea);
+}
+
+function myFunction(){
+    var copy = document.getElementById("myInput");
+    copyText = copy.textContent;
+    copyToClipboard(copyText);
+
+    //copyToClipboard(copyText.value);
+}
+