Alessia 1 vuosi sitten
vanhempi
commit
767d8da8d4
11 muutettua tiedostoa jossa 810 lisäystä ja 118 poistoa
  1. 1 1
      Persona.html
  2. 47 0
      css/lettera.css
  3. 311 0
      css/timeline.css
  4. 22 4
      js/lettera.js
  5. 4 1
      js/lettera_query.js
  6. 103 16
      js/query/managerQuery.js
  7. 274 64
      js/results.js
  8. 2 0
      js/results_query.js
  9. 1 1
      js/search.js
  10. 4 31
      js/word_cloud.js
  11. 41 0
      results.html

+ 1 - 1
Persona.html

@@ -562,10 +562,10 @@
 		</div>
 	</footer>
 
+	<script src="js/query/managerQuery.js"></script>
 	<script src="js/people.js"></script>
 	<script src="js/rectangles.js"></script>
 	<script src="js/word_cloud.js"></script>
-	<script src="js/query/managerQuery.js"></script>
 
 	<!-- Bootstrap core JavaScript -->
 	<script src="vendor/jquery/jquery.min.js"></script>

+ 47 - 0
css/lettera.css

@@ -440,3 +440,50 @@ header.masthead {
   text-decoration: none;
   cursor: pointer;
 }
+
+.inner_results {
+  background-color: #ffffffa1;
+  border: 0;
+}
+
+#lemmi_container {
+  border: 1px solid;
+  border-radius: 6px;
+  overflow: auto;
+}
+
+.res_list .btn-icon {
+  font-size: 16px;
+}
+
+.def_res {
+  background-color: #3f4149;
+  color: #fff;
+  padding-top: 7px;
+  padding-bottom: 10px;
+  font-weight: 600;
+}
+
+.def_res .num_res {
+  display: flex;
+  justify-content: end;
+  align-items: end;
+}
+
+.def_res p {
+  margin-bottom: 0;
+}
+
+.res {
+  padding-top: 15px;
+  padding-bottom: 15px;
+  font-size: 14px;
+}
+
+.res:not(:last-child) {
+  border-bottom: 1px solid #000;
+}
+
+.explore {
+  color: #b61924;
+}

+ 311 - 0
css/timeline.css

@@ -0,0 +1,311 @@
+body{
+    margin-top:20px;
+    background:#eee;
+}
+
+.timeline {
+    list-style-type: none;
+    margin: 0;
+    padding: 0;
+    position: relative
+}
+
+.timeline:before {
+    content: '';
+    position: absolute;
+    top: 5px;
+    bottom: 5px;
+    width: 5px;
+    background: #2d353c;
+    left: 20%;
+    margin-left: -2.5px
+}
+
+.timeline>li {
+    position: relative;
+    min-height: 50px;
+    padding: 20px 0
+}
+
+.timeline .timeline-time {
+    position: absolute;
+    left: 0;
+    width: 18%;
+    text-align: right;
+    top: 30px
+}
+
+.timeline .timeline-time .date,
+.timeline .timeline-time .time {
+    display: block;
+    font-weight: 600
+}
+
+.timeline .timeline-time .date {
+    line-height: 16px;
+    font-size: 12px
+}
+
+.timeline .timeline-time .time {
+    line-height: 24px;
+    font-size: 20px;
+    color: #242a30
+}
+
+.timeline .timeline-icon {
+    left: 15%;
+    position: absolute;
+    width: 10%;
+    text-align: center;
+    top: 40px
+}
+
+.timeline .timeline-icon a {
+    text-decoration: none;
+    width: 20px;
+    height: 20px;
+    display: inline-block;
+    border-radius: 20px;
+    background: #d9e0e7;
+    line-height: 10px;
+    color: #fff;
+    font-size: 14px;
+    border: 5px solid #2d353c;
+    transition: border-color .2s linear
+}
+
+.timeline .timeline-body {
+    margin-left: 23%;
+    margin-right: 17%;
+    background: #fff;
+    position: relative;
+    padding: 20px 25px;
+    border-radius: 6px;
+}
+
+.timeline .timeline-body:before {
+    content: '';
+    display: block;
+    position: absolute;
+    border: 10px solid transparent;
+    border-right-color: #fff;
+    left: -20px;
+    top: 20px
+}
+
+.timeline .timeline-body>div+div {
+    margin-top: 15px
+}
+
+.timeline .timeline-body>div+div:last-child {
+    margin-bottom: -20px;
+    padding-bottom: 20px;
+    border-radius: 0 0 6px 6px
+}
+
+.timeline-header {
+    padding-bottom: 10px;
+    border-bottom: 1px solid #e2e7eb;
+    line-height: 30px
+}
+
+.timeline-header .userimage {
+    float: left;
+    width: 34px;
+    height: 34px;
+    border-radius: 40px;
+    overflow: hidden;
+    margin: -2px 10px -2px 0
+}
+
+.timeline-header .username {
+    font-size: 16px;
+    font-weight: 600
+}
+
+.timeline-header .username,
+.timeline-header .username a {
+    color: #2d353c
+}
+
+.timeline img {
+    max-width: 100%;
+    display: block
+}
+
+.timeline-content {
+    letter-spacing: .25px;
+    line-height: 18px;
+    font-size: 13px
+}
+
+.timeline-content:after,
+.timeline-content:before {
+    content: '';
+    display: table;
+    clear: both
+}
+
+.timeline-title {
+    margin-top: 0
+}
+
+.timeline-footer {
+    background: #fff;
+    border-top: 1px solid #e2e7ec;
+    padding-top: 15px
+}
+
+.timeline-footer a:not(.btn) {
+    color: #575d63
+}
+
+.timeline-footer a:not(.btn):focus,
+.timeline-footer a:not(.btn):hover {
+    color: #2d353c
+}
+
+.timeline-likes {
+    color: #6d767f;
+    font-weight: 600;
+    font-size: 12px
+}
+
+.timeline-likes .stats-right {
+    float: right
+}
+
+.timeline-likes .stats-total {
+    display: inline-block;
+    line-height: 20px
+}
+
+.timeline-likes .stats-icon {
+    float: left;
+    margin-right: 5px;
+    font-size: 9px
+}
+
+.timeline-likes .stats-icon+.stats-icon {
+    margin-left: -2px
+}
+
+.timeline-likes .stats-text {
+    line-height: 20px
+}
+
+.timeline-likes .stats-text+.stats-text {
+    margin-left: 15px
+}
+
+.timeline-comment-box {
+    background: #f2f3f4;
+    margin-left: -25px;
+    margin-right: -25px;
+    padding: 20px 25px
+}
+
+.timeline-comment-box .user {
+    float: left;
+    width: 34px;
+    height: 34px;
+    overflow: hidden;
+    border-radius: 30px
+}
+
+.timeline-comment-box .user img {
+    max-width: 100%;
+    max-height: 100%
+}
+
+.timeline-comment-box .user+.input {
+    margin-left: 44px
+}
+
+.lead {
+    margin-bottom: 20px;
+    font-size: 21px;
+    font-weight: 300;
+    line-height: 1.4;
+}
+
+.text-danger, .text-red {
+    color: #ff5b57!important;
+}
+
+.highlight {
+    background-color: yellow;
+}
+
+.timeline .timeline-icon span {
+    text-decoration: none;
+    width: 70px;
+    height: 30px;
+    display: inline-block;
+    border-radius: 50px;
+    background: #ffffff;
+    line-height: 20px;
+    color: #732828;
+    font-size: 18px;
+    font-weight: 800;
+    border: 5px solid #2d353c;
+    transition: border-color .2s linear;
+}
+
+#anni {
+    max-height: 400px;
+    overflow: auto;
+    position: sticky;
+    top: 100px;
+    z-index: 1020;
+    border: 1px solid #dee2e6;
+    border-radius: 20px;
+}
+
+#anni ul {
+    list-style-type: none;
+    scroll-snap-type: y mandatory;
+    padding-left: 0;
+    text-align: center;
+  }
+  
+.anno {
+    scroll-snap-align: start;
+}
+
+#anni .btn:hover {
+    font-size: 36px;
+}
+
+.timeline-content div[type='ref']{
+    max-height: 100px;
+    overflow: auto;
+}
+
+#anni h3 {
+    text-align: center;
+    color: #b61924;
+    font-weight: 400;
+}
+
+#lemma_buttons {
+    margin-bottom: 20px;
+}
+
+#lemma_buttons button:not(:last-child) {
+    margin-right: 20px;
+}
+#lemma_buttons button {
+    color: #30383f;
+    font-size: 15px;
+    position:relative;
+    width:12%;
+}
+  
+#lemma_buttons button .fa {
+    position:absolute;
+    line-height: 24px;
+    top:50%;
+    margin-top: -12px; /* Half of line height to keep left middle postion of container */
+    left: 10px;
+}

+ 22 - 4
js/lettera.js

@@ -178,12 +178,16 @@ function schedaASPO(info){
 	window.open(info);
 }
 
+function openTLIO(info){
+	window.open(info);
+}
+
 function schedaEdizione(info){
+	alert("Hello");
 	$("#myModal").empty();
 	$("#myModal").css("display", "block");
 	$('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" + 
 		info + "</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
-
 		
 }
 
@@ -220,6 +224,7 @@ function handle_lemmi(array, type, partOfSpeech) {
 			var pos = partOfSpeech;
 			var uri_iperlemma = "";
 			var iperlemma = "";
+			var place = "";
 
 			if (value.hasOwnProperty('tipo')) {
 				tipo = value['tipo']['value'];
@@ -233,20 +238,33 @@ function handle_lemmi(array, type, partOfSpeech) {
 			if (value.hasOwnProperty('iperlemma')) {
 				iperlemma = value['iperlemma']['value'];
 			}
+			if (value.hasOwnProperty('uri_place')) {
+				place = value['uri_place']['value'];
+			}
 
-			const cells = [uri_lemma, lemma, tipo, pos, uri_iperlemma, iperlemma];    
+			const cells = [uri_lemma, lemma, tipo, pos, uri_iperlemma, iperlemma, place];    
       		lemmi.push(cells); 
 					
 	  });
 
 
 	for (var i=0; i<lemmi.length; i++) {
+		var button_tlio = "";
+		var button_place = "";
+		if (lemmi[i][0].includes("tlio")) {
+			button_tlio = '<button type="button" class="btn btn-default explore" onclick="openTLIO(\'' + lemmi[i][0] + '\')">TLIO</button>';
+		}
+		if (lemmi[i][6] != "") {
+			button_place = createButton("explore fa fa-map", "", "schedaMappa('LUOGO')".replace("LUOGO", lemmi[i][6]));
+		}
 		var new_lemma = '<tr class="res">' +
 		'<th class="col-4">' + lemmi[i][1] + '</th>' +
 		'<th class="col-2">' + lemmi[i][2] + '</th>' +
 		'<th class="col-2">' + lemmi[i][3] + '</th>' +
-		'<th id="' + lemmi[i][4] + '" class="col-2 iperlemma link">' + lemmi[i][5] + '</th>' +
-		'<th onclick="exploreDocuments(\'' + lemmi[i][0] + '\', \''+ lemmi[i][1] + '\');" class="col-2 explore link"><i class="fa fa-search" aria-hidden="true"></i></th>' +
+		'<th class="col-2">' + lemmi[i][5] + '</th>' +
+		'<th class="col-2">' + 
+		'<button onclick="exploreDocuments(\'' + lemmi[i][0] + '\', \''+ lemmi[i][1] + '\');" class="btn btn-default explore"><i class="fa fa-search" aria-hidden="true"></i></button>' +
+		button_tlio + button_place + '</th>' +
 		'</tr>';
 
 		$('#lemmi').append(new_lemma);

+ 4 - 1
js/lettera_query.js

@@ -183,10 +183,13 @@ rdfs:label ?raccolta . \
 ?racc_type rdfs:label 'Raccolta'. \
 } LIMIT 1"
 
-queryToponimi = prefixes + "SELECT DISTINCT ?uri_lemma ?lemma \
+queryToponimi = prefixes + "SELECT DISTINCT ?uri_lemma ?lemma ?uri_place \
 WHERE {<" + thisUrlParams.link + "> crm:P67_refers_to ?uri_lemma . \
 ?uri_lemma rdfs:label ?lemma ; \
 crm:P2_has_type 'Toponimo' . \
+OPTIONAL {?uri_place crm:P1_is_identified_by ?uri_lemma ; \
+crm:P168_place_is_defined_by ?coords .	\
+} \
 }"
 
 queryAntroponimi = prefixes + "SELECT DISTINCT ?uri_lemma ?lemma \

+ 103 - 16
js/query/managerQuery.js

@@ -31,14 +31,14 @@ var queryManager = {
         FILTER (?type = \"Opera d'Arte\") \
         }", 
 
-        queryIdentificatore: " SELECT DISTINCT ?g ?subject ?label ?identifier \
+        queryIdentificatore: " SELECT DISTINCT ?g AS ?graph ?subject ?label ?identifier \
         WHERE {<{GRAPH}> \
         GRAPH ?g {?subject rdf:type crm:E22_Man-Made_Object } \
         ?subject rdfs:label ?label . \
         ?subject crm:P1_is_identified_by ?uri_identifier . \
         ?uri_identifier rdfs:label ?identifier ; \
         crm:P2_has_type 'Segnatura' . \
-        FILTER (CONTAINS(?identifier, <{WORD}>)) \
+        FILTER (CONTAINS(?identifier, '<{WORD}>')) \
         }"
     }, 
     queryINF: { 
@@ -80,12 +80,8 @@ var queryManager = {
         OPTIONAL {?subject crm:P1_is_identified_by ?id_subject . \
         ?id_subject rdfs:label ?id ; \
         rdf:type crm:E42_Identifier . } \
-        OPTIONAL { \
-        {?subject crm:P2_has_type ?type .} \
-        UNION { \
-        ?subject crm:P2_has_type ?uri_type . \
+        OPTIONAL {?subject crm:P2_has_type ?uri_type . \
         ?uri_type rdfs:label ?type . } \
-        } \
         ?subject crm:P67_refers_to ?object_uri . \
         ?object_uri rdfs:label ?object_Label . \
         <{WORD}> \
@@ -160,18 +156,109 @@ var queryManager = {
         rdfs:label ?document . \
         }",
 
-        queryEsploraDocumenti : " SELECT DISTINCT ?document ?uri_document ?uri_infObj (group_concat(distinct ?type ;separator=', ') as ?types) \
+        queryEsploraDocumenti : " SELECT DISTINCT ?document ?uri_document ?sigla ?time_span ?year ?month ?day ?text ?uri_infObj (group_concat(distinct ?type ;separator=', ') as ?types) \
+        WHERE { \
+        { ?uri_thing crm:P128_carries <{URI}> . \
+        ?uri_infObj crm:P67_refers_to ?uri_thing . \
+        } UNION { \
+        ?uri_infObj crm:P67_refers_to <{URI}> . } \
+        ?uri_document crm:P128_carries ?uri_infObj ; \
+        rdfs:label ?document . \
+        OPTIONAL {?uri_infObj crm:P2_has_type ?uri_type . \
+        ?uri_type rdfs:label ?type . } \
+        OPTIONAL {?uri_infObj crm:P190_has_symbolic_content ?text .} \
+        GRAPH <http://dev.restore.ovi.cnr.it:8890/aspo/datini> {?uri_document crm:P25i_moved_by ?mov_ev .} \
+        ?send rdfs:subClassOf ?mov_ev ; \
+        rdf:type crm:EL2_Send_Letter . \
+        OPTIONAL {?uri_infObj crm:P1_is_identified_by ?uri_sigla . \
+        ?uri_sigla crm:P2_has_type ?sigla_type ; \
+        rdfs:label ?sigla . \
+        ?sigla_type rdfs:label 'Sigla OVI' .} \
+        OPTIONAL {?send crm:P4_has_time-span ?uri_time_span . \
+        ?uri_time_span rdfs:label ?time_span . \
+        OPTIONAL {?uri_time_span time:year ?year } \
+        OPTIONAL {?uri_time_span time:month ?month } \
+        OPTIONAL {?uri_time_span time:day ?day } \
+        } \
+        } \
+        ORDER BY ?year ?month ?day",
+
+        queryTrovaSigla : " SELECT DISTINCT ?id \
+        WHERE {?subject rdf:type crm:E73_Information_Object; \
+        rdfs:label '<{SIGLA}>' . \
+        ?uri_lemma crm:P67_refers_to ?subject; \
+        rdfs:label '<{LEMMA}>' ; \
+        crm:P1_is_identified_by ?uri_id . \
+        ?uri_id rdfs:label ?id} \
+        LIMIT 1",
+
+        queryEsploraMappa : " SELECT DISTINCT ?place ?label ?coordinates \
         WHERE { \
-            { ?uri_thing crm:P128_carries <{URI}> . \
-                ?uri_infObj crm:P67_refers_to ?uri_thing . \
-            } UNION { \
-                ?uri_infObj crm:P67_refers_to <{URI}> . } \
-                ?uri_document crm:P128_carries ?uri_infObj ; \
-                rdfs:label ?document . \
-                OPTIONAL {?uri_infObj crm:P2_has_type ?uri_type . \
-                    ?uri_type rdfs:label ?type . } \
+        VALUES ?uri {<{LEMMA}>} \
+        ?uri_thing crm:P128_carries ?uri . \
+        ?uri_infObj crm:P67_refers_to ?uri_thing . \
+        ?uri_document crm:P128_carries ?uri_infObj ; \
+        rdfs:label ?document ; \
+        crm:P25i_moved_by ?mov_ev . \
+        ?ev_send rdfs:subClassOf ?mov_ev ; \
+        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 . \
         }"
 
+    },
+
+    querySchedaPersona : {
+        queryNetwork : " SELECT COUNT(?event1) AS ?count1 COUNT(?event2) AS ?count2 COUNT(?event3) AS ?count3 ?uri2 SAMPLE(?label2) AS ?text \
+        WHERE { \
+        {?event1 rdf:type crm:EL1_Exchange_Letters . \
+        ?event_to rdfs:subClassOf ?event1; \
+            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 ?event1; \
+            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 = <{URI}>) \
+        } UNION { \
+        ?event2 rdf:type crm:EL1_Exchange_Letters . \
+        ?event_to rdfs:subClassOf ?event2; \
+            rdf:type crm:EL3_Receive_Letter ; \
+            crm:P01_has_domain ?pc_from . \
+        ?pc_from crm:P02_has_range ?uri . \
+        ?uri rdfs:label ?label . \
+        ?event_from rdfs:subClassOf ?event2; \
+            rdf:type crm:EL2_Send_Letter; \
+            crm:P01_has_domain ?pc_to . \
+        ?pc_to crm:P02_has_range ?uri2 . \
+        ?uri2 rdfs:label ?label2 . \
+        FILTER (?uri = <{URI}>) \
+        } UNION { \
+        ?pc crm:P02_has_range <{URI}> . \
+        ?event3 crm:P01_has_domain ?pc . \
+        ?event3 crm:P01_has_domain ?pc1 . \
+        ?pc1 crm:P02_has_range ?uri2 . \
+        ?uri2 rdfs:label ?label2 . \
+        FILTER (?pc != ?pc1) \
+        } \
+        }",
+
+        queryNetwork2 : " SELECT DISTINCT ?uri_person ?name \
+        WHERE { \
+        VALUES ?uri {<{URI}>} \
+        ?pc crm:P02_has_range ?uri . \
+        ?event crm:P01_has_domain ?pc . \
+        ?event crm:P01_has_domain ?pc1 . \
+        ?pc1 crm:P02_has_range ?uri_person . \
+        ?uri_person rdfs:label ?name . \
+        FILTER (?pc != ?pc1) \
+        }"
     }
 };
 

+ 274 - 64
js/results.js

@@ -64,6 +64,8 @@ function handle_Letters(json, mittente, destinatario){
 }
 
 function handleLemma(json, lemma) {
+
+	let anni = [];
 	
 	thead = '<div class="row def_res"> \
 				<div class="col-10">Documento</div> \
@@ -73,6 +75,7 @@ function handleLemma(json, lemma) {
 	var DocumentsTable = thead;
 
 	var i = 0;
+	var anno = "";
 
 	$.each(
 		json['results']['bindings'],
@@ -81,6 +84,12 @@ function handleLemma(json, lemma) {
 			var uri_document = value['uri_document']['value'];
 			var uri_info = "";
 			var type = "";
+			var date = "";
+			var year = "";
+			var month = "";
+			var day = "";
+			var sigla = "";
+			var text = "Nessun testo trovato";
 			var object_button = "";
 		
 			if(value.hasOwnProperty('uri_infObj')) {
@@ -89,6 +98,24 @@ function handleLemma(json, lemma) {
 			if(value.hasOwnProperty('types')) {
 				type = value['types']['value'];
 			}
+			if(value.hasOwnProperty('time_span')) {
+				date = value['time_span']['value'];
+			}
+			if(value.hasOwnProperty('year')) {
+				year = value['year']['value'];
+			}
+			if(value.hasOwnProperty('month')) {
+				month = value['month']['value'];
+			}
+			if(value.hasOwnProperty('day')) {
+				day = value['day']['value'];
+			}
+			if(value.hasOwnProperty('text')) {
+				text = value['text']['value'];
+			}
+			if(value.hasOwnProperty('sigla')) {
+				sigla = value['sigla']['value'];
+			}
 
 			if (type.includes("lettera")) {
 				object_button  = '<button type="button" id="' + uri_info + 
@@ -106,80 +133,219 @@ function handleLemma(json, lemma) {
 			'<div class="col-2">' + object_button + '</div>' +
 			'</div>';
 
+			var aaaa = "";
+
+			if (anno != year) {
+				anno = year;
+				aaaa = year;
+				createYearPoint(aaaa);
+			}
+
+			anni.push(year);
+
+			querySigla = prefixes + (queryManager['queryRES']['queryTrovaSigla']).replace('<{SIGLA}>', sigla).replace('<{LEMMA}>', lemma);
+    		doJsonQuery(querySigla).done(function(r) { manageTimeline(r, date, aaaa, month, day, document, uri_document, text); });
+
+			let element = [date, year, month, day, document, uri_document, text, uri_info];
+
+			createTimelineNode(element);
+
 			i++;
 
 	});
-		
 
-	document.getElementById("results_table").innerHTML = DocumentsTable;
-	document.getElementById("results_title").innerHTML = i + " documenti con citazione di " + lemma;
-}
+	let uniqueyears = [...new Set(anni)];
 
-	/*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("imageASPO").innerHTML = createEmbed(pageInfo.query1.subject.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.uriLuogoPartenza.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.uriLuogoArrivo.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.sigla) document.getElementById("sigla_OVI").innerHTML = pageInfo.sigla.sigla_OVI.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);
-	}
+	var AnniList = "<h3>Anni</h3><ul>";
 
-	if(pageInfo.query2) {
-		if(pageInfo.query2.hasOwnProperty('mittente')) document.getElementById("mittente_id_ASPO").innerHTML = pageInfo.query2.mittente.value;
-		if(pageInfo.query2.hasOwnProperty('uriSender')) document.getElementById("mittente_btn_ASPO").innerHTML = createButton("fa fa-user", "Scheda persona", "schedaPersona('PERS')".replace("PERS", pageInfo.query2.uriSender.value));
-		if(pageInfo.query2.hasOwnProperty('destinatario')) document.getElementById("destinatario_id_ASPO").innerHTML = pageInfo.query2.destinatario.value;
-		if(pageInfo.query2.hasOwnProperty('uriReceiver')) document.getElementById("destinatario_btn_ASPO").innerHTML = createButton("fa fa-user", "Scheda persona", "schedaPersona('PERS')".replace("PERS", pageInfo.query2.uriReceiver.value));
-		if(pageInfo.query2.hasOwnProperty('placeSend')) document.getElementById("luogo_partenza_id_ASPO").innerHTML = pageInfo.query2.placeSend.value;
-		if(pageInfo.query2.hasOwnProperty('placeReceive')) document.getElementById("luogo_arrivo_id_ASPO").innerHTML = pageInfo.query2.placeReceive.value;
-		if(pageInfo.query2.hasOwnProperty('timeSpanSend')) document.getElementById("data_partenza_id_ASPO").innerHTML = pageInfo.query2.timeSpanSend.value;
-		if(pageInfo.query2.hasOwnProperty('timeSpanReceive')) document.getElementById("data_arrivo_id_ASPO").innerHTML = pageInfo.query2.timeSpanReceive.value;
-		if(pageInfo.query2.hasOwnProperty('material')) document.getElementById("consistenzaASPO").innerHTML = pageInfo.query2.material.value;
-		if(pageInfo.query2.hasOwnProperty('dimension')) document.getElementById("dimensioneASPO").innerHTML = pageInfo.query2.dimension.value;
-		if(pageInfo.query2.hasOwnProperty('identifier')) document.getElementById("segnatura_id_ASPO").innerHTML = pageInfo.query2.identifier.value;
-		if(pageInfo.query2.hasOwnProperty('currentLocation')) document.getElementById("ownerASPO").innerHTML = pageInfo.query2.currentLocation.value;
-		
+	for (var i=0; i<uniqueyears.length; i++) {
+		if (uniqueyears[i] != "") {
+			AnniList += "<li><button class='btn btn-default anno' id=\""+ uniqueyears[i] + "\">" + uniqueyears[i] + "</button></li>";
+		}
 	}
 
+	AnniList += "</ul>";
+
+	document.getElementById("lemma_buttons").style.display = "flex";
+	document.getElementById("anni").innerHTML = AnniList;
+	document.getElementById("results_table").innerHTML = DocumentsTable;
+	document.getElementById("results_title").innerHTML = titleCase(lemma);
+
+}
+
+function manageTimeline(json, date, year, month, day, document, uri_document, text) {
+
+	num = "";
+	
+	$.each(
+		json['results']['bindings'],
+		function (index, value) {
+		  	
+			if(value.hasOwnProperty('id')) {
+				num = value['id']['value'];	
+			}
+		});
 	
-	if(pageInfo.sigla){
-		document.getElementById("evt_button").innerHTML = createButtonEVT(pageInfo.sigla.sigla_OVI.value);
+	var testo = text;
+
+	/*if (num != "") {
+		var toReplace = "n='" + num + "'";
+		var toSearch = "<lem n='numero'\.* />[a-z]+";
+		testo = text.replaceAll(toReplace, "class='highlight'");
+		let rr = toSearch.replace("numero", num)
+		let rer = new RegExp(rr);
+		var pos = text.search(rer);
+		var searchedString = text.match(rer);
+		const regex = new RegExp(/<lem n=${testVar}.*>/);
+		text.replace(regex, num);
+		let regE = new RegExp("[0-9]+[]a$|[0-9]+[]" , 'g') 
+		var result = String("la tua stringa").match(regE );
+		var ss = pos-150;
+		var ee = pos+150;
+		var start = 0;
+		var end = ee;
+		if (ss<0) {
+			start = 0;
+		} else {
+			start = ss;
+		}
+
+		testo = text.substring(start, end)
+
+		console.log([start, end, testo]);
+	} else {
+		testo = text;
 	}*/
 
+}
+
+function createTimelineNode(array) {
+
+	var data = array[0];
+	var anno = array[1];
+	var mese = array[2];
+	var giorno = array[3];
+	var titolo = array[4];
+	var testo = array[6];
+	var link = array[5];
+	var infObj = array[7]
+
+
+	var TimelineNode = '<li>' +
+	'<div class="timeline-time">' +
+		'<span class="time">'+ data +'</span>' +
+	'</div>' +
+	'<div class="timeline-icon">' +
+        '<a href="javascript:;">&nbsp;</a>' +
+    '</div>' +
+	'<div class="timeline-body">' +
+        '<div class="timeline-header">' +
+            '<span id="' + infObj + '" class="lettera username">' + titolo + '</span>' +
+        '</div>' +
+        '<div class="timeline-content">' +
+            '<p>' + testo + '</p>' +
+        '</div>' +
+    '</div></li>';
+
+	document.getElementById("docTimeline").innerHTML += TimelineNode;
+
+}
+
+function createYearPoint(anno) {
+
+	var TimelineNode = '<li>' +
+	'<div class="timeline-icon">' +
+		'<span id="anno_' + anno + '">' + anno + '</span>' +
+    '</div></li>';
+
+	document.getElementById("docTimeline").innerHTML += TimelineNode;
+
+}
+
+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 uri = 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='clickPlace col-10' data-point='"+ coordinates + "'>" + label + "</div><div class='luogo col' id='" + 
+	  //uri + "'><i class='far fa-map' style='cursor:pointer'></i></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++;
+		  
+		});
+
+	console.log(locations);
+  
+	var latitude = lat/i;
+	var longitude = long/i;
+  
+	//document.getElementById("list_places_person").innerHTML = myPlaces;
+  
+  
+	var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
+		  cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade, Points &copy 2012 LINZ',
+		  cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 17, attribution: cloudmadeAttribution}),
+		  latlng = new L.LatLng(latitude, longitude);
+  
+	  
+	var map = new L.Map('map', {center: latlng, zoom: 5, layers: [cloudmade]});
+	mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
+  
+	var markers = new L.MarkerClusterGroup();
+	var markerList = [];
+  
+	var geo = new L.tileLayer(
+	  'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+		attribution: '&copy; ' + mapLink + ' Contributors',
+		maxZoom: 18,
+	  }).addTo(map);
+  
+	function populate() {
+	  for (var i = 0; i < locations.length; i++) {
+		var a = locations[i];
+		var title = a[0];
+		var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
+		marker.bindPopup(title);
+		markers.addLayer(marker);
+		markerList.push(marker);
+	  }
+	}
+  
+	populate();
+  
+	map.addLayer(markers);
+  
+	$('.clickPlace').on('click', function(){
+	  // parse lat and lng from the divs data attribute
+	  var latlng = $(this).data().point.split(',');
+	  var lat = latlng[0];
+	  var lng = latlng[1];
+	  var zoom = 10;
+  
+	  // set the view
+	  map.setView([lat, lng], zoom);
+  });
+}
+
 // Mini-utility per formattare liste
 function formatListAsLi(thisList){
 	toRet = "";
@@ -355,5 +521,49 @@ $(document).on("click", ".object", function (ev) {
   //$('#myModal').text("");
   window.open("object.html?link="+this.id);
   
+});
+
+function scrollPos(point) {
+	alert("helo");
+	var div = document.getElementById(point).scrollTop;
+	document.getElementById("pos").innerHTML = div;
+}
+
+$(document).on("click", ".anno", function (ev) {
+	var link = this.id;
+	var point = "#anno_" + link;
+	$('html, body').animate({
+		scrollTop: $(point).offset().top
+	}, 2000);
+
+});
+
+function titleCase(str) {
+	var splitStr = str.toLowerCase().split(' ');
+	for (var i = 0; i < splitStr.length; i++) {
+		// You do not need to check if i is larger than splitStr length, as your for does that for you
+		// Assign it back to the array
+		splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);     
+	}
+	// Directly return the joined string
+	return splitStr.join(' '); 
+  }
+
+function show_list(){
+	document.getElementById("res_container").style.display = "block";
+	document.getElementById("lemmiMappa").style.display = "none";
+	document.getElementById("lemmiTimeline").style.display = "none";
+}
+
+
+function show_timeline(){
+	document.getElementById("res_container").style.display = "none";
+	document.getElementById("lemmiMappa").style.display = "none";
+	document.getElementById("lemmiTimeline").style.display = "block";
+}
 
-});
+function show_map(){
+	document.getElementById("res_container").style.display = "none";
+	document.getElementById("lemmiMappa").style.display = "block";
+	document.getElementById("lemmiTimeline").style.display = "none";
+}

+ 2 - 0
js/results_query.js

@@ -19,7 +19,9 @@ if (tipo=="lemma") {
     var uri_lemma = pp[1];
     var lemma = pp[2].replace(/%20/g, " ");;
     queryEsplora = prefixes + (queryManager['queryRES']['queryEsploraDocumenti']).replaceAll('{URI}', uri_lemma);
+    queryMappa = prefixes + (queryManager['queryRES']['queryEsploraMappa']).replaceAll('{LEMMA}', uri_lemma);
     doJsonQuery(queryEsplora).done(function(r) { handleLemma(r, lemma); });
+    doJsonQuery(queryMappa).done(function(r) { handle_map(r); });
 }
 
 if (tipo=="lettera") {

+ 1 - 1
js/search.js

@@ -63,7 +63,7 @@ $(document).ready(function () {
 		var pref = queryManager['prefixes']['all'];
 		var query1 = pref + (queryManager['queryMMO']['queryLabel']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', Label);
 		var query2 = pref + (queryManager['queryMMO']['queryArte']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', Label);
-		var query3 = pref + (queryManager['queryMMO']['queryIdentificatore']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', search_name);
+		var query3 = pref + (queryManager['queryMMO']['queryIdentificatore']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', testo);
 		var query4 = pref + (queryManager['queryINF']['queryContenuti1']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label);
 		var query5 = pref + (queryManager['queryINF']['queryContenuti2']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label);
 		var query6 = pref + (queryManager['queryINF']['queryContenuti3']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label);

+ 4 - 31
js/word_cloud.js

@@ -5,35 +5,7 @@
  *               */
 
 // SPARQL Query text -- 'prefixes' and 'thisUrlParams' defined in people.js; 
-let queryNetwork = prefixes + " SELECT COUNT(?event1) AS ?count1 COUNT(?event2) AS ?count2 ?uri2 SAMPLE(?label2) AS ?text \
-WHERE { \
-{?event1 rdf:type crm:EL1_Exchange_Letters . \
-?event_to rdfs:subClassOf ?event1; \
-    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 ?event1; \
-    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 { \
-?event2 rdf:type crm:EL1_Exchange_Letters . \
-?event_to rdfs:subClassOf ?event2; \
-    rdf:type crm:EL3_Receive_Letter ; \
-    crm:P01_has_domain ?pc_from . \
-?pc_from crm:P02_has_range ?uri . \
-?uri rdfs:label ?label . \
-?event_from rdfs:subClassOf ?event2; \
-    rdf:type crm:EL2_Send_Letter; \
-    crm:P01_has_domain ?pc_to . \
-?pc_to crm:P02_has_range ?uri2 . \
-?uri2 rdfs:label ?label2 . \
-FILTER (?uri = <" + thisUrlParams.link + ">) \
-} \
-}"
+let queryNetwork = prefixes + (queryManager['querySchedaPersona']['queryNetwork']).replaceAll('{URI}', thisUrlParams.link);
 
 // 'prepareQueryURL' defined in people.js
 let queryNet = prepareQueryURL(queryNetwork);
@@ -46,7 +18,6 @@ $.ajax({
 });
 
 // queryLetters defined in people.js
-console.log(queryLetters);
 
 
 /**
@@ -76,8 +47,9 @@ function processQuery(json) {
           let link = value['uri2']['value'];
           let sent = parseInt(value['count1']['value']);
           let received = parseInt(value['count2']['value']);
+          let other = parseInt(value['count3']['value']);
           let count = sent + received;
-          tempArray.push({'text': text, 'sent': sent, 'received': received, 'count': count, 'hlink': link});
+          tempArray.push({'text': text, 'sent': sent, 'received': received, 'other': other, 'count': count, 'hlink': link});
         }
     );
 
@@ -101,6 +73,7 @@ function doListPersonNetwork(words){
                 element['text'] +
                 "<br /><span onclick='exchangeLetter(\"lettera\", \"" + labelName + "\", \""+ thisUrlParams.link + "\", \""+ filteredText + "\", \""+ element['hlink'] + "\");' class='num_occ'>[Lettere inviate: " + element['sent'] + "]</span>" +
                 "<br /><span onclick='exchangeLetter(\"lettera\", \"" + "\", \""+ element['hlink'] + "\", \""+ labelName + "\", \""+ thisUrlParams.link + "\");' class='num_occ'>[Lettere ricevute: " + element['received'] + "]</span>" +
+                "<br /><span class='num_occ'>[Altro: " + element['other'] + "]</span>" +
                 "<br /><span id='tot-"+filteredText+"' class='num_occ'>[Totale corrispondenza: " + element['count'] + "]</span>" +
             "</div>" +
             "<div class='item-place-person-action'>" +

+ 41 - 0
results.html

@@ -15,10 +15,22 @@
     <link href="vendor/simple-line-icons/css/simple-line-icons.css" rel="stylesheet" type="text/css">
 
     <link href="css/pages.css" rel="stylesheet">
+    <link href="css/timeline.css" rel="stylesheet">
 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
     <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
     <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?lang=css&amp;skin=default"></script>
+    <script src="js/jquery.csv.js"></script>
+    <script src="js/query/lemmi.js"></script>
+
+    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.4/leaflet.css" />
+	<script src="http://cdn.leafletjs.com/leaflet-0.4.4/leaflet.js"></script>
+
+	<link rel="stylesheet" href="js/dist/MarkerCluster.css" />
+	<link rel="stylesheet" href="js/dist/MarkerCluster.Default.css" />
+	<script src="js/dist/leaflet.markercluster-src.js"></script>
+
+
 
     <link href="css/styles.min.css" rel="stylesheet">
 </head>
@@ -87,6 +99,35 @@
                                     <h1 id="results_title" class="box-info-main-title"></h1>
                                 </div>
                             </div>
+
+                            <div id="lemma_buttons" class="justify-content-end" style="display:none;">
+                                <button type="button" class="btn btn-default nav-link active" data-toggle="tab" onclick="show_list()"><i class="fa fa-list" aria-hidden="true"></i>Lista</button>
+                                <button type="button" class="btn btn-default nav-link" data-toggle="tab" onclick="show_timeline()"><i class="fa fa-clock" aria-hidden="true"></i>Timeline</button>
+                                <button type="button" class="btn btn-default nav-link" data-toggle="tab" onclick="show_map()"><i class="fa fa-globe" aria-hidden="true"></i>Mappa</button>
+                            </div>
+
+                            <div class="container" id="lemmiMappa" style="display:none;">
+                                <div class="row">
+                                    <div class="col" id="place_map">
+                                        <div id="map" style="height:600px;"></div>
+                                    </div>
+                                </div>
+                            </div>
+
+                            <div class="container" id="lemmiTimeline" style="display:none;">
+                                <div class="row">
+                                    <div class="col-2" id="anni">
+
+                                    </div>
+                                    <div class="col">
+                                        <ul id="docTimeline" class="timeline">
+                                            <div id="pos">
+                                            </div>
+                                        </ul>
+                                    </div>
+                                </div>
+                            </div>
+
                             <div class="row box-info-container container-fluid" id="res_container">
                                 <div class="col inner_results" id="results_table">