people.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  1. var link = thisUrlParams.link;
  2. prefixes = queryManager['prefixes']['all'];
  3. query = prefixes + (queryManager['querySchedaPersona']['queryInfo']).replace('{URI}', link);
  4. doJsonQuery(query).done(function(data) { handle_data(data); });
  5. queryURL = prefixes + (queryManager['querySchedaPersona']['query']).replace('{URI}', link);
  6. doJsonQuery(queryURL).done(function(data) { handle_map(data); });
  7. queryEx = prefixes + (queryManager['querySchedaPersona']['queryLetters']).replace('{URI}', link);
  8. doJsonQuery(queryEx).done(function(data) { handle_Letters(data); });
  9. queryOA = prefixes + (queryManager['querySchedaPersona']['queryOpere']).replace('{URI}', link);
  10. doJsonQuery(queryOA).done(function(data) { handle_Artwork(data); });
  11. queryOt = prefixes + (queryManager['querySchedaPersona']['queryOtherDoc']).replace('{URI}', link);
  12. doJsonQuery(queryOt).done(function(data) { handle_Other_Documents(data); });
  13. queryGt = prefixes + (queryManager['querySchedaPersona']['queryGettatelliEv']).replace('{URI}', link);
  14. doJsonQuery(queryGt).done(function(data) { handle_Gettatelli(data); });
  15. queryInfoGt = prefixes + (queryManager['querySchedaPersona']['queryInfoGettatelli']).replace('{URI}', link);
  16. doJsonQuery(queryInfoGt).done(function(data) { handle_InfoGettatelli(data); });
  17. queryRel = prefixes + (queryManager['querySchedaPersona']['queryRelazioni']).replace('{URI}', link);
  18. doJsonQuery(queryRel).done(function(data) { handle_Relazioni(data); });
  19. queryRelIn = prefixes + (queryManager['querySchedaPersona']['queryRelazioniInverse']).replace('{URI}', link);
  20. doJsonQuery(queryRelIn).done(function(data) { handle_RelazioniInverse(data); });
  21. queryCom = prefixes + (queryManager['querySchedaPersona']['queryCompagnia']).replace('{URI}', link);
  22. doJsonQuery(queryCom).done(function(data) { handle_Compagnia(data); });
  23. queryEv = prefixes + (queryManager['querySchedaPersona']['queryEventi']).replace('{URI}', link);
  24. doJsonQuery(queryEv).done(function(data) { handle_Events(data); });
  25. queryCon = prefixes + (queryManager['querySchedaPersona']['queryContrassegni']).replace('{URI}', link);
  26. doJsonQuery(queryCon).done(function(data) { handle_Contrassegni(data); });
  27. var labelName = "";
  28. function handle_data(json) {
  29. var graph = "";
  30. var label = "";
  31. if ("givenName" in json.results.bindings) {
  32. givenName = value['givenName']['value'];
  33. }
  34. $.each(
  35. json['results']['bindings'],
  36. function (index, value) {
  37. var graph = value['graph']['value'];
  38. var uri = value['uri']['value'];
  39. var label = value['label']['value'];
  40. var name = value['name']['value'];
  41. var givenName = "";
  42. var familyName = "";
  43. var alias = "";
  44. var gender = "";
  45. var patronymic = "";
  46. var occupation = "";
  47. var relative2 = "";
  48. var relative3 = "";
  49. var identifier = "";
  50. var id_type = "";
  51. var birth_date = "";
  52. var birth_place = "";
  53. var death_date = "";
  54. var death_place = "";
  55. var qualification = "";
  56. var group = "";
  57. var type = "";
  58. var provenence = "";
  59. var variants = "";
  60. if ((value.hasOwnProperty('identifier')) && (value.hasOwnProperty('id_type'))) {
  61. $("#identifier").css("display", "flex");
  62. identifier = value['identifier']['value'];
  63. id_type = value['id_type']['value'];
  64. }
  65. if (value.hasOwnProperty('givenName')) {
  66. $("#givenName").css("display", "flex");
  67. givenName = value['givenName']['value'];
  68. }
  69. if (value.hasOwnProperty('familyName')) {
  70. $("#familyName").css("display", "flex");
  71. familyName = value['familyName']['value'].toLowerCase();
  72. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1);
  73. }
  74. if (value.hasOwnProperty('alias')) {
  75. $("#aliasName").css("display", "flex");
  76. alias = value['alias']['value'];
  77. }
  78. if (value.hasOwnProperty('gender')) {
  79. $("#gender").css("display", "flex");
  80. gender = value['gender']['value'];
  81. }
  82. if (value.hasOwnProperty('patronymic')) {
  83. $("#patronymic").css("display", "flex");
  84. patronymic = value['patronymic']['value'];
  85. }
  86. if (value.hasOwnProperty('provenienza')) {
  87. $("#PlaceProvenence").css("display", "flex");
  88. provenence = value['provenienza']['value'];
  89. }
  90. if (value.hasOwnProperty('occupation')) {
  91. $("#occupation").css("display", "flex");
  92. occupation = value['occupation']['value'];
  93. }
  94. if (value.hasOwnProperty('relative2')) {
  95. relative2 = value['relative2']['value'];
  96. }
  97. if (value.hasOwnProperty('relative3')) {
  98. relative3 = value['relative3']['value'];
  99. }
  100. if (value.hasOwnProperty('qualification')) {
  101. $("#honorific").css("display", "flex");
  102. qualification = value['qualification']['value'];
  103. }
  104. if (value.hasOwnProperty('person_type')) {
  105. $("#type").css("display", "flex");
  106. type = value['person_type']['value'];
  107. }
  108. if (value.hasOwnProperty('Birth_Date')) {
  109. $("#BirthDate").css("display", "flex");
  110. birth_date = value['Birth_Date']['value'];
  111. }
  112. if (value.hasOwnProperty('Birth_Place')) {
  113. $("#BirthPlace").css("display", "flex");
  114. birth_place = value['Birth_Place']['value'];
  115. }
  116. if (value.hasOwnProperty('Death_Date')) {
  117. $("#DeathDate").css("display", "flex");
  118. death_date = value['Death_Date']['value'];
  119. }
  120. if (value.hasOwnProperty('Death_Place')) {
  121. $("#DeathPlace").css("display", "flex");
  122. death_place = value['Death_Place']['value'];
  123. }
  124. if (value.hasOwnProperty('group')) {
  125. $("#groups").css("display", "flex");
  126. group = value['group']['value'];
  127. }
  128. if (value.hasOwnProperty('variants')) {
  129. if (value['variants']['value'] != "| ") {
  130. alert(value['variants']['value']);
  131. $("#otherNames").css("display", "flex");
  132. let strings = value['variants']['value'];
  133. variants = strings.split(";");
  134. }
  135. }
  136. var dataset = get_dataset_name(graph);
  137. var second_name = patronymic;
  138. if (relative2 != "") {
  139. second_name = second_name + " " + relative2;
  140. }
  141. if (relative3 != "") {
  142. second_name = second_name + " " + relative3;
  143. }
  144. if (familyName != "") {
  145. second_name = second_name + " " + familyName;
  146. }
  147. var first_name = "";
  148. if ((givenName != "") || (second_name != "") || (provenence != "")) {
  149. first_name = givenName + " " + second_name + " " + provenence;
  150. } else {
  151. first_name = name;
  152. }
  153. first_name = first_name.replace(",", "");
  154. first_name = titleCase(first_name);
  155. name = titleCase(name);
  156. givenName = titleCase(givenName);
  157. var name_string = "";
  158. if (variants.length>0) {
  159. for (var i=0; i<variants.length; i++) {
  160. let chunk = variants[i].split("| ");
  161. name_string = name_string + "<a href='" + chunk[0] + "'>" + chunk[1] + "</a><br />";
  162. }
  163. }
  164. labelName = first_name;
  165. var Buttons = '<button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  166. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  167. <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> \
  168. <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> \
  169. <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>';
  170. var id_snippet = "<div class='col-sm-4'><span class='label'>" + id_type + ":</span></div><div class='col' id='identificatore'>" + identifier + "</div>";
  171. document.getElementById("grafo").innerHTML = dataset;
  172. document.getElementById("nome_persona").innerHTML = first_name;
  173. document.getElementById("nome").innerHTML = name;
  174. document.getElementById("genere").innerHTML = gender;
  175. document.getElementById("nome_proprio").innerHTML = givenName;
  176. document.getElementById("nome_famiglia").innerHTML = familyName;
  177. document.getElementById("patronimico").innerHTML = second_name.replace("di ", "");
  178. document.getElementById("provenienza").innerHTML = provenence;
  179. document.getElementById("identifier").innerHTML = id_snippet;
  180. document.getElementById("alias").innerHTML = alias;
  181. document.getElementById("tipologia").innerHTML = type;
  182. document.getElementById("variants").innerHTML = name_string;
  183. document.getElementById("qualifica").innerHTML = qualification;
  184. document.getElementById("occupazione").innerHTML = occupation;
  185. document.getElementById("data_nascita").innerHTML = birth_date;
  186. document.getElementById("data_morte").innerHTML = death_date;
  187. document.getElementById("luogo_nascita").innerHTML = birth_place;
  188. document.getElementById("luogo_morte").innerHTML = death_place;
  189. document.getElementById("gruppi_appartenenza").innerHTML = group;
  190. document.getElementById("link_buttons").innerHTML = Buttons;
  191. const collection = document.getElementsByClassName("PN");
  192. for (var i=0; i<collection.length; i++) {
  193. collection[i].innerHTML = first_name;
  194. }
  195. });
  196. }
  197. function get_dataset_name(graph) {
  198. var string = "Scheda Onomastica";
  199. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica") {
  200. string = string + " / Onomastica Datini";
  201. }
  202. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/authors"){
  203. string = string + " / Artisti";
  204. }
  205. else {
  206. string = string;
  207. }
  208. return (string);
  209. }
  210. function handle_InfoGettatelli(json) {
  211. var card = "";
  212. var uri_card = "";
  213. $.each(
  214. json['results']['bindings'],
  215. function (index, value) {
  216. if ((value.hasOwnProperty('uri_card')) && (value.hasOwnProperty('card'))) {
  217. $("#card").css("display", "flex");
  218. uri_card = value['uri_card']['value'];
  219. card = value['card']['value'];
  220. }
  221. });
  222. var button_obj = "";
  223. if (uri_card != "") {
  224. button_obj = '<button type="button" id="' + uri_card +
  225. '" class="object btn btn-default" alt="oggetto" title="' + uri_card +
  226. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  227. }
  228. document.getElementById("scheda_anagrafica").innerHTML = card;
  229. document.getElementById("btn_scheda").innerHTML = button_obj;
  230. }
  231. function handle_Gettatelli(json) {
  232. //console.log(json);
  233. var generic = "";
  234. var find = "";
  235. var reunite = "";
  236. var adoption = "";
  237. $.each(
  238. json['results']['bindings'],
  239. function (index, value) {
  240. var event_type = value['event_type']['value'];
  241. var data = value['time_span']['value'];
  242. if (event_type == "Evento generico") {
  243. $("#generic_event").css("display", "flex");
  244. generic = data;
  245. }
  246. else if (event_type == "Ritrovamento") {
  247. $("#find_event").css("display", "flex");
  248. find = data;
  249. }
  250. else if (event_type == "Ricongiungimento") {
  251. $("#reunion_event").css("display", "flex");
  252. reunite = data;
  253. }
  254. else if (event_type == "Adozione") {
  255. $("#adoption_event").css("display", "flex");
  256. adoption = data;
  257. }
  258. });
  259. document.getElementById("anno").innerHTML = generic;
  260. document.getElementById("ritrovamento").innerHTML = find;
  261. document.getElementById("ricongiungimento").innerHTML = reunite;
  262. document.getElementById("adozione").innerHTML = adoption;
  263. }
  264. function handle_Relazioni(json) {
  265. //console.log(json);
  266. var Relazioni = "";
  267. const myArray = []
  268. $.each(
  269. json['results']['bindings'],
  270. function (index, value) {
  271. var tipo = value['relation_type']['value'];
  272. var uri_person = value['uri_person']['value'];
  273. var nome = value['name']['value'];
  274. var principale = "";
  275. var givenName = "";
  276. var familyName = "";
  277. var patronymic = "";
  278. var provenence = "";
  279. if (value.hasOwnProperty('givenName')) {
  280. givenName = value['givenName']['value'];
  281. }
  282. if (value.hasOwnProperty('note')) {
  283. principale = " principale";
  284. }
  285. if (value.hasOwnProperty('familyName')) {
  286. familyName = value['familyName']['value'].toLowerCase();
  287. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
  288. }
  289. if (value.hasOwnProperty('patronymic')) {
  290. patronymic = value['patronymic']['value'];
  291. }
  292. if (value.hasOwnProperty('provenienza')) {
  293. provenence = value['provenienza']['value'];
  294. }
  295. var type = tipo.charAt(0).toUpperCase() + tipo.slice(1) + principale;
  296. if ((type == "Socio") || (type == "Socio principale")) {
  297. type = "Società";
  298. }
  299. if (type == "Mano lettera") {
  300. type = "Altre collaborazioni"
  301. }
  302. var first_name = "";
  303. if ((givenName != "") || (patronymic != "") || (familyName != "") || (provenence != "")) {
  304. first_name = givenName + " " + patronymic + " " + familyName + " " + provenence;
  305. } else {
  306. first_name = nome;
  307. }
  308. myArray.push([type, first_name, uri_person]);
  309. });
  310. const checkRel = [];
  311. for (var i=0; i<myArray.length; i++) {
  312. var key = myArray[i][0];
  313. checkRel.push(key);
  314. }
  315. var params = [];
  316. $.each(checkRel, function(i, el){
  317. if($.inArray(el, params) === -1) params.push(el);
  318. });
  319. for (var i=0; i<params.length; i++) {
  320. var par = params[i];
  321. var par_id = par.replaceAll(" ", "_");
  322. var rel = createDivRelazione(par, par_id);
  323. Relazioni = Relazioni + rel;
  324. }
  325. $(Relazioni).insertAfter( "#groups" );
  326. for (var j=0; j<params.length; j++) {
  327. var el = params[j];
  328. var par = el.replaceAll(" ", "_");
  329. var Colums = "";
  330. for (var i=0; i<myArray.length; i++) {
  331. var text = myArray[i][1];
  332. var link = myArray[i][2];
  333. var rel = myArray[i][0].replaceAll(" ", "_");
  334. if (par == rel) {
  335. var col = createColRelazione(text, link);
  336. Colums = Colums + col;
  337. }
  338. }
  339. document.getElementById(par).innerHTML = Colums;
  340. }
  341. }
  342. function handle_RelazioniInverse(json) {
  343. //console.log(json);
  344. var Relazioni = "";
  345. const myArray = []
  346. $.each(
  347. json['results']['bindings'],
  348. function (index, value) {
  349. var tipo = value['relation_type']['value'];
  350. var uri_person = value['uri_person']['value'];
  351. var nome = "";
  352. var principale = "";
  353. var givenName = "";
  354. var familyName = "";
  355. var patronymic = "";
  356. var provenence = "";
  357. if (value.hasOwnProperty('name')) {
  358. nome = value['name']['value'];
  359. }
  360. if (value.hasOwnProperty('givenName')) {
  361. givenName = value['givenName']['value'];
  362. }
  363. if (value.hasOwnProperty('note')) {
  364. principale = " principale";
  365. }
  366. if (value.hasOwnProperty('familyName')) {
  367. familyName = value['familyName']['value'].toLowerCase();
  368. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
  369. }
  370. if (value.hasOwnProperty('patronymic')) {
  371. patronymic = value['patronymic']['value'];
  372. }
  373. if (value.hasOwnProperty('provenienza')) {
  374. provenence = value['provenienza']['value'];
  375. }
  376. var type = tipo.charAt(0).toUpperCase() + tipo.slice(1) + principale + " di";
  377. if (type == "Socio di") {
  378. type = "Soci";
  379. }
  380. if (type == "Socio principale di") {
  381. type = "Intestatario principale";
  382. }
  383. if (type == "Mano lettera di") {
  384. type = "Collaboratori";
  385. }
  386. var first_name = "";
  387. if ((givenName != "") || (patronymic != "") || (familyName != "") || (provenence != "")) {
  388. first_name = givenName + " " + patronymic + " " + familyName + " " + provenence;
  389. } else {
  390. first_name = nome;
  391. }
  392. myArray.push([type, first_name, uri_person]);
  393. });
  394. const checkRel = [];
  395. for (var i=0; i<myArray.length; i++) {
  396. var key = myArray[i][0];
  397. checkRel.push(key);
  398. }
  399. var params = [];
  400. $.each(checkRel, function(i, el){
  401. if($.inArray(el, params) === -1) params.push(el);
  402. });
  403. for (var i=0; i<params.length; i++) {
  404. var par = params[i];
  405. var par_id = par.replaceAll(" ", "_");
  406. var rel = createDivRelazione(par, par_id);
  407. Relazioni = Relazioni + rel;
  408. }
  409. $(Relazioni).insertAfter( "#groups" );
  410. for (var j=0; j<params.length; j++) {
  411. var el = params[j];
  412. var par = el.replaceAll(" ", "_");
  413. var Colums = "";
  414. for (var i=0; i<myArray.length; i++) {
  415. var text = myArray[i][1];
  416. var link = myArray[i][2];
  417. var rel = myArray[i][0].replaceAll(" ", "_");
  418. if (par == rel) {
  419. var col = createColRelazione(text, link);
  420. Colums = Colums + col;
  421. }
  422. }
  423. document.getElementById(par).innerHTML = Colums;
  424. }
  425. }
  426. function createDivRelazione(type, id){
  427. htmlCode = '\
  428. <div class="row mb-2"> \
  429. <div class="col-sm-4"> \
  430. <span class="label"><RELATIONSHIP></span> \
  431. </div> \
  432. <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
  433. </div> \
  434. '.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
  435. return htmlCode;
  436. }
  437. function createColRelazione(text, link) {
  438. htmlCode = '\
  439. <div class="row mb-1"> \
  440. <div class="col"><NAME></div> \
  441. <div class="col-auto"> \
  442. <button class="persona btn btn-default" type="button" id="<URI>">\
  443. <i class="fa fa-user" aria-hidden="true">\
  444. <p class="btn-text">Scheda Persona</p>\
  445. </i>\
  446. </button>\</div> \
  447. </div>\
  448. '.replace("<NAME>", text).replace("<URI>", link);
  449. return htmlCode;
  450. }
  451. function handle_Events(json) {
  452. const events = [];
  453. $.each(
  454. json['results']['bindings'],
  455. function (index, value) {
  456. var event_type = value['event_type']['value'];
  457. var role = value['role']['value'];
  458. var uri_document = value['uri_document']['value'];
  459. var document = value['document']['value'];
  460. var time_span = "";
  461. var uri_place = "";
  462. var place = "";
  463. if (value.hasOwnProperty('time_span')) {
  464. time_span = value['time_span']['value'];
  465. }
  466. if (value.hasOwnProperty('uri_place')) {
  467. uri_place = value['uri_place']['value'];
  468. }
  469. if (value.hasOwnProperty('place')) {
  470. place = value['place']['value'];
  471. place = titleCase(place);
  472. }
  473. const cells = [event_type, role, time_span, uri_place, place, uri_document, document];
  474. events.push(cells);
  475. });
  476. var thead = '<thead id="ev_thead" class="def_res"><tr>' +
  477. '<th class="col-2">Evento</th>' +
  478. '<th class="col-2">Ruolo</th>' +
  479. '<th class="col-2">Data</th>' +
  480. '<th class="col-2">Luogo</th>' +
  481. '<th class="col-4">Documento</th>' +
  482. '</tr></thead>';
  483. var EventsTable = thead;
  484. EventsTable += '<tbody>';
  485. for (var i=0; i<events.length; i++) {
  486. EventsTable += '<tr class="res">' +
  487. '<th class="col-2">' + events[i][0] + '</th>' +
  488. '<th class="col-2">' + events[i][1] + '</th>' +
  489. '<th class="col-2">' + events[i][2] + '</th>' +
  490. '<th id="' + events[i][3] + '" class="col-2 luogo link">' + events[i][4] + '</th>' +
  491. '<th id="' + events[i][5] + '" class="col-4 object link">' + events[i][6] + '</th>' +
  492. '</tr>';
  493. }
  494. EventsTable += '</tbody>';
  495. if (events.length != 0) {
  496. document.getElementById("res_events").innerHTML = EventsTable;
  497. } else {
  498. var eventIcon = "<div id='map_icon' class='no_info_icon'> \
  499. <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'> \
  500. <g id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'> \
  501. <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> \
  502. </g> \
  503. </svg> \
  504. <p>Nessun evento trovato</p> \
  505. </div>";
  506. document.getElementById("res_events_container").style.display = "none";
  507. document.getElementById("res_events_no_res").innerHTML = eventIcon;
  508. }
  509. }
  510. function handle_Compagnia(json) {
  511. //console.log(json);
  512. var denominazione = "";
  513. var sede = "";
  514. var uri_sede = "";
  515. var uri_place = "";
  516. $.each(
  517. json['results']['bindings'],
  518. function (index, value) {
  519. if (value.hasOwnProperty('denomination')) {
  520. $("#type_society").css("display", "flex");
  521. denominazione = value['denomination']['value'];
  522. }
  523. if (value.hasOwnProperty('uri_place')) {
  524. $("#sede").css("display", "flex");
  525. uri_place = value['uri_place']['value'];
  526. }
  527. if (value.hasOwnProperty('uri_sede')) {
  528. $("#sede").css("display", "flex");
  529. uri_sede = value['uri_sede']['value'];
  530. }
  531. if (value.hasOwnProperty('sede')) {
  532. sede = value['sede']['value'];
  533. }
  534. });
  535. }
  536. function handle_Contrassegni(json) {
  537. var id_image = "";
  538. var name_image = "";
  539. $.each(
  540. json['results']['bindings'],
  541. function (index, value) {
  542. if (value.hasOwnProperty('image')) {
  543. $("#mark_image").css("display", "block");
  544. id_image = value['image']['value'];
  545. }
  546. if (value.hasOwnProperty('contrassegno')) {
  547. name_image = value['contrassegno']['value'];
  548. }
  549. });
  550. var Image = '<img style="width:100%;" src="img/contrassegni/' + id_image + '" />'
  551. document.getElementById("contrassegno").innerHTML = Image;
  552. document.getElementById("nome_contrassegno").innerHTML = titleCase(name_image);
  553. }
  554. function handle_Letters(json) {
  555. //console.log(json);
  556. const send = [];
  557. const receive = [];
  558. var i=0;
  559. var j=0;
  560. $.each(
  561. json['results']['bindings'],
  562. function (index, value) {
  563. type = value['type']['value'];
  564. uri = value['document_uri']['value'];
  565. title = value['document_name']['value'];
  566. segnatura = value['segnatura']['value'];
  567. var data = "";
  568. var InfObj = "";
  569. if (value.hasOwnProperty('time_span')) {
  570. data = value['time_span']['value'];
  571. }
  572. if (value.hasOwnProperty('InfObj')) {
  573. InfObj = value['InfObj']['value'];
  574. }
  575. if (type == "Invio") {
  576. send.push([uri, title, segnatura, data, InfObj]);
  577. i++;
  578. } else {
  579. receive.push([uri, title, segnatura, data, InfObj]);
  580. j++;
  581. }
  582. });
  583. var Send_Letters = "";
  584. var Receive_Letters = "";
  585. //POPULATE SEND LETTERS BOX
  586. for (var i=0; i<send.length; i++) {
  587. var letter = "";
  588. var infObject_button = "";
  589. var object_type = "";
  590. if (send[i][4] != "") {
  591. letter = '<div class="col-8"><p><span id="' + send[i][0] + '" class="title_doc lettera">'+ send[i][1] + '</span>';
  592. object_type = "lettera";
  593. infObject_button += '<button type="button" id="' + send[i][4] +
  594. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  595. } else {
  596. letter = '<div class="col-8"><p><span id="' + send[i][0] + '" class="title_doc object">'+ send[i][1] + '</span>';
  597. object_type = "object";
  598. infObject_button += '<button type="button" id="' + send[i][0] +
  599. '" class="object btn btn-default" alt="oggetto" title="' + send[i][1] +
  600. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  601. }
  602. if (send[i][2] != "") {
  603. letter = letter + "<br />Segnatura: " + send[i][2];
  604. }
  605. if (send[i][3] != "") {
  606. letter = letter + "<br />Data: " + send[i][3];
  607. }
  608. letter = letter + '</p></div>';
  609. Send_Letters += '<div class="row res">'+ letter +
  610. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  611. '<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>' +
  612. '<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>' +
  613. '<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>';
  614. }
  615. //POPULATE RECEIVE LETTERS BOX
  616. for (var i=0; i<receive.length; i++) {
  617. var letter = "";
  618. var infObject_button = "";
  619. var object_type = "";
  620. if (receive[i][4] != "") {
  621. letter = '<div class="col-8"><p><span id="' + receive[i][0] + '" class="title_doc lettera">'+ receive[i][1] + '</span>';
  622. object_type = "lettera";
  623. infObject_button += '<button type="button" id="' + receive[i][4] +
  624. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  625. } else {
  626. letter = '<div class="col-8"><p><span id="' + receive[i][0] + '" class="title_doc object">'+ receive[i][1] + '</span>';
  627. object_type = "object";
  628. infObject_button += '<button type="button" id="' + receive[i][0] +
  629. '" class="object btn btn-default" alt="oggetto" title="' + receive[i][1] +
  630. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  631. }
  632. if (receive[i][2] != "") {
  633. letter = letter + "<br />Segnatura: " + receive[i][2];
  634. }
  635. if (receive[i][3] != "") {
  636. letter = letter + "<br />Data: " + receive[i][3];
  637. }
  638. letter = letter + '</p></div>';
  639. Receive_Letters += '<div class="row res">'+ letter +
  640. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  641. '<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>' +
  642. '<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>' +
  643. '<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>';
  644. }
  645. document.getElementById("l_send").innerHTML = send.length;
  646. document.getElementById("l_receive").innerHTML = receive.length;
  647. document.getElementById("letters_send").innerHTML = Send_Letters;
  648. document.getElementById("letters_receive").innerHTML = Receive_Letters;
  649. if (send.length==0) {
  650. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  651. document.getElementById("letters_send").innerHTML = messaggio;
  652. }
  653. if (receive.length==0) {
  654. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  655. document.getElementById("letters_receive").innerHTML = messaggio;
  656. }
  657. }
  658. function handle_Artwork(json) {
  659. //console.log(json);
  660. const oa = [];
  661. $.each(
  662. json['results']['bindings'],
  663. function (index, value) {
  664. uri = value['subject']['value'];
  665. label = value['label']['value'];
  666. nct = value['nct']['value'];
  667. var data = "";
  668. if (value.hasOwnProperty('time_span')) {
  669. data = value['time_span']['value'];
  670. }
  671. oa.push([uri, label, nct, data]);
  672. });
  673. var Artworks = "";
  674. for (var i=0; i<oa.length; i++) {
  675. var artwork = '<a href=' + oa[i][0] + ' target="_blank">' + oa[i][1] + '</a><br />NCT: ' + oa[i][2];
  676. if (oa[i][3] != "") {
  677. artwork = artwork + "<br />Data: " + oa[i][3];
  678. }
  679. var object_button = '<button type="button" id="' + oa[i][0] +
  680. '" class="artwork btn btn-default" alt="opera d\'arte" title="' + oa[i][1] +
  681. '"><i class="fas fa-paint-brush"></i><p class="btn-text">Scheda Opera d\'Arte</p></button>';
  682. Artworks += '<div class="row res"><div class="col-8"><p>'+ artwork +'</p></div>' +
  683. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  684. '<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>' +
  685. '<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>' +
  686. '<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>';
  687. }
  688. document.getElementById("n_oa").innerHTML = oa.length;
  689. document.getElementById("object_oa").innerHTML = Artworks;
  690. if (oa.length==0) {
  691. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  692. document.getElementById("object_oa").innerHTML = messaggio;
  693. }
  694. }
  695. function handle_Other_Documents(json) {
  696. //console.log(json);
  697. const doc = [];
  698. $.each(
  699. json['results']['bindings'],
  700. function (index, value) {
  701. uri = value['document']['value'];
  702. label = value['label']['value'];
  703. var data = "";
  704. var id = "";
  705. if (value.hasOwnProperty('time_span')) {
  706. data = value['time_span']['value'];
  707. }
  708. if (value.hasOwnProperty('id')) {
  709. id = value['id']['value'];
  710. }
  711. doc.push([uri, label, id, data]);
  712. });
  713. var Documents = "";
  714. for (var i=0; i<doc.length; i++) {
  715. var paper = '<div class="col-8"><p><span id="' + doc[i][0] + '" class="title_doc object">'+ doc[i][1] + '</span>';
  716. var object_button = '<button type="button" id="' + doc[i][0] +
  717. '" class="object btn btn-default" alt="oggetto" title="' + doc[i][1] +
  718. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  719. if (doc[i][2] != "") {
  720. paper = paper + "<br />Segnatura: " + doc[i][2];
  721. }
  722. if (doc[i][3] != "") {
  723. paper = paper + "<br />Data: " + doc[i][3];
  724. }
  725. paper = paper + '</p></div>';
  726. Documents += '<div class="row res">'+ paper +
  727. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  728. '<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>' +
  729. '<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>' +
  730. '<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>';
  731. }
  732. document.getElementById("n_ass").innerHTML = doc.length;
  733. document.getElementById("other_documents").innerHTML = Documents;
  734. if (doc.length==0) {
  735. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  736. document.getElementById("other_documents").innerHTML = messaggio;
  737. }
  738. }
  739. function handle_map(json) {
  740. //console.log(json);
  741. const locations = [];
  742. const place_names = [];
  743. const place_events = [];
  744. const luoghi = [];
  745. var lat = 0;
  746. var long = 0;
  747. var i=0;
  748. var myPlaces = "";
  749. $.each(
  750. json['results']['bindings'],
  751. function (index, value) {
  752. const loc = []
  753. var uri = value['place']['value'];
  754. var label = value['label']['value'];
  755. var coord = value['coordinates']['value'];
  756. var evento = value['tipo']['value']
  757. var count = value['count']['value']
  758. place_events.push([uri, evento, count]);
  759. if (!place_names.includes(uri)) {
  760. place_names.push(uri);
  761. const coordinates = coord.split(", ");
  762. loc.push(uri);
  763. label = titleCase(label);
  764. loc.push(label);
  765. 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='" +
  766. uri + "'><i class='far fa-map' style='cursor:pointer'></i></div></div></div>";
  767. loc.push(coordinates[0]);
  768. lat += parseInt(coordinates[0]);
  769. loc.push(coordinates[1]);
  770. long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  771. locations.push(loc);
  772. i++;
  773. }
  774. });
  775. for (var k=0; k<locations.length; k++) {
  776. const tempArray = [];
  777. var nomeLuogo = locations[k][1];
  778. var lt = locations[k][2];
  779. var lg = locations[k][3];
  780. tempArray.push(nomeLuogo);
  781. tempArray.push(lt);
  782. tempArray.push(lg);
  783. for (var y=0; y<place_events.length; y++) {
  784. var ev = place_events[y][1];
  785. var number = place_events[y][2]
  786. var dict = ev + ": " + number;
  787. if (locations[k][0] == place_events[y][0]) {
  788. tempArray.push(dict);
  789. }
  790. }
  791. luoghi.push(tempArray);
  792. }
  793. //console.log(luoghi);
  794. var latitude = lat/i;
  795. var longitude = long/i;
  796. var mapIcon = "<div id='map_icon' class='no_info_icon'> \
  797. <svg xmlns='http://www.w3.org/2000/svg' width='30' viewBox='0 0 576 512'> \
  798. <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'/> \
  799. </svg> \
  800. <p>Nessun luogo trovato</p> \
  801. </div>";
  802. if (locations.length == 0) {
  803. $("#people_map").css("display", "none");
  804. $("#references_persona").css("display", "none");
  805. document.getElementById("people_map_no_res").innerHTML = mapIcon;
  806. }
  807. document.getElementById("list_places_person").innerHTML = myPlaces;
  808. var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
  809. cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade, Points &copy 2012 LINZ',
  810. cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 17, attribution: cloudmadeAttribution}),
  811. latlng = new L.LatLng(latitude, longitude);
  812. var map = new L.Map('map', {center: latlng, zoom: 5, layers: [cloudmade]});
  813. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  814. var markers = new L.MarkerClusterGroup();
  815. var markerList = [];
  816. var geo = new L.tileLayer(
  817. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  818. attribution: '&copy; ' + mapLink + ' Contributors',
  819. maxZoom: 18,
  820. }).addTo(map);
  821. function populate() {
  822. for (var i = 0; i < luoghi.length; i++) {
  823. var a = luoghi[i];
  824. var len = a.length;
  825. var title = "<h2>" + titleCase(a[0]) + "</h2>";
  826. for (var k=3; k<len; k++) {
  827. var dix = a[k].replace("Invio:", "Invio lettere:").replace("Ricezione:", "Ricezione lettere:");
  828. title = title + "<p style='font-size: 14px;'>" + dix + " occorrenze</p><hr>";
  829. }
  830. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  831. marker.bindPopup(title);
  832. markers.addLayer(marker);
  833. markerList.push(marker);
  834. }
  835. }
  836. populate();
  837. map.addLayer(markers);
  838. $('.clickPlace').on('click', function(){
  839. // parse lat and lng from the divs data attribute
  840. var latlng = $(this).data().point.split(',');
  841. var lat = latlng[0];
  842. var lng = latlng[1];
  843. var zoom = 10;
  844. // set the view
  845. map.setView([lat, lng], zoom);
  846. });
  847. }
  848. function exchangeLetter(tipo, mittente, uri_mittente, destinatario, uri_destinatario) {
  849. var params = tipo + ";" + mittente + ";" + uri_mittente + ";" + destinatario + ";" + uri_destinatario;
  850. window.open("results.html?params="+ params);
  851. }