people.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  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 ?coordinates \
  41. WHERE { \
  42. {?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
  43. ?event_from crm:P01_has_domain ?pc ; \
  44. rdf:type crm:EL3_Receive_Letter; \
  45. crm:P26_moved_to ?place_from . \
  46. ?place_from rdf:type crm:E53_Place ; \
  47. owl:sameAs ?place . \
  48. ?place rdfs:label ?label ; \
  49. crm:P168_place_is_defined_by ?coordinates . \
  50. } UNION { \
  51. ?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
  52. ?event_from crm:P01_has_domain ?pc ; \
  53. rdf:type crm:EL2_Send_Letter; \
  54. crm:P27_moved_from ?place_from . \
  55. ?place_from rdf:type crm:E53_Place ; \
  56. owl:sameAs ?place . \
  57. ?place rdfs:label ?label ; \
  58. crm:P168_place_is_defined_by ?coordinates . \
  59. } UNION { \
  60. <" + thisUrlParams.link + "> crm:P100i_died_in ?uri_death . \
  61. ?uri_death crm:P7_took_place_at ?uri_place . \
  62. ?uri_place rdf:type crm:E53_Place ; \
  63. owl:sameAs ?place . \
  64. ?place rdfs:label ?label ; \
  65. crm:P168_place_is_defined_by ?coordinates . \
  66. } UNION { \
  67. <" + thisUrlParams.link + "> crm:P98i_was_born ?uri_birth . \
  68. ?uri_birth crm:P7_took_place_at ?uri_place . \
  69. ?uri_place rdf:type crm:E53_Place ; \
  70. owl:sameAs ?place . \
  71. ?place rdfs:label ?label ; \
  72. crm:P168_place_is_defined_by ?coordinates . \
  73. } \
  74. }"
  75. queryInfo = prefixes + " SELECT DISTINCT ?graph ?label ?identifier ?id_type ?name ?givenName ?familyName ?relative2 ?relative3 ?alias ?provenienza (GROUP_CONCAT(DISTINCT CONCAT(?variant, '| ', ?otherName) ; SEPARATOR = ';') AS ?variants) ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group \
  76. WHERE { \
  77. VALUES ?uri {<" + thisUrlParams.link + ">} \
  78. GRAPH ?graph {?uri rdfs:label ?label} \
  79. ?uri foaf:name ?name . \
  80. OPTIONAL {?uri crm:P1_is_identified_by ?id . \
  81. ?id rdfs:label ?identifier ; \
  82. crm:P2_has_type ?id_type .} \
  83. OPTIONAL {?uri foaf:givenName ?givenName} \
  84. OPTIONAL {?uri foaf:familyName ?familyName} \
  85. OPTIONAL {?uri foaf:gender ?gender} \
  86. OPTIONAL {?uri person:patronymicName ?patronymic } \
  87. OPTIONAL {?uri crm:P74_has_current_or_former_residence ?uri_provenienza . \
  88. ?uri_provenienza crm:P2_has_type 'Provenienza'; \
  89. rdfs:label ?provenienza . } \
  90. OPTIONAL {?uri crm:P2_has_type ?uri_person_type . \
  91. ?uri_person_type rdfs:label ?person_type } \
  92. OPTIONAL {?uri schema:hasOccupation ?uriOccupation . \
  93. ?uriOccupation rdf:type schema:Occupation; \
  94. rdfs:label ?occupation } \
  95. OPTIONAL {?uri schema:honorificPrefix ?qualification} \
  96. OPTIONAL {?uri crm:P100i_died_in ?Death . \
  97. ?Death crm:P4_has_time-span ?Death_TS; \
  98. crm:P7_took_place_at ?Place_D . \
  99. ?Death_TS rdfs:label ?Death_Date . \
  100. ?Place_D rdfs:label ?Death_Place } \
  101. OPTIONAL {?uri crm:P98i_was_born ?Birth . \
  102. ?Birth crm:P4_has_time-span ?Birth_TS; \
  103. crm:P7_took_place_at ?Place_B . \
  104. ?Birth_TS rdfs:label ?Birth_Date . \
  105. ?Place_B rdfs:label ?Birth_Place } \
  106. OPTIONAL {?uri crm:P107i_is_current_or_former_member_of ?uriGroup . \
  107. ?uriGroup rdfs:label ?group } \
  108. OPTIONAL {?uri schema:alternateName ?alias . } \
  109. OPTIONAL {?uri owl:sameAs ?variant . \
  110. ?variant foaf:name ?otherName . } \
  111. OPTIONAL {?relation2 crm:P141_assigned ?uri ; \
  112. crm:P42_assigned ?uri_rel_type2 . \
  113. ?uri_rel_type2 rdfs:label 'Avo di secondo grado' . \
  114. ?uri_relative2 crm:P141_assigned ?relation2; \
  115. rdfs:label ?relative2 .} \
  116. OPTIONAL {?relation3 crm:P141_assigned ?uri ; \
  117. crm:P42_assigned ?uri_rel_type3 . \
  118. ?uri_rel_type3 rdfs:label 'Avo di terzo grado' . \
  119. ?uri_relative3 crm:P141_assigned ?relation3; \
  120. rdfs:label ?relative3 .} \
  121. } \
  122. GROUP BY ?graph ?label ?identifier ?id_type ?name ?givenName ?familyName ?relative2 ?relative3 ?alias ?provenienza ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group \
  123. LIMIT 1 "
  124. queryInfoGettatelli = prefixes + " SELECT DISTINCT ?card ?uri_card \
  125. WHERE { \
  126. VALUES ?uri {<" + thisUrlParams.link + ">} \
  127. ?documentation crm:P67_refers_to ?uri ; \
  128. crm:P141_assigned ?uri_card . \
  129. ?uri_card rdfs:label ?card . \
  130. } "
  131. queryRelazioni = prefixes + " SELECT DISTINCT ?relation_type ?note ?uri_person ?name ?givenName ?familyName ?patronymic ?provenienza \
  132. WHERE { \
  133. VALUES ?uri {<" + thisUrlParams.link + ">} \
  134. ?uri crm:P141_assigned ?relation . \
  135. ?relation crm:P42_assigned ?uri_type ; \
  136. crm:P141_assigned ?uri_person . \
  137. ?uri_type rdfs:label ?relation_type . \
  138. OPTIONAL {?uri_type crm:P3_has_note ?note } \
  139. ?uri_person foaf:name ?name . \
  140. OPTIONAL {?uri_person foaf:givenName ?givenName} \
  141. OPTIONAL {?uri_person foaf:familyName ?familyName} \
  142. OPTIONAL {?uri_person person:patronymicName ?patronymic } \
  143. OPTIONAL {?uri_person crm:P74_has_current_or_former_residence ?uri_provenienza . \
  144. ?uri_provenienza crm:P2_has_type 'Provenienza'; \
  145. rdfs:label ?provenienza . } \
  146. } "
  147. queryLetters = prefixes + " SELECT DISTINCT ?type ?segnatura ?document_uri ?document_name ?time_span ?InfObj \
  148. WHERE {?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
  149. ?ev_move crm:P01_has_domain ?pc ; \
  150. rdfs:label ?type ; \
  151. rdfs:subClassOf ?event . \
  152. ?document_uri crm:P25i_moved_by ?event ; \
  153. rdfs:label ?document_name . \
  154. ?document_uri crm:P1_is_identified_by ?uriSegnatura . \
  155. ?uriSegnatura crm:P2_has_type 'Segnatura' ; \
  156. rdfs:label ?segnatura . \
  157. OPTIONAL {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?document_uri crm:P128_carries ?InfObj . \
  158. ?InfObj rdf:type crm:E73_Information_Object} }. \
  159. OPTIONAL {?ev_move crm:P4_has_time-span ?uri_ts . \
  160. ?uri_ts rdfs:label ?time_span . } \
  161. }"
  162. queryDocuments = prefixes + " SELECT DISTINCT ?role ?document ?label ?id (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  163. WHERE { \
  164. ?document ?property ?event ; \
  165. crm:P1_is_identified_by ?uri_id ; \
  166. rdfs:label ?label . \
  167. ?uri_id rdfs:label ?id ; \
  168. crm:P2_has_type 'Segnatura' . \
  169. OPTIONAL { \
  170. {?event crm:P4_has_time-span ?uri_time_span . \
  171. ?uri_time_span rdfs:label ?time_span . \
  172. } UNION { \
  173. ?sub_event rdfs:subClassOf ?event ; \
  174. crm:P4_has_time-span ?uri_time_span . \
  175. ?uri_time_span rdfs:label ?time_span . } \
  176. } \
  177. ?event crm:P01_has_domain ?domain . \
  178. ?domain crm:P02_has_range <" + thisUrlParams.link + "> ; \
  179. crm:P14.1_in_the_role_of ?uri_role . \
  180. ?uri_role rdfs:label ?role . \
  181. } \
  182. GROUP BY ?document ?label ?id ?role "
  183. queryOtherDoc = prefixes + " SELECT DISTINCT ?document ?label ?id (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  184. WHERE { \
  185. VALUES ?uri {<" + thisUrlParams.link + ">} \
  186. ?uri rdf:type crm:E21_Person . \
  187. ?event crm:P67_refers_to ?uri . \
  188. {?document crm:P92i_was_brought_into_existence_by ?event ; \
  189. rdfs:label ?label ; \
  190. crm:P1_is_identified_by ?uri_id . \
  191. ?uri_id rdfs:label ?id ; \
  192. crm:P2_has_type 'Segnatura' . } \
  193. UNION \
  194. {?documentation crm:P67_refers_to ?uri ; \
  195. crm:P141_assigned ?card . \
  196. ?document crm:P46_is_composed_of ?card ; \
  197. rdfs:label ?label ; \
  198. crm:P1_is_identified_by ?uri_id . \
  199. ?uri_id rdfs:label ?id ; \
  200. crm:P2_has_type 'Segnatura' . \
  201. } \
  202. OPTIONAL {?event crm:P4_has_time-span ?uri_time_span . \
  203. ?uri_time_span rdfs:label ?time_span . } \
  204. } \
  205. GROUP BY ?document ?label ?id "
  206. queryOpere = prefixes + " SELECT DISTINCT ?subject ?label ?nct (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  207. WHERE {?subject rdf:type crm:E22_Man-Made_Object ; \
  208. rdfs:label ?label ; \
  209. crm:P1_is_identified_by ?uri_nct . \
  210. ?uri_nct rdfs:label ?nct . \
  211. ?production crm:P108_has_produced ?subject . \
  212. OPTIONAL {?production crm:P4_has_time-span ?uri_time_span . \
  213. ?uri_time_span rdfs:label ?time_span } \
  214. ?pc crm:P01_has_domain ?production ; \
  215. crm:P02_has_range <" + thisUrlParams.link + "> } \
  216. GROUP BY ?subject ?label ?nct "
  217. queryNetwork = prefixes + " SELECT DISTINCT COUNT(?event) AS ?count ?uri2 SAMPLE(?label2) AS ?text \
  218. WHERE { \
  219. {?event rdf:type crm:EL1_Exchange_Letters . \
  220. ?event_to rdfs:subClassOf ?event; \
  221. rdf:type crm:EL2_Send_Letter ; \
  222. crm:P01_has_domain ?pc_to . \
  223. ?pc_to crm:P02_has_range ?uri . \
  224. ?uri rdfs:label ?label . \
  225. ?event_from rdfs:subClassOf ?event; \
  226. rdf:type crm:EL3_Receive_Letter; \
  227. crm:P01_has_domain ?pc_from . \
  228. ?pc_from crm:P02_has_range ?uri2 . \
  229. ?uri2 rdfs:label ?label2 . \
  230. FILTER (?uri = <" + thisUrlParams.link + ">) \
  231. } UNION { \
  232. ?event rdf:type crm:EL1_Exchange_Letters . \
  233. ?event_to rdfs:subClassOf ?event; \
  234. rdf:type crm:EL3_Receive_Letter ; \
  235. crm:P01_has_domain ?pc_from . \
  236. ?pc_from crm:P02_has_range ?uri . \
  237. ?uri rdfs:label ?label . \
  238. ?event_from rdfs:subClassOf ?event; \
  239. rdf:type crm:EL2_Send_Letter; \
  240. crm:P01_has_domain ?pc_to . \
  241. ?pc_to crm:P02_has_range ?uri2 . \
  242. ?uri2 rdfs:label ?label2 . \
  243. FILTER (?uri = <" + thisUrlParams.link + ">) \
  244. } \
  245. } ORDER BY DESC (?count)"
  246. queryGettatelliEv = prefixes + " SELECT DISTINCT ?event_type ?time_span \
  247. WHERE { \
  248. VALUES ?uri {<" + thisUrlParams.link + ">} \
  249. ?uri crm:P12i_was_present_at ?event . \
  250. ?event crm:P2_has_type ?uri_event_type ; \
  251. crm:P4_has_time-span ?uri_time_span . \
  252. ?uri_time_span rdfs:label ?time_span . \
  253. ?uri_event_type rdfs:label ?event_type . \
  254. } "
  255. queryURL = prepareQueryURL(query);
  256. queryNet = prepareQueryURL(queryNetwork);
  257. queryDoc = prepareQueryURL(queryDocuments);
  258. queryOt = prepareQueryURL(queryOtherDoc);
  259. queryOA = prepareQueryURL(queryOpere);
  260. query = prepareQueryURL(queryInfo);
  261. queryEx = prepareQueryURL(queryLetters);
  262. queryGt = prepareQueryURL(queryGettatelliEv);
  263. queryInfoGt = prepareQueryURL(queryInfoGettatelli);
  264. queryRel = prepareQueryURL(queryRelazioni);
  265. response = $.ajax({
  266. url: query,
  267. dataType: "json",
  268. success: function (data){
  269. handle_data(data);
  270. },
  271. error: function (e) {}
  272. });
  273. response = $.ajax({
  274. url: queryURL,
  275. dataType: "json",
  276. success: function (data){
  277. handle_map(data);
  278. },
  279. error: function (e) {}
  280. });
  281. responseNet = $.ajax({
  282. url: queryNet,
  283. dataType: "json",
  284. success: function (data){
  285. handle_network(data);
  286. },
  287. error: function (e) {}
  288. });
  289. responseLet = $.ajax({
  290. url: queryEx,
  291. dataType: "json",
  292. success: function (data){
  293. handle_Letters(data);
  294. },
  295. error: function (e) {}
  296. });
  297. responseOA = $.ajax({
  298. url: queryOA,
  299. dataType: "json",
  300. success: function (data){
  301. handle_Artwork(data);
  302. },
  303. error: function (e) {}
  304. });
  305. responseOt = $.ajax({
  306. url: queryOt,
  307. dataType: "json",
  308. success: function (data){
  309. handle_Other_Documents(data);
  310. },
  311. error: function (e) {}
  312. });
  313. responseDoc = $.ajax({
  314. url: queryDoc,
  315. dataType: "json",
  316. success: function (data){
  317. handle_Documents(data);
  318. },
  319. error: function (e) {}
  320. });
  321. responseDoc = $.ajax({
  322. url: queryGt,
  323. dataType: "json",
  324. success: function (data){
  325. handle_Gettatelli(data);
  326. },
  327. error: function (e) {}
  328. });
  329. responseDoc = $.ajax({
  330. url: queryInfoGt,
  331. dataType: "json",
  332. success: function (data){
  333. handle_InfoGettatelli(data);
  334. },
  335. error: function (e) {}
  336. });
  337. responseRel = $.ajax({
  338. url: queryRel,
  339. dataType: "json",
  340. success: function (data){
  341. handle_Relazioni(data);
  342. },
  343. error: function (e) {}
  344. });
  345. var labelName = "";
  346. function handle_data(json) {
  347. console.log(json['results']['bindings']);
  348. var graph = "";
  349. var label = "";
  350. if ("givenName" in json.results.bindings) {
  351. givenName = value['givenName']['value'];
  352. }
  353. $.each(
  354. json['results']['bindings'],
  355. function (index, value) {
  356. var graph = value['graph']['value'];
  357. var label = value['label']['value'];
  358. var name = value['name']['value'];
  359. var givenName = "";
  360. var familyName = "";
  361. var alias = "";
  362. var gender = "";
  363. var patronymic = "";
  364. var occupation = "";
  365. var relative2 = "";
  366. var relative3 = "";
  367. var identifier = "";
  368. var id_type = "";
  369. var birth_date = "";
  370. var birth_place = "";
  371. var death_date = "";
  372. var death_place = "";
  373. var qualification = "";
  374. var group = "";
  375. var type = "";
  376. var provenence = "";
  377. var variants = "";
  378. if ((value.hasOwnProperty('identifier')) && (value.hasOwnProperty('id_type'))) {
  379. $("#identifier").css("display", "flex");
  380. identifier = value['identifier']['value'];
  381. id_type = value['id_type']['value'];
  382. }
  383. if (value.hasOwnProperty('givenName')) {
  384. $("#givenName").css("display", "flex");
  385. givenName = value['givenName']['value'];
  386. }
  387. if (value.hasOwnProperty('familyName')) {
  388. $("#familyName").css("display", "flex");
  389. familyName = value['familyName']['value'].toLowerCase();
  390. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1);
  391. }
  392. if (value.hasOwnProperty('alias')) {
  393. $("#aliasName").css("display", "flex");
  394. alias = value['alias']['value'];
  395. }
  396. if (value.hasOwnProperty('gender')) {
  397. $("#gender").css("display", "flex");
  398. gender = value['gender']['value'];
  399. }
  400. if (value.hasOwnProperty('patronymic')) {
  401. $("#patronymic").css("display", "flex");
  402. patronymic = value['patronymic']['value'];
  403. }
  404. if (value.hasOwnProperty('provenienza')) {
  405. $("#PlaceProvenence").css("display", "flex");
  406. provenence = value['provenienza']['value'];
  407. }
  408. if (value.hasOwnProperty('occupation')) {
  409. $("#occupation").css("display", "flex");
  410. occupation = value['occupation']['value'];
  411. }
  412. if (value.hasOwnProperty('relative2')) {
  413. relative2 = value['relative2']['value'];
  414. }
  415. if (value.hasOwnProperty('relative3')) {
  416. relative3 = value['relative3']['value'];
  417. }
  418. if (value.hasOwnProperty('qualification')) {
  419. $("#honorific").css("display", "flex");
  420. qualification = value['qualification']['value'];
  421. }
  422. if (value.hasOwnProperty('person_type')) {
  423. $("#type").css("display", "flex");
  424. type = value['person_type']['value'];
  425. }
  426. if (value.hasOwnProperty('Birth_Date')) {
  427. $("#BirthDate").css("display", "flex");
  428. birth_date = value['Birth_Date']['value'];
  429. }
  430. if (value.hasOwnProperty('Birth_Place')) {
  431. $("#BirthPlace").css("display", "flex");
  432. birth_place = value['Birth_Place']['value'];
  433. }
  434. if (value.hasOwnProperty('Death_Date')) {
  435. $("#DeathDate").css("display", "flex");
  436. death_date = value['Death_Date']['value'];
  437. }
  438. if (value.hasOwnProperty('Death_Place')) {
  439. $("#DeathPlace").css("display", "flex");
  440. death_place = value['Death_Place']['value'];
  441. }
  442. if (value.hasOwnProperty('group')) {
  443. $("#groups").css("display", "flex");
  444. group = value['group']['value'];
  445. }
  446. if (value.hasOwnProperty('variants')) {
  447. if (value['variants']['value'] != "| ") {
  448. alert(value['variants']['value']);
  449. $("#otherNames").css("display", "flex");
  450. let strings = value['variants']['value'];
  451. variants = strings.split(";");
  452. }
  453. }
  454. var dataset = get_dataset_name(graph);
  455. var second_name = patronymic + " " + relative2 + " " + relative3;
  456. var first_name = "";
  457. if ((givenName != "") || (second_name != " ") || (familyName != "") || (provenence != "")) {
  458. first_name = givenName + " " + second_name + " " + familyName + " " + provenence;
  459. } else {
  460. first_name = name;
  461. }
  462. first_name = first_name.replace(",", "");
  463. var name_string = "";
  464. if (variants.length>0) {
  465. for (var i=0; i<variants.length; i++) {
  466. let chunk = variants[i].split("| ");
  467. name_string = name_string + "<a href='" + chunk[0] + "'>" + chunk[1] + "</a><br />";
  468. }
  469. }
  470. labelName = first_name;
  471. console.log(variants);
  472. var id_snippet = "<div class='col-sm-4'><span class='label'>" + id_type + ":</span></div><div class='col' id='identificatore'>" + identifier + "</div>";
  473. document.getElementById("grafo").innerHTML = dataset;
  474. document.getElementById("nome_persona").innerHTML = first_name;
  475. document.getElementById("nome").innerHTML = name;
  476. document.getElementById("genere").innerHTML = gender;
  477. document.getElementById("nome_proprio").innerHTML = givenName;
  478. document.getElementById("nome_famiglia").innerHTML = familyName;
  479. document.getElementById("provenienza").innerHTML = provenence;
  480. document.getElementById("identifier").innerHTML = id_snippet;
  481. document.getElementById("alias").innerHTML = alias;
  482. document.getElementById("tipologia").innerHTML = type;
  483. document.getElementById("variants").innerHTML = name_string;
  484. document.getElementById("patronimico").innerHTML = second_name;
  485. document.getElementById("qualifica").innerHTML = qualification;
  486. document.getElementById("occupazione").innerHTML = occupation;
  487. document.getElementById("data_nascita").innerHTML = birth_date;
  488. document.getElementById("data_morte").innerHTML = death_date;
  489. document.getElementById("luogo_nascita").innerHTML = birth_place;
  490. document.getElementById("luogo_morte").innerHTML = death_place;
  491. document.getElementById("gruppi_appartenenza").innerHTML = group;
  492. const collection = document.getElementsByClassName("PN");
  493. for (var i=0; i<collection.length; i++) {
  494. collection[i].innerHTML = first_name;
  495. }
  496. });
  497. }
  498. function get_dataset_name(graph) {
  499. var string = "Scheda Onomastica";
  500. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica") {
  501. string = string + " / Onomastica Datini";
  502. }
  503. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/authors"){
  504. string = string + " / Artisti";
  505. }
  506. else {
  507. string = string;
  508. }
  509. return (string);
  510. }
  511. function handle_InfoGettatelli(json) {
  512. console.log(json);
  513. var card = "";
  514. var uri_card = "";
  515. $.each(
  516. json['results']['bindings'],
  517. function (index, value) {
  518. if ((value.hasOwnProperty('uri_card')) && (value.hasOwnProperty('card'))) {
  519. $("#card").css("display", "flex");
  520. uri_card = value['uri_card']['value'];
  521. card = value['card']['value'];
  522. }
  523. });
  524. var button_obj = "";
  525. if (uri_card != "") {
  526. button_obj = '<button type="button" id="' + uri_card +
  527. '" class="object btn btn-default" alt="oggetto" title="' + uri_card +
  528. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  529. }
  530. document.getElementById("scheda_anagrafica").innerHTML = card;
  531. document.getElementById("btn_scheda").innerHTML = button_obj;
  532. }
  533. function handle_Gettatelli(json) {
  534. console.log(json);
  535. var generic = "";
  536. var find = "";
  537. var reunite = "";
  538. var adoption = "";
  539. $.each(
  540. json['results']['bindings'],
  541. function (index, value) {
  542. var event_type = value['event_type']['value'];
  543. var data = value['time_span']['value'];
  544. if (event_type == "Evento generico") {
  545. $("#generic_event").css("display", "flex");
  546. generic = data;
  547. }
  548. else if (event_type == "Ritrovamento") {
  549. $("#find_event").css("display", "flex");
  550. find = data;
  551. }
  552. else if (event_type == "Ricongiungimento") {
  553. $("#reunion_event").css("display", "flex");
  554. reunite = data;
  555. }
  556. else if (event_type == "Adozione") {
  557. $("#adoption_event").css("display", "flex");
  558. adoption = data;
  559. }
  560. });
  561. document.getElementById("anno").innerHTML = generic;
  562. document.getElementById("ritrovamento").innerHTML = find;
  563. document.getElementById("ricongiungimento").innerHTML = reunite;
  564. document.getElementById("adozione").innerHTML = adoption;
  565. }
  566. function handle_Relazioni(json) {
  567. console.log(json);
  568. var Relazioni = "";
  569. const myArray = []
  570. $.each(
  571. json['results']['bindings'],
  572. function (index, value) {
  573. var tipo = value['relation_type']['value'];
  574. var uri_person = value['uri_person']['value'];
  575. var nome = value['name']['value'];
  576. var principale = "";
  577. var givenName = "";
  578. var familyName = "";
  579. var patronymic = "";
  580. var provenence = "";
  581. if (value.hasOwnProperty('givenName')) {
  582. $("#givenName").css("display", "flex");
  583. givenName = value['givenName']['value'];
  584. }
  585. if (value.hasOwnProperty('note')) {
  586. principale = " principale";
  587. }
  588. if (value.hasOwnProperty('familyName')) {
  589. $("#familyName").css("display", "flex");
  590. familyName = value['familyName']['value'].toLowerCase();
  591. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
  592. }
  593. if (value.hasOwnProperty('patronymic')) {
  594. $("#patronymic").css("display", "flex");
  595. patronymic = value['patronymic']['value'];
  596. }
  597. if (value.hasOwnProperty('provenienza')) {
  598. $("#PlaceProvenence").css("display", "flex");
  599. provenence = value['provenienza']['value'];
  600. }
  601. var type = tipo.charAt(0).toUpperCase() + tipo.slice(1) + principale;
  602. if ((type == "Socio") || (type == "Socio principale")) {
  603. type = type + " di";
  604. }
  605. var first_name = "";
  606. if ((givenName != "") || (patronymic != "") || (familyName != "") || (provenence != "")) {
  607. first_name = givenName + " " + patronymic + " " + familyName + " " + provenence;
  608. } else {
  609. first_name = nome;
  610. }
  611. myArray.push([type, first_name, uri_person]);
  612. });
  613. const checkRel = [];
  614. for (var i=0; i<myArray.length; i++) {
  615. var key = myArray[i][0];
  616. checkRel.push(key);
  617. }
  618. var params = [];
  619. $.each(checkRel, function(i, el){
  620. if($.inArray(el, params) === -1) params.push(el);
  621. });
  622. for (var i=0; i<params.length; i++) {
  623. var par = params[i];
  624. var par_id = par.replaceAll(" ", "_");
  625. var rel = createDivRelazione(par, par_id);
  626. Relazioni = Relazioni + rel;
  627. }
  628. $(Relazioni).insertAfter( "#groups" );
  629. for (var j=0; j<params.length; j++) {
  630. var el = params[j];
  631. var par = el.replaceAll(" ", "_");
  632. var Colums = "";
  633. for (var i=0; i<myArray.length; i++) {
  634. var text = myArray[i][1];
  635. var link = myArray[i][2];
  636. var rel = myArray[i][0].replaceAll(" ", "_");
  637. if (par == rel) {
  638. var col = createColRelazione(text, link);
  639. Colums = Colums + col;
  640. }
  641. }
  642. document.getElementById(par).innerHTML = Colums;
  643. }
  644. }
  645. function createDivRelazione(type, id){
  646. htmlCode = '\
  647. <div class="row mb-2"> \
  648. <div class="col-sm-4"> \
  649. <span class="label"><RELATIONSHIP></span> \
  650. </div> \
  651. <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
  652. </div> \
  653. '.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
  654. return htmlCode;
  655. }
  656. function createColRelazione(text, link) {
  657. htmlCode = '\
  658. <div class="row"> \
  659. <div class="col"><NAME></div> \
  660. <div class="col-auto"> \
  661. <button class="persona btn btn-default" type="button" id="<URI>">\
  662. <i class="fa fa-user" aria-hidden="true">\
  663. <p class="btn-text">Scheda Persona</p>\
  664. </i>\
  665. </button>\</div> \
  666. </div>\
  667. '.replace("<NAME>", text).replace("<URI>", link);
  668. return htmlCode;
  669. }
  670. function handle_Letters(json) {
  671. console.log(json);
  672. const send = [];
  673. const receive = [];
  674. var i=0;
  675. var j=0;
  676. $.each(
  677. json['results']['bindings'],
  678. function (index, value) {
  679. type = value['type']['value'];
  680. uri = value['document_uri']['value'];
  681. title = value['document_name']['value'];
  682. segnatura = value['segnatura']['value'];
  683. var data = "";
  684. var InfObj = "";
  685. if (value.hasOwnProperty('time_span')) {
  686. data = value['time_span']['value'];
  687. }
  688. if (value.hasOwnProperty('InfObj')) {
  689. InfObj = value['InfObj']['value'];
  690. }
  691. if (type == "Invio") {
  692. send.push([uri, title, segnatura, data, InfObj]);
  693. i++;
  694. } else {
  695. receive.push([uri, title, segnatura, data, InfObj]);
  696. j++;
  697. }
  698. });
  699. var Send_Letters = "";
  700. var Receive_Letters = "";
  701. //POPULATE SEND LETTERS BOX
  702. for (var i=0; i<send.length; i++) {
  703. var letter = '<a href=' + send[i][0] + ' target="_blank">' + send[i][1] + '</a>';
  704. var infObject_button = "";
  705. if (send[i][2] != "") {
  706. letter = letter + "<br />Segnatura: " + send[i][2];
  707. }
  708. if (send[i][3] != "") {
  709. letter = letter + "<br />Data invio: " + send[i][3];
  710. }
  711. if (send[i][4] != "") {
  712. infObject_button += '<button type="button" id="' + send[i][4] +
  713. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  714. } else {
  715. infObject_button += '<button type="button" id="' + send[i][0] +
  716. '" class="object btn btn-default" alt="oggetto" title="' + send[i][1] +
  717. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  718. }
  719. Send_Letters += '<div class="row res"><div class="col-8"><p>'+ letter +'</p></div>' +
  720. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  721. '<button type="button" 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>' +
  722. '<button type="button" 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>' +
  723. '<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>';
  724. }
  725. //POPULATE RECEIVE LETTERS BOX
  726. for (var i=0; i<receive.length; i++) {
  727. var letter = '<a href=' + receive[i][0] + ' target="_blank">' + receive[i][1] + '</a>';
  728. var infObject_button = "";
  729. if (receive[i][2] != "") {
  730. letter = letter + "<br />Segnatura: " + receive[i][2];
  731. }
  732. if (receive[i][3] != "") {
  733. letter = letter + "<br />Data ricezione: " + receive[i][3];
  734. }
  735. if (receive[i][4] != "") {
  736. infObject_button += '<button type="button" id="' + receive[i][4] +
  737. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  738. } else {
  739. infObject_button += '<button type="button" id="' + receive[i][0] +
  740. '" class="object btn btn-default" alt="oggetto" title="' + receive[i][1] +
  741. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  742. }
  743. Receive_Letters += '<div class="row res"><div class="col-8"><p>'+ letter +'</p></div>' +
  744. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  745. '<button type="button" 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>' +
  746. '<button type="button" 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>' +
  747. '<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>';
  748. }
  749. document.getElementById("l_send").innerHTML = send.length;
  750. document.getElementById("l_receive").innerHTML = receive.length;
  751. document.getElementById("letters_send").innerHTML = Send_Letters;
  752. document.getElementById("letters_receive").innerHTML = Receive_Letters;
  753. if (send.length==0) {
  754. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  755. document.getElementById("letters_send").innerHTML = messaggio;
  756. }
  757. if (receive.length==0) {
  758. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  759. document.getElementById("letters_receive").innerHTML = messaggio;
  760. }
  761. }
  762. function handle_Artwork(json) {
  763. console.log(json);
  764. const oa = [];
  765. $.each(
  766. json['results']['bindings'],
  767. function (index, value) {
  768. uri = value['subject']['value'];
  769. label = value['label']['value'];
  770. nct = value['nct']['value'];
  771. var data = "";
  772. if (value.hasOwnProperty('time_span')) {
  773. data = value['time_span']['value'];
  774. }
  775. oa.push([uri, label, nct, data]);
  776. });
  777. var Artworks = "";
  778. for (var i=0; i<oa.length; i++) {
  779. var artwork = '<a href=' + oa[i][0] + ' target="_blank">' + oa[i][1] + '</a><br />NCT: ' + oa[i][2];
  780. if (oa[i][3] != "") {
  781. artwork = artwork + "<br />Data: " + oa[i][3];
  782. }
  783. var object_button = '<button type="button" id="' + oa[i][0] +
  784. '" class="artwork btn btn-default" alt="opera d\'arte" title="' + oa[i][1] +
  785. '"><i class="fas fa-paint-brush"></i><p class="btn-text">Scheda Opera d\'Arte</p></button>';
  786. Artworks += '<div class="row res"><div class="col-8"><p>'+ artwork +'</p></div>' +
  787. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  788. '<button 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>' +
  789. '<button 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>' +
  790. '<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>';
  791. }
  792. document.getElementById("n_oa").innerHTML = oa.length;
  793. document.getElementById("object_oa").innerHTML = Artworks;
  794. if (oa.length==0) {
  795. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  796. document.getElementById("object_oa").innerHTML = messaggio;
  797. }
  798. }
  799. function handle_Documents(json) {
  800. console.log(json);
  801. const docs = [];
  802. $.each(
  803. json['results']['bindings'],
  804. function (index, value) {
  805. uri = value['document']['value'];
  806. label = value['label']['value'];
  807. id = value['id']['value'];
  808. ruolo = value['role']['value'];
  809. var data = "";
  810. if (value.hasOwnProperty('time_span')) {
  811. data = value['time_span']['value'];
  812. }
  813. docs.push([uri, label, id, data, ruolo]);
  814. });
  815. var Docs = "";
  816. for (var i=0; i<docs.length; i++) {
  817. var object = '<a href=' + docs[i][0] + ' target="_blank">' + docs[i][1] + '</a><br />Segnatura: ' + docs[i][2];
  818. if (docs[i][3] != "") {
  819. object = object + "<br />Data: " + docs[i][3];
  820. }
  821. object = object + "<br /><span>" + labelName + "</span> nel ruolo di " + docs[i][4];
  822. var object_button = '<button type="button" id="' + docs[i][0] +
  823. '" class="object btn btn-default" alt="opera d\'arte" title="' + docs[i][1] +
  824. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  825. Docs += '<div class="row res"><div class="col-8"><p>'+ object +'</p></div>' +
  826. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  827. '<button type="button" id="' + docs[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>' +
  828. '<button type="button" id="' + docs[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  829. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + docs[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>';
  830. }
  831. document.getElementById("n_dc").innerHTML = docs.length;
  832. document.getElementById("written_documents").innerHTML = Docs;
  833. if (docs.length==0) {
  834. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  835. document.getElementById("written_documents").innerHTML = messaggio;
  836. }
  837. }
  838. function handle_Other_Documents(json) {
  839. console.log(json);
  840. const doc = [];
  841. $.each(
  842. json['results']['bindings'],
  843. function (index, value) {
  844. uri = value['document']['value'];
  845. label = value['label']['value'];
  846. var data = "";
  847. var id = "";
  848. if (value.hasOwnProperty('time_span')) {
  849. data = value['time_span']['value'];
  850. }
  851. if (value.hasOwnProperty('id')) {
  852. id = value['id']['value'];
  853. }
  854. doc.push([uri, label, id, data]);
  855. });
  856. var Documents = "";
  857. for (var i=0; i<doc.length; i++) {
  858. var artwork = '<a href=' + doc[i][0] + ' target="_blank">' + doc[i][1] + '</a><br />Segnatura: ' + doc[i][2];
  859. if (doc[i][3] != "") {
  860. artwork = artwork + "<br />Data: " + doc[i][3];
  861. }
  862. var object_button = '<button type="button" id="' + doc[i][0] +
  863. '" class="object btn btn-default" alt="opera d\'arte" title="' + doc[i][1] +
  864. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  865. Documents += '<div class="row res"><div class="col-8"><p>'+ artwork +'</p></div>' +
  866. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  867. '<button 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>' +
  868. '<button 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>' +
  869. '<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>';
  870. }
  871. document.getElementById("n_ass").innerHTML = doc.length;
  872. document.getElementById("other_documents").innerHTML = Documents;
  873. if (doc.length==0) {
  874. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  875. document.getElementById("other_documents").innerHTML = messaggio;
  876. }
  877. }
  878. function handle_map(json) {
  879. console.log(json);
  880. const locations = [];
  881. const place_names = [];
  882. var lat = 0;
  883. var long = 0;
  884. var i=0;
  885. var myPlaces = "";
  886. $.each(
  887. json['results']['bindings'],
  888. function (index, value) {
  889. const loc = []
  890. var uri = value['place']['value'];
  891. var label = value['label']['value'];
  892. var coord = value['coordinates']['value'];
  893. const coordinates = coord.split(", ");
  894. loc.push(label);
  895. 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='" +
  896. uri + "'><i class='far fa-map' style='cursor:pointer'></i></div></div></div>";
  897. loc.push(coordinates[0]);
  898. lat += parseInt(coordinates[0]);
  899. loc.push(coordinates[1]);
  900. long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  901. locations.push(loc);
  902. i++;
  903. });
  904. var latitude = lat/i;
  905. var longitude = long/i;
  906. var mapIcon = "<div id='map_icon' class='no_info_icon'> \
  907. <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'> \
  908. <!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><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'/> \
  909. </svg> \
  910. <p>Nessun luogo trovato</p> \
  911. </div>";
  912. if (locations.length == 0) {
  913. $("#references_persona").css("display", "none");
  914. document.getElementById("map").innerHTML = mapIcon;
  915. }
  916. document.getElementById("list_places_person").innerHTML = myPlaces;
  917. var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
  918. cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade, Points &copy 2012 LINZ',
  919. cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 17, attribution: cloudmadeAttribution}),
  920. latlng = new L.LatLng(latitude, longitude);
  921. var map = new L.Map('map', {center: latlng, zoom: 5, layers: [cloudmade]});
  922. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  923. var markers = new L.MarkerClusterGroup();
  924. var markerList = [];
  925. var geo = new L.tileLayer(
  926. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  927. attribution: '&copy; ' + mapLink + ' Contributors',
  928. maxZoom: 18,
  929. }).addTo(map);
  930. function populate() {
  931. for (var i = 0; i < locations.length; i++) {
  932. var a = locations[i];
  933. var title = a[0];
  934. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  935. marker.bindPopup(title);
  936. markers.addLayer(marker);
  937. markerList.push(marker);
  938. }
  939. }
  940. populate();
  941. map.addLayer(markers);
  942. $('.clickPlace').on('click', function(){
  943. // parse lat and lng from the divs data attribute
  944. var latlng = $(this).data().point.split(',');
  945. var lat = latlng[0];
  946. var lng = latlng[1];
  947. var zoom = 10;
  948. // set the view
  949. map.setView([lat, lng], zoom);
  950. });
  951. }
  952. function handle_network(json) {
  953. console.log(json);
  954. const words = [];
  955. const tempArray = [];
  956. var listwords = "";
  957. var ArrayNames = "";
  958. var temp = 0;
  959. var sum = 0;
  960. var i=0;
  961. var j=0;
  962. $.each(
  963. json['results']['bindings'],
  964. function (index, value) {
  965. text = value['text']['value'];
  966. link = value['uri2']['value'];
  967. num = parseInt(value['count']['value']);
  968. /*count = 0;
  969. if ((num - temp) > 50) {
  970. count = temp + 12;
  971. } else {
  972. count = num;
  973. }
  974. words.push([text, count]);
  975. temp = count;
  976. sum += temp;*/
  977. tempArray.push([text, num]);
  978. ArrayNames += "<div class='item-place-person'><div class='item-place-person-label'>" +
  979. text + "<br /><span class='num_occ'>[Co-occorrenze: " + num + "]</span></div><div class='item-place-person-action'><div class='persona' id='" +
  980. link + "'><i class='fa fa-user' style='cursor:pointer'></i></div></div></div></div>";
  981. });
  982. if (tempArray.length < 8) {
  983. for (var k=0; k<tempArray.length; k++) {
  984. text = tempArray[k][0];
  985. count = tempArray[k][1] + 36;
  986. words.push([text, count]);
  987. }
  988. } else {
  989. for (var k=tempArray.length-1; k>=0; k--) {
  990. text = tempArray[k][0];
  991. num = tempArray[k][1];
  992. count = 0;
  993. if ((num - temp) > 50) {
  994. count = temp + 12;
  995. } else {
  996. count = num;
  997. }
  998. words.push([text, count]);
  999. temp = count;
  1000. sum += temp;
  1001. }
  1002. }
  1003. document.getElementById("list_person_network").innerHTML = ArrayNames;
  1004. $('#myWordCloud').empty();
  1005. /*var tot = parseInt(words[0][1]);*/
  1006. for (var i in words) {
  1007. var text = words[i][0]
  1008. var count = words[i][1];
  1009. listwords += '{ "word": \"' + text + '\", "size": \"' + count + '\"},';
  1010. }
  1011. let listL = ('[' + listwords + ']').replace(',]', ']');
  1012. const links = JSON.parse(listL);
  1013. console.log(links);
  1014. // List of words
  1015. var myWords = links;
  1016. // set the dimensions and margins of the graph
  1017. var margin = {top: 10, right: 10, bottom: 10, left: 10},
  1018. width = 850 - margin.left - margin.right,
  1019. height = 500 - margin.top - margin.bottom;
  1020. // append the svg object to the body of the page
  1021. var svg = d3.select("#myWordCloud").append("svg")
  1022. .attr("id", "wordcloudNetwork")
  1023. .attr("width", width + margin.left + margin.right)
  1024. .attr("height", height + margin.top + margin.bottom)
  1025. .append("g")
  1026. .attr("transform",
  1027. "translate(" + (width/2-50) + "," + (height/2+20) + ")");
  1028. // Constructs a new cloud layout instance. It run an algorithm to find the position of words that suits your requirements
  1029. // Wordcloud features that are different from one word to the other must be here
  1030. var layout = d3.layout.cloud()
  1031. .size([width, height])
  1032. .words(myWords.map(function(d) { return {text: d.word, size:d.size/2}; }))
  1033. .padding(5) //space between words
  1034. .rotate(function() { return ~~(Math.random() * 2);})
  1035. .fontSize(function(d) { return d.size + 6; }) // font size of words
  1036. .on("end", draw);
  1037. layout.start();
  1038. // This function takes the output of 'layout' above and draw the words
  1039. // Wordcloud features that are THE SAME from one word to the other can be here
  1040. function draw(words) {
  1041. var cloud = svg.selectAll("g text")
  1042. .data(words, function(d) { return d.text; })
  1043. //Entering words
  1044. cloud.enter()
  1045. .append("text")
  1046. .style("font-family", "Impact")
  1047. .attr("text-anchor", "middle")
  1048. .attr('font-size', 1)
  1049. .text(function(d) { return d.text; });
  1050. //Entering and existing words
  1051. cloud
  1052. .transition()
  1053. .duration(600)
  1054. .style("font-size", function(d) { return d.size + "px"; })
  1055. .attr("transform", function(d) {
  1056. return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
  1057. })
  1058. .style("fill-opacity", 1);
  1059. //Exiting words
  1060. cloud.exit()
  1061. .transition()
  1062. .duration(200)
  1063. .style('fill-opacity', 1e-6)
  1064. .attr('font-size', 1)
  1065. .remove();
  1066. }
  1067. var wordIcon = "<div id='users_icon' class='no_info_icon'> \
  1068. <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 512'> \
  1069. <!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d='M319.9 320c57.41 0 103.1-46.56 103.1-104c0-57.44-46.54-104-103.1-104c-57.41 0-103.1 46.56-103.1 104C215.9 273.4 262.5 320 319.9 320zM369.9 352H270.1C191.6 352 128 411.7 128 485.3C128 500.1 140.7 512 156.4 512h327.2C499.3 512 512 500.1 512 485.3C512 411.7 448.4 352 369.9 352zM512 160c44.18 0 80-35.82 80-80S556.2 0 512 0c-44.18 0-80 35.82-80 80S467.8 160 512 160zM183.9 216c0-5.449 .9824-10.63 1.609-15.91C174.6 194.1 162.6 192 149.9 192H88.08C39.44 192 0 233.8 0 285.3C0 295.6 7.887 304 17.62 304h199.5C196.7 280.2 183.9 249.7 183.9 216zM128 160c44.18 0 80-35.82 80-80S172.2 0 128 0C83.82 0 48 35.82 48 80S83.82 160 128 160zM551.9 192h-61.84c-12.8 0-24.88 3.037-35.86 8.24C454.8 205.5 455.8 210.6 455.8 216c0 33.71-12.78 64.21-33.16 88h199.7C632.1 304 640 295.6 640 285.3C640 233.8 600.6 192 551.9 192z'/> \
  1070. </svg> \
  1071. <p>Nessuna persona trovata</p> \
  1072. </div>";
  1073. if (words.length == 0) {
  1074. $("#wordcloudNetwork").css("display", "none");
  1075. $("#references_network").css("display", "none");
  1076. document.getElementById("myWordCloud").innerHTML = wordIcon;
  1077. }
  1078. }
  1079. $(document).on("click", ".luogo", function (ev) {
  1080. var link = this.id;
  1081. //alert(nome_autore);
  1082. //$('#myModal').text("");
  1083. window.open("Luogo.html?link="+this.id);
  1084. });
  1085. $(document).on("click", ".persona", function (ev) {
  1086. var link = this.id;
  1087. window.open("Persona.html?link="+this.id);
  1088. });
  1089. $(document).on("click", ".lettera", function (ev) {
  1090. var link = this.id;
  1091. //alert(nome_autore);
  1092. //$('#myModal').text("");
  1093. window.open("lettera.html?link="+this.id);
  1094. });
  1095. $(document).on("click", ".object", function (ev) {
  1096. var link = this.id;
  1097. //alert(nome_autore);
  1098. //$('#myModal').text("");
  1099. window.open("object.html?link="+this.id);
  1100. });
  1101. $(document).on("click", ".hyp", function (ev) {
  1102. var link = this.id;
  1103. $("#myModal").empty();
  1104. $("#myModal").css("display", "block");
  1105. $('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
  1106. link + "</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  1107. });
  1108. $(document).on("click", ".artwork", function (ev) {
  1109. var link = this.id;
  1110. //alert(nome_autore);
  1111. //$('#myModal').text("");
  1112. window.open("OA.html?link="+this.id);
  1113. });
  1114. $(document).on("click", ".close", function (ev) {
  1115. var link = this.id;
  1116. //alert(nome_autore);
  1117. //$('#myModal').text("");
  1118. $("#myModal").css("display", "none");
  1119. });
  1120. $(document).on("click", ".back", function (ev) {
  1121. $("#myTab").css("display", "none");
  1122. });
  1123. $(document).on("click", ".cit", function (ev) {
  1124. var author ="RESTORE. smart access to digital heritage and memory"
  1125. var year = new Date().getFullYear()
  1126. var today = new Date();
  1127. var dd = String(today.getDate()).padStart(2, '0');
  1128. var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  1129. var yyyy = today.getFullYear();
  1130. today = dd + '/' + mm + '/' + yyyy;
  1131. var link = this.id;
  1132. //alert(nome_autore);
  1133. //$('#myModal').text("");
  1134. $("#myModal").empty();
  1135. $("#myModal").css("display", "block");
  1136. $('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
  1137. author + " " + year + ", accesso effettuato: " + today + ", &lt;" + link + "&gt;</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  1138. });
  1139. function copyToClipboard(text) {
  1140. var sampleTextarea = document.createElement("textarea");
  1141. document.body.appendChild(sampleTextarea);
  1142. sampleTextarea.value = text; //save main text in it
  1143. sampleTextarea.select(); //select textarea contenrs
  1144. document.execCommand("copy");
  1145. document.body.removeChild(sampleTextarea);
  1146. }
  1147. function myFunction(){
  1148. var copy = document.getElementById("myInput");
  1149. copyText = copy.textContent;
  1150. copyToClipboard(copyText);
  1151. //copyToClipboard(copyText.value);
  1152. }