map.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  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. query = prefixes + " SELECT DISTINCT ?graph ?name_place ?coordinates {\
  38. GRAPH ?graph {<" + thisUrlParams.link + "> crm:P168_place_is_defined_by ?coordinates;\
  39. rdfs:label ?name_place .\
  40. }\
  41. }"
  42. queryRiferimenti = prefixes + " SELECT DISTINCT ?references {\
  43. <" + thisUrlParams.link + "> owl:sameAs ?references\
  44. }"
  45. queryToponimi = prefixes + " SELECT DISTINCT ?toponimi {\
  46. <" + thisUrlParams.link + "> crm:P1_is_identified_by ?uri_toponym .\
  47. ?uri_toponym rdfs:label ?toponimi\
  48. }"
  49. queryRicezione = prefixes + " SELECT DISTINCT ?segnatura ?document_uri ?document_name ?time_span ?InfObj \
  50. WHERE { \
  51. <" + thisUrlParams.link + "> owl:sameAs ?place . \
  52. ?event_to crm:P26_moved_to ?place ; \
  53. rdf:type crm:EL3_Receive_Letter ; \
  54. rdfs:subClassOf ?event . \
  55. ?document_uri crm:P25i_moved_by ?event ; \
  56. rdfs:label ?document_name . \
  57. ?document_uri crm:P1_is_identified_by ?uriSegnatura . \
  58. ?uriSegnatura crm:P2_has_type 'Segnatura' ; \
  59. rdfs:label ?segnatura . \
  60. OPTIONAL {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?document_uri crm:P128_carries ?InfObj . \
  61. ?InfObj rdf:type crm:E73_Information_Object} }. \
  62. OPTIONAL {?event_to crm:P4_has_time-span ?uri_ts . \
  63. ?uri_ts rdfs:label ?time_span . } \
  64. } "
  65. queryInvio = prefixes + " SELECT DISTINCT ?segnatura ?document_uri ?document_name ?time_span ?InfObj \
  66. WHERE { \
  67. <" + thisUrlParams.link + "> owl:sameAs ?place . \
  68. ?event_to crm:P27_moved_from ?place ; \
  69. rdf:type crm:EL2_Send_Letter ; \
  70. rdfs:subClassOf ?event . \
  71. ?document_uri crm:P25i_moved_by ?event ; \
  72. rdfs:label ?document_name . \
  73. ?document_uri crm:P1_is_identified_by ?uriSegnatura . \
  74. ?uriSegnatura crm:P2_has_type 'Segnatura' ; \
  75. rdfs:label ?segnatura . \
  76. OPTIONAL {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?document_uri crm:P128_carries ?InfObj . \
  77. ?InfObj rdf:type crm:E73_Information_Object} }. \
  78. OPTIONAL {?event_to crm:P4_has_time-span ?uri_ts . \
  79. ?uri_ts rdfs:label ?time_span . } \
  80. }"
  81. queryCitazione = prefixes + " SELECT DISTINCT ?segnatura ?document_uri ?document_name SAMPLE(?time_span) AS ?time_span ?InfObj \
  82. WHERE { \
  83. <" + thisUrlParams.link + "> crm:P1_is_identified_by ?toponym . \
  84. ?InfObj crm:P67_refers_to ?toponym . \
  85. ?document_uri crm:P128_carries ?InfObj ; \
  86. rdfs:label ?document_name . \
  87. OPTIONAL {?document_uri crm:P1_is_identified_by ?uriSegnatura . \
  88. ?uriSegnatura crm:P2_has_type 'Segnatura' ; \
  89. rdfs:label ?segnatura . } \
  90. OPTIONAL {?document_uri crm:P25i_moved_by ?event . \
  91. ?event_send rdfs:subClassOf ?event ; \
  92. rdf:type crm:EL2_Send_Letter ; \
  93. crm:P4_has_time-span ?uri_ts . \
  94. ?uri_ts rdfs:label ?time_span . } \
  95. } "
  96. queryPersone = prefixes + " SELECT DISTINCT ?role ?range ?label COUNT(?range) AS ?count \
  97. WHERE{ \
  98. {?place owl:sameAs <" + thisUrlParams.link + "> . \
  99. ?event_to crm:P26_moved_to ?place ; \
  100. rdf:type crm:EL3_Receive_Letter ; \
  101. crm:P01_has_domain ?domain . \
  102. ?domain crm:P02_has_range ?range ; \
  103. crm:P14.1_in_the_role_of ?uri_role . \
  104. ?uri_role rdfs:label ?role . \
  105. ?range rdfs:label ?label . \
  106. } UNION { \
  107. ?place owl:sameAs <" + thisUrlParams.link + "> . \
  108. ?event_to crm:P27_moved_from ?place ; \
  109. rdf:type crm:EL2_Send_Letter ; \
  110. crm:P01_has_domain ?domain . \
  111. ?domain crm:P02_has_range ?range ; \
  112. crm:P14.1_in_the_role_of ?uri_role . \
  113. ?uri_role rdfs:label ?role . \
  114. ?range rdfs:label ?label . \
  115. } \
  116. } GROUP BY ?role ?range ?label"
  117. queryCount = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
  118. WHERE{ \
  119. ?place_to owl:sameAs <" + thisUrlParams.link + "> . \
  120. ?event_to crm:P26_moved_to ?place_to ; \
  121. rdf:type crm:EL3_Receive_Letter ; \
  122. rdfs:subClassOf ?event . \
  123. ?event_from rdfs:subClassOf ?event ; \
  124. rdf:type crm:EL2_Send_Letter ; \
  125. crm:P27_moved_from ?place . \
  126. ?place rdfs:label ?label \
  127. } \
  128. ORDER BY DESC (?Count)"
  129. queryCount2 = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
  130. WHERE{ \
  131. ?place_from owl:sameAs <" + thisUrlParams.link + "> . \
  132. ?event_from crm:P27_moved_from ?place_from ; \
  133. rdf:type crm:EL2_Send_Letter ; \
  134. rdfs:subClassOf ?event . \
  135. ?event_to rdfs:subClassOf ?event ; \
  136. rdf:type crm:EL2_Send_Letter ; \
  137. crm:P27_moved_from ?place . \
  138. ?place rdfs:label ?label . \
  139. } \
  140. ORDER BY DESC (?Count) "
  141. queryURL = prepareQueryURL(query);
  142. queryRef = prepareQueryURL(queryRiferimenti);
  143. queryTopo = prepareQueryURL(queryToponimi);
  144. queryRec = prepareQueryURL(queryRicezione);
  145. querySend = prepareQueryURL(queryInvio);
  146. queryCit = prepareQueryURL(queryCitazione);
  147. queryPer = prepareQueryURL(queryPersone);
  148. queryCon1 = prepareQueryURL(queryCount);
  149. queryCon2 = prepareQueryURL(queryCount2);
  150. response = $.ajax({//OGGETTO
  151. url: queryURL,
  152. dataType: "json",
  153. success: function (data){
  154. handle_data(data);
  155. },
  156. error: function (e) {}
  157. });
  158. response_ref = $.ajax({//OGGETTO
  159. url: queryRef,
  160. dataType: "json",
  161. success: function (data){
  162. handle_ref(data);
  163. },
  164. error: function (e) {}
  165. });
  166. response_top = $.ajax({//OGGETTO
  167. url: queryTopo,
  168. dataType: "json",
  169. success: function (data){
  170. handle_toponym(data);
  171. },
  172. error: function (e) {}
  173. });
  174. response_receive = $.ajax({//OGGETTO
  175. url: queryRec,
  176. dataType: "json",
  177. success: function (data){
  178. handle_receive(data);
  179. },
  180. error: function (e) {}
  181. });
  182. response_send = $.ajax({//OGGETTO
  183. url: querySend,
  184. dataType: "json",
  185. success: function (data){
  186. handle_send(data);
  187. },
  188. error: function (e) {}
  189. });
  190. response_cit = $.ajax({//OGGETTO
  191. url: queryCit,
  192. dataType: "json",
  193. success: function (data){
  194. handle_cit(data);
  195. },
  196. error: function (e) {}
  197. });
  198. response_per = $.ajax({//OGGETTO
  199. url: queryPer,
  200. dataType: "json",
  201. success: function (data){
  202. handle_persons(data);
  203. },
  204. error: function (e) {}
  205. });
  206. responseCountA = $.ajax({//OGGETTO
  207. url: queryCon1,
  208. dataType: "json",
  209. success: function (data){
  210. handle_count(data);
  211. },
  212. error: function (e) {}
  213. });
  214. responseCountP = $.ajax({//OGGETTO
  215. url: queryCon2,
  216. dataType: "json",
  217. success: function (data){
  218. handle_count2(data);
  219. },
  220. error: function (e) {}
  221. });
  222. function handle_data(json) {
  223. console.log(json);
  224. const locations = [];
  225. $.each(
  226. json['results']['bindings'],
  227. function (index, value) {
  228. const loc = []
  229. var graph = value['graph']['value'];
  230. var label = value['name_place']['value'];
  231. var coord = value['coordinates']['value'];
  232. var variante = "";
  233. var note = "";
  234. const coordinates = coord.split(", ");
  235. loc.push(label);
  236. loc.push(coordinates[0]);
  237. loc.push(coordinates[1]);
  238. locations.push(loc);
  239. if (value.hasOwnProperty('variant')) {
  240. variante = value['variant']['value'];
  241. } else {
  242. variante = "Nessun risultato trovato";
  243. }
  244. if (value.hasOwnProperty('notes')) {
  245. note = value['notes']['value'];
  246. } else {
  247. note = "Nessuna informazione trovata";
  248. }
  249. document.getElementById("grafo").innerHTML = graph;
  250. document.getElementById("nome_luogo").innerHTML = label;
  251. document.getElementById("place_name").innerHTML = label;
  252. document.getElementById("coords").innerHTML = coord;
  253. document.getElementById("note").innerHTML = note;
  254. document.getElementById("variants").innerHTML = variante;
  255. document.getElementById("nome_lu").innerHTML = label;
  256. document.getElementById("nome_lp").innerHTML = label;
  257. document.getElementById("nome_ll").innerHTML = label;
  258. document.getElementById("nome_lg").innerHTML = label;
  259. });
  260. var map = L.map('map').setView([locations[0][1], locations[0][2]], 7);
  261. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  262. L.tileLayer(
  263. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  264. attribution: '&copy; ' + mapLink + ' Contributors',
  265. maxZoom: 18,
  266. }).addTo(map);
  267. for (var i = 0; i < locations.length; i++) {
  268. marker = new L.marker([locations[i][1], locations[i][2]])
  269. .bindPopup(locations[i][0])
  270. .addTo(map);
  271. }
  272. }
  273. function handle_ref(json) {
  274. console.log(json);
  275. const references = [];
  276. var list_ref = "";
  277. $.each(
  278. json['results']['bindings'],
  279. function (index, value) {
  280. var ref = value['references']['value'];
  281. references.push(ref);
  282. });
  283. for (i=0; i<references.length; i++) {
  284. list_ref += "<a target='_blank' href='" + references[i] + "'>" + references[i] + "</a>";
  285. }
  286. document.getElementById("riferimenti").innerHTML = list_ref;
  287. }
  288. function handle_toponym(json) {
  289. console.log(json);
  290. const toponym = [];
  291. $.each(
  292. json['results']['bindings'],
  293. function (index, value) {
  294. var topo = value['toponimi']['value'];
  295. toponym.push(" " + topo);
  296. });
  297. document.getElementById("toponimi").innerHTML = toponym;
  298. }
  299. function handle_receive(json) {
  300. console.log(json);
  301. const received = [];
  302. var i=0;
  303. $.each(
  304. json['results']['bindings'],
  305. function (index, value) {
  306. uri = value['document_uri']['value'];
  307. title = value['document_name']['value'];
  308. segnatura = value['segnatura']['value'];
  309. var data = "";
  310. var InfObj = "";
  311. if (value.hasOwnProperty('time_span')) {
  312. data = value['time_span']['value'];
  313. }
  314. if (value.hasOwnProperty('InfObj')) {
  315. InfObj = value['InfObj']['value'];
  316. }
  317. received.push([uri, title, segnatura, data, InfObj]);
  318. });
  319. var myArray = "";
  320. for (var i=0; i<received.length; i++) {
  321. var letter = '<a href=' + received[i][0] + ' target="_blank">' + received[i][1] + '</a>';
  322. var infObject_button = "";
  323. if (received[i][2] != "") {
  324. letter = letter + "<br />Segnatura: " + received[i][2];
  325. }
  326. if (received[i][3] != "") {
  327. letter = letter + "<br />Data: " + received[i][3];
  328. }
  329. if (received[i][4] != "") {
  330. infObject_button += '<button type="button" id="' + received[i][4] +
  331. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  332. } else {
  333. infObject_button += '<button type="button" id="' + received[i][0] +
  334. '" class="object btn btn-default" alt="oggetto" title="' + received[i][1] +
  335. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  336. }
  337. myArray += '<div class="row res"><div class="col-8"><p>'+ letter +'</p></div>' +
  338. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  339. '<button type="button" id="' + received[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>' +
  340. '<button type="button" id="' + received[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  341. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + received[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>';
  342. }
  343. document.getElementById("n_receive").innerHTML = received.length;
  344. document.getElementById("object_receive").innerHTML = myArray;
  345. if (received.length==0) {
  346. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  347. document.getElementById("object_receive").innerHTML = messaggio;
  348. }
  349. }
  350. function handle_send(json) {
  351. console.log(json);
  352. const sent = [];
  353. var i=0;
  354. $.each(
  355. json['results']['bindings'],
  356. function (index, value) {
  357. uri = value['document_uri']['value'];
  358. title = value['document_name']['value'];
  359. segnatura = value['segnatura']['value'];
  360. var data = "";
  361. var InfObj = "";
  362. if (value.hasOwnProperty('time_span')) {
  363. data = value['time_span']['value'];
  364. }
  365. if (value.hasOwnProperty('InfObj')) {
  366. InfObj = value['InfObj']['value'];
  367. }
  368. sent.push([uri, title, segnatura, data, InfObj]);
  369. });
  370. var myArray = "";
  371. for (var i=0; i<sent.length; i++) {
  372. var letter = '<a href=' + sent[i][0] + ' target="_blank">' + sent[i][1] + '</a>';
  373. var infObject_button = "";
  374. if (sent[i][2] != "") {
  375. letter = letter + "<br />Segnatura: " + sent[i][2];
  376. }
  377. if (sent[i][3] != "") {
  378. letter = letter + "<br />Data: " + sent[i][3];
  379. }
  380. if (sent[i][4] != "") {
  381. infObject_button += '<button type="button" id="' + sent[i][4] +
  382. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  383. } else {
  384. infObject_button += '<button type="button" id="' + sent[i][0] +
  385. '" class="object btn btn-default" alt="oggetto" title="' + sent[i][1] +
  386. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  387. }
  388. myArray += '<div class="row res"><div class="col-8"><p>'+ letter +'</p></div>' +
  389. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  390. '<button type="button" id="' + sent[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>' +
  391. '<button type="button" id="' + sent[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  392. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + sent[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>';
  393. }
  394. document.getElementById("n_send").innerHTML = sent.length;
  395. document.getElementById("object_send").innerHTML = myArray;
  396. if (sent.length==0) {
  397. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  398. document.getElementById("object_send").innerHTML = messaggio;
  399. }
  400. }
  401. function handle_cit(json) {
  402. console.log(json);
  403. const citations = [];
  404. var i=0;
  405. $.each(
  406. json['results']['bindings'],
  407. function (index, value) {
  408. uri = value['document_uri']['value'];
  409. title = value['document_name']['value'];
  410. segnatura = value['segnatura']['value'];
  411. var data = "";
  412. var InfObj = "";
  413. if (value.hasOwnProperty('time_span')) {
  414. data = value['time_span']['value'];
  415. }
  416. if (value.hasOwnProperty('InfObj')) {
  417. InfObj = value['InfObj']['value'];
  418. }
  419. citations.push([uri, title, segnatura, data, InfObj]);
  420. });
  421. var myArray = "";
  422. for (var i=0; i<citations.length; i++) {
  423. var letter = '<a href=' + citations[i][0] + ' target="_blank">' + citations[i][1] + '</a>';
  424. var infObject_button = "";
  425. if (citations[i][2] != "") {
  426. letter = letter + "<br />Segnatura: " + citations[i][2];
  427. }
  428. if (citations[i][3] != "") {
  429. letter = letter + "<br />Data: " + citations[i][3];
  430. }
  431. if (citations[i][4] != "") {
  432. infObject_button += '<button type="button" id="' + citations[i][4] +
  433. '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  434. } else {
  435. infObject_button += '<button type="button" id="' + citations[i][0] +
  436. '" class="object btn btn-default" alt="oggetto" title="' + citations[i][1] +
  437. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  438. }
  439. myArray += '<div class="row res"><div class="col-8"><p>'+ letter +'</p></div>' +
  440. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  441. '<button type="button" id="' + citations[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>' +
  442. '<button type="button" id="' + citations[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  443. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + citations[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>';
  444. }
  445. document.getElementById("n_cit").innerHTML = citations.length;
  446. document.getElementById("object_cit").innerHTML = myArray;
  447. if (citations.length==0) {
  448. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  449. document.getElementById("object_cit").innerHTML = messaggio;
  450. }
  451. }
  452. function handle_persons(json) {
  453. console.log(json);
  454. const people = [];
  455. const person_names = [];
  456. const person_events = [];
  457. var Person = "";
  458. $.each(
  459. json['results']['bindings'],
  460. function (index, value) {
  461. var uri = value['range']['value'];
  462. var label = value['label']['value'];
  463. var ruolo = value['role']['value']
  464. var count = value['count']['value']
  465. var evento = ruolo + ": " + count
  466. person_events.push([uri, label, evento]);
  467. if (!person_names.includes(uri)) {
  468. person_names.push([uri, label]);
  469. }
  470. });
  471. for (var k=0; k<person_names.length; k++) {
  472. const tempArray = [];
  473. var uri = person_names[k][0];
  474. var nome = person_names[k][1]
  475. tempArray.push(uri);
  476. tempArray.push(nome);
  477. for (var y=0; y<person_events.length; y++) {
  478. var ev = person_events[y][2];
  479. if (person_names[k][0] == person_events[y][0]) {
  480. tempArray.push(ev);
  481. }
  482. }
  483. people.push(tempArray);
  484. }
  485. for (var i=0; i<people.length; i++) {
  486. var info = "";
  487. for (var h=2; h<people[i].length; h++) {
  488. info += people[i][h] + ' occorrenze<br />';
  489. }
  490. Person += '<div class="row res"><div class="col-8">' +
  491. '<a href=' + people[i][0] + ' target="_blank">' + people[i][1] + '</a><br />' + info + '</div>' +
  492. '<div class="col d-flex align-items-start justify-content-end"><button type="button" id="' + people[i][0] + '" class="persona btn btn-default" alt="persona" title="' +
  493. people[i][1] + '"><i class="fa fa-user"></i><p class="btn-text">Scheda Persona</p></button>' +
  494. '<button type="button" id="' + people[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>' +
  495. /*DA QUI HYPERLINK ->*/'<button type="button" id="' + people[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  496. /*DA QUI LOD ->*/'<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + people[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>';
  497. }
  498. document.getElementById("n_per").innerHTML = people.length;
  499. document.getElementById("object_per").innerHTML = Person;
  500. if (people.length==0) {
  501. var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
  502. document.getElementById("object_per").innerHTML = messaggio;
  503. }
  504. }
  505. function handle_count(json) {
  506. console.log(json);
  507. const toponimi = [];
  508. const dataToponimi = [];
  509. var max = 0;
  510. $.each(
  511. json['results']['bindings'],
  512. function (index, value) {
  513. const topo = [];
  514. var toponimo = value['label']['value'];
  515. var count = value['Count']['value'];
  516. var temp = parseInt(count);
  517. toponimi.push(toponimo);
  518. dataToponimi.push([toponimo, count]);
  519. if (temp>max) {
  520. max = temp;
  521. }
  522. });
  523. // set the dimensions and margins of the graph
  524. var margin = {top: 20, right: 30, bottom: 40, left: 90},
  525. width = 460 - margin.left - margin.right,
  526. height = 400 - margin.top - margin.bottom;
  527. // append the svg object to the body of the page
  528. var svg = d3.select("#my_dataviz")
  529. .append("svg")
  530. .attr("width", width + margin.left + margin.right)
  531. .attr("height", height + margin.top + margin.bottom)
  532. .append("g")
  533. .attr("transform",
  534. "translate(" + margin.left + "," + margin.top + ")");
  535. // Parse the Data
  536. //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
  537. // Add X axis
  538. var x = d3.scaleLinear()
  539. .domain([0, max])
  540. .range([ 0, width]);
  541. svg.append("g")
  542. .attr("transform", "translate(0," + height + ")")
  543. .call(d3.axisBottom(x))
  544. .selectAll("text")
  545. .attr("transform", "translate(-10,0)rotate(-45)")
  546. .style("text-anchor", "end");
  547. // Y axis
  548. var y = d3.scaleBand()
  549. .range([ 0, height ])
  550. .domain(toponimi)
  551. .padding(.1);
  552. svg.append("g")
  553. .call(d3.axisLeft(y))
  554. //Bars
  555. svg.selectAll("myRect")
  556. .data(dataToponimi)
  557. .enter()
  558. .append("rect")
  559. .attr("x", x(0) )
  560. .attr("y", function(d) { return y(d[0]); })
  561. .attr("width", function(d) { return x(d[1]); })
  562. .attr("height", y.bandwidth() )
  563. .attr("fill", "#69b3a2")
  564. /*var texts = svg.selectAll("myRect")
  565. .data(dataToponimi)
  566. .enter()
  567. .append("text");
  568. texts.attr("x", function(d){ return d[1] / 4 - 20})
  569. .attr("y", function(d,i){ return 22.26*i +20})
  570. .attr("text-anchor", "middle")
  571. .attr("fill", "#fff")
  572. .text(function(d){ return d[1]});*/
  573. }
  574. function handle_count2(json) {
  575. console.log(json);
  576. const toponimi = [];
  577. const dataToponimi = [];
  578. const values = [];
  579. var max = 0;
  580. $.each(
  581. json['results']['bindings'],
  582. function (index, value) {
  583. const topo = [];
  584. var toponimo = value['label']['value'];
  585. var count = value['Count']['value'];
  586. var temp = parseInt(count);
  587. toponimi.push(toponimo);
  588. dataToponimi.push([toponimo, count]);
  589. if (temp>max) {
  590. max = temp;
  591. }
  592. });
  593. // set the dimensions and margins of the graph
  594. var margin = {top: 20, right: 30, bottom: 40, left: 90},
  595. width = 460 - margin.left - margin.right,
  596. height = 400 - margin.top - margin.bottom;
  597. // append the svg object to the body of the page
  598. var svg = d3.select("#my_dataviz2")
  599. .append("svg")
  600. .attr("width", width + margin.left + margin.right)
  601. .attr("height", height + margin.top + margin.bottom)
  602. .append("g")
  603. .attr("transform",
  604. "translate(" + margin.left + "," + margin.top + ")");
  605. // Parse the Data
  606. //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
  607. // Add X axis
  608. var x = d3.scaleLinear()
  609. .domain([0, max])
  610. .range([ 0, width]);
  611. svg.append("g")
  612. .attr("transform", "translate(0," + height + ")")
  613. .call(d3.axisBottom(x))
  614. .selectAll("text")
  615. .attr("transform", "translate(-10,0)rotate(-45)")
  616. .style("text-anchor", "end");
  617. // Y axis
  618. var y = d3.scaleBand()
  619. .range([ 0, height ])
  620. .domain(toponimi)
  621. .padding(.1);
  622. svg.append("g")
  623. .call(d3.axisLeft(y))
  624. //Bars
  625. svg.selectAll("myRect")
  626. .data(dataToponimi)
  627. .enter()
  628. .append("rect")
  629. .attr("x", x(0) )
  630. .attr("y", function(d) { return y(d[0]); })
  631. .attr("width", function(d) { return x(d[1]); })
  632. .attr("height", y.bandwidth() )
  633. .attr("fill", "#69b3a2")
  634. svg.selectAll("text2")
  635. .data(dataToponimi)
  636. .enter().append("text2")
  637. .text(function(d) {return d[1]})
  638. .attr("class", "text")
  639. }
  640. function open_info() {
  641. document.getElementById("info_luogo").style.display = "block";
  642. document.getElementById("place_info").style.display = "block";
  643. document.getElementById("topo").style.display = "none";
  644. document.getElementById("rif").style.display = "none";
  645. }
  646. function open_toponimi() {
  647. document.getElementById("info_luogo").style.display = "block";
  648. document.getElementById("place_info").style.display = "none";
  649. document.getElementById("topo").style.display = "block";
  650. document.getElementById("rif").style.display = "none";
  651. }
  652. function open_riferimenti() {
  653. document.getElementById("info_luogo").style.display = "block";
  654. document.getElementById("place_info").style.display = "none";
  655. document.getElementById("topo").style.display = "none";
  656. document.getElementById("rif").style.display = "block";
  657. }
  658. function open_collegamenti() {
  659. document.getElementById("references").style.display = "flex";
  660. document.getElementById("statistiche").style.display = "none";
  661. document.getElementById("regole_associazione").style.display = "none";
  662. }
  663. function open_statistiche() {
  664. document.getElementById("references").style.display = "none";
  665. document.getElementById("statistiche").style.display = "flex";
  666. document.getElementById("regole_associazione").style.display = "none";
  667. }
  668. function open_correlazioni() {
  669. document.getElementById("references").style.display = "none";
  670. document.getElementById("statistiche").style.display = "none";
  671. document.getElementById("regole_associazione").style.display = "flex";
  672. }
  673. /*
  674. var header = document.getElementById("ref_buttons");
  675. var btns = header.getElementsByClassName("btn");
  676. for (var i = 0; i < btns.length; i++) {
  677. btns[i].addEventListener("click", function() {
  678. var current = document.getElementsByClassName("active");
  679. current[0].className = current[0].className.replace(" active", "");
  680. this.className += " active";
  681. });
  682. }
  683. */
  684. //out = "";
  685. //for(i = 0; i < resultArray.length; i++){
  686. // out = out + JSON.stringify(resultArray[i])
  687. //}
  688. //queryStringOutput = (queryStringOutput + out).replace("}{",",");
  689. /*
  690. var locations = [
  691. ["LOCATION_1", 11.8166, 122.0942],
  692. ["LOCATION_2", 11.9804, 121.9189],
  693. ["LOCATION_3", 10.7202, 122.5621],
  694. ["LOCATION_4", 11.3889, 122.6277],
  695. ["LOCATION_5", 10.5929, 122.6325]
  696. ];
  697. var map = L.map('map').setView([11.206051, 122.447886], 8);
  698. mapLink =
  699. '<a href="http://openstreetmap.org">OpenStreetMap</a>';
  700. L.tileLayer(
  701. 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  702. attribution: '&copy; ' + mapLink + ' Contributors',
  703. maxZoom: 18,
  704. }).addTo(map);
  705. for (var i = 0; i < locations.length; i++) {
  706. marker = new L.marker([locations[i][1], locations[i][2]])
  707. .bindPopup(locations[i][0])
  708. .addTo(map);
  709. }
  710. */
  711. $(document).on("click", ".persona", function (ev) {
  712. var link = this.id;
  713. //alert(nome_autore);
  714. //$('#myModal').text("");
  715. window.open("Persona.html?link="+this.id);
  716. });
  717. $(document).on("click", ".lettera", function (ev) {
  718. var link = this.id;
  719. //alert(nome_autore);
  720. //$('#myModal').text("");
  721. window.open("lettera.html?link="+this.id);
  722. });
  723. $(document).on("click", ".object", function (ev) {
  724. var link = this.id;
  725. //alert(nome_autore);
  726. //$('#myModal').text("");
  727. window.open("object.html?link="+this.id);
  728. });
  729. $(document).on("click", ".hyp", function (ev) {
  730. var link = this.id;
  731. $("#myModal").empty();
  732. $("#myModal").css("display", "block");
  733. $('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" +
  734. link + "</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  735. });
  736. $(document).on("click", ".close", function (ev) {
  737. var link = this.id;
  738. //alert(nome_autore);
  739. //$('#myModal').text("");
  740. $("#myModal").css("display", "none");
  741. });
  742. $(document).on("click", ".back", function (ev) {
  743. $("#myTab").css("display", "none");
  744. });
  745. $(document).on("click", ".cit", function (ev) {
  746. var author ="RESTORE. smart access to digital heritage and memory"
  747. var year = new Date().getFullYear()
  748. var today = new Date();
  749. var dd = String(today.getDate()).padStart(2, '0');
  750. var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  751. var yyyy = today.getFullYear();
  752. today = dd + '/' + mm + '/' + yyyy;
  753. var link = this.id;
  754. //alert(nome_autore);
  755. //$('#myModal').text("");
  756. $("#myModal").empty();
  757. $("#myModal").css("display", "block");
  758. $('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" +
  759. author + " " + year + ", accesso effettuato: " + today + ", &lt;" + link + "&gt;</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  760. });
  761. function copyToClipboard(text) {
  762. var sampleTextarea = document.createElement("textarea");
  763. document.body.appendChild(sampleTextarea);
  764. sampleTextarea.value = text; //save main text in it
  765. sampleTextarea.select(); //select textarea contenrs
  766. document.execCommand("copy");
  767. document.body.removeChild(sampleTextarea);
  768. }
  769. function myFunction(){
  770. var copy = document.getElementById("myInput");
  771. copyText = copy.textContent;
  772. copyToClipboard(copyText);
  773. //copyToClipboard(copyText.value);
  774. }