Parcourir la source

Update object

Alessia il y a 1 an
Parent
commit
c5db932f3c
6 fichiers modifiés avec 292 ajouts et 9 suppressions
  1. 48 0
      css/object.css
  2. 92 1
      css/tree.css
  3. 1 1
      js/lettera.js
  4. 108 3
      js/object.js
  5. 9 4
      js/query/managerQuery.js
  6. 34 0
      object.html

+ 48 - 0
css/object.css

@@ -0,0 +1,48 @@
+/* The grid: Four equal columns that floats next to each other */
+.singleImg {
+    float: left;
+    width: 25%;
+    padding: 10px;
+  }
+  
+  /* Style the images inside the grid */
+  .singleImg img {
+    opacity: 0.8; 
+    cursor: pointer; 
+  }
+  
+  .singleImg img:hover {
+    opacity: 1;
+  }
+  
+  /* Clear floats after the columns */
+  .row#images:after {
+    content: "";
+    display: table;
+    clear: both;
+  }
+  
+  /* The expanding image container */
+  .container_img {
+    position: relative;
+    display: none;
+  }
+  
+  /* Expanding image text */
+  #imgtext {
+    position: absolute;
+    bottom: 15px;
+    left: 15px;
+    color: white;
+    font-size: 20px;
+  }
+  
+  /* Closable button inside the expanded image */
+  .closebtn {
+    top: 10px;
+    right: 15px;
+    color: #000;
+    font-size: 40px;
+    cursor: pointer;
+    float:right;
+  }

+ 92 - 1
css/tree.css

@@ -86,4 +86,95 @@ span.tree_label:after {
   background: #eee;
   padding: 1em;
   border-radius: 0.3em;
-}
+}
+
+span.tree_seed:after {
+  position: absolute;
+    left: -2em;
+    display: block;
+    height: 1.5em;
+    width: 1.8em;
+    border-bottom: 1px solid #777;
+    border-left: 1px solid #777;
+    border-radius: 0 0 0 0.3em;
+    content: '';
+    }
+
+.tree_el {
+  margin-top: 10px;
+}
+
+/*
+#treeView li ul li:before {
+  position: absolute;
+    left: 4.5em;
+    display: block;
+    width: 0;
+    height: -webkit-fill-available;
+    border-left: 1px solid #777;
+    content: "";
+}
+
+#treeView li:last-child:before {
+  height: 1em;
+  bottom: auto;
+  }
+
+#treeView > li:last-child:before { display: none; }
+*/
+
+
+#treeView li {
+  line-height: 1.2;
+  position: relative;
+  padding: 0 0 1em 1em;
+  }
+
+#treeView ul li { padding: 1em 0 0 1em; }
+
+#treeView > li:last-child { padding-bottom: 0; }
+
+
+#treeView li:before {
+  position: absolute;
+  top: 0;
+  bottom: 0;
+  left: -2em;
+  margin-top: -10px;
+  display: block;
+  width: 0;
+  border-left: 1px solid #777;
+  content: "";
+  }
+
+.tree_seed:after {
+  position: absolute;
+  top: 0;
+  left: -1.5em;
+  display: block;
+  height: 0.5em;
+  width: 1em;
+  border-bottom: 1px solid #777;
+  border-left: 1px solid #777;
+  border-radius: 0 0 0 .3em;
+  content: '';
+  }
+
+label.tree_seed:after {
+  border-radius: 0 .3em 0 0;
+  border-top: 1px solid #777;
+  border-right: 1px solid #777;
+  border-bottom: 0;
+  border-left: 0;
+  bottom: 0;
+  top: 0.5em;
+  height: auto;
+  }
+
+#treeView li:last-child:before {
+  height: 1em;
+  bottom: auto;
+  }
+
+#treeView > li:last-child:before { display: none; }
+

+ 1 - 1
js/lettera.js

@@ -162,7 +162,7 @@ function createButtonEVT(sigla){
 
 function loadPageEVT(sigla)
 {
-     window.location="http://restore.ovi.cnr.it/mockup/evt/#/imageText?p=" + sigla + "_01&el=diplomatic";
+     window.location="http://restore.ovi.cnr.it/beta/evt/#/imageText?p=" + sigla + "_01&el=diplomatic";
 }  		 
 
 function createEmbed(link) {

+ 108 - 3
js/object.js

@@ -3,11 +3,15 @@ var link = thisUrlParams.link;
 prefixes = queryManager['prefixes']['all'];
 
 queryURL = prefixes + (queryManager['querySchedaOggetto']['queryInfo']).replace('{URI}', link);
+console.log(queryURL);
 doJsonQuery(queryURL).done(function(data) { handle_objectData(data); });
 
 queryINF = prefixes + (queryManager['querySchedaOggetto']['queryContent']).replace('{URI}', link);
 doJsonQuery(queryINF).done(function(data) { handle_objectInfo(data); });
 
+queryGT = prefixes + (queryManager['querySchedaOggetto']['queryContrassegni']).replace('{URI}', link);
+doJsonQuery(queryGT).done(function(data) { handle_contrassegni(data); });
+
 queryOVI = prefixes + (queryManager['querySchedaOggetto']['queryOviLetter']).replace('{URI}', link);
 doJsonQuery(queryOVI).done(function(data) { handle_oviLetter(data); });
 
@@ -22,7 +26,7 @@ doJsonQuery(queryTR).done(function(data) { handle_treeview(data, link); });
 
 function handle_objectData(json) {
 
-  console.log(json['results']['bindings']);
+  console.log(json);
 
   $.each(
       json['results']['bindings'],
@@ -155,6 +159,107 @@ function get_graph_name(graph) {
   return dataset;
 }
 
+function handle_contrassegni(json) {
+
+  console.log(json);
+
+  var uri = "";
+  var graph = "";
+  var contrassegno = "";
+  var immagine = "";
+  var uri_gettatello = "";
+  var gettatello = "";
+  var Images = "";
+  let markImg = [];
+
+  $.each(
+    json['results']['bindings'],
+    function (index, value) {
+
+      uri = value['uri']['value'];;
+      contrassegno = value['contrassegno']['value'];
+      immagine = value['image']['value'];
+      uri_gettatello = value['uri_person']['value'];
+      gettatello = value['gettatello']['value'];
+      graph = value['g']['value'];
+      
+    });
+
+  if (immagine != "") {
+        $("#IMM").css("display", "flex");
+
+        let imgs = immagine.split("_");
+        const suffix = ["_a", "_b", "_c", "_a_2", "_a1", "_a2"];
+
+        for (var k=0; k<suffix.length; k++) {
+
+          var image_url = "img/contrassegni/" + imgs[0] + suffix[k] + ".jpg";
+          markImg.push(image_url);
+          createImage(image_url);
+      }
+    }
+
+  if ((gettatello != "") && (uri_gettatello != "")) {
+    $("#GT").css("display", "flex");
+
+    var gt_btn = '<button type="button" id="' + uri_gettatello + 
+    '" class="persona btn btn-default" alt="persona"><i class="fa fa-user"></i><p class="btn-text">Persona</p></button>';
+
+    document.getElementById('pp_gettatello').innerHTML = gettatello;
+    document.getElementById('btn_gt').innerHTML = gt_btn;
+  
+  }
+
+  var dataset = get_graph_name(graph);
+
+
+  document.getElementById("nome_oggetto").innerHTML = contrassegno;
+  document.getElementById("grafo").innerHTML = dataset;
+  
+
+}
+
+function createImage(image) {
+  checkIfImageExists(image, (exists) => {
+    if (exists) {
+      console.log(image);
+      var Image = '<div class="singleImg"> \
+      <img src="' + image + '" alt="contrassegno" style="width:100%" onclick="expandImg(this);"> \
+      </div>';
+      console.log(Image);
+      $('#images').append(Image);
+    } else {
+      console.error('Image does not exists.')
+    }
+  });
+}
+
+function checkIfImageExists(url, callback) {
+  const img = new Image();
+  img.src = url;
+  
+  if (img.complete) {
+    callback(true);
+  } else {
+    img.onload = () => {
+      callback(true);
+    };
+    
+    img.onerror = () => {
+      callback(false);
+    };
+  }
+}
+
+function expandImg(imgs) {
+  var expandImg = document.getElementById("expandedImg");
+  var imgText = document.getElementById("imgtext");
+  expandImg.src = imgs.src;
+  imgText.innerHTML = imgs.alt;
+  expandImg.parentElement.style.display = "block";
+}
+
+
 function handle_objectInfo(json) {
 
   console.log(json['results']['bindings']);
@@ -315,14 +420,14 @@ function handle_treeview(json, uri_subject) {
         var uri = value['uri_document']['value'];
         var document = value['document']['value'];
 
-        tree_doc += '<li><i class="fa fa-file-alt"></i><span id="' + uri + '" class="link object">' + document + '</span><li>'
+        tree_doc += '<li class="tree_el"><i class="fa fa-file-alt"></i><span id="' + uri + '" class="tree_seed link object">' + document + '</span><li>'
 
         
       });
 
       if (tree_doc != "") {
 
-          var tree_list = '<li class="upLevel"><span style="cursor:pointer;" class="caret"><i class="fa fa-folder-open"></i>' + 
+          var tree_list = '<li class="upLevelTree"><span style="cursor:pointer;" class="caret"><i class="fa fa-folder-open"></i>' + 
         '<w>' + upLevel + '</w></span><ul id="nested" style="display: none;">' + tree_doc + '</ul></li>';
 
           document.getElementById("treeView").innerHTML = tree_list;

+ 9 - 4
js/query/managerQuery.js

@@ -576,6 +576,7 @@ var queryManager = {
             WHERE { \
             VALUES ?uri {<{URI}>} \
             GRAPH ?g { ?uri rdfs:label ?label } \
+            ?uri rdf:type crm:E22_Man-Made_Object . \
             OPTIONAL {?uri crm:P1_is_identified_by ?uri_id . \
             ?uri_id rdfs:label ?id ; \
             crm:P2_has_type 'Segnatura' .} \
@@ -681,12 +682,16 @@ var queryManager = {
             } \
             }",
 
-            queryContrassegni : " SELECT DISTINCT ?uri_contrassegno ?contrassegno \
+            queryContrassegni : " SELECT DISTINCT ?g ?uri ?contrassegno ?image ?uri_person ?gettatello\
             WHERE {VALUES ?uri {<{URI}>} \
-            ?uri crm:P46_is_composed_of ?uri_paper . \
-            ?uri_documentation crm:P141_assigned ?uri_paper ; \
-            crm:P140_assigned_attribute_to ?uri_contrassegno . \
+            GRAPH ?g {?uri ?p ?o} \
+            ?uri crm:P138_represents ?uri_contrassegno ; \
+            crm:P1_is_identified_by ?uri_id . \
+            ?uri_id rdfs:label ?image . \
             ?uri_contrassegno rdfs:label ?contrassegno . \
+            ?uri_documentation crm:P140_assigned_attribute_to ?uri_contrassegno ; \
+            crm:P141_assigned ?uri_person . \
+            ?uri_person rdfs:label ?gettatello . \
             }",
 
             queryEventiGettatelli : " SELECT DISTINCT ?uri_obj ?object ?name_event ?event_type ?uri_person ?label ?role ?time_span ?uri_place ?place \

+ 34 - 0
object.html

@@ -17,6 +17,7 @@
 
 	<link href="css/pages.css" rel="stylesheet">
 	<link href="css/tree.css" rel="stylesheet">
+	<link href="css/object.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>
@@ -121,6 +122,7 @@
 									</div>
 
 									<div id="info_oggetto">
+
 										<div class="row mb-2" id="ID" style="display:none;">
 											<div class="col-sm-4">
 												<span class="label">Segnatura:</span>
@@ -199,6 +201,30 @@
 											</div>
 											<div class="col" id="nota"></div>
 										</div>
+
+										<div class="row mb-2" id="IMM" style="display:none;">
+											<div class="col">
+												<div class="row">
+													<div class="col-sm-4">
+														<span class="label">Immagini</span>
+													</div>
+												</div>
+												<div class="row">
+													<div class="col" id="mark_images">
+														<div class="row" id="images">
+															
+														</div>
+													</div>
+												</div>
+											</div>
+										</div>
+
+										<div class="container_img">
+											<span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>
+											<img id="expandedImg" style="width:100%">
+											<div id="imgtext"></div>
+										</div>
+
 									</div>
 								</div>
 
@@ -222,6 +248,14 @@
 											<div class="col" id="type"></div>
 										</div>
 
+										<div class="row mb-2" id="GT" style="display:none;">
+											<div class="col-sm-4">
+												<span class="label">Gettatello:</span>
+											</div>
+											<div class="col" id="pp_gettatello"></div>
+											<div class="col-auto" id="btn_gt"></div>
+										</div>
+
 										<div class="row mb-2" id="argomento" style="display:none;">
 											<div class="col-sm-4">
 												<span class="label">Entità citate nel testo:</span>