Alessia Spadi hace 1 año
padre
commit
f3ae7a2483
Se han modificado 4 ficheros con 139 adiciones y 104 borrados
  1. 119 81
      js/results.js
  2. 17 20
      js/results_query.js
  3. 1 1
      object.html
  4. 2 2
      results.html

+ 119 - 81
js/results.js

@@ -1,88 +1,89 @@
-
-// 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.query = await doJsonQuery(queryLettere, true);
+//Parametri da passare alla funzione onclick
+
+queryChoice = queryLettere;
+tipoRisorsa = "scambio epistolare";
+mittente = "Bellandi Simone di Andrea";
+uri_mittente = "http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00003-0000806";
+destinatario = "Compagnia di Datini Francesco di Marco & co";
+uri_destinatario = "http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00003-0001817";
+//////
+
+query = prepareQueryURL(queryChoice);
+
+response = $.ajax({
+
+    url: query,
+    dataType: "json",
+    success: function (data){
+      handle_Letters(data, mittente, uri_mittente, destinatario, uri_destinatario);
+    },
+    error: function (e) {}
+});
+
+function handle_Letters(json, mittente, uri_mittente, destinatario, uri_destinatario){
+
+	thead = '<div class="row def_res"> \
+				<div class="col-4">Documento</div> \
+				<div class="col-2">Data di partenza</div> \
+				<div class="col-2">Data di arrivo</div> \
+				<div class="col-2">Luogo di partenza</div> \
+				<div class="col-2">Luogo di arrivo</div> \
+				</div>';
+
+	var EventsTable = thead;
+
+	$.each(
+		json['results']['bindings'],
+		function (index, value) {
+		  	var uri_document = "";
+			var doc = "";
+			var time_span_from = "";
+			var time_span_to = "";
+			var uri_place_from = "";
+			var place_from = "";
+			var uri_place_to = "";
+			var place_to = "";
 		
-	} 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.query) {
-		for (var i=0; i<pageInfo.query.length; i++) {
-			if(pageInfo.query[i].hasOwnProperty('uri_document')) {
-				alert("Here");
-				uri_document = pageInfo.query.uri_document.value;
+			if(value.hasOwnProperty('uri_document')) {
+				uri_document = value['uri_document']['value'];	
+			}
+			if(value.hasOwnProperty('document')) {
+				doc = value['document']['value'];
+			}
+			if(value.hasOwnProperty('time_span_from')) {
+				time_span_from = value['time_span_from']['value'];
+			}
+			if(value.hasOwnProperty('time_span_to')) {
+				time_span_to = value['time_span_to']['value'];
+			}
+			if(value.hasOwnProperty('uri_place_from')) {
+				uri_place_from = value['uri_place_from']['value'];
+			}
+			if(value.hasOwnProperty('place_from')) {
+				place_from = value['place_from']['value'];
+			}
+			if(value.hasOwnProperty('uri_place_to')) {
+				uri_place_to = value['uri_place_to']['value'];
+			}
+			if(value.hasOwnProperty('place_to')) {
+				place_to = value['place_to']['value'];
 			}
-			var l = pageInfo.query[i].uri_document.value;
-		}
-        var uri_document = "";
-        var doc = "";
-        var time_span_from = "";
-        var time_span_to = "";
-        var uri_place_from = "";
-        var place_from = "";
-        var uri_place_to = "";
-        var place_to = "";
-        var EventsTable = "";
 
-		
-        if(pageInfo.query.hasOwnProperty('document')) {
-            doc = pageInfo.query.document.value;
-        }
-        if(pageInfo.query.hasOwnProperty('time_span_from')) {
-            time_span_from = pageInfo.query.time_span_from.value;
-        }
-        if(pageInfo.query.hasOwnProperty('time_span_to')) {
-            time_span_to = pageInfo.query.time_span_to.value;
-        }
-        if(pageInfo.query.hasOwnProperty('uri_place_from')) {
-            uri_place_from = pageInfo.query.uri_place_from.value;
-        }
-        if(pageInfo.query.hasOwnProperty('place_from')) {
-            place_from = pageInfo.query.place_from.value;
-        }
-        if(pageInfo.query.hasOwnProperty('uri_place_to')) {
-            uri_place_to = pageInfo.query.uri_place_to.value;
-        }
-        if(pageInfo.query.hasOwnProperty('place_to')) {
-            place_to = pageInfo.query.place_to.value;
-        }
-
-        EventsTable += '<div class="row">' +
-    '<div class="col-2">' + doc + '</div>' +
-    '<div class="col-2">' + time_span_from + '</div>' +
-    '<div class="col-2">' + time_span_to + '</div>' +
-    '<div class="col-2">' + place_from + '</div>' +
-    '<div class="col-4">' + place_to + '</div>' +
-    '</div>';
+			EventsTable += '<div class="row">' +
+			'<div id="' + uri_document + '" class="col-4 object">' + doc + '</div>' +
+			'<div class="col-2">' + time_span_from + '</div>' +
+			'<div class="col-2">' + time_span_to + '</div>' +
+			'<div id="' + uri_place_from + '" class="col-2 luogo">' + place_from + '</div>' +
+			'<div id="' + uri_place_to + '" class="col-2 luogo">' + place_to + '</div>' +
+			'</div>';
+
+	});
 		
 
 		document.getElementById("results_table").innerHTML = EventsTable;
-	}
-	
+		document.getElementById("results_title").innerHTML = "Lettere da " + mittente + " a " + destinatario;
+		
+}
 
 	/*if(pageInfo.query1){
 		document.getElementById("mittente_id").innerHTML = pageInfo.query1.mittente.value;
@@ -148,7 +149,6 @@ function updatePage(){
 	if(pageInfo.sigla){
 		document.getElementById("evt_button").innerHTML = createButtonEVT(pageInfo.sigla.sigla_OVI.value);
 	}*/
-}
 
 // Mini-utility per formattare liste
 function formatListAsLi(thisList){
@@ -288,4 +288,42 @@ function myFunction(){
     copyToClipboard(copyText);
 
     //copyToClipboard(copyText.value);
-}
+}
+
+$(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", ".persona", function (ev) {
+
+    var link = this.id;
+    window.open("Persona.html?link="+this.id);
+    
+
+  });
+
+$(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", ".object", function (ev) {
+
+  var link = this.id;
+  //alert(nome_autore);
+  //$('#myModal').text("");
+  window.open("object.html?link="+this.id);
+  
+
+});

+ 17 - 20
js/results_query.js

@@ -1,48 +1,45 @@
 
-// Recupero i parametri dall'URL -- mi aspetto un parametro di nome 'link'!
+// 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);
-
+//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){
+function doJsonQuery(query){
 
     queryURL = prepareQueryURL(query);
 
-    response = await $.ajax({//OGGETTO
+    response = $.ajax({//OGGETTO
 
         url: queryURL,
         dataType: "json",
         success: function (data){},
-        error: function (e) {
-            console.log("Exception in query:", e);
-        }
+        error: function (e) {}
     });
 
-    let out = [];
-    let bin = response['results']['bindings'];
-    for (var i=0; i<bin.length; i++) {
-        out.push(bin[i]);
-    }
-    return out;
+    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("}{",",");
+}
+
 ////////////////////
 // TESTI DELLE QUERY
 ////////////////////

+ 1 - 1
object.html

@@ -288,7 +288,7 @@
                                           
 											<div class="row def_res">
 												<div class="col">
-													<b>Oggetti collegati <span id="nome_au" class="PN"></span></b>
+													<b>Luoghi citati <span id="nome_au" class="PN"></span></b>
 												</div>
 												<div class="col num_res">
 													<span><span id="n_sec"></span> risultati</span>

+ 2 - 2
results.html

@@ -84,10 +84,10 @@
                         <div class="container-fluid">
                             <div class="row box-info-title" id="head_standard">
                                 <div class="col">
-                                    <h1 id="results_title" class="box-info-main-title">Title</h1>
+                                    <h1 id="results_title" class="box-info-main-title"></h1>
                                 </div>
                             </div>
-                            <div class="row box-info-container" id="res_container">
+                            <div class="row box-info-container container-fluid" id="res_container">
                                 <div class="col" id="results_table">
                                    
                                 </div>