people.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  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 ?name ?givenName ?familyName ?alias (GROUP_CONCAT(DISTINCT CONCAT(?variant, '| ', ?otherName) ; SEPARATOR = ';') AS ?variants) ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation (group_concat(distinct ?relative1 ;separator=', ') as ?relatives) ?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. OPTIONAL {?uri foaf:givenName ?givenName} \
  83. OPTIONAL {?uri foaf:familyName ?familyName} \
  84. OPTIONAL {?uri foaf:gender ?gender} \
  85. OPTIONAL {?uri person:patronymicName ?patronymic } \
  86. OPTIONAL {?uri schema:hasOccupation ?uriOccupation . \
  87. ?uriOccupation rdf:type schema:Occupation; \
  88. rdfs:label ?occupation } \
  89. OPTIONAL {?uri schema:honorificPrefix ?qualification} \
  90. OPTIONAL {?uri schema:relatedTo ?uriRel1 . \
  91. ?uriRel1 rdfs:label ?relative1} \
  92. OPTIONAL {?uri crm:P100i_died_in ?Death . \
  93. ?Death crm:P4_has_time-span ?Death_TS; \
  94. crm:P7_took_place_at ?Place_D .\
  95. ?Death_TS rdfs:label ?Death_Date . \
  96. ?Place_D rdfs:label ?Death_Place } \
  97. OPTIONAL {?uri crm:P98i_was_born ?Birth . \
  98. ?Birth crm:P4_has_time-span ?Birth_TS; \
  99. crm:P7_took_place_at ?Place_B . \
  100. ?Birth_TS rdfs:label ?Birth_Date . \
  101. ?Place_B rdfs:label ?Birth_Place } \
  102. OPTIONAL {?uri crm:P107i_is_current_or_former_member_of ?uriGroup . \
  103. ?uriGroup rdfs:label ?group } \
  104. OPTIONAL {?uri schema:alternateName ?alias . } \
  105. OPTIONAL {?uri owl:sameAs ?variant . \
  106. ?variant foaf:name ?otherName . } \
  107. } \
  108. GROUP BY ?graph ?label ?identifier ?name ?givenName ?familyName ?alias ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group \
  109. LIMIT 1 "
  110. queryLetters = prefixes + " SELECT DISTINCT ?type ?segnatura ?document_uri ?document_name ?time_span ?InfObj \
  111. WHERE {?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
  112. ?ev_move crm:P01_has_domain ?pc ; \
  113. rdfs:label ?type ; \
  114. rdfs:subClassOf ?event . \
  115. ?document_uri crm:P25i_moved_by ?event ; \
  116. rdfs:label ?document_name . \
  117. ?document_uri crm:P1_is_identified_by ?uriSegnatura . \
  118. ?uriSegnatura crm:P2_has_type 'Segnatura' ; \
  119. rdfs:label ?segnatura . \
  120. OPTIONAL {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?document_uri crm:P128_carries ?InfObj . \
  121. ?InfObj rdf:type crm:E73_Information_Object} }. \
  122. OPTIONAL {?ev_move crm:P4_has_time-span ?uri_ts . \
  123. ?uri_ts rdfs:label ?time_span . } \
  124. }"
  125. queryDocuments = prefixes + " SELECT DISTINCT ?role ?document ?label ?id (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  126. WHERE { \
  127. ?document ?property ?event ; \
  128. crm:P1_is_identified_by ?uri_id ; \
  129. rdfs:label ?label . \
  130. ?uri_id rdfs:label ?id ; \
  131. crm:P2_has_type 'Segnatura' . \
  132. OPTIONAL { \
  133. {?event crm:P4_has_time-span ?uri_time_span . \
  134. ?uri_time_span rdfs:label ?time_span . \
  135. } UNION { \
  136. ?sub_event rdfs:subClassOf ?event ; \
  137. crm:P4_has_time-span ?uri_time_span . \
  138. ?uri_time_span rdfs:label ?time_span . } \
  139. } \
  140. ?event crm:P01_has_domain ?domain . \
  141. ?domain crm:P02_has_range <" + thisUrlParams.link + "> ; \
  142. crm:P14.1_in_the_role_of ?uri_role . \
  143. ?uri_role rdfs:label ?role . \
  144. } \
  145. GROUP BY ?document ?label ?id ?role "
  146. queryOtherDoc = prefixes + " SELECT DISTINCT ?document ?label ?id (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  147. WHERE {<" + thisUrlParams.link + "> rdf:type crm:E21_Person . \
  148. ?creation crm:P67_refers_to <" + thisUrlParams.link + "> . \
  149. ?document crm:P92i_was_brought_into_existence_by ?creation ; \
  150. rdfs:label ?label ; \
  151. crm:P1_is_identified_by ?uri_id . \
  152. ?uri_id rdfs:label ?id ; \
  153. crm:P2_has_type 'Segnatura' . \
  154. OPTIONAL {?creation crm:P4_has_time-span ?uri_time_span . \
  155. ?uri_time_span rdfs:label ?time_span . } \
  156. } \
  157. GROUP BY ?document ?label ?id "
  158. queryOpere = prefixes + " SELECT DISTINCT ?subject ?label ?nct (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
  159. WHERE {?subject rdf:type crm:E22_Man-Made_Object ; \
  160. rdfs:label ?label ; \
  161. crm:P1_is_identified_by ?uri_nct . \
  162. ?uri_nct rdfs:label ?nct . \
  163. ?production crm:P108_has_produced ?subject . \
  164. OPTIONAL {?production crm:P4_has_time-span ?uri_time_span . \
  165. ?uri_time_span rdfs:label ?time_span } \
  166. ?pc crm:P01_has_domain ?production ; \
  167. crm:P02_has_range <" + thisUrlParams.link + "> } \
  168. GROUP BY ?subject ?label ?nct "
  169. queryNetwork = prefixes + " SELECT DISTINCT COUNT(?event) AS ?count ?uri2 SAMPLE(?label2) AS ?text \
  170. WHERE { \
  171. {?event rdf:type crm:EL1_Exchange_Letters . \
  172. ?event_to rdfs:subClassOf ?event; \
  173. rdf:type crm:EL2_Send_Letter ; \
  174. crm:P01_has_domain ?pc_to . \
  175. ?pc_to crm:P02_has_range ?uri . \
  176. ?uri rdfs:label ?label . \
  177. ?event_from rdfs:subClassOf ?event; \
  178. rdf:type crm:EL3_Receive_Letter; \
  179. crm:P01_has_domain ?pc_from . \
  180. ?pc_from crm:P02_has_range ?uri2 . \
  181. ?uri2 rdfs:label ?label2 . \
  182. FILTER (?uri = <" + thisUrlParams.link + ">) \
  183. } UNION { \
  184. ?event rdf:type crm:EL1_Exchange_Letters . \
  185. ?event_to rdfs:subClassOf ?event; \
  186. rdf:type crm:EL3_Receive_Letter ; \
  187. crm:P01_has_domain ?pc_from . \
  188. ?pc_from crm:P02_has_range ?uri . \
  189. ?uri rdfs:label ?label . \
  190. ?event_from rdfs:subClassOf ?event; \
  191. rdf:type crm:EL2_Send_Letter; \
  192. crm:P01_has_domain ?pc_to . \
  193. ?pc_to crm:P02_has_range ?uri2 . \
  194. ?uri2 rdfs:label ?label2 . \
  195. FILTER (?uri = <" + thisUrlParams.link + ">) \
  196. } \
  197. } ORDER BY DESC (?count)"
  198. queryURL = prepareQueryURL(query);
  199. queryNet = prepareQueryURL(queryNetwork);
  200. queryDoc = prepareQueryURL(queryDocuments);
  201. queryOt = prepareQueryURL(queryOtherDoc);
  202. queryOA = prepareQueryURL(queryOpere);
  203. query = prepareQueryURL(queryInfo);
  204. queryEx = prepareQueryURL(queryLetters);
  205. response = $.ajax({
  206. url: query,
  207. dataType: "json",
  208. success: function (data){
  209. handle_data(data);
  210. },
  211. error: function (e) {}
  212. });
  213. response = $.ajax({
  214. url: queryURL,
  215. dataType: "json",
  216. success: function (data){
  217. handle_map(data);
  218. },
  219. error: function (e) {}
  220. });
  221. responseNet = $.ajax({
  222. url: queryNet,
  223. dataType: "json",
  224. success: function (data){
  225. handle_network(data);
  226. },
  227. error: function (e) {}
  228. });
  229. responseLet = $.ajax({
  230. url: queryEx,
  231. dataType: "json",
  232. success: function (data){
  233. handle_Letters(data);
  234. },
  235. error: function (e) {}
  236. });
  237. responseOA = $.ajax({
  238. url: queryOA,
  239. dataType: "json",
  240. success: function (data){
  241. handle_Artwork(data);
  242. },
  243. error: function (e) {}
  244. });
  245. responseOt = $.ajax({
  246. url: queryOt,
  247. dataType: "json",
  248. success: function (data){
  249. handle_Other_Documents(data);
  250. },
  251. error: function (e) {}
  252. });
  253. responseDoc = $.ajax({
  254. url: queryDoc,
  255. dataType: "json",
  256. success: function (data){
  257. handle_Documents(data);
  258. },
  259. error: function (e) {}
  260. });
  261. function handle_data(json) {
  262. console.log(json['results']['bindings']);
  263. var graph = "";
  264. var label = "";
  265. if ("givenName" in json.results.bindings) {
  266. givenName = value['givenName']['value'];
  267. }
  268. $.each(
  269. json['results']['bindings'],
  270. function (index, value) {
  271. var graph = value['graph']['value'];
  272. var label = value['label']['value'];
  273. var name = value['name']['value'];
  274. var givenName = "";
  275. var familyName = "";
  276. var alias = "";
  277. var gender = "";
  278. var patronymic = "";
  279. var occupation = "";
  280. var relative = "";
  281. var identifier = "";
  282. var birth_date = "";
  283. var birth_place = "";
  284. var death_date = "";
  285. var death_place = "";
  286. var qualification = "";
  287. var group = "";
  288. var variants = "";
  289. if (value.hasOwnProperty('givenName')) {
  290. $("#givenName").css("display", "flex");
  291. givenName = value['givenName']['value'];
  292. }
  293. if (value.hasOwnProperty('familyName')) {
  294. $("#familyName").css("display", "flex");
  295. familyName = value['familyName']['value'].toLowerCase();
  296. familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
  297. }
  298. if (value.hasOwnProperty('alias')) {
  299. $("#aliasName").css("display", "flex");
  300. alias = value['alias']['value'];
  301. }
  302. if (value.hasOwnProperty('gender')) {
  303. $("#gender").css("display", "flex");
  304. gender = value['gender']['value'];
  305. }
  306. if (value.hasOwnProperty('patronymic')) {
  307. $("#patronymic").css("display", "flex");
  308. patronymic = value['patronymic']['value'];
  309. }
  310. if (value.hasOwnProperty('occupation')) {
  311. $("#occupation").css("display", "flex");
  312. occupation = value['occupation']['value'];
  313. }
  314. if (value.hasOwnProperty('relatives')) {
  315. if (value['relatives']['value'] != "") {
  316. relative = value['relatives']['value'];
  317. }
  318. }
  319. if (value.hasOwnProperty('qualification')) {
  320. $("#honorific").css("display", "flex");
  321. qualification = value['qualification']['value'];
  322. }
  323. if (value.hasOwnProperty('Birth_Date')) {
  324. $("#BirthDate").css("display", "flex");
  325. birth_date = value['Birth_Date']['value'];
  326. }
  327. if (value.hasOwnProperty('Birth_Place')) {
  328. $("#BirthPlace").css("display", "flex");
  329. birth_place = value['Birth_Place']['value'];
  330. }
  331. if (value.hasOwnProperty('Death_Date')) {
  332. $("#DeathDate").css("display", "flex");
  333. death_date = value['Death_Date']['value'];
  334. }
  335. if (value.hasOwnProperty('Death_Place')) {
  336. $("#DeathPlace").css("display", "flex");
  337. death_place = value['Death_Place']['value'];
  338. }
  339. if (value.hasOwnProperty('group')) {
  340. $("#groups").css("display", "flex");
  341. group = value['group']['value'];
  342. }
  343. if (value.hasOwnProperty('variants')) {
  344. if (value['variants']['value'] != "| ") {
  345. alert(value['variants']['value']);
  346. $("#otherNames").css("display", "flex");
  347. let strings = value['variants']['value'];
  348. variants = strings.split(";");
  349. }
  350. }
  351. var dataset = get_dataset_name(graph);
  352. var second_name = patronymic + " " + relative;
  353. var first_name = "";
  354. if ((givenName != "") || (second_name != " ") || (familyName != "")) {
  355. first_name = givenName + " " + second_name + " " + familyName;
  356. } else {
  357. first_name = name;
  358. }
  359. var name_string = "";
  360. if (variants.length>0) {
  361. for (var i=0; i<variants.length; i++) {
  362. let chunk = variants[i].split("| ");
  363. name_string = name_string + "<a href='" + chunk[0] + "'>" + chunk[1] + "</a><br />";
  364. }
  365. }
  366. console.log(variants);
  367. /*for (var i=0; i<l; i++) {
  368. names_string = names_string + "<a href='" + variants[i][0] + "'>" + variants[i][1] + "</a>";
  369. }*/
  370. document.getElementById("grafo").innerHTML = dataset;
  371. document.getElementById("nome_persona").innerHTML = first_name;
  372. document.getElementById("nome").innerHTML = name;
  373. document.getElementById("genere").innerHTML = gender;
  374. document.getElementById("nome_proprio").innerHTML = givenName;
  375. document.getElementById("nome_famiglia").innerHTML = familyName;
  376. document.getElementById("alias").innerHTML = alias;
  377. document.getElementById("variants").innerHTML = name_string;
  378. document.getElementById("patronimico").innerHTML = second_name;
  379. document.getElementById("qualifica").innerHTML = qualification;
  380. document.getElementById("occupazione").innerHTML = occupation;
  381. document.getElementById("data_nascita").innerHTML = birth_date;
  382. document.getElementById("data_morte").innerHTML = death_date;
  383. document.getElementById("luogo_nascita").innerHTML = birth_place;
  384. document.getElementById("luogo_morte").innerHTML = death_place;
  385. document.getElementById("gruppi_appartenenza").innerHTML = group;
  386. const collection = document.getElementsByClassName("PN");
  387. for (var i=0; i<collection.length; i++) {
  388. collection[i].innerHTML = first_name;
  389. }
  390. });
  391. }
  392. function get_dataset_name(graph) {
  393. var string = "Scheda Onomastica";
  394. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica") {
  395. string = string + " / Onomastica Datini";
  396. }
  397. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/authors"){
  398. string = string + " / Artisti";
  399. }
  400. else {
  401. string = string;
  402. }
  403. return (string);
  404. }
  405. function handle_Letters(json) {
  406. console.log(json);
  407. const send = [];
  408. const receive = [];
  409. var i=0;
  410. var j=0;
  411. $.each(
  412. json['results']['bindings'],
  413. function (index, value) {
  414. type = value['type']['value'];
  415. uri = value['document_uri']['value'];
  416. title = value['document_name']['value'];
  417. segnatura = value['segnatura']['value'];
  418. var data = "";
  419. var InfObj = "";
  420. if (value.hasOwnProperty('time_span')) {
  421. data = value['time_span']['value'];
  422. }
  423. if (value.hasOwnProperty('InfObj')) {
  424. InfObj = value['InfObj']['value'];
  425. }
  426. if (type == "Invio") {
  427. send.push([uri, title, segnatura, data, InfObj]);
  428. i++;
  429. } else {
  430. receive.push([uri, title, segnatura, data, InfObj]);
  431. j++;
  432. }
  433. });
  434. var Send_Letters = "";
  435. var Receive_Letters = "";
  436. //POPULATE SEND LETTERS BOX
  437. for (var i=0; i<send.length; i++) {
  438. var letter = '<a href=' + send[i][0] + ' target="_blank">' + send[i][1] + '</a>';
  439. var infObject_button = "";
  440. if (send[i][2] != "") {
  441. letter = letter + "<br />Segnatura: " + send[i][2];
  442. }
  443. if (send[i][3] != "") {
  444. letter = letter + "<br />Data invio: " + send[i][3];
  445. }
  446. if (send[i][4] != "") {
  447. infObject_button += '<button type="button" id="' + send[i][4] +
  448. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  449. } else {
  450. infObject_button += '<button type="button" id="' + send[i][0] +
  451. '" class="object btn btn-default" alt="oggetto" title="' + send[i][1] +
  452. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  453. }
  454. Send_Letters += '<div class="row res"><div class="col-8"><p>'+ letter +'</p></div>' +
  455. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  456. '<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>' +
  457. '<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>' +
  458. '<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>';
  459. }
  460. //POPULATE RECEIVE LETTERS BOX
  461. for (var i=0; i<receive.length; i++) {
  462. var letter = '<a href=' + receive[i][0] + ' target="_blank">' + receive[i][1] + '</a>';
  463. var infObject_button = "";
  464. if (receive[i][2] != "") {
  465. letter = letter + "<br />Segnatura: " + receive[i][2];
  466. }
  467. if (receive[i][3] != "") {
  468. letter = letter + "<br />Data ricezione: " + receive[i][3];
  469. }
  470. if (receive[i][4] != "") {
  471. infObject_button += '<button type="button" id="' + receive[i][4] +
  472. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  473. } else {
  474. infObject_button += '<button type="button" id="' + receive[i][0] +
  475. '" class="object btn btn-default" alt="oggetto" title="' + receive[i][1] +
  476. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  477. }
  478. Receive_Letters += '<div class="row res"><div class="col-8"><p>'+ letter +'</p></div>' +
  479. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  480. '<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>' +
  481. '<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>' +
  482. '<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>';
  483. }
  484. document.getElementById("l_send").innerHTML = send.length;
  485. document.getElementById("l_receive").innerHTML = receive.length;
  486. document.getElementById("letters_send").innerHTML = Send_Letters;
  487. document.getElementById("letters_receive").innerHTML = Receive_Letters;
  488. if (send.length==0) {
  489. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  490. document.getElementById("letters_send").innerHTML = messaggio;
  491. }
  492. if (receive.length==0) {
  493. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  494. document.getElementById("letters_receive").innerHTML = messaggio;
  495. }
  496. }
  497. function handle_Artwork(json) {
  498. console.log(json);
  499. const oa = [];
  500. $.each(
  501. json['results']['bindings'],
  502. function (index, value) {
  503. uri = value['subject']['value'];
  504. label = value['label']['value'];
  505. nct = value['nct']['value'];
  506. var data = "";
  507. if (value.hasOwnProperty('time_span')) {
  508. data = value['time_span']['value'];
  509. }
  510. oa.push([uri, label, nct, data]);
  511. });
  512. var Artworks = "";
  513. for (var i=0; i<oa.length; i++) {
  514. var artwork = '<a href=' + oa[i][0] + ' target="_blank">' + oa[i][1] + '</a><br />NCT: ' + oa[i][2];
  515. if (oa[i][3] != "") {
  516. artwork = artwork + "<br />Data: " + oa[i][3];
  517. }
  518. var object_button = '<button type="button" id="' + oa[i][0] +
  519. '" class="artwork btn btn-default" alt="opera d\'arte" title="' + oa[i][1] +
  520. '"><i class="fas fa-paint-brush"></i><p class="btn-text">Scheda Opera d\'Arte</p></button>';
  521. Artworks += '<div class="row res"><div class="col-8"><p>'+ artwork +'</p></div>' +
  522. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  523. '<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>' +
  524. '<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>' +
  525. '<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>';
  526. }
  527. document.getElementById("n_oa").innerHTML = oa.length;
  528. document.getElementById("object_oa").innerHTML = Artworks;
  529. if (oa.length==0) {
  530. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  531. document.getElementById("object_oa").innerHTML = messaggio;
  532. }
  533. }
  534. function handle_Documents(json) {
  535. console.log(json);
  536. const docs = [];
  537. $.each(
  538. json['results']['bindings'],
  539. function (index, value) {
  540. uri = value['document']['value'];
  541. label = value['label']['value'];
  542. id = value['id']['value'];
  543. ruolo = value['role']['value'];
  544. var data = "";
  545. if (value.hasOwnProperty('time_span')) {
  546. data = value['time_span']['value'];
  547. }
  548. docs.push([uri, label, id, data, ruolo]);
  549. });
  550. var Docs = "";
  551. for (var i=0; i<docs.length; i++) {
  552. var object = '<a href=' + docs[i][0] + ' target="_blank">' + docs[i][1] + '</a><br />Segnatura: ' + docs[i][2];
  553. if (docs[i][3] != "") {
  554. object = object + "<br />Data: " + docs[i][3];
  555. }
  556. object = object + "<br /><span class='PN'></span> nel ruolo di " + docs[i][4];
  557. var object_button = '<button type="button" id="' + docs[i][0] +
  558. '" class="object btn btn-default" alt="opera d\'arte" title="' + docs[i][1] +
  559. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  560. Docs += '<div class="row res"><div class="col-8"><p>'+ object +'</p></div>' +
  561. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  562. '<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>' +
  563. '<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>' +
  564. '<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>';
  565. }
  566. document.getElementById("n_dc").innerHTML = docs.length;
  567. document.getElementById("written_documents").innerHTML = Docs;
  568. }
  569. function handle_Other_Documents(json) {
  570. console.log(json);
  571. const doc = [];
  572. $.each(
  573. json['results']['bindings'],
  574. function (index, value) {
  575. uri = value['document']['value'];
  576. label = value['label']['value'];
  577. id = value['id']['value'];
  578. var data = "";
  579. if (value.hasOwnProperty('time_span')) {
  580. data = value['time_span']['value'];
  581. }
  582. doc.push([uri, label, id, data]);
  583. });
  584. var Documents = "";
  585. for (var i=0; i<doc.length; i++) {
  586. var artwork = '<a href=' + doc[i][0] + ' target="_blank">' + doc[i][1] + '</a><br />Segnatura: ' + doc[i][2];
  587. if (doc[i][3] != "") {
  588. artwork = artwork + "<br />Data: " + doc[i][3];
  589. }
  590. var object_button = '<button type="button" id="' + doc[i][0] +
  591. '" class="object btn btn-default" alt="opera d\'arte" title="' + doc[i][1] +
  592. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  593. Documents += '<div class="row res"><div class="col-8"><p>'+ artwork +'</p></div>' +
  594. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  595. '<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>' +
  596. '<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>' +
  597. '<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>';
  598. }
  599. document.getElementById("n_ass").innerHTML = doc.length;
  600. document.getElementById("other_documents").innerHTML = Documents;
  601. if (doc.length==0) {
  602. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  603. document.getElementById("other_documents").innerHTML = messaggio;
  604. }
  605. }
  606. function handle_map(json) {
  607. console.log(json);
  608. const locations = [];
  609. const place_names = [];
  610. var lat = 0;
  611. var long = 0;
  612. var i=0;
  613. var myPlaces = "";
  614. $.each(
  615. json['results']['bindings'],
  616. function (index, value) {
  617. const loc = []
  618. var uri = value['place']['value'];
  619. var label = value['label']['value'];
  620. var coord = value['coordinates']['value'];
  621. const coordinates = coord.split(", ");
  622. loc.push(label);
  623. 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='" +
  624. uri + "'><i class='far fa-map' style='cursor:pointer'></i></div></div></div>";
  625. loc.push(coordinates[0]);
  626. lat += parseInt(coordinates[0]);
  627. loc.push(coordinates[1]);
  628. long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  629. locations.push(loc);
  630. i++;
  631. });
  632. var latitude = lat/i;
  633. var longitude = long/i;
  634. if (locations.length > 0) {
  635. $("#map_icon").css("display", "none");
  636. } else {
  637. $("#references_persona").css("display", "none");
  638. }
  639. document.getElementById("list_places_person").innerHTML = myPlaces;
  640. var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
  641. cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade, Points &copy 2012 LINZ',
  642. cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 17, attribution: cloudmadeAttribution}),
  643. latlng = new L.LatLng(latitude, longitude);
  644. var map = new L.Map('map', {center: latlng, zoom: 5, layers: [cloudmade]});
  645. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  646. var markers = new L.MarkerClusterGroup();
  647. var markerList = [];
  648. var geo = new L.tileLayer(
  649. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  650. attribution: '&copy; ' + mapLink + ' Contributors',
  651. maxZoom: 18,
  652. }).addTo(map);
  653. function populate() {
  654. for (var i = 0; i < locations.length; i++) {
  655. var a = locations[i];
  656. var title = a[0];
  657. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  658. marker.bindPopup(title);
  659. markers.addLayer(marker);
  660. markerList.push(marker);
  661. }
  662. }
  663. populate();
  664. map.addLayer(markers);
  665. $('.clickPlace').on('click', function(){
  666. // parse lat and lng from the divs data attribute
  667. var latlng = $(this).data().point.split(',');
  668. var lat = latlng[0];
  669. var lng = latlng[1];
  670. var zoom = 10;
  671. // set the view
  672. map.setView([lat, lng], zoom);
  673. });
  674. }
  675. function handle_network(json) {
  676. console.log(json);
  677. const words = [];
  678. const tempArray = [];
  679. var listwords = "";
  680. var ArrayNames = "";
  681. var temp = 0;
  682. var sum = 0;
  683. var i=0;
  684. var j=0;
  685. $.each(
  686. json['results']['bindings'],
  687. function (index, value) {
  688. text = value['text']['value'];
  689. link = value['uri2']['value'];
  690. num = parseInt(value['count']['value']);
  691. /*count = 0;
  692. if ((num - temp) > 50) {
  693. count = temp + 12;
  694. } else {
  695. count = num;
  696. }
  697. words.push([text, count]);
  698. temp = count;
  699. sum += temp;*/
  700. tempArray.push([text, num]);
  701. ArrayNames += "<div class='item-place-person'><div class='item-place-person-label'>" +
  702. text + "<br /><span class='num_occ'>[Co-occorrenze: " + num + "]</span></div><div class='item-place-person-action'><div class='persona' id='" +
  703. link + "'><i class='fa fa-user' style='cursor:pointer'></i></div></div></div></div>";
  704. });
  705. if (tempArray.length < 8) {
  706. for (var k=0; k<tempArray.length; k++) {
  707. text = tempArray[k][0];
  708. count = tempArray[k][1] + 36;
  709. words.push([text, count]);
  710. }
  711. } else {
  712. for (var k=tempArray.length-1; k>=0; k--) {
  713. text = tempArray[k][0];
  714. num = tempArray[k][1];
  715. count = 0;
  716. if ((num - temp) > 50) {
  717. count = temp + 12;
  718. } else {
  719. count = num;
  720. }
  721. words.push([text, count]);
  722. temp = count;
  723. sum += temp;
  724. }
  725. }
  726. document.getElementById("list_person_network").innerHTML = ArrayNames;
  727. /*var tot = parseInt(words[0][1]);*/
  728. for (var i in words) {
  729. var text = words[i][0]
  730. var count = words[i][1];
  731. listwords += '{ "word": \"' + text + '\", "size": \"' + count + '\"},';
  732. }
  733. let listL = ('[' + listwords + ']').replace(',]', ']');
  734. const links = JSON.parse(listL);
  735. console.log(links);
  736. // List of words
  737. var myWords = links;
  738. // set the dimensions and margins of the graph
  739. var margin = {top: 10, right: 10, bottom: 10, left: 10},
  740. width = 850 - margin.left - margin.right,
  741. height = 500 - margin.top - margin.bottom;
  742. // append the svg object to the body of the page
  743. var svg = d3.select("#myWordCloud").append("svg")
  744. .attr("id", "wordcloudNetwork")
  745. .attr("width", width + margin.left + margin.right)
  746. .attr("height", height + margin.top + margin.bottom)
  747. .append("g")
  748. .attr("transform",
  749. "translate(" + (width/2-50) + "," + (height/2+20) + ")");
  750. // Constructs a new cloud layout instance. It run an algorithm to find the position of words that suits your requirements
  751. // Wordcloud features that are different from one word to the other must be here
  752. var layout = d3.layout.cloud()
  753. .size([width, height])
  754. .words(myWords.map(function(d) { return {text: d.word, size:d.size/2}; }))
  755. .padding(5) //space between words
  756. .rotate(function() { return ~~(Math.random() * 2);})
  757. .fontSize(function(d) { return d.size + 6; }) // font size of words
  758. .on("end", draw);
  759. layout.start();
  760. // This function takes the output of 'layout' above and draw the words
  761. // Wordcloud features that are THE SAME from one word to the other can be here
  762. function draw(words) {
  763. var cloud = svg.selectAll("g text")
  764. .data(words, function(d) { return d.text; })
  765. //Entering words
  766. cloud.enter()
  767. .append("text")
  768. .style("font-family", "Impact")
  769. .attr("text-anchor", "middle")
  770. .attr('font-size', 1)
  771. .text(function(d) { return d.text; });
  772. //Entering and existing words
  773. cloud
  774. .transition()
  775. .duration(600)
  776. .style("font-size", function(d) { return d.size + "px"; })
  777. .attr("transform", function(d) {
  778. return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
  779. })
  780. .style("fill-opacity", 1);
  781. //Exiting words
  782. cloud.exit()
  783. .transition()
  784. .duration(200)
  785. .style('fill-opacity', 1e-6)
  786. .attr('font-size', 1)
  787. .remove();
  788. }
  789. if (words.length > 0) {
  790. $("#users_icon").css("display", "none");
  791. } else {
  792. $("#wordcloudNetwork").css("display", "none");
  793. $("#references_network").css("display", "none");
  794. }
  795. }
  796. $(document).on("click", ".luogo", function (ev) {
  797. var link = this.id;
  798. //alert(nome_autore);
  799. //$('#myModal').text("");
  800. window.open("Luogo.html?link="+this.id);
  801. });
  802. $(document).on("click", ".persona", function (ev) {
  803. var link = this.id;
  804. //alert(nome_autore);
  805. //$('#myModal').text("");
  806. window.open("Persona.html?link="+this.id);
  807. });
  808. $(document).on("click", ".lettera", function (ev) {
  809. var link = this.id;
  810. //alert(nome_autore);
  811. //$('#myModal').text("");
  812. window.open("lettera.html?link="+this.id);
  813. });
  814. $(document).on("click", ".object", function (ev) {
  815. var link = this.id;
  816. //alert(nome_autore);
  817. //$('#myModal').text("");
  818. window.open("object.html?link="+this.id);
  819. });
  820. $(document).on("click", ".hyp", function (ev) {
  821. var link = this.id;
  822. $("#myModal").empty();
  823. $("#myModal").css("display", "block");
  824. $('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
  825. link + "</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  826. });
  827. $(document).on("click", ".artwork", function (ev) {
  828. var link = this.id;
  829. //alert(nome_autore);
  830. //$('#myModal').text("");
  831. window.open("OA.html?link="+this.id);
  832. });
  833. $(document).on("click", ".close", function (ev) {
  834. var link = this.id;
  835. //alert(nome_autore);
  836. //$('#myModal').text("");
  837. $("#myModal").css("display", "none");
  838. });
  839. $(document).on("click", ".back", function (ev) {
  840. $("#myTab").css("display", "none");
  841. });
  842. $(document).on("click", ".cit", function (ev) {
  843. var author ="RESTORE. smart access to digital heritage and memory"
  844. var year = new Date().getFullYear()
  845. var today = new Date();
  846. var dd = String(today.getDate()).padStart(2, '0');
  847. var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  848. var yyyy = today.getFullYear();
  849. today = dd + '/' + mm + '/' + yyyy;
  850. var link = this.id;
  851. //alert(nome_autore);
  852. //$('#myModal').text("");
  853. $("#myModal").empty();
  854. $("#myModal").css("display", "block");
  855. $('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
  856. author + " " + year + ", accesso effettuato: " + today + ", &lt;" + link + "&gt;</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  857. });
  858. function copyToClipboard(text) {
  859. var sampleTextarea = document.createElement("textarea");
  860. document.body.appendChild(sampleTextarea);
  861. sampleTextarea.value = text; //save main text in it
  862. sampleTextarea.select(); //select textarea contenrs
  863. document.execCommand("copy");
  864. document.body.removeChild(sampleTextarea);
  865. }
  866. function myFunction(){
  867. var copy = document.getElementById("myInput");
  868. copyText = copy.textContent;
  869. copyToClipboard(copyText);
  870. //copyToClipboard(copyText.value);
  871. }