people.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  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. var mapIcon = "<div id='map_icon' class='no_info_icon'> \
  635. <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'> \
  636. <!--! 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'/> \
  637. </svg> \
  638. <p>Nessun luogo trovato</p> \
  639. </div>";
  640. if (locations.length == 0) {
  641. $("#references_persona").css("display", "none");
  642. document.getElementById("map").innerHTML = mapIcon;
  643. }
  644. document.getElementById("list_places_person").innerHTML = myPlaces;
  645. var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
  646. cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade, Points &copy 2012 LINZ',
  647. cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 17, attribution: cloudmadeAttribution}),
  648. latlng = new L.LatLng(latitude, longitude);
  649. var map = new L.Map('map', {center: latlng, zoom: 5, layers: [cloudmade]});
  650. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  651. var markers = new L.MarkerClusterGroup();
  652. var markerList = [];
  653. var geo = new L.tileLayer(
  654. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  655. attribution: '&copy; ' + mapLink + ' Contributors',
  656. maxZoom: 18,
  657. }).addTo(map);
  658. function populate() {
  659. for (var i = 0; i < locations.length; i++) {
  660. var a = locations[i];
  661. var title = a[0];
  662. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  663. marker.bindPopup(title);
  664. markers.addLayer(marker);
  665. markerList.push(marker);
  666. }
  667. }
  668. populate();
  669. map.addLayer(markers);
  670. $('.clickPlace').on('click', function(){
  671. // parse lat and lng from the divs data attribute
  672. var latlng = $(this).data().point.split(',');
  673. var lat = latlng[0];
  674. var lng = latlng[1];
  675. var zoom = 10;
  676. // set the view
  677. map.setView([lat, lng], zoom);
  678. });
  679. }
  680. function handle_network(json) {
  681. console.log(json);
  682. const words = [];
  683. const tempArray = [];
  684. var listwords = "";
  685. var ArrayNames = "";
  686. var temp = 0;
  687. var sum = 0;
  688. var i=0;
  689. var j=0;
  690. $.each(
  691. json['results']['bindings'],
  692. function (index, value) {
  693. text = value['text']['value'];
  694. link = value['uri2']['value'];
  695. num = parseInt(value['count']['value']);
  696. /*count = 0;
  697. if ((num - temp) > 50) {
  698. count = temp + 12;
  699. } else {
  700. count = num;
  701. }
  702. words.push([text, count]);
  703. temp = count;
  704. sum += temp;*/
  705. tempArray.push([text, num]);
  706. ArrayNames += "<div class='item-place-person'><div class='item-place-person-label'>" +
  707. text + "<br /><span class='num_occ'>[Co-occorrenze: " + num + "]</span></div><div class='item-place-person-action'><div class='persona' id='" +
  708. link + "'><i class='fa fa-user' style='cursor:pointer'></i></div></div></div></div>";
  709. });
  710. if (tempArray.length < 8) {
  711. for (var k=0; k<tempArray.length; k++) {
  712. text = tempArray[k][0];
  713. count = tempArray[k][1] + 36;
  714. words.push([text, count]);
  715. }
  716. } else {
  717. for (var k=tempArray.length-1; k>=0; k--) {
  718. text = tempArray[k][0];
  719. num = tempArray[k][1];
  720. count = 0;
  721. if ((num - temp) > 50) {
  722. count = temp + 12;
  723. } else {
  724. count = num;
  725. }
  726. words.push([text, count]);
  727. temp = count;
  728. sum += temp;
  729. }
  730. }
  731. document.getElementById("list_person_network").innerHTML = ArrayNames;
  732. $('#myWordCloud').empty();
  733. /*var tot = parseInt(words[0][1]);*/
  734. for (var i in words) {
  735. var text = words[i][0]
  736. var count = words[i][1];
  737. listwords += '{ "word": \"' + text + '\", "size": \"' + count + '\"},';
  738. }
  739. let listL = ('[' + listwords + ']').replace(',]', ']');
  740. const links = JSON.parse(listL);
  741. console.log(links);
  742. // List of words
  743. var myWords = links;
  744. // set the dimensions and margins of the graph
  745. var margin = {top: 10, right: 10, bottom: 10, left: 10},
  746. width = 850 - margin.left - margin.right,
  747. height = 500 - margin.top - margin.bottom;
  748. // append the svg object to the body of the page
  749. var svg = d3.select("#myWordCloud").append("svg")
  750. .attr("id", "wordcloudNetwork")
  751. .attr("width", width + margin.left + margin.right)
  752. .attr("height", height + margin.top + margin.bottom)
  753. .append("g")
  754. .attr("transform",
  755. "translate(" + (width/2-50) + "," + (height/2+20) + ")");
  756. // Constructs a new cloud layout instance. It run an algorithm to find the position of words that suits your requirements
  757. // Wordcloud features that are different from one word to the other must be here
  758. var layout = d3.layout.cloud()
  759. .size([width, height])
  760. .words(myWords.map(function(d) { return {text: d.word, size:d.size/2}; }))
  761. .padding(5) //space between words
  762. .rotate(function() { return ~~(Math.random() * 2);})
  763. .fontSize(function(d) { return d.size + 6; }) // font size of words
  764. .on("end", draw);
  765. layout.start();
  766. // This function takes the output of 'layout' above and draw the words
  767. // Wordcloud features that are THE SAME from one word to the other can be here
  768. function draw(words) {
  769. var cloud = svg.selectAll("g text")
  770. .data(words, function(d) { return d.text; })
  771. //Entering words
  772. cloud.enter()
  773. .append("text")
  774. .style("font-family", "Impact")
  775. .attr("text-anchor", "middle")
  776. .attr('font-size', 1)
  777. .text(function(d) { return d.text; });
  778. //Entering and existing words
  779. cloud
  780. .transition()
  781. .duration(600)
  782. .style("font-size", function(d) { return d.size + "px"; })
  783. .attr("transform", function(d) {
  784. return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
  785. })
  786. .style("fill-opacity", 1);
  787. //Exiting words
  788. cloud.exit()
  789. .transition()
  790. .duration(200)
  791. .style('fill-opacity', 1e-6)
  792. .attr('font-size', 1)
  793. .remove();
  794. }
  795. var wordIcon = "<div id='users_icon' class='no_info_icon'> \
  796. <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 512'> \
  797. <!--! 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'/> \
  798. </svg> \
  799. <p>Nessuna persona trovata</p> \
  800. </div>";
  801. if (words.length == 0) {
  802. $("#wordcloudNetwork").css("display", "none");
  803. $("#references_network").css("display", "none");
  804. document.getElementById("myWordCloud").innerHTML = wordIcon;
  805. }
  806. }
  807. $(document).on("click", ".luogo", function (ev) {
  808. var link = this.id;
  809. //alert(nome_autore);
  810. //$('#myModal').text("");
  811. window.open("Luogo.html?link="+this.id);
  812. });
  813. $(document).on("click", ".persona", function (ev) {
  814. var link = this.id;
  815. //alert(nome_autore);
  816. //$('#myModal').text("");
  817. window.open("Persona.html?link="+this.id);
  818. });
  819. $(document).on("click", ".lettera", function (ev) {
  820. var link = this.id;
  821. //alert(nome_autore);
  822. //$('#myModal').text("");
  823. window.open("lettera.html?link="+this.id);
  824. });
  825. $(document).on("click", ".object", function (ev) {
  826. var link = this.id;
  827. //alert(nome_autore);
  828. //$('#myModal').text("");
  829. window.open("object.html?link="+this.id);
  830. });
  831. $(document).on("click", ".hyp", function (ev) {
  832. var link = this.id;
  833. $("#myModal").empty();
  834. $("#myModal").css("display", "block");
  835. $('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
  836. link + "</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  837. });
  838. $(document).on("click", ".artwork", function (ev) {
  839. var link = this.id;
  840. //alert(nome_autore);
  841. //$('#myModal').text("");
  842. window.open("OA.html?link="+this.id);
  843. });
  844. $(document).on("click", ".close", function (ev) {
  845. var link = this.id;
  846. //alert(nome_autore);
  847. //$('#myModal').text("");
  848. $("#myModal").css("display", "none");
  849. });
  850. $(document).on("click", ".back", function (ev) {
  851. $("#myTab").css("display", "none");
  852. });
  853. $(document).on("click", ".cit", function (ev) {
  854. var author ="RESTORE. smart access to digital heritage and memory"
  855. var year = new Date().getFullYear()
  856. var today = new Date();
  857. var dd = String(today.getDate()).padStart(2, '0');
  858. var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  859. var yyyy = today.getFullYear();
  860. today = dd + '/' + mm + '/' + yyyy;
  861. var link = this.id;
  862. //alert(nome_autore);
  863. //$('#myModal').text("");
  864. $("#myModal").empty();
  865. $("#myModal").css("display", "block");
  866. $('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
  867. author + " " + year + ", accesso effettuato: " + today + ", &lt;" + link + "&gt;</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  868. });
  869. function copyToClipboard(text) {
  870. var sampleTextarea = document.createElement("textarea");
  871. document.body.appendChild(sampleTextarea);
  872. sampleTextarea.value = text; //save main text in it
  873. sampleTextarea.select(); //select textarea contenrs
  874. document.execCommand("copy");
  875. document.body.removeChild(sampleTextarea);
  876. }
  877. function myFunction(){
  878. var copy = document.getElementById("myInput");
  879. copyText = copy.textContent;
  880. copyToClipboard(copyText);
  881. //copyToClipboard(copyText.value);
  882. }