people.js 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629
  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 title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  564. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  565. <button title="Citazione" 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 title="Permalink" 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" title="Naviga il grafo" 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. }
  1340. function exchangeLetter(tipo, mittente, uri_mittente, destinatario, uri_destinatario) {
  1341. var params = tipo + ";" + mittente + ";" + uri_mittente + ";" + destinatario + ";" + uri_destinatario;
  1342. window.open("results.html?params="+ params);
  1343. }