people.js 33 KB

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