people.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624
  1. // Raccatto i parametri dall'URL -- mi aspetto un parametro di nome 'link'!
  2. thisUrlParams = {};
  3. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  4. thisUrlParams[key] = value;
  5. });
  6. //console.log('URL get params: ', thisUrlParams);
  7. // Funzioni per eseguire le queries
  8. function prepareQueryURL(query){
  9. sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
  10. sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
  11. return sparqlEndpoint + sparqlUrlParams;
  12. }
  13. function doJsonQuery(query){
  14. queryURL = prepareQueryURL(query);
  15. response = $.ajax({//OGGETTO
  16. url: queryURL,
  17. dataType: "json",
  18. success: function (data){},
  19. error: function (e) {}
  20. });
  21. return response;
  22. }
  23. // Funzioni per raccattare + stringhificare l'output
  24. queryStringOutput = "";
  25. function stringifyResponse(val){
  26. resultArray = val['results']['bindings'];
  27. out = "";
  28. for(i = 0; i < resultArray.length; i++){
  29. out = out + JSON.stringify(resultArray[i])
  30. }
  31. queryStringOutput = (queryStringOutput + out).replace("}{",",");
  32. }
  33. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  34. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  35. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  36. PREFIX owl: <http://www.w3.org/2002/07/owl#> \
  37. PREFIX schema: <http://schema.org/> \
  38. PREFIX foaf: <http://xmlns.com/foaf/0.1/> \
  39. PREFIX person: <http://www.w3.org/ns/person#>"
  40. query = prefixes + " SELECT DISTINCT ?place ?label ?tipo ?coordinates COUNT(?pc) AS ?count \
  41. WHERE { \
  42. VALUES ?uri {<" + thisUrlParams.link + ">} \
  43. {?pc crm:P02_has_range ?uri . \
  44. ?event_from crm:P01_has_domain ?pc ; \
  45. rdf:type crm:EL3_Receive_Letter; \
  46. rdfs:label ?tipo ; \
  47. crm:P26_moved_to ?place_from . \
  48. ?place_from rdf:type crm:E53_Place ; \
  49. owl:sameAs ?place . \
  50. ?place rdfs:label ?label ; \
  51. crm:P168_place_is_defined_by ?coordinates . \
  52. } UNION { \
  53. ?pc crm:P02_has_range ?uri . \
  54. ?event_from crm:P01_has_domain ?pc ; \
  55. rdf:type crm:EL2_Send_Letter; \
  56. rdfs:label ?tipo ; \
  57. crm:P27_moved_from ?place_from . \
  58. ?place_from rdf:type crm:E53_Place ; \
  59. owl:sameAs ?place . \
  60. ?place rdfs:label ?label ; \
  61. crm:P168_place_is_defined_by ?coordinates . \
  62. } UNION { \
  63. ?uri crm:P100i_died_in ?uri_death . \
  64. ?uri_death crm:P7_took_place_at ?uri_place . \
  65. ?uri_place rdf:type crm:E53_Place ; \
  66. owl:sameAs ?place . \
  67. ?place rdfs:label ?label ; \
  68. crm:P168_place_is_defined_by ?coordinates . \
  69. } UNION { \
  70. ?uri crm:P98i_was_born ?uri_birth . \
  71. ?uri_birth crm:P7_took_place_at ?uri_place . \
  72. ?uri_place rdf:type crm:E53_Place ; \
  73. owl:sameAs ?place . \
  74. ?place rdfs:label ?label ; \
  75. crm:P168_place_is_defined_by ?coordinates . \
  76. } \
  77. UNION { \
  78. ?pc crm:P02_has_range ?uri . \
  79. ?uri_event crm:P01_has_domain ?pc; \
  80. crm:P7_took_place_at ?uri_place ; \
  81. crm:P2_has_type ?uri_type . \
  82. ?uri_type rdfs:label ?tipo . \
  83. ?uri_place rdf:type crm:E53_Place ; \
  84. rdfs:label ?label . \
  85. ?place owl:sameAs ?uri_place ; \
  86. crm:P168_place_is_defined_by ?coordinates . \
  87. } \
  88. }"
  89. queryInfo = prefixes + " SELECT DISTINCT ?uri ?graph ?label ?identifier ?id_type ?name ?givenName ?familyName ?relative2 ?relative3 ?provenienza (GROUP_CONCAT(DISTINCT CONCAT(?variant, '| ', ?otherName) ; SEPARATOR = ';') AS ?variants) ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group \
  90. WHERE { \
  91. VALUES ?uri {<" + thisUrlParams.link + ">} \
  92. GRAPH ?graph {?uri rdfs:label ?label} \
  93. ?uri foaf:name ?name . \
  94. OPTIONAL {?uri crm:P1_is_identified_by ?id . \
  95. ?id rdfs:label ?identifier ; \
  96. crm:P2_has_type ?id_type .} \
  97. OPTIONAL {?uri foaf:givenName ?givenName} \
  98. OPTIONAL {?uri foaf:familyName ?familyName} \
  99. OPTIONAL {?uri foaf:gender ?gender} \
  100. OPTIONAL {?uri person:patronymicName ?patronymic } \
  101. OPTIONAL {?uri crm:P74_has_current_or_former_residence ?uri_provenienza . \
  102. ?uri_provenienza crm:P2_has_type 'Provenienza'; \
  103. rdfs:label ?provenienza . } \
  104. OPTIONAL {?uri crm:P2_has_type ?uri_person_type . \
  105. ?uri_person_type rdfs:label ?person_type } \
  106. OPTIONAL {?uri schema:hasOccupation ?uriOccupation . \
  107. ?uriOccupation rdf:type schema:Occupation; \
  108. rdfs:label ?occupation } \
  109. OPTIONAL {?uri schema:honorificPrefix ?qualification} \
  110. OPTIONAL {?uri crm:P100i_died_in ?Death . \
  111. OPTIONAL {?Death crm:P4_has_time-span ?Death_TS . \
  112. ?Death_TS rdfs:label ?Death_Date . } \
  113. OPTIONAL {?Death crm:P7_took_place_at ?Place_D . \
  114. ?Place_D rdfs:label ?Death_Place } \
  115. } \
  116. OPTIONAL {?uri crm:P98i_was_born ?Birth . \
  117. OPTIONAL {?Birth crm:P4_has_time-span ?Birth_TS . \
  118. ?Birth_TS rdfs:label ?Birth_Date . } \
  119. OPTIONAL {?Birth crm:P7_took_place_at ?Place_B . \
  120. ?Place_B rdfs:label ?Birth_Place } \
  121. } \
  122. OPTIONAL {?uri crm:P107i_is_current_or_former_member_of ?uriGroup . \
  123. ?uriGroup rdfs:label ?group } \
  124. OPTIONAL {?uri schema:alternateName ?alias . } \
  125. OPTIONAL {?uri owl:sameAs ?variant . \
  126. ?variant foaf:name ?otherName . } \
  127. OPTIONAL {?relation2 crm:P141_assigned ?uri ; \
  128. crm:P42_assigned ?uri_rel_type2 . \
  129. ?uri_rel_type2 rdfs:label 'Avo di secondo grado' . \
  130. ?uri_relative2 crm:P141_assigned ?relation2; \
  131. rdfs:label ?relative2 .} \
  132. OPTIONAL {?relation3 crm:P141_assigned ?uri ; \
  133. crm:P42_assigned ?uri_rel_type3 . \
  134. ?uri_rel_type3 rdfs:label 'Avo di terzo grado' . \
  135. ?uri_relative3 crm:P141_assigned ?relation3; \
  136. rdfs:label ?relative3 .} \
  137. } \
  138. GROUP BY ?graph ?uri ?label ?identifier ?id_type ?name ?givenName ?familyName ?relative2 ?relative3 ?provenienza ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group \
  139. LIMIT 1 "
  140. queryInfoGettatelli = prefixes + " SELECT DISTINCT ?card ?uri_card \
  141. WHERE { \
  142. VALUES ?uri {<" + thisUrlParams.link + ">} \
  143. ?documentation crm:P67_refers_to ?uri ; \
  144. crm:P141_assigned ?uri_card . \
  145. ?uri_card rdfs:label ?card . \
  146. } "
  147. queryRelazioni = prefixes + " SELECT DISTINCT ?relation_type ?note ?uri_person ?name ?givenName ?familyName ?patronymic ?provenienza \
  148. WHERE { \
  149. VALUES ?uri {<" + thisUrlParams.link + ">} \
  150. ?uri crm:P141_assigned ?relation . \
  151. ?relation crm:P42_assigned ?uri_type ; \
  152. crm:P141_assigned ?uri_person . \
  153. ?uri_type rdfs:label ?relation_type . \
  154. OPTIONAL {?uri_type crm:P3_has_note ?note } \
  155. ?uri_person foaf:name ?name . \
  156. OPTIONAL {?uri_person foaf:givenName ?givenName} \
  157. OPTIONAL {?uri_person foaf:familyName ?familyName} \
  158. OPTIONAL {?uri_person person:patronymicName ?patronymic } \
  159. OPTIONAL {?uri_person crm:P74_has_current_or_former_residence ?uri_provenienza . \
  160. ?uri_provenienza crm:P2_has_type 'Provenienza'; \
  161. rdfs:label ?provenienza . } \
  162. } "
  163. queryRelazioniInverse = prefixes + " SELECT DISTINCT ?relation_type ?note ?uri_person SAMPLE(?name) AS ?name ?givenName ?familyName ?patronymic ?provenienza \
  164. WHERE { \
  165. VALUES ?uri {<" + thisUrlParams.link + ">} \
  166. ?relation crm:P141_assigned ?uri; \
  167. crm:P42_assigned ?uri_type . \
  168. ?uri_person crm:P141_assigned ?relation . \
  169. ?uri_type rdfs:label ?relation_type . \
  170. OPTIONAL {?uri_type crm:P3_has_note ?note } \
  171. OPTIONAL {?uri_person foaf:name ?name } \
  172. OPTIONAL {?uri_person foaf:givenName ?givenName} \
  173. OPTIONAL {?uri_person foaf:familyName ?familyName} \
  174. OPTIONAL {?uri_person person:patronymicName ?patronymic } \
  175. OPTIONAL {?uri_person crm:P74_has_current_or_former_residence ?uri_provenienza . \
  176. ?uri_provenienza crm:P2_has_type 'Provenienza'; \
  177. rdfs:label ?provenienza . } \
  178. } "
  179. queryLetters = prefixes + " SELECT DISTINCT ?type ?segnatura ?document_uri ?document_name ?time_span ?InfObj \
  180. WHERE { \
  181. VALUES ?uri {<" + thisUrlParams.link + ">} \
  182. {?pc crm:P02_has_range ?uri . \
  183. } UNION { \
  184. ?group crm:P107_has_current_or_former_member ?uri; \
  185. crm:P2_has_type 'Gruppo scrittura lettera' . \
  186. ?pc crm:P02_has_range ?group . \
  187. } \
  188. ?ev_move crm:P01_has_domain ?pc ; \
  189. rdfs:label ?type ; \
  190. rdfs:subClassOf ?event . \
  191. ?document_uri crm:P25i_moved_by ?event ; \
  192. rdfs:label ?document_name . \
  193. ?document_uri crm:P1_is_identified_by ?uriSegnatura . \
  194. ?uriSegnatura crm:P2_has_type 'Segnatura' ; \
  195. rdfs:label ?segnatura . \
  196. OPTIONAL {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?document_uri crm:P128_carries ?InfObj . \
  197. ?InfObj rdf:type crm:E73_Information_Object} }. \
  198. OPTIONAL {?ev_move crm:P4_has_time-span ?uri_ts . \
  199. ?uri_ts rdfs:label ?time_span . } \
  200. }"
  201. queryDocuments = prefixes + " SELECT DISTINCT ?role ?document ?label ?id (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  202. WHERE { \
  203. ?document ?property ?event ; \
  204. crm:P1_is_identified_by ?uri_id ; \
  205. rdfs:label ?label . \
  206. ?uri_id rdfs:label ?id ; \
  207. crm:P2_has_type 'Segnatura' . \
  208. OPTIONAL { \
  209. {?event crm:P4_has_time-span ?uri_time_span . \
  210. ?uri_time_span rdfs:label ?time_span . \
  211. } UNION { \
  212. ?sub_event rdfs:subClassOf ?event ; \
  213. crm:P4_has_time-span ?uri_time_span . \
  214. ?uri_time_span rdfs:label ?time_span . } \
  215. } \
  216. ?event crm:P01_has_domain ?domain . \
  217. ?domain crm:P02_has_range <" + thisUrlParams.link + "> ; \
  218. crm:P14.1_in_the_role_of ?uri_role . \
  219. ?uri_role rdfs:label ?role . \
  220. } \
  221. GROUP BY ?document ?label ?id ?role "
  222. queryOtherDoc = prefixes + " SELECT DISTINCT ?document ?label ?id (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  223. WHERE { \
  224. VALUES ?uri {<" + thisUrlParams.link + "> } \
  225. {?domain crm:P02_has_range ?uri . \
  226. ?event crm:P01_has_domain ?domain . \
  227. ?document crm:P92i_was_brought_into_existence_by ?event ; \
  228. crm:P1_is_identified_by ?uri_id ; \
  229. rdfs:label ?label . \
  230. ?uri_id crm:P2_has_type 'Segnatura'; \
  231. rdfs:label ?id . \
  232. } UNION { \
  233. ?event crm:P67_refers_to ?uri . \
  234. ?document crm:P92i_was_brought_into_existence_by ?event ; \
  235. rdfs:label ?label ; \
  236. crm:P1_is_identified_by ?uri_id . \
  237. ?uri_id rdfs:label ?id ; \
  238. crm:P2_has_type 'Segnatura' . \
  239. } UNION { \
  240. ?event crm:P67_refers_to ?uri . \
  241. ?documentation crm:P67_refers_to ?uri ; \
  242. crm:P141_assigned ?card . \
  243. ?document crm:P46_is_composed_of ?card ; \
  244. rdfs:label ?label ; \
  245. crm:P1_is_identified_by ?uri_id . \
  246. ?uri_id rdfs:label ?id ; \
  247. crm:P2_has_type 'Segnatura' . \
  248. } \
  249. OPTIONAL {?event crm:P4_has_time-span ?uri_time_span . \
  250. ?uri_time_span rdfs:label ?time_span} \
  251. } "
  252. queryOpere = prefixes + " SELECT DISTINCT ?subject ?label ?nct (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  253. WHERE {?subject rdf:type crm:E22_Man-Made_Object ; \
  254. rdfs:label ?label ; \
  255. crm:P1_is_identified_by ?uri_nct . \
  256. ?uri_nct rdfs:label ?nct . \
  257. ?production crm:P108_has_produced ?subject . \
  258. OPTIONAL {?production crm:P4_has_time-span ?uri_time_span . \
  259. ?uri_time_span rdfs:label ?time_span } \
  260. ?pc crm:P01_has_domain ?production ; \
  261. crm:P02_has_range <" + thisUrlParams.link + "> } \
  262. GROUP BY ?subject ?label ?nct "
  263. queryGettatelliEv = prefixes + " SELECT DISTINCT ?event_type ?time_span \
  264. WHERE { \
  265. VALUES ?uri {<" + thisUrlParams.link + ">} \
  266. ?uri crm:P12i_was_present_at ?event . \
  267. ?event crm:P2_has_type ?uri_event_type ; \
  268. crm:P4_has_time-span ?uri_time_span . \
  269. ?uri_time_span rdfs:label ?time_span . \
  270. ?uri_event_type rdfs:label ?event_type . \
  271. } "
  272. queryEventi = prefixes + " SELECT DISTINCT ?event_type ?role ?time_span ?place ?uri_place ?document ?uri_document \
  273. WHERE { \
  274. VALUES ?uri {<" + thisUrlParams.link + ">} \
  275. ?domain crm:P02_has_range ?uri ; \
  276. crm:P14.1_in_the_role_of ?uri_role . \
  277. ?uri_role rdfs:label ?role . \
  278. ?event crm:P01_has_domain ?domain ; \
  279. crm:P2_has_type ?uri_event_type . \
  280. ?uri_event_type rdfs:label ?event_type . \
  281. OPTIONAL {?event crm:P4_has_time-span ?uri_time_span . \
  282. ?uri_time_span rdfs:label ?time_span .} \
  283. OPTIONAL {?event crm:P7_took_place_at ?uri_location . \
  284. ?uri_location rdfs:label ?place . \
  285. OPTIONAL {?uri_place owl:sameAs ?uri_location . \
  286. ?uri_place crm:P168_place_is_defined_by ?coords }} \
  287. ?document_info crm:P70_documents ?event . \
  288. ?uri_document crm:P128_carries ?document_info ; \
  289. rdfs:label ?document . \
  290. } "
  291. queryCompagnia = prefixes + " SELECT DISTINCT ?denomination ?occupation ?uri_sede ?uri_place ?sede \
  292. WHERE { \
  293. VALUES ?uri {<" + thisUrlParams.link + ">} \
  294. ?uri rdf:type crm:E74_Group . \
  295. ?uri crm:P2_has_type ?denomination . \
  296. OPTIONAL {?uri schema:hasOccupation ?uri_Occupation . \
  297. ?uri_Occupation rdfs:label ?occupation .} \
  298. OPTIONAL {?uri crm:P74_has_current_or_former_residence ?uri_sede . \
  299. ?uri_sede rdfs:label ?sede . \
  300. OPTIONAL {?uri_sede owl:sameAs ?uri_place . \
  301. ?uri_place crm:P168_place_is_defined_by ?coords .} \
  302. } \
  303. }"
  304. queryContrassegni = prefixes + " SELECT DISTINCT ?contrassegno ?image \
  305. WHERE { \
  306. VALUES ?uri {<" + thisUrlParams.link + ">} \
  307. ?event crm:P141_assigned ?uri ; \
  308. crm:P140_assigned_attribute_to ?uri_contrassegno . \
  309. ?uri_contrassegno crm:P2_has_type 'Contrassegno'; \
  310. rdfs:label ?contrassegno . \
  311. ?uri_image crm:P138_represents ?uri_contrassegno ; \
  312. crm:P1_is_identified_by ?uri_id . \
  313. ?uri_id rdfs:label ?image . \
  314. } "
  315. queryURL = prepareQueryURL(query);
  316. queryOt = prepareQueryURL(queryOtherDoc);
  317. queryOA = prepareQueryURL(queryOpere);
  318. query = prepareQueryURL(queryInfo);
  319. queryEx = prepareQueryURL(queryLetters);
  320. queryGt = prepareQueryURL(queryGettatelliEv);
  321. queryInfoGt = prepareQueryURL(queryInfoGettatelli);
  322. queryRel = prepareQueryURL(queryRelazioni);
  323. queryRelIn = prepareQueryURL(queryRelazioniInverse);
  324. queryCom = prepareQueryURL(queryCompagnia);
  325. queryEv = prepareQueryURL(queryEventi);
  326. queryCon = prepareQueryURL(queryContrassegni);
  327. response = $.ajax({
  328. url: query,
  329. dataType: "json",
  330. success: function (data){
  331. handle_data(data);
  332. },
  333. error: function (e) {}
  334. });
  335. response = $.ajax({
  336. url: queryURL,
  337. dataType: "json",
  338. success: function (data){
  339. handle_map(data);
  340. },
  341. error: function (e) {}
  342. });
  343. responseLet = $.ajax({
  344. url: queryEx,
  345. dataType: "json",
  346. success: function (data){
  347. handle_Letters(data);
  348. },
  349. error: function (e) {}
  350. });
  351. responseOA = $.ajax({
  352. url: queryOA,
  353. dataType: "json",
  354. success: function (data){
  355. handle_Artwork(data);
  356. },
  357. error: function (e) {}
  358. });
  359. responseOt = $.ajax({
  360. url: queryOt,
  361. dataType: "json",
  362. success: function (data){
  363. handle_Other_Documents(data);
  364. },
  365. error: function (e) {}
  366. });
  367. responseGet = $.ajax({
  368. url: queryGt,
  369. dataType: "json",
  370. success: function (data){
  371. handle_Gettatelli(data);
  372. },
  373. error: function (e) {}
  374. });
  375. responseDoc = $.ajax({
  376. url: queryInfoGt,
  377. dataType: "json",
  378. success: function (data){
  379. handle_InfoGettatelli(data);
  380. },
  381. error: function (e) {}
  382. });
  383. responseRel = $.ajax({
  384. url: queryRel,
  385. dataType: "json",
  386. success: function (data){
  387. handle_Relazioni(data);
  388. },
  389. error: function (e) {}
  390. });
  391. responseRel = $.ajax({
  392. url: queryRelIn,
  393. dataType: "json",
  394. success: function (data){
  395. handle_RelazioniInverse(data);
  396. },
  397. error: function (e) {}
  398. });
  399. responseRel = $.ajax({
  400. url: queryCom,
  401. dataType: "json",
  402. success: function (data){
  403. handle_Compagnia(data);
  404. },
  405. error: function (e) {}
  406. });
  407. responseEv = $.ajax({
  408. url: queryEv,
  409. dataType: "json",
  410. success: function (data){
  411. handle_Events(data);
  412. },
  413. error: function (e) {}
  414. });
  415. responseEv = $.ajax({
  416. url: queryCon,
  417. dataType: "json",
  418. success: function (data){
  419. handle_Contrassegni(data);
  420. },
  421. error: function (e) {}
  422. });
  423. var labelName = "";
  424. function handle_data(json) {
  425. //console.log(json['results']['bindings']);
  426. var graph = "";
  427. var label = "";
  428. if ("givenName" in json.results.bindings) {
  429. givenName = value['givenName']['value'];
  430. }
  431. $.each(
  432. json['results']['bindings'],
  433. function (index, value) {
  434. var graph = value['graph']['value'];
  435. var uri = value['uri']['value'];
  436. var label = value['label']['value'];
  437. var name = value['name']['value'];
  438. var givenName = "";
  439. var familyName = "";
  440. var alias = "";
  441. var gender = "";
  442. var patronymic = "";
  443. var occupation = "";
  444. var relative2 = "";
  445. var relative3 = "";
  446. var identifier = "";
  447. var id_type = "";
  448. var birth_date = "";
  449. var birth_place = "";
  450. var death_date = "";
  451. var death_place = "";
  452. var qualification = "";
  453. var group = "";
  454. var type = "";
  455. var provenence = "";
  456. var variants = "";
  457. if ((value.hasOwnProperty('identifier')) && (value.hasOwnProperty('id_type'))) {
  458. $("#identifier").css("display", "flex");
  459. identifier = value['identifier']['value'];
  460. id_type = value['id_type']['value'];
  461. }
  462. if (value.hasOwnProperty('givenName')) {
  463. $("#givenName").css("display", "flex");
  464. givenName = value['givenName']['value'];
  465. }
  466. if (value.hasOwnProperty('familyName')) {
  467. $("#familyName").css("display", "flex");
  468. familyName = value['familyName']['value'].toLowerCase();
  469. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1);
  470. }
  471. if (value.hasOwnProperty('alias')) {
  472. $("#aliasName").css("display", "flex");
  473. alias = value['alias']['value'];
  474. }
  475. if (value.hasOwnProperty('gender')) {
  476. $("#gender").css("display", "flex");
  477. gender = value['gender']['value'];
  478. }
  479. if (value.hasOwnProperty('patronymic')) {
  480. $("#patronymic").css("display", "flex");
  481. patronymic = value['patronymic']['value'];
  482. }
  483. if (value.hasOwnProperty('provenienza')) {
  484. $("#PlaceProvenence").css("display", "flex");
  485. provenence = value['provenienza']['value'];
  486. }
  487. if (value.hasOwnProperty('occupation')) {
  488. $("#occupation").css("display", "flex");
  489. occupation = value['occupation']['value'];
  490. }
  491. if (value.hasOwnProperty('relative2')) {
  492. relative2 = value['relative2']['value'];
  493. }
  494. if (value.hasOwnProperty('relative3')) {
  495. relative3 = value['relative3']['value'];
  496. }
  497. if (value.hasOwnProperty('qualification')) {
  498. $("#honorific").css("display", "flex");
  499. qualification = value['qualification']['value'];
  500. }
  501. if (value.hasOwnProperty('person_type')) {
  502. $("#type").css("display", "flex");
  503. type = value['person_type']['value'];
  504. }
  505. if (value.hasOwnProperty('Birth_Date')) {
  506. $("#BirthDate").css("display", "flex");
  507. birth_date = value['Birth_Date']['value'];
  508. }
  509. if (value.hasOwnProperty('Birth_Place')) {
  510. $("#BirthPlace").css("display", "flex");
  511. birth_place = value['Birth_Place']['value'];
  512. }
  513. if (value.hasOwnProperty('Death_Date')) {
  514. $("#DeathDate").css("display", "flex");
  515. death_date = value['Death_Date']['value'];
  516. }
  517. if (value.hasOwnProperty('Death_Place')) {
  518. $("#DeathPlace").css("display", "flex");
  519. death_place = value['Death_Place']['value'];
  520. }
  521. if (value.hasOwnProperty('group')) {
  522. $("#groups").css("display", "flex");
  523. group = value['group']['value'];
  524. }
  525. if (value.hasOwnProperty('variants')) {
  526. if (value['variants']['value'] != "| ") {
  527. alert(value['variants']['value']);
  528. $("#otherNames").css("display", "flex");
  529. let strings = value['variants']['value'];
  530. variants = strings.split(";");
  531. }
  532. }
  533. var dataset = get_dataset_name(graph);
  534. var second_name = patronymic;
  535. if (relative2 != "") {
  536. second_name = second_name + " " + relative2;
  537. }
  538. if (relative3 != "") {
  539. second_name = second_name + " " + relative3;
  540. }
  541. if (familyName != "") {
  542. second_name = second_name + " " + familyName;
  543. }
  544. var first_name = "";
  545. if ((givenName != "") || (second_name != "") || (provenence != "")) {
  546. first_name = givenName + " " + second_name + " " + provenence;
  547. } else {
  548. first_name = name;
  549. }
  550. first_name = first_name.replace(",", "");
  551. first_name = titleCase(first_name);
  552. name = titleCase(name);
  553. givenName = titleCase(givenName);
  554. var name_string = "";
  555. if (variants.length>0) {
  556. for (var i=0; i<variants.length; i++) {
  557. let chunk = variants[i].split("| ");
  558. name_string = name_string + "<a href='" + chunk[0] + "'>" + chunk[1] + "</a><br />";
  559. }
  560. }
  561. labelName = first_name;
  562. //console.log(variants);
  563. var Buttons = '<button class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  564. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  565. <button type="button" value="object" id="' + uri + '" class="cit btn btn-default" alt="scheda" title="Citazione"><i class="fa fa-quote-right"></i></button> \
  566. <button type="button" value="object" id="' + uri + '" class="hyp btn btn-default" alt="scheda" title="Hyperlink"><i class="fa fa-link"></i></button> \
  567. <a href="http://dev.restore.ovi.cnr.it/lodlive/?' + uri + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD" title="LodLive"><i class="fa fa-share-alt"></i></button></a></div></div>';
  568. var id_snippet = "<div class='col-sm-4'><span class='label'>" + id_type + ":</span></div><div class='col' id='identificatore'>" + identifier + "</div>";
  569. document.getElementById("grafo").innerHTML = dataset;
  570. document.getElementById("nome_persona").innerHTML = first_name;
  571. document.getElementById("nome").innerHTML = name;
  572. document.getElementById("genere").innerHTML = gender;
  573. document.getElementById("nome_proprio").innerHTML = givenName;
  574. document.getElementById("nome_famiglia").innerHTML = familyName;
  575. document.getElementById("patronimico").innerHTML = second_name.replace("di ", "");
  576. document.getElementById("provenienza").innerHTML = provenence;
  577. document.getElementById("identifier").innerHTML = id_snippet;
  578. document.getElementById("alias").innerHTML = alias;
  579. document.getElementById("tipologia").innerHTML = type;
  580. document.getElementById("variants").innerHTML = name_string;
  581. document.getElementById("qualifica").innerHTML = qualification;
  582. document.getElementById("occupazione").innerHTML = occupation;
  583. document.getElementById("data_nascita").innerHTML = birth_date;
  584. document.getElementById("data_morte").innerHTML = death_date;
  585. document.getElementById("luogo_nascita").innerHTML = birth_place;
  586. document.getElementById("luogo_morte").innerHTML = death_place;
  587. document.getElementById("gruppi_appartenenza").innerHTML = group;
  588. document.getElementById("link_buttons").innerHTML = Buttons;
  589. const collection = document.getElementsByClassName("PN");
  590. for (var i=0; i<collection.length; i++) {
  591. collection[i].innerHTML = first_name;
  592. }
  593. });
  594. }
  595. function get_dataset_name(graph) {
  596. var string = "Scheda Onomastica";
  597. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica") {
  598. string = string + " / Onomastica Datini";
  599. }
  600. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/authors"){
  601. string = string + " / Artisti";
  602. }
  603. else {
  604. string = string;
  605. }
  606. return (string);
  607. }
  608. function handle_InfoGettatelli(json) {
  609. //console.log(json);
  610. var card = "";
  611. var uri_card = "";
  612. $.each(
  613. json['results']['bindings'],
  614. function (index, value) {
  615. if ((value.hasOwnProperty('uri_card')) && (value.hasOwnProperty('card'))) {
  616. $("#card").css("display", "flex");
  617. uri_card = value['uri_card']['value'];
  618. card = value['card']['value'];
  619. }
  620. });
  621. var button_obj = "";
  622. if (uri_card != "") {
  623. button_obj = '<button type="button" id="' + uri_card +
  624. '" class="object btn btn-default" alt="oggetto" title="' + uri_card +
  625. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  626. }
  627. document.getElementById("scheda_anagrafica").innerHTML = card;
  628. document.getElementById("btn_scheda").innerHTML = button_obj;
  629. }
  630. function handle_Gettatelli(json) {
  631. //console.log(json);
  632. var generic = "";
  633. var find = "";
  634. var reunite = "";
  635. var adoption = "";
  636. $.each(
  637. json['results']['bindings'],
  638. function (index, value) {
  639. var event_type = value['event_type']['value'];
  640. var data = value['time_span']['value'];
  641. if (event_type == "Evento generico") {
  642. $("#generic_event").css("display", "flex");
  643. generic = data;
  644. }
  645. else if (event_type == "Ritrovamento") {
  646. $("#find_event").css("display", "flex");
  647. find = data;
  648. }
  649. else if (event_type == "Ricongiungimento") {
  650. $("#reunion_event").css("display", "flex");
  651. reunite = data;
  652. }
  653. else if (event_type == "Adozione") {
  654. $("#adoption_event").css("display", "flex");
  655. adoption = data;
  656. }
  657. });
  658. document.getElementById("anno").innerHTML = generic;
  659. document.getElementById("ritrovamento").innerHTML = find;
  660. document.getElementById("ricongiungimento").innerHTML = reunite;
  661. document.getElementById("adozione").innerHTML = adoption;
  662. }
  663. function handle_Relazioni(json) {
  664. //console.log(json);
  665. var Relazioni = "";
  666. const myArray = []
  667. $.each(
  668. json['results']['bindings'],
  669. function (index, value) {
  670. var tipo = value['relation_type']['value'];
  671. var uri_person = value['uri_person']['value'];
  672. var nome = value['name']['value'];
  673. var principale = "";
  674. var givenName = "";
  675. var familyName = "";
  676. var patronymic = "";
  677. var provenence = "";
  678. if (value.hasOwnProperty('givenName')) {
  679. givenName = value['givenName']['value'];
  680. }
  681. if (value.hasOwnProperty('note')) {
  682. principale = " principale";
  683. }
  684. if (value.hasOwnProperty('familyName')) {
  685. familyName = value['familyName']['value'].toLowerCase();
  686. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
  687. }
  688. if (value.hasOwnProperty('patronymic')) {
  689. patronymic = value['patronymic']['value'];
  690. }
  691. if (value.hasOwnProperty('provenienza')) {
  692. provenence = value['provenienza']['value'];
  693. }
  694. var type = tipo.charAt(0).toUpperCase() + tipo.slice(1) + principale;
  695. if ((type == "Socio") || (type == "Socio principale")) {
  696. type = "Società";
  697. }
  698. if (type == "Mano lettera") {
  699. type = "Altre collaborazioni"
  700. }
  701. var first_name = "";
  702. if ((givenName != "") || (patronymic != "") || (familyName != "") || (provenence != "")) {
  703. first_name = givenName + " " + patronymic + " " + familyName + " " + provenence;
  704. } else {
  705. first_name = nome;
  706. }
  707. myArray.push([type, first_name, uri_person]);
  708. });
  709. const checkRel = [];
  710. for (var i=0; i<myArray.length; i++) {
  711. var key = myArray[i][0];
  712. checkRel.push(key);
  713. }
  714. var params = [];
  715. $.each(checkRel, function(i, el){
  716. if($.inArray(el, params) === -1) params.push(el);
  717. });
  718. for (var i=0; i<params.length; i++) {
  719. var par = params[i];
  720. var par_id = par.replaceAll(" ", "_");
  721. var rel = createDivRelazione(par, par_id);
  722. Relazioni = Relazioni + rel;
  723. }
  724. $(Relazioni).insertAfter( "#groups" );
  725. for (var j=0; j<params.length; j++) {
  726. var el = params[j];
  727. var par = el.replaceAll(" ", "_");
  728. var Colums = "";
  729. for (var i=0; i<myArray.length; i++) {
  730. var text = myArray[i][1];
  731. var link = myArray[i][2];
  732. var rel = myArray[i][0].replaceAll(" ", "_");
  733. if (par == rel) {
  734. var col = createColRelazione(text, link);
  735. Colums = Colums + col;
  736. }
  737. }
  738. document.getElementById(par).innerHTML = Colums;
  739. }
  740. }
  741. function handle_RelazioniInverse(json) {
  742. //console.log(json);
  743. var Relazioni = "";
  744. const myArray = []
  745. $.each(
  746. json['results']['bindings'],
  747. function (index, value) {
  748. var tipo = value['relation_type']['value'];
  749. var uri_person = value['uri_person']['value'];
  750. var nome = "";
  751. var principale = "";
  752. var givenName = "";
  753. var familyName = "";
  754. var patronymic = "";
  755. var provenence = "";
  756. if (value.hasOwnProperty('name')) {
  757. nome = value['name']['value'];
  758. }
  759. if (value.hasOwnProperty('givenName')) {
  760. givenName = value['givenName']['value'];
  761. }
  762. if (value.hasOwnProperty('note')) {
  763. principale = " principale";
  764. }
  765. if (value.hasOwnProperty('familyName')) {
  766. familyName = value['familyName']['value'].toLowerCase();
  767. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
  768. }
  769. if (value.hasOwnProperty('patronymic')) {
  770. patronymic = value['patronymic']['value'];
  771. }
  772. if (value.hasOwnProperty('provenienza')) {
  773. provenence = value['provenienza']['value'];
  774. }
  775. var type = tipo.charAt(0).toUpperCase() + tipo.slice(1) + principale + " di";
  776. if (type == "Socio di") {
  777. type = "Soci";
  778. }
  779. if (type == "Socio principale di") {
  780. type = "Intestatario principale";
  781. }
  782. if (type == "Mano lettera di") {
  783. type = "Collaboratori";
  784. }
  785. var first_name = "";
  786. if ((givenName != "") || (patronymic != "") || (familyName != "") || (provenence != "")) {
  787. first_name = givenName + " " + patronymic + " " + familyName + " " + provenence;
  788. } else {
  789. first_name = nome;
  790. }
  791. myArray.push([type, first_name, uri_person]);
  792. });
  793. const checkRel = [];
  794. for (var i=0; i<myArray.length; i++) {
  795. var key = myArray[i][0];
  796. checkRel.push(key);
  797. }
  798. var params = [];
  799. $.each(checkRel, function(i, el){
  800. if($.inArray(el, params) === -1) params.push(el);
  801. });
  802. for (var i=0; i<params.length; i++) {
  803. var par = params[i];
  804. var par_id = par.replaceAll(" ", "_");
  805. var rel = createDivRelazione(par, par_id);
  806. Relazioni = Relazioni + rel;
  807. }
  808. $(Relazioni).insertAfter( "#groups" );
  809. for (var j=0; j<params.length; j++) {
  810. var el = params[j];
  811. var par = el.replaceAll(" ", "_");
  812. var Colums = "";
  813. for (var i=0; i<myArray.length; i++) {
  814. var text = myArray[i][1];
  815. var link = myArray[i][2];
  816. var rel = myArray[i][0].replaceAll(" ", "_");
  817. if (par == rel) {
  818. var col = createColRelazione(text, link);
  819. Colums = Colums + col;
  820. }
  821. }
  822. document.getElementById(par).innerHTML = Colums;
  823. }
  824. }
  825. function createDivRelazione(type, id){
  826. htmlCode = '\
  827. <div class="row mb-2"> \
  828. <div class="col-sm-4"> \
  829. <span class="label"><RELATIONSHIP></span> \
  830. </div> \
  831. <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
  832. </div> \
  833. '.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
  834. return htmlCode;
  835. }
  836. function createColRelazione(text, link) {
  837. htmlCode = '\
  838. <div class="row mb-1"> \
  839. <div class="col"><NAME></div> \
  840. <div class="col-auto"> \
  841. <button class="persona btn btn-default" type="button" id="<URI>">\
  842. <i class="fa fa-user" aria-hidden="true">\
  843. <p class="btn-text">Scheda Persona</p>\
  844. </i>\
  845. </button>\</div> \
  846. </div>\
  847. '.replace("<NAME>", text).replace("<URI>", link);
  848. return htmlCode;
  849. }
  850. function handle_Events(json) {
  851. const events = [];
  852. $.each(
  853. json['results']['bindings'],
  854. function (index, value) {
  855. var event_type = value['event_type']['value'];
  856. var role = value['role']['value'];
  857. var uri_document = value['uri_document']['value'];
  858. var document = value['document']['value'];
  859. var time_span = "";
  860. var uri_place = "";
  861. var place = "";
  862. if (value.hasOwnProperty('time_span')) {
  863. time_span = value['time_span']['value'];
  864. }
  865. if (value.hasOwnProperty('uri_place')) {
  866. uri_place = value['uri_place']['value'];
  867. }
  868. if (value.hasOwnProperty('place')) {
  869. place = value['place']['value'];
  870. place = titleCase(place);
  871. }
  872. const cells = [event_type, role, time_span, uri_place, place, uri_document, document];
  873. events.push(cells);
  874. });
  875. var thead = '<thead id="ev_thead" class="def_res"><tr>' +
  876. '<th class="col-2">Evento</th>' +
  877. '<th class="col-2">Ruolo</th>' +
  878. '<th class="col-2">Data</th>' +
  879. '<th class="col-2">Luogo</th>' +
  880. '<th class="col-4">Documento</th>' +
  881. '</tr></thead>';
  882. var EventsTable = thead;
  883. EventsTable += '<tbody>';
  884. for (var i=0; i<events.length; i++) {
  885. EventsTable += '<tr class="res">' +
  886. '<th class="col-2">' + events[i][0] + '</th>' +
  887. '<th class="col-2">' + events[i][1] + '</th>' +
  888. '<th class="col-2">' + events[i][2] + '</th>' +
  889. '<th id="' + events[i][3] + '" class="col-2 luogo link">' + events[i][4] + '</th>' +
  890. '<th id="' + events[i][5] + '" class="col-4 object link">' + events[i][6] + '</th>' +
  891. '</tr>';
  892. }
  893. EventsTable += '</tbody>';
  894. if (events.length != 0) {
  895. document.getElementById("res_events").innerHTML = EventsTable;
  896. } else {
  897. var eventIcon = "<div id='map_icon' class='no_info_icon'> \
  898. <svg width='30' viewBox='0 0 411 404' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'> \
  899. <g id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'> \
  900. <g id='noun-event-1989064' fill='#000000' fill-rule='nonzero'><path d='M31.55,403.44 L380.46,403.44 C397.304,403.44 410.538,389.331 410.538,372.378 L410.538,166.098 L0.378,166.098 L0.378,372.378 C0.378,389.331 14.706,403.44 31.55,403.44 Z' id='Path'></path><polygon id='Path' points='76.94 0.562 129.44 0.562 129.44 69.468 76.94 69.468'></polygon><path d='M410.53,80.08 C410.53,63.236 397.296,49.783 380.452,49.783 L361.311,49.783 L361.311,82.924 C361.311,90.1428 355.186,95.721 347.967,95.721 L269.655,95.721 C262.4362,95.721 256.202,90.1429 256.202,82.924 L256.202,49.783 L155.582,49.783 L155.582,82.924 C155.582,90.1428 149.457,95.721 142.129,95.721 L63.817,95.721 C56.5982,95.721 50.473,90.1429 50.473,82.924 L50.473,49.783 L31.551,49.783 C14.707,49.783 0.379,63.127 0.379,80.08 L0.379,143.846 L410.539,143.846 L410.53,80.08 Z' id='Path'></path><polygon id='Path' points='282.56 0.562 335.06 0.562 335.06 69.468 282.56 69.468'></polygon></g> \
  901. </g> \
  902. </svg> \
  903. <p>Nessun evento trovato</p> \
  904. </div>";
  905. document.getElementById("res_events_container").style.display = "none";
  906. document.getElementById("res_events_no_res").innerHTML = eventIcon;
  907. }
  908. }
  909. function handle_Compagnia(json) {
  910. //console.log(json);
  911. var denominazione = "";
  912. var sede = "";
  913. var uri_sede = "";
  914. var uri_place = "";
  915. $.each(
  916. json['results']['bindings'],
  917. function (index, value) {
  918. if (value.hasOwnProperty('denomination')) {
  919. $("#type_society").css("display", "flex");
  920. denominazione = value['denomination']['value'];
  921. }
  922. if (value.hasOwnProperty('uri_place')) {
  923. $("#sede").css("display", "flex");
  924. uri_place = value['uri_place']['value'];
  925. }
  926. if (value.hasOwnProperty('uri_sede')) {
  927. $("#sede").css("display", "flex");
  928. uri_sede = value['uri_sede']['value'];
  929. }
  930. if (value.hasOwnProperty('sede')) {
  931. sede = value['sede']['value'];
  932. }
  933. });
  934. }
  935. function handle_Contrassegni(json) {
  936. var id_image = "";
  937. var name_image = "";
  938. $.each(
  939. json['results']['bindings'],
  940. function (index, value) {
  941. if (value.hasOwnProperty('image')) {
  942. $("#mark_image").css("display", "block");
  943. id_image = value['image']['value'];
  944. }
  945. if (value.hasOwnProperty('contrassegno')) {
  946. name_image = value['contrassegno']['value'];
  947. }
  948. });
  949. var Image = '<img style="width:100%;" src="img/contrassegni/' + id_image + '" />'
  950. document.getElementById("contrassegno").innerHTML = Image;
  951. document.getElementById("nome_contrassegno").innerHTML = name_image;
  952. }
  953. function handle_Letters(json) {
  954. //console.log(json);
  955. const send = [];
  956. const receive = [];
  957. var i=0;
  958. var j=0;
  959. $.each(
  960. json['results']['bindings'],
  961. function (index, value) {
  962. type = value['type']['value'];
  963. uri = value['document_uri']['value'];
  964. title = value['document_name']['value'];
  965. segnatura = value['segnatura']['value'];
  966. var data = "";
  967. var InfObj = "";
  968. if (value.hasOwnProperty('time_span')) {
  969. data = value['time_span']['value'];
  970. }
  971. if (value.hasOwnProperty('InfObj')) {
  972. InfObj = value['InfObj']['value'];
  973. }
  974. if (type == "Invio") {
  975. send.push([uri, title, segnatura, data, InfObj]);
  976. i++;
  977. } else {
  978. receive.push([uri, title, segnatura, data, InfObj]);
  979. j++;
  980. }
  981. });
  982. var Send_Letters = "";
  983. var Receive_Letters = "";
  984. //POPULATE SEND LETTERS BOX
  985. for (var i=0; i<send.length; i++) {
  986. var letter = "";
  987. var infObject_button = "";
  988. var object_type = "";
  989. if (send[i][4] != "") {
  990. letter = '<div class="col-8"><p><span id="' + send[i][0] + '" class="title_doc lettera">'+ send[i][1] + '</span>';
  991. object_type = "lettera";
  992. infObject_button += '<button type="button" id="' + send[i][4] +
  993. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  994. } else {
  995. letter = '<div class="col-8"><p><span id="' + send[i][0] + '" class="title_doc object">'+ send[i][1] + '</span>';
  996. object_type = "object";
  997. infObject_button += '<button type="button" id="' + send[i][0] +
  998. '" class="object btn btn-default" alt="oggetto" title="' + send[i][1] +
  999. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  1000. }
  1001. if (send[i][2] != "") {
  1002. letter = letter + "<br />Segnatura: " + send[i][2];
  1003. }
  1004. if (send[i][3] != "") {
  1005. letter = letter + "<br />Data: " + send[i][3];
  1006. }
  1007. letter = letter + '</p></div>';
  1008. Send_Letters += '<div class="row res">'+ letter +
  1009. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  1010. '<button type="button" value="' + object_type + '" id="' + send[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  1011. '<button type="button" value="' + object_type + '" id="' + send[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  1012. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + send[i][0] + '" 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>';
  1013. }
  1014. //POPULATE RECEIVE LETTERS BOX
  1015. for (var i=0; i<receive.length; i++) {
  1016. var letter = "";
  1017. var infObject_button = "";
  1018. var object_type = "";
  1019. if (receive[i][4] != "") {
  1020. letter = '<div class="col-8"><p><span id="' + receive[i][0] + '" class="title_doc lettera">'+ receive[i][1] + '</span>';
  1021. object_type = "lettera";
  1022. infObject_button += '<button type="button" id="' + receive[i][4] +
  1023. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  1024. } else {
  1025. letter = '<div class="col-8"><p><span id="' + receive[i][0] + '" class="title_doc object">'+ receive[i][1] + '</span>';
  1026. object_type = "object";
  1027. infObject_button += '<button type="button" id="' + receive[i][0] +
  1028. '" class="object btn btn-default" alt="oggetto" title="' + receive[i][1] +
  1029. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  1030. }
  1031. if (receive[i][2] != "") {
  1032. letter = letter + "<br />Segnatura: " + receive[i][2];
  1033. }
  1034. if (receive[i][3] != "") {
  1035. letter = letter + "<br />Data: " + receive[i][3];
  1036. }
  1037. letter = letter + '</p></div>';
  1038. Receive_Letters += '<div class="row res">'+ letter +
  1039. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  1040. '<button type="button" value="' + object_type + '" id="' + receive[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  1041. '<button type="button" value="' + object_type + '" id="' + receive[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  1042. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + receive[i][0] + '" 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>';
  1043. }
  1044. document.getElementById("l_send").innerHTML = send.length;
  1045. document.getElementById("l_receive").innerHTML = receive.length;
  1046. document.getElementById("letters_send").innerHTML = Send_Letters;
  1047. document.getElementById("letters_receive").innerHTML = Receive_Letters;
  1048. if (send.length==0) {
  1049. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  1050. document.getElementById("letters_send").innerHTML = messaggio;
  1051. }
  1052. if (receive.length==0) {
  1053. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  1054. document.getElementById("letters_receive").innerHTML = messaggio;
  1055. }
  1056. }
  1057. function handle_Artwork(json) {
  1058. //console.log(json);
  1059. const oa = [];
  1060. $.each(
  1061. json['results']['bindings'],
  1062. function (index, value) {
  1063. uri = value['subject']['value'];
  1064. label = value['label']['value'];
  1065. nct = value['nct']['value'];
  1066. var data = "";
  1067. if (value.hasOwnProperty('time_span')) {
  1068. data = value['time_span']['value'];
  1069. }
  1070. oa.push([uri, label, nct, data]);
  1071. });
  1072. var Artworks = "";
  1073. for (var i=0; i<oa.length; i++) {
  1074. var artwork = '<a href=' + oa[i][0] + ' target="_blank">' + oa[i][1] + '</a><br />NCT: ' + oa[i][2];
  1075. if (oa[i][3] != "") {
  1076. artwork = artwork + "<br />Data: " + oa[i][3];
  1077. }
  1078. var object_button = '<button type="button" id="' + oa[i][0] +
  1079. '" class="artwork btn btn-default" alt="opera d\'arte" title="' + oa[i][1] +
  1080. '"><i class="fas fa-paint-brush"></i><p class="btn-text">Scheda Opera d\'Arte</p></button>';
  1081. Artworks += '<div class="row res"><div class="col-8"><p>'+ artwork +'</p></div>' +
  1082. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  1083. '<button value="OA" type="button" id="' + oa[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  1084. '<button value="OA" type="button" id="' + oa[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  1085. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + oa[i][0] + '" 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>';
  1086. }
  1087. document.getElementById("n_oa").innerHTML = oa.length;
  1088. document.getElementById("object_oa").innerHTML = Artworks;
  1089. if (oa.length==0) {
  1090. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  1091. document.getElementById("object_oa").innerHTML = messaggio;
  1092. }
  1093. }
  1094. function handle_Other_Documents(json) {
  1095. //console.log(json);
  1096. const doc = [];
  1097. $.each(
  1098. json['results']['bindings'],
  1099. function (index, value) {
  1100. uri = value['document']['value'];
  1101. label = value['label']['value'];
  1102. var data = "";
  1103. var id = "";
  1104. if (value.hasOwnProperty('time_span')) {
  1105. data = value['time_span']['value'];
  1106. }
  1107. if (value.hasOwnProperty('id')) {
  1108. id = value['id']['value'];
  1109. }
  1110. doc.push([uri, label, id, data]);
  1111. });
  1112. var Documents = "";
  1113. for (var i=0; i<doc.length; i++) {
  1114. var paper = '<div class="col-8"><p><span id="' + doc[i][0] + '" class="title_doc object">'+ doc[i][1] + '</span>';
  1115. var object_button = '<button type="button" id="' + doc[i][0] +
  1116. '" class="object btn btn-default" alt="oggetto" title="' + doc[i][1] +
  1117. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  1118. if (doc[i][2] != "") {
  1119. paper = paper + "<br />Segnatura: " + doc[i][2];
  1120. }
  1121. if (doc[i][3] != "") {
  1122. paper = paper + "<br />Data: " + doc[i][3];
  1123. }
  1124. paper = paper + '</p></div>';
  1125. Documents += '<div class="row res">'+ paper +
  1126. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  1127. '<button value="object" type="button" id="' + doc[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  1128. '<button value="object" type="button" id="' + doc[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  1129. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + doc[i][0] + '" 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>';
  1130. }
  1131. document.getElementById("n_ass").innerHTML = doc.length;
  1132. document.getElementById("other_documents").innerHTML = Documents;
  1133. if (doc.length==0) {
  1134. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  1135. document.getElementById("other_documents").innerHTML = messaggio;
  1136. }
  1137. }
  1138. function handle_map(json) {
  1139. //console.log(json);
  1140. const locations = [];
  1141. const place_names = [];
  1142. const place_events = [];
  1143. const luoghi = [];
  1144. var lat = 0;
  1145. var long = 0;
  1146. var i=0;
  1147. var myPlaces = "";
  1148. $.each(
  1149. json['results']['bindings'],
  1150. function (index, value) {
  1151. const loc = []
  1152. var uri = value['place']['value'];
  1153. var label = value['label']['value'];
  1154. var coord = value['coordinates']['value'];
  1155. var evento = value['tipo']['value']
  1156. var count = value['count']['value']
  1157. place_events.push([uri, evento, count]);
  1158. if (!place_names.includes(uri)) {
  1159. place_names.push(uri);
  1160. const coordinates = coord.split(", ");
  1161. loc.push(uri);
  1162. label = titleCase(label);
  1163. loc.push(label);
  1164. myPlaces += "<div class='item-place-person'><div class='clickPlace item-place-person-label' data-point='"+ coordinates + "'>" + label + "</div><div class='item-place-person-action'><div class='luogo' id='" +
  1165. uri + "'><i class='far fa-map' style='cursor:pointer'></i></div></div></div>";
  1166. loc.push(coordinates[0]);
  1167. lat += parseInt(coordinates[0]);
  1168. loc.push(coordinates[1]);
  1169. long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  1170. locations.push(loc);
  1171. i++;
  1172. }
  1173. });
  1174. for (var k=0; k<locations.length; k++) {
  1175. const tempArray = [];
  1176. var nomeLuogo = locations[k][1];
  1177. var lt = locations[k][2];
  1178. var lg = locations[k][3];
  1179. tempArray.push(nomeLuogo);
  1180. tempArray.push(lt);
  1181. tempArray.push(lg);
  1182. for (var y=0; y<place_events.length; y++) {
  1183. var ev = place_events[y][1];
  1184. var number = place_events[y][2]
  1185. var dict = ev + ": " + number;
  1186. if (locations[k][0] == place_events[y][0]) {
  1187. tempArray.push(dict);
  1188. }
  1189. }
  1190. luoghi.push(tempArray);
  1191. }
  1192. //console.log(luoghi);
  1193. var latitude = lat/i;
  1194. var longitude = long/i;
  1195. var mapIcon = "<div id='map_icon' class='no_info_icon'> \
  1196. <svg xmlns='http://www.w3.org/2000/svg' width='30' viewBox='0 0 576 512'> \
  1197. <path d='M408 120C408 174.6 334.9 271.9 302.8 311.1C295.1 321.6 280.9 321.6 273.2 311.1C241.1 271.9 168 174.6 168 120C168 53.73 221.7 0 288 0C354.3 0 408 53.73 408 120zM288 152C310.1 152 328 134.1 328 112C328 89.91 310.1 72 288 72C265.9 72 248 89.91 248 112C248 134.1 265.9 152 288 152zM425.6 179.8C426.1 178.6 426.6 177.4 427.1 176.1L543.1 129.7C558.9 123.4 576 135 576 152V422.8C576 432.6 570 441.4 560.9 445.1L416 503V200.4C419.5 193.5 422.7 186.7 425.6 179.8zM150.4 179.8C153.3 186.7 156.5 193.5 160 200.4V451.8L32.91 502.7C17.15 508.1 0 497.4 0 480.4V209.6C0 199.8 5.975 190.1 15.09 187.3L137.6 138.3C140 152.5 144.9 166.6 150.4 179.8H150.4zM327.8 331.1C341.7 314.6 363.5 286.3 384 255V504.3L192 449.4V255C212.5 286.3 234.3 314.6 248.2 331.1C268.7 357.6 307.3 357.6 327.8 331.1L327.8 331.1z'/> \
  1198. </svg> \
  1199. <p>Nessun luogo trovato</p> \
  1200. </div>";
  1201. if (locations.length == 0) {
  1202. $("#people_map").css("display", "none");
  1203. $("#references_persona").css("display", "none");
  1204. document.getElementById("people_map_no_res").innerHTML = mapIcon;
  1205. }
  1206. document.getElementById("list_places_person").innerHTML = myPlaces;
  1207. var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
  1208. cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade, Points &copy 2012 LINZ',
  1209. cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 17, attribution: cloudmadeAttribution}),
  1210. latlng = new L.LatLng(latitude, longitude);
  1211. var map = new L.Map('map', {center: latlng, zoom: 5, layers: [cloudmade]});
  1212. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  1213. var markers = new L.MarkerClusterGroup();
  1214. var markerList = [];
  1215. var geo = new L.tileLayer(
  1216. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1217. attribution: '&copy; ' + mapLink + ' Contributors',
  1218. maxZoom: 18,
  1219. }).addTo(map);
  1220. function populate() {
  1221. for (var i = 0; i < luoghi.length; i++) {
  1222. var a = luoghi[i];
  1223. var len = a.length;
  1224. var title = "<h2>" + titleCase(a[0]) + "</h2>";
  1225. for (var k=3; k<len; k++) {
  1226. var dix = a[k].replace("Invio:", "Invio lettere:").replace("Ricezione:", "Ricezione lettere:");
  1227. title = title + "<p style='font-size: 14px;'>" + dix + " occorrenze</p><hr>";
  1228. }
  1229. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  1230. marker.bindPopup(title);
  1231. markers.addLayer(marker);
  1232. markerList.push(marker);
  1233. }
  1234. }
  1235. populate();
  1236. map.addLayer(markers);
  1237. $('.clickPlace').on('click', function(){
  1238. // parse lat and lng from the divs data attribute
  1239. var latlng = $(this).data().point.split(',');
  1240. var lat = latlng[0];
  1241. var lng = latlng[1];
  1242. var zoom = 10;
  1243. // set the view
  1244. map.setView([lat, lng], zoom);
  1245. });
  1246. }
  1247. $(document).on("click", ".luogo", function (ev) {
  1248. var link = this.id;
  1249. //alert(nome_autore);
  1250. //$('#myModal').text("");
  1251. window.open("Luogo.html?link="+this.id);
  1252. });
  1253. $(document).on("click", ".persona", function (ev) {
  1254. var link = this.id;
  1255. window.open("Persona.html?link="+this.id);
  1256. });
  1257. $(document).on("click", ".lettera", function (ev) {
  1258. var link = this.id;
  1259. //alert(nome_autore);
  1260. //$('#myModal').text("");
  1261. window.open("lettera.html?link="+this.id);
  1262. });
  1263. $(document).on("click", ".object", function (ev) {
  1264. var link = this.id;
  1265. //alert(nome_autore);
  1266. //$('#myModal').text("");
  1267. window.open("object.html?link="+this.id);
  1268. });
  1269. $(document).on("click", ".hyp", function (ev) {
  1270. var baseurl = window.location.origin+window.location.pathname;
  1271. let slash = baseurl.lastIndexOf("/");
  1272. var type = $(this).val() + '.html';
  1273. var link = this.id;
  1274. var url = baseurl.substr(0, slash+1) + type + "?link="+link;
  1275. var link = this.id;
  1276. $("#myModal").empty();
  1277. $("#myModal").css("display", "block");
  1278. $('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" +
  1279. url + "</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  1280. });
  1281. $(document).on("click", ".artwork", function (ev) {
  1282. var link = this.id;
  1283. //alert(nome_autore);
  1284. //$('#myModal').text("");
  1285. window.open("OA.html?link="+this.id);
  1286. });
  1287. $(document).on("click", ".close", function (ev) {
  1288. var link = this.id;
  1289. //alert(nome_autore);
  1290. //$('#myModal').text("");
  1291. $("#myModal").css("display", "none");
  1292. });
  1293. $(document).on("click", ".back", function (ev) {
  1294. $("#myTab").css("display", "none");
  1295. });
  1296. $(document).on("click", ".cit", function (ev) {
  1297. var author ="RESTORE. smart access to digital heritage and memory"
  1298. var year = new Date().getFullYear()
  1299. var today = new Date();
  1300. var dd = String(today.getDate()).padStart(2, '0');
  1301. var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  1302. var yyyy = today.getFullYear();
  1303. today = dd + '/' + mm + '/' + yyyy;
  1304. var baseurl = window.location.origin+window.location.pathname;
  1305. let slash = baseurl.lastIndexOf("/");
  1306. var type = $(this).val() + '.html';
  1307. var link = this.id;
  1308. var url = baseurl.substr(0, slash+1) + type + "?link="+link;
  1309. //alert(nome_autore);
  1310. //$('#myModal').text("");
  1311. $("#myModal").empty();
  1312. $("#myModal").css("display", "block");
  1313. $('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" +
  1314. author + " " + year + ", accesso effettuato: " + today + ", &lt;" + url + "&gt;</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  1315. });
  1316. function titleCase(str) {
  1317. var splitStr = str.toLowerCase().split(' ');
  1318. for (var i = 0; i < splitStr.length; i++) {
  1319. // You do not need to check if i is larger than splitStr length, as your for does that for you
  1320. // Assign it back to the array
  1321. splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
  1322. }
  1323. // Directly return the joined string
  1324. return splitStr.join(' ');
  1325. }
  1326. function copyToClipboard(text) {
  1327. var sampleTextarea = document.createElement("textarea");
  1328. document.body.appendChild(sampleTextarea);
  1329. sampleTextarea.value = text; //save main text in it
  1330. sampleTextarea.select(); //select textarea contenrs
  1331. document.execCommand("copy");
  1332. document.body.removeChild(sampleTextarea);
  1333. }
  1334. function myFunction(){
  1335. var copy = document.getElementById("myInput");
  1336. copyText = copy.textContent;
  1337. copyToClipboard(copyText);
  1338. //copyToClipboard(copyText.value);
  1339. }