geospace.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. /*var link = thisUrlParams.link;
  2. prefixes = queryManager['prefixes']['all'];
  3. queryURL = prefixes + (queryManager['queryTimeSpace']['queryTimeLetters']);
  4. doJsonQuery(queryURL).done(function(data) { manageJson(data); });*/
  5. // Raccatto i parametri dall'URL -- mi aspetto un parametro di nome 'link'!
  6. thisUrlParams = {};
  7. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  8. thisUrlParams[key] = value;
  9. });
  10. console.log('URL get params: ', thisUrlParams.params);
  11. var params = thisUrlParams.params;
  12. const pp = params.split(";");
  13. var tipo = pp[0];
  14. var sigleFinished = false;
  15. var lemmaFinished = false;
  16. var mappaFinished = false;
  17. prefixes = queryManager['prefixes']['all'];
  18. if (tipo=="lemma") {
  19. var uri_lemma = pp[1];
  20. var lemma = pp[2].replace(/%20/g, " ");
  21. querySigle = prefixes + (queryManager['queryRES']['queryTrovaSigla']).replaceAll('{URI}', uri_lemma);
  22. queryEsplora = prefixes + (queryManager['queryRES']['queryEsploraDocumenti']).replaceAll('{URI}', uri_lemma);
  23. queryMappa = prefixes + (queryManager['queryRES']['queryEsploraMappa']).replaceAll('{URI}', uri_lemma);
  24. doJsonQuery(querySigle).done(function(r) { manageArraySigle(r, lemma); });
  25. doJsonQuery(queryEsplora).done(function(r) { handleLemma(r, lemma); });
  26. doJsonQuery(queryMappa).done(function(r) { manageJson(r, lemma); });
  27. }
  28. if (tipo=="lettera") {
  29. var uri_mittente = pp[2];
  30. var uri_destinatario = pp[4];
  31. var mittente = pp[1].replace(/%20/g, " ");
  32. var destinatario = pp[3].replace(/%20/g, " ");
  33. queryLettere = prefixes + (queryManager['queryRES']['queryExchange']).replace('{MITTENTE}', uri_mittente).replace('{DESTINATARIO}', uri_destinatario);
  34. doJsonQuery(queryLettere).done(function(r) { handle_Letters(r, mittente, destinatario); });
  35. }
  36. //console.log(luoghi);
  37. var latitude = 43.8777049;
  38. var longitude = 11.102228;
  39. var mapIcon = "<div id='map_icon' class='no_info_icon'> \
  40. <svg xmlns='http://www.w3.org/2000/svg' width='30' viewBox='0 0 576 512'> \
  41. <path d='M408 120C408 174.6 334.9 271.9 302.8 311.1C295.1 321.6 280.9 321.6 273.2 311.1C241.1 271.9 168 174.6 168 120C168 53.73 221.7 0 288 0C354.3 0 408 53.73 408 120zM288 152C310.1 152 328 134.1 328 112C328 89.91 310.1 72 288 72C265.9 72 248 89.91 248 112C248 134.1 265.9 152 288 152zM425.6 179.8C426.1 178.6 426.6 177.4 427.1 176.1L543.1 129.7C558.9 123.4 576 135 576 152V422.8C576 432.6 570 441.4 560.9 445.1L416 503V200.4C419.5 193.5 422.7 186.7 425.6 179.8zM150.4 179.8C153.3 186.7 156.5 193.5 160 200.4V451.8L32.91 502.7C17.15 508.1 0 497.4 0 480.4V209.6C0 199.8 5.975 190.1 15.09 187.3L137.6 138.3C140 152.5 144.9 166.6 150.4 179.8H150.4zM327.8 331.1C341.7 314.6 363.5 286.3 384 255V504.3L192 449.4V255C212.5 286.3 234.3 314.6 248.2 331.1C268.7 357.6 307.3 357.6 327.8 331.1L327.8 331.1z'/> \
  42. </svg> \
  43. <p>Nessun luogo trovato</p> \
  44. </div>";
  45. var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
  46. cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade, Points &copy 2012 LINZ',
  47. cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 17, attribution: cloudmadeAttribution}),
  48. latlng = new L.LatLng(latitude, longitude);
  49. map = new L.Map('map', {center: latlng, zoom: 5, layers: [cloudmade]});
  50. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  51. //var markers = new L.MarkerClusterGroup();
  52. //var markerList = [];
  53. var geo = new L.tileLayer(
  54. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  55. attribution: '&copy; ' + mapLink + ' Contributors',
  56. maxZoom: 18,
  57. }).addTo(map);
  58. var markerList = [];
  59. var markers = new L.MarkerClusterGroup();
  60. let anni = [];
  61. let eventi = {};
  62. let testi_ovi = [];
  63. function handleLemma(json, lemma) {
  64. let anni = [];
  65. thead = '<div class="row def_res"> \
  66. <div class="col-10">Documento</div> \
  67. <div class="col-2">Esplora</div> \
  68. </div>';
  69. var DocumentsTable = thead;
  70. var i = 0;
  71. $.each(
  72. json['results']['bindings'],
  73. function (index, value) {
  74. var document = value['document']['value'];
  75. var uri_document = value['uri_document']['value'];
  76. var uri_info = "";
  77. var type = "";
  78. var date = "";
  79. var year = "";
  80. var month = "";
  81. var day = "";
  82. var sigla = "";
  83. var text = "Nessun testo trovato";
  84. var object_button = "";
  85. if(value.hasOwnProperty('uri_infObj')) {
  86. uri_info = value['uri_infObj']['value'];
  87. }
  88. if(value.hasOwnProperty('types')) {
  89. type = value['types']['value'];
  90. }
  91. if(value.hasOwnProperty('time_span')) {
  92. date = value['time_span']['value'];
  93. }
  94. if(value.hasOwnProperty('year')) {
  95. year = value['year']['value'];
  96. }
  97. if(value.hasOwnProperty('month')) {
  98. month = value['month']['value'];
  99. }
  100. if(value.hasOwnProperty('day')) {
  101. day = value['day']['value'];
  102. }
  103. if(value.hasOwnProperty('text')) {
  104. text = value['text']['value'];
  105. }
  106. if(value.hasOwnProperty('sigla')) {
  107. sigla = value['sigla']['value'];
  108. }
  109. if (type.includes("lettera")) {
  110. object_button = '<button type="button" id="' + uri_info +
  111. '" class="lettera btn btn-default" alt="opera d\'arte" title="' + document +
  112. '"><i class="fa fa-envelope"></i></button>';
  113. } else {
  114. object_button = '<button type="button" id="' + uri_document +
  115. '" class="object btn btn-default" alt="oggetto" title="' + document +
  116. '"><i class="fa fa-book"></i></button>';
  117. }
  118. DocumentsTable += '<div class="row res">' +
  119. '<div id="' + uri_document + '" class="col-10 object">' + document + '</div>' +
  120. '<div class="col-2">' + object_button + '</div>' +
  121. '</div>';
  122. i++;
  123. });
  124. document.getElementById("lemma_buttons").style.display = "flex";
  125. document.getElementById("results_table").innerHTML = DocumentsTable;
  126. document.getElementById("results_title").innerHTML = titleCase(lemma);
  127. }
  128. function manageArraySigle(json, lemma) {
  129. sigleFinished = true;
  130. $.each(
  131. json['results']['bindings'],
  132. function (index, value) {
  133. var uri = value['uri']['value'];
  134. var sigla = value['sigla']['value'];
  135. var testo = value['text']['value'];
  136. queryIdLemma = prefixes + (queryManager['queryRES']['queryTrovaIDlemma']).replace('<{SIGLA}>', sigla).replace('<{LEMMA}>', lemma);
  137. console.log(queryIdLemma);
  138. doJsonQuery(queryIdLemma).done(function(r) { manageTestoLettere(r, uri, testo); });
  139. });
  140. if (sigleFinished && lemmaFinished && mappaFinished) {
  141. $('#Loader').css("display", "none");
  142. $('#overlay').css("display", "none");
  143. }
  144. }
  145. function manageTestoLettere(json, uri, testo) {
  146. var id = "";
  147. $.each(
  148. json['results']['bindings'],
  149. function (index, value) {
  150. id = value['id']['value'];
  151. });
  152. let regex = "<w>(.{0,50})</w>(.{0,5})<lem n='ID' (.*?)>";
  153. let regex2 = "<lem n='ID' (.*?)>(.*?)(\\s|,|;|<)";
  154. regex = regex.replace('ID', id);
  155. regex = new RegExp(regex);
  156. regex2 = regex2.replace('ID', id);
  157. regex2 = new RegExp(regex2);
  158. var testo3 = "";
  159. console.log(regex.exec(testo));
  160. if (regex.test(testo)) {
  161. console.log("true");
  162. const match = regex.exec(testo);
  163. let index = regex.exec(testo).index;
  164. let last = index + match[0].length;
  165. let toaddfirst = '<span class="highlight">';
  166. let toaddlast = '</span>';
  167. let testo2 = [testo.slice(0, last), toaddlast, testo.slice(last)].join('');
  168. testo3 = [testo2.slice(0, index), toaddfirst, testo2.slice(index)].join('');
  169. } else if (regex2.test(testo)) {
  170. const match = regex2.exec(testo);
  171. let index = regex2.exec(testo).index;
  172. let last = index + match[0].length-1;
  173. let toaddfirst = '<span class="highlight">';
  174. let toaddlast = '</span>';
  175. let testo2 = [testo.slice(0, last), toaddlast, testo.slice(last)].join('');
  176. testo3 = [testo2.slice(0, index), toaddfirst, testo2.slice(index)].join('');
  177. } else {
  178. testo = testo3;
  179. }
  180. testi_ovi.push([uri, testo3]);
  181. /*let regex = "<lem n='ID' (.*?)>(.*?)(\\s|,|;|<)";
  182. regex = regex.replace('ID', id);
  183. regex = new RegExp(regex);
  184. const match = regex.exec(testo);
  185. var index = regex.exec(testo).index;
  186. var last = index + match[0].length-1;
  187. var toaddfirst = '<span class="highlight">';
  188. var toaddlast = '</span>';
  189. var testo2 = [testo.slice(0, last), toaddlast, testo.slice(last)].join('');
  190. var testo3 = [testo2.slice(0, index), toaddfirst, testo2.slice(index)].join('');
  191. testi_ovi.push([uri, testo3]); */
  192. }
  193. console.log(testi_ovi);
  194. function manageJson(json, lemma) {
  195. lemmaFinished = true;
  196. console.log("lemmaFinished");
  197. var i=0;
  198. $.each(
  199. json['results']['bindings'],
  200. function (index, value) {
  201. var uri = value['uri_place']['value'];
  202. var label = value['place']['value'];
  203. var coord = value['coords']['value'];
  204. var uri_inf = value['uri_infObj']['value'];
  205. var year = "";
  206. var month = "";
  207. var day = "";
  208. var uri_soggetto = value['uri_subject']['value'];
  209. var soggetto = value['subject']['value'];
  210. //var evento = value['event']['value'];
  211. var evento = "Invio"
  212. var data = value['time_span']['value'];
  213. var testo = "";
  214. if (value.hasOwnProperty('year')) {
  215. year = value['year']['value'];
  216. if (!anni.includes(year)) {
  217. anni.push(year);
  218. }
  219. }
  220. if (value.hasOwnProperty('month')) {
  221. month = value['month']['value'];
  222. }
  223. if (value.hasOwnProperty('day')) {
  224. day = value['day']['value'];
  225. }
  226. if (value.hasOwnProperty('text')) {
  227. testo = value['text']['value'];
  228. }
  229. for (kk in testi_ovi) {
  230. if (testi_ovi[kk][0] == uri_inf) {
  231. testo = testi_ovi[kk][1];
  232. }
  233. }
  234. eventi[i] = {"uri_soggetto": uri_soggetto, "uri_info": uri_inf,"soggetto": soggetto, "uri_luogo": uri, "luogo": label, "coordinate": coord, "evento": evento, "data": data, "anno": year, "mese": month, "giorno": day, "testo": testo};
  235. i++;
  236. });
  237. handle_map(eventi);
  238. manageYears(anni);
  239. manageEvents(eventi);
  240. console.log("lemmaFinished2");
  241. if (sigleFinished && lemmaFinished && mappaFinished) {
  242. $('#Loader').css("display", "none");
  243. $('#overlay').css("display", "none");
  244. }
  245. }
  246. function handle_map(myArray) {
  247. //console.log(json);
  248. mappaFinished = true;
  249. console.log("mappaFinished");
  250. const locations = [];
  251. const place_names = [];
  252. const luoghi = [];
  253. for (i in myArray) {
  254. const loc = []
  255. var uri = myArray[i]['uri_luogo'];
  256. var label = myArray[i]['luogo'];
  257. var coord = myArray[i]['coordinate'];
  258. var year = myArray[i]['anno'];
  259. var month = myArray[i]['mese'];
  260. var day = myArray[i]['giorno'];
  261. var uri_soggetto = myArray[i]['uri_soggetto'];
  262. var soggetto = myArray[i]['soggetto'];
  263. //var evento = value['event']['value'];
  264. var evento = myArray[i]['evento']
  265. var data = myArray[i]['data'];
  266. if (!place_names.includes(uri)) {
  267. place_names.push(uri);
  268. const coordinates = coord.split(", ");
  269. loc.push(uri);
  270. label = titleCase(label);
  271. loc.push(label);
  272. loc.push(coordinates[0]);
  273. //lat += parseInt(coordinates[0]);
  274. loc.push(coordinates[1]);
  275. //long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  276. locations.push(loc);
  277. }
  278. }
  279. for (var k=0; k<locations.length; k++) {
  280. const tempArray = [];
  281. var nomeLuogo = locations[k][1];
  282. var lt = locations[k][2];
  283. var lg = locations[k][3];
  284. tempArray.push(nomeLuogo);
  285. tempArray.push(lt);
  286. tempArray.push(lg);
  287. luoghi.push(tempArray);
  288. }
  289. function populate() {
  290. for (var i = 0; i < luoghi.length; i++) {
  291. var a = luoghi[i];
  292. var title = titleCase(a[0]);
  293. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  294. marker.bindPopup(title);
  295. marker.on('mouseover', function (e) {
  296. this.openPopup();
  297. });
  298. marker.on('mouseout', function (e) {
  299. this.closePopup();
  300. });
  301. //marker.on('click', markerOnClick);
  302. //$(marker._icon).addClass('selectedMarker');
  303. marker.on('click', function(){
  304. var name_place = $(this)[0].options.title;
  305. var markerLat = $(this)[0]._latlng['lat'];
  306. var markerLng = $(this)[0]._latlng['lng'];
  307. managePlace(name_place);
  308. });
  309. markers.addLayer(marker);
  310. markerList.push(marker);
  311. }
  312. }
  313. populate();
  314. //manageYears(anni);
  315. map.addLayer(markers);
  316. //manageEvents(eventi)
  317. console.log("mappaFinished2");
  318. if (sigleFinished && lemmaFinished && mappaFinished) {
  319. $('#Loader').css("display", "none");
  320. $('#overlay').css("display", "none");
  321. }
  322. }
  323. function markerOnClick(e)
  324. {
  325. alert("hi. you clicked the marker at " + e.LatLng);
  326. console.log(e);
  327. }
  328. let time_span = [];
  329. /*
  330. function handle_map2(json) {
  331. cleanMap();
  332. const locations = [];
  333. const place_names = [];
  334. const luoghi = [];
  335. time_span = [];
  336. var lat = 0;
  337. var long = 0;
  338. var i=0;
  339. $.each(
  340. json['results']['bindings'],
  341. function (index, value) {
  342. const loc = []
  343. var uri = value['uri_place']['value'];
  344. var label = value['place']['value'];
  345. var coord = value['coords']['value'];
  346. if (!place_names.includes(uri)) {
  347. place_names.push(uri);
  348. const coordinates = coord.split(", ");
  349. loc.push(uri);
  350. label = titleCase(label);
  351. loc.push(label);
  352. loc.push(coordinates[0]);
  353. lat += parseInt(coordinates[0]);
  354. loc.push(coordinates[1]);
  355. long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  356. locations.push(loc);
  357. i++;
  358. }
  359. if (value.hasOwnProperty('time_span')) {
  360. data = value['time_span']['value'];
  361. if (!time_span.includes(data)) {
  362. time_span.push(data);
  363. }
  364. }
  365. });
  366. for (var k=0; k<locations.length; k++) {
  367. const tempArray = [];
  368. var nomeLuogo = locations[k][1];
  369. var lt = locations[k][2];
  370. var lg = locations[k][3];
  371. tempArray.push(nomeLuogo);
  372. tempArray.push(lt);
  373. tempArray.push(lg);
  374. luoghi.push(tempArray);
  375. }
  376. function populate() {
  377. for (var i = 0; i < luoghi.length; i++) {
  378. var a = luoghi[i];
  379. var title = "<p>" + titleCase(a[0]) + "</p>";
  380. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  381. marker.bindPopup(title);
  382. markers.addLayer(marker);
  383. markerList.push(marker);
  384. }
  385. }
  386. populate();
  387. manageDates(time_span);
  388. }
  389. */
  390. /*
  391. function handle_map3(json) {
  392. cleanMap();
  393. const locations = [];
  394. const place_names = [];
  395. const luoghi = [];
  396. let eventi = [];
  397. var lat = 0;
  398. var long = 0;
  399. var i=0;
  400. $.each(
  401. json['results']['bindings'],
  402. function (index, value) {
  403. const loc = []
  404. var uri = value['uri_place']['value'];
  405. var label = value['place']['value'];
  406. var coord = value['coords']['value'];
  407. if (!place_names.includes(uri)) {
  408. place_names.push(uri);
  409. const coordinates = coord.split(", ");
  410. loc.push(uri);
  411. label = titleCase(label);
  412. loc.push(label);
  413. loc.push(coordinates[0]);
  414. lat += parseInt(coordinates[0]);
  415. loc.push(coordinates[1]);
  416. long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  417. locations.push(loc);
  418. i++;
  419. }
  420. var uri_person = "";
  421. var person = "";
  422. var ev = "";
  423. if (value.hasOwnProperty('uri_person')) {
  424. uri_person = value['uri_person']['value'];
  425. }
  426. if (value.hasOwnProperty('person')) {
  427. person = value['person']['value'];
  428. }
  429. if (value.hasOwnProperty('event')) {
  430. ev = value['event']['value'];
  431. }
  432. eventi.push([ev, person, uri_person, coord]);
  433. });
  434. for (var k=0; k<locations.length; k++) {
  435. const tempArray = [];
  436. var nomeLuogo = locations[k][1];
  437. var lt = locations[k][2];
  438. var lg = locations[k][3];
  439. tempArray.push(nomeLuogo);
  440. tempArray.push(lt);
  441. tempArray.push(lg);
  442. luoghi.push(tempArray);
  443. }
  444. function populate() {
  445. for (var i = 0; i < luoghi.length; i++) {
  446. var a = luoghi[i];
  447. var title = "<p>" + titleCase(a[0]) + "</p>";
  448. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  449. marker.bindPopup(title);
  450. markers.addLayer(marker);
  451. markerList.push(marker);
  452. }
  453. }
  454. populate();
  455. manageEvents(eventi);
  456. }
  457. */
  458. function managePlace(namePlace) {
  459. let eventPlace = {};
  460. var j=0;
  461. var place = namePlace.replace('<p>', '').replace('</p>', '');
  462. for (i in eventi) {
  463. if (eventi[i]['luogo'] == place) {
  464. eventPlace[j] = eventi[i];
  465. j++;
  466. }
  467. }
  468. console.log(eventPlace);
  469. document.getElementById('timeline').innerHTML = "";
  470. manageEvents(eventPlace);
  471. }
  472. function manageYears(anni) {
  473. var Anni = "";
  474. anni.sort();
  475. var left = 10;
  476. for (i in anni) {
  477. var anno = anni[i];
  478. if (anno.length == 4) {
  479. Anni += '<li id="'+ anno + '" class="year event_days" style="left:' + left + 'px"><div>' + anno + '</div></li>';
  480. left = left + 80;
  481. }
  482. }
  483. document.getElementById("anni").innerHTML = Anni;
  484. }
  485. let uniqueDates = [];
  486. function manageDates(date) {
  487. uniqueDates = [];
  488. let evDates = {};
  489. var Date = "";
  490. var left = 30;
  491. for (i in date) {
  492. if (!uniqueDates.includes(date[i])) {
  493. uniqueDates.push(date[i]);
  494. var data = date[i];
  495. Date += '<li id="'+ data + '" class="date event_days" style="left:' + left + 'px"><div>' + data + '</div></li>';
  496. left = left + 100;
  497. }
  498. for (j in eventi) {
  499. if (date[i] == eventi[j]['data']) {
  500. evDates[i] = eventi[j];
  501. }
  502. }
  503. }
  504. document.getElementById("anni").innerHTML = Date;
  505. }
  506. function manageEvents(events) {
  507. var Eventi = "";
  508. var anni = [];
  509. var days = [];
  510. var simpleDate = "";
  511. for (i in events) {
  512. var ev = events[i]['evento'];
  513. var soggetto = events[i]['soggetto'];
  514. var uri_soggetto = events[i]['uri_soggetto'];
  515. var uri_luogo = events[i]['uri_luogo'];
  516. var luogo = events[i]['place'];
  517. var coordinates = events[i]['coordinate'];
  518. var date = events[i]['data'];
  519. var anno = events[i]['anno'];
  520. var mese = events[i]['mese'];
  521. var giorno = events[i]['giorno'];
  522. var testo = events[i]['testo'];
  523. var informationObject = eventi[i]['uri_info'];
  524. if (anno.length == 4) {
  525. if (!anni.includes(anno)) {
  526. createYearSeed(anno);
  527. anni.push(anno);
  528. }
  529. }
  530. if (!days.includes(date)) {
  531. days.push(date);
  532. simpleDate = date;
  533. createDateSeed(simpleDate);
  534. } else {
  535. simpleDate = "";
  536. }
  537. var object_button = '<button type="button" id="' + uri_soggetto +
  538. '" class="object btn btn-default geo-text" alt="oggetto" title="' + soggetto +
  539. '">Vedi scheda oggetto <i class="fa fa-book"></i></button>';
  540. Eventi = '<div class="event"> \
  541. <div class="eventSeed"><div data-point="' + coordinates + '" style="cursor:zoom-in;" class="event_title">' + soggetto + '</div><div class="d-flex justify-content-end">' + object_button +'</div> \
  542. <div>' + testo + '</div></div></div>';
  543. $('#timeline').append(Eventi);
  544. }
  545. }
  546. function createYearSeed(year) {
  547. var Anno = "<div class='yearSeed' id='" + year + "'><h2>" + year + "</h2></div>";
  548. $('#timeline').append(Anno);
  549. }
  550. function cleanMap() {
  551. markers.clearLayers();
  552. }
  553. function createDateSeed(date) {
  554. var Data = "<div id='" + date + "'><div class='dateSeed'>" + date + "</div>";
  555. $('#timeline').append(Data);
  556. }
  557. function cleanMap() {
  558. markers.clearLayers();
  559. }
  560. $(document).on("click", ".year", function (ev) {
  561. let eventYear = {};
  562. let date = [];
  563. var zoom = 5;
  564. var j=0;
  565. map.setView([latitude, longitude], zoom);
  566. anno = parseInt(this.id);
  567. for (i in eventi) {
  568. if (eventi[i]['anno'] == anno) {
  569. var data = eventi[i]['data'];
  570. date.push(data);
  571. eventYear[j] = eventi[i];
  572. j++;
  573. }
  574. }
  575. document.getElementById('timeline').innerHTML = "";
  576. manageDates(date);
  577. manageEvents(eventYear);
  578. cleanMap();
  579. handle_map(eventYear);
  580. //queryAnno = prefixes + (queryManager['queryTimeSpace']['queryTime1']).replace('{YEAR}', anno);
  581. //doJsonQuery(queryAnno).done(function(data) { handle_map2(data); });
  582. });
  583. $(document).on("click", ".date", function (ev) {
  584. var date = this.id;
  585. let eventDay = {};
  586. var zoom = 5;
  587. var j=0;
  588. map.setView([latitude, longitude], zoom);
  589. var data = parseInt(this.id);
  590. for (i in eventi) {
  591. if (eventi[i]['data'] == date) {
  592. eventDay[j] = eventi[i];
  593. j++;
  594. }
  595. }
  596. console.log(eventDay);
  597. document.getElementById('timeline').innerHTML = "";
  598. manageEvents(eventDay);
  599. cleanMap();
  600. handle_map(eventDay);
  601. //queryAnno = prefixes + (queryManager['queryTimeSpace']['queryTime2']).replace('{DATE}', date);
  602. //doJsonQuery(queryAnno).done(function(data) { handle_map3(data); });
  603. });
  604. //EVENT ON HOVER. ACTIVATE BY PASSING ON TITLE
  605. /*
  606. $(document).on("mouseover", ".event", function(){
  607. // parse lat and lng from the divs data attribute
  608. var latlng = $(this).data().point.split(', ');
  609. var lat = latlng[0];
  610. var lng = latlng[1];
  611. var zoom = 10;
  612. map.setView([lat, lng], zoom);
  613. });
  614. */
  615. $(document).on("click", ".event_title", function(){
  616. // parse lat and lng from the divs data attribute
  617. var latlng = $(this).data().point.split(', ');
  618. var lat = latlng[0];
  619. var lng = latlng[1];
  620. var zoom = 14;
  621. map.setView([lat, lng], zoom);
  622. });
  623. $(document).on("click", "#backToAnni", function (ev) {
  624. manageYears(anni);
  625. });
  626. $(document).on("click", "#backToDate", function (ev) {
  627. manageDates(time_span);
  628. });
  629. function show_list(){
  630. document.getElementById("res_container").style.display = "block";
  631. document.getElementById("evenTime").style.display = "none";
  632. }
  633. function show_map(){
  634. document.getElementById("res_container").style.display = "none";
  635. document.getElementById("evenTime").style.display = "block";
  636. }