Prechádzať zdrojové kódy

more-functionality-to-person-list

Francesco 1 rok pred
rodič
commit
6e0f72850b
2 zmenil súbory, kde vykonal 69 pridanie a 23 odobranie
  1. 5 5
      js/people.js
  2. 64 18
      js/word_cloud.js

+ 5 - 5
js/people.js

@@ -186,17 +186,17 @@ VALUES ?uri {<" + thisUrlParams.link + ">} \
 {?pc crm:P02_has_range ?uri . \
 } UNION { \
 ?group crm:P107_has_current_or_former_member ?uri; \
-crm:P2_has_type 'Gruppo scrittura lettera' . \
+    crm:P2_has_type 'Gruppo scrittura lettera' . \
 ?pc crm:P02_has_range ?group . \
 } \
 ?ev_move crm:P01_has_domain ?pc ; \
-rdfs:label ?type ; \
-rdfs:subClassOf ?event . \
+    rdfs:label ?type ; \
+    rdfs:subClassOf ?event . \
 ?document_uri crm:P25i_moved_by ?event ; \
-rdfs:label ?document_name . \
+    rdfs:label ?document_name . \
 ?document_uri crm:P1_is_identified_by ?uriSegnatura . \
 ?uriSegnatura crm:P2_has_type 'Segnatura' ; \
-rdfs:label ?segnatura . \
+    rdfs:label ?segnatura . \
 OPTIONAL {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?document_uri crm:P128_carries ?InfObj . \
 ?InfObj rdf:type crm:E73_Information_Object} }. \
 OPTIONAL {?ev_move crm:P4_has_time-span ?uri_ts . \

+ 64 - 18
js/word_cloud.js

@@ -9,26 +9,26 @@ let queryNetwork = prefixes + " SELECT COUNT(?event1) AS ?count1 COUNT(?event2)
 WHERE { \
 {?event1 rdf:type crm:EL1_Exchange_Letters . \
 ?event_to rdfs:subClassOf ?event1; \
-rdf:type crm:EL2_Send_Letter ; \
+    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 . \
+    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 . \
+    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 . \
+    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 + ">) \
@@ -46,6 +46,9 @@ $.ajax({
 });
 
 
+// queryLetters defined in people.js
+console.log(queryLetters);
+
 
 /**
  * COMPONENT CREATION SECTION
@@ -87,18 +90,19 @@ function processQuery(json) {
 
 
 // Create formatted list of people in the network
-function doListPersonNetwork(tempArray){
+function doListPersonNetwork(words){
 
     let ArrayNames = "";
 
-    tempArray.forEach(element => {
+    words.forEach(element => {
+        filteredText = element['text'].replace('"', '').replace("'", '');
         ArrayNames +=
         "<div class='item-place-person'>"+
-            "<div class='item-place-person-label' id='list-" + element['text'].replace('"', '').replace("'", '') + "'>" +
+            "<div class='item-place-person-label' id='list-" + filteredText + "'>" +
                 element['text'] +
                 "<br /><span class='num_occ'>[Lettere inviate: " + element['sent'] + "]</span>" +
                 "<br /><span class='num_occ'>[Lettere ricevute: " + element['received'] + "]</span>" +
-                "<br /><span class='num_occ'>[Totale corrispondenza: " + element['count'] + "]</span>" +
+                "<br /><span id='tot-"+filteredText+"' class='num_occ'>[Totale corrispondenza: " + element['count'] + "]</span>" +
             "</div>" +
             "<div class='item-place-person-action'>" +
                 "<div class='persona' id='" + element['hlink'] +"'>" +
@@ -110,9 +114,49 @@ function doListPersonNetwork(tempArray){
 
     document.getElementById("list_person_network").innerHTML = ArrayNames;
 
+    addEventsToNameList(words);
+
+}
+
+function addEventsToNameList(words){
+
+    let counter = 0
+    for(let word of words){
+        if(counter>0) break;
+        let listElem = document.getElementById('tot-' + word.text.replace('"', '').replace("'", ''));
+        if(listElem!=null){
+            listElem.addEventListener("click", filterLetters);
+            listElem.addEventListener("mouseover", highlightWord);
+            listElem.addEventListener("mouseout", unHighlightWord);
+        }
+        counter++;
+    }
+}
+
+function filterLetters(e){
+
+    try{
+        let preText = e.target.parentNode.textContent;
+        console.log('text content', preText);
+        let name = preText.split("[")[0];
+        console.log('name', name);            
+
+        // responseLet defined in people.js
+        responseLet.then(data => {
+            
+            let lettersJson = data.results.bindings;
+            console.log('AH!', lettersJson[0]);
+        });
+
+    } catch{
+        console.log("Couldn't get the name"); 
+    }
+
 }
 
 
+
+
 // Create the word cloud
 function doWordCloud(words){
     
@@ -161,7 +205,7 @@ function doWordCloud(words){
     let wordCloudText = createWordCloud(words, wcParameters);
     svg.innerHTML = wordCloudText;
 
-    addEvents(words);
+    addEventsToWordCloud(words);
 
 }
 
@@ -311,15 +355,16 @@ function checkBorder(rect, minX, maxX, minY, maxY){
 }
 
 
-function addEvents(words){
+function addEventsToWordCloud(words){
 
     for(let word of words){
         let wcElem = document.getElementById('word-' + word.text.replace('"', '').replace("'", ''));
-        wcElem.addEventListener("click", focusPersonInList);
-        wcElem.addEventListener("mouseover", highlightWord);
-        wcElem.addEventListener("mouseout", unHighlightWord);
+        if(wcElem!=null){
+            wcElem.addEventListener("click", focusPersonInList);
+            wcElem.addEventListener("mouseover", highlightWord);
+            wcElem.addEventListener("mouseout", unHighlightWord);
+        }
     }
-
 }
 
 function focusPersonInList(e){
@@ -334,4 +379,5 @@ function highlightWord(e){
 }
 function unHighlightWord(e){
     e.target.style['text-decoration'] = "";
-}
+}
+