瀏覽代碼

Carica file su 'js'

Alessia 2 年之前
父節點
當前提交
cba9dffe4d
共有 2 個文件被更改,包括 1011 次插入0 次删除
  1. 347 0
      js/map.js
  2. 664 0
      js/search.js

+ 347 - 0
js/map.js

@@ -0,0 +1,347 @@
+// 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 ?ref ?toponym {\
+GRAPH ?graph {<" + thisUrlParams.link + "> crm:P168_place_is_defined_by ?coordinates;\
+rdfs:label ?name_place ;\
+owl:sameAs ?ref;\
+crm:P1_is_identified_by ?uri_toponym .\
+?uri_toponym rdfs:label ?toponym\
+}\
+}"
+
+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\
+}"
+
+
+queryURL = prepareQueryURL(query);
+
+queryRef = prepareQueryURL(queryRiferimenti);
+
+queryTopo = prepareQueryURL(queryToponimi);
+
+queryRec = prepareQueryURL(queryRicezione);
+
+querySend = prepareQueryURL(queryInvio);
+
+queryCit = prepareQueryURL(queryCitazione);
+
+
+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) {}
+});
+
+
+function handle_data(json) {
+	console.log(json);
+
+	const locations = [];
+
+	$.each(
+			json['results']['bindings'],
+			function (index, value) {
+				const loc = []
+				var graph = value['graph']['value'];
+        var ref = value['ref']['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;
+				
+			});
+
+	var map = L.map('map').setView([locations[0][1], locations[0][2]], 12);
+	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 = [];
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        var ref = value['references']['value'];
+        references.push(ref);        
+      });
+  
+  document.getElementById("riferimenti").innerHTML = references;
+  
+}
+
+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 = {};
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        key = value['object']['value'];
+        data = value['label']['value'];   
+        received[key] = data;     
+      });
+
+  var myArray = "";
+
+  for (var key in received) {
+    myArray += received[key] + "<br />";
+  }
+
+  document.getElementById("object_receive").innerHTML = myArray;
+
+}
+
+
+function handle_send(json) {
+
+  console.log(json);
+
+  const sent = {};
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        key = value['object']['value'];
+        data = value['label']['value'];   
+        sent[key] = data;     
+      });
+
+  var myArray = "";
+
+  for (var key in sent) {
+    myArray += sent[key] + "<br />";
+  }
+
+  document.getElementById("object_send").innerHTML = myArray;
+
+}
+
+function handle_cit(json) {
+
+  console.log(json);
+
+  const citations = {};
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        key = value['object']['value'];
+        data = value['label']['value'];   
+        citations[key] = data;     
+      });
+
+  var myArray = "";
+
+  for (var key in citations) {
+    myArray += citations[key] + "<br />";
+  }
+
+  document.getElementById("object_cit").innerHTML = myArray;
+
+}
+
+
+
+
+//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);
+}
+*/

+ 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/trascr"],
+	["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);
+}
+