map.js 32 KB

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