geospace.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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('click', markerOnClick);
  296. //$(marker._icon).addClass('selectedMarker');
  297. marker.on('click', function(){
  298. var name_place = $(this)[0].options.title;
  299. var markerLat = $(this)[0]._latlng['lat'];
  300. var markerLng = $(this)[0]._latlng['lng'];
  301. managePlace(name_place);
  302. });
  303. markers.addLayer(marker);
  304. markerList.push(marker);
  305. }
  306. }
  307. populate();
  308. //manageYears(anni);
  309. map.addLayer(markers);
  310. //manageEvents(eventi)
  311. console.log("mappaFinished2");
  312. if (sigleFinished && lemmaFinished && mappaFinished) {
  313. $('#Loader').css("display", "none");
  314. $('#overlay').css("display", "none");
  315. }
  316. }
  317. function markerOnClick(e)
  318. {
  319. alert("hi. you clicked the marker at " + e.LatLng);
  320. console.log(e);
  321. }
  322. let time_span = [];
  323. /*
  324. function handle_map2(json) {
  325. cleanMap();
  326. const locations = [];
  327. const place_names = [];
  328. const luoghi = [];
  329. time_span = [];
  330. var lat = 0;
  331. var long = 0;
  332. var i=0;
  333. $.each(
  334. json['results']['bindings'],
  335. function (index, value) {
  336. const loc = []
  337. var uri = value['uri_place']['value'];
  338. var label = value['place']['value'];
  339. var coord = value['coords']['value'];
  340. if (!place_names.includes(uri)) {
  341. place_names.push(uri);
  342. const coordinates = coord.split(", ");
  343. loc.push(uri);
  344. label = titleCase(label);
  345. loc.push(label);
  346. loc.push(coordinates[0]);
  347. lat += parseInt(coordinates[0]);
  348. loc.push(coordinates[1]);
  349. long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  350. locations.push(loc);
  351. i++;
  352. }
  353. if (value.hasOwnProperty('time_span')) {
  354. data = value['time_span']['value'];
  355. if (!time_span.includes(data)) {
  356. time_span.push(data);
  357. }
  358. }
  359. });
  360. for (var k=0; k<locations.length; k++) {
  361. const tempArray = [];
  362. var nomeLuogo = locations[k][1];
  363. var lt = locations[k][2];
  364. var lg = locations[k][3];
  365. tempArray.push(nomeLuogo);
  366. tempArray.push(lt);
  367. tempArray.push(lg);
  368. luoghi.push(tempArray);
  369. }
  370. function populate() {
  371. for (var i = 0; i < luoghi.length; i++) {
  372. var a = luoghi[i];
  373. var title = "<p>" + titleCase(a[0]) + "</p>";
  374. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  375. marker.bindPopup(title);
  376. markers.addLayer(marker);
  377. markerList.push(marker);
  378. }
  379. }
  380. populate();
  381. manageDates(time_span);
  382. }
  383. */
  384. /*
  385. function handle_map3(json) {
  386. cleanMap();
  387. const locations = [];
  388. const place_names = [];
  389. const luoghi = [];
  390. let eventi = [];
  391. var lat = 0;
  392. var long = 0;
  393. var i=0;
  394. $.each(
  395. json['results']['bindings'],
  396. function (index, value) {
  397. const loc = []
  398. var uri = value['uri_place']['value'];
  399. var label = value['place']['value'];
  400. var coord = value['coords']['value'];
  401. if (!place_names.includes(uri)) {
  402. place_names.push(uri);
  403. const coordinates = coord.split(", ");
  404. loc.push(uri);
  405. label = titleCase(label);
  406. loc.push(label);
  407. loc.push(coordinates[0]);
  408. lat += parseInt(coordinates[0]);
  409. loc.push(coordinates[1]);
  410. long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
  411. locations.push(loc);
  412. i++;
  413. }
  414. var uri_person = "";
  415. var person = "";
  416. var ev = "";
  417. if (value.hasOwnProperty('uri_person')) {
  418. uri_person = value['uri_person']['value'];
  419. }
  420. if (value.hasOwnProperty('person')) {
  421. person = value['person']['value'];
  422. }
  423. if (value.hasOwnProperty('event')) {
  424. ev = value['event']['value'];
  425. }
  426. eventi.push([ev, person, uri_person, coord]);
  427. });
  428. for (var k=0; k<locations.length; k++) {
  429. const tempArray = [];
  430. var nomeLuogo = locations[k][1];
  431. var lt = locations[k][2];
  432. var lg = locations[k][3];
  433. tempArray.push(nomeLuogo);
  434. tempArray.push(lt);
  435. tempArray.push(lg);
  436. luoghi.push(tempArray);
  437. }
  438. function populate() {
  439. for (var i = 0; i < luoghi.length; i++) {
  440. var a = luoghi[i];
  441. var title = "<p>" + titleCase(a[0]) + "</p>";
  442. var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
  443. marker.bindPopup(title);
  444. markers.addLayer(marker);
  445. markerList.push(marker);
  446. }
  447. }
  448. populate();
  449. manageEvents(eventi);
  450. }
  451. */
  452. function managePlace(namePlace) {
  453. let eventPlace = {};
  454. var j=0;
  455. var place = namePlace.replace('<p>', '').replace('</p>', '');
  456. for (i in eventi) {
  457. if (eventi[i]['luogo'] == place) {
  458. eventPlace[j] = eventi[i];
  459. j++;
  460. }
  461. }
  462. console.log(eventPlace);
  463. document.getElementById('timeline').innerHTML = "";
  464. manageEvents(eventPlace);
  465. }
  466. function manageYears(anni) {
  467. var Anni = "";
  468. anni.sort();
  469. var left = 10;
  470. for (i in anni) {
  471. var anno = anni[i];
  472. if (anno.length == 4) {
  473. Anni += '<li id="'+ anno + '" class="year event_days" style="left:' + left + 'px"><div>' + anno + '</div></li>';
  474. left = left + 80;
  475. }
  476. }
  477. document.getElementById("anni").innerHTML = Anni;
  478. }
  479. let uniqueDates = [];
  480. function manageDates(date) {
  481. uniqueDates = [];
  482. let evDates = {};
  483. var Date = "";
  484. var left = 30;
  485. for (i in date) {
  486. if (!uniqueDates.includes(date[i])) {
  487. uniqueDates.push(date[i]);
  488. var data = date[i];
  489. Date += '<li id="'+ data + '" class="date event_days" style="left:' + left + 'px"><div>' + data + '</div></li>';
  490. left = left + 100;
  491. }
  492. for (j in eventi) {
  493. if (date[i] == eventi[j]['data']) {
  494. evDates[i] = eventi[j];
  495. }
  496. }
  497. }
  498. document.getElementById("anni").innerHTML = Date;
  499. }
  500. function manageEvents(events) {
  501. var Eventi = "";
  502. var anni = [];
  503. var days = [];
  504. var simpleDate = "";
  505. for (i in events) {
  506. var ev = events[i]['evento'];
  507. var soggetto = events[i]['soggetto'];
  508. var uri_soggetto = events[i]['uri_soggetto'];
  509. var uri_luogo = events[i]['uri_luogo'];
  510. var luogo = events[i]['place'];
  511. var coordinates = events[i]['coordinate'];
  512. var date = events[i]['data'];
  513. var anno = events[i]['anno'];
  514. var mese = events[i]['mese'];
  515. var giorno = events[i]['giorno'];
  516. var testo = events[i]['testo'];
  517. var informationObject = eventi[i]['uri_info'];
  518. if (anno.length == 4) {
  519. if (!anni.includes(anno)) {
  520. createYearSeed(anno);
  521. anni.push(anno);
  522. }
  523. }
  524. if (!days.includes(date)) {
  525. days.push(date);
  526. simpleDate = date;
  527. createDateSeed(simpleDate);
  528. } else {
  529. simpleDate = "";
  530. }
  531. var object_button = '<button type="button" id="' + uri_soggetto +
  532. '" class="object btn btn-default geo-text" alt="oggetto" title="' + soggetto +
  533. '">Vedi scheda oggetto <i class="fa fa-book"></i></button>';
  534. Eventi = '<div class="event"> \
  535. <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> \
  536. <div>' + testo + '</div></div></div>';
  537. //<div class="col-2"><div class="row">' + object_button + '</div></div></div>';
  538. $('#timeline').append(Eventi);
  539. }
  540. }
  541. function createYearSeed(year) {
  542. var Anno = "<div class='yearSeed' id='" + year + "'><h2>" + year + "</h2></div>";
  543. $('#timeline').append(Anno);
  544. }
  545. function cleanMap() {
  546. markers.clearLayers();
  547. }
  548. function createDateSeed(date) {
  549. var Data = "<div id='" + date + "'><div class='dateSeed'>" + date + "</div>";
  550. $('#timeline').append(Data);
  551. }
  552. function cleanMap() {
  553. markers.clearLayers();
  554. }
  555. $(document).on("click", ".year", function (ev) {
  556. let eventYear = {};
  557. let date = [];
  558. var zoom = 5;
  559. var j=0;
  560. map.setView([latitude, longitude], zoom);
  561. anno = parseInt(this.id);
  562. for (i in eventi) {
  563. if (eventi[i]['anno'] == anno) {
  564. var data = eventi[i]['data'];
  565. date.push(data);
  566. eventYear[j] = eventi[i];
  567. j++;
  568. }
  569. }
  570. document.getElementById('timeline').innerHTML = "";
  571. manageDates(date);
  572. manageEvents(eventYear);
  573. cleanMap();
  574. handle_map(eventYear);
  575. //queryAnno = prefixes + (queryManager['queryTimeSpace']['queryTime1']).replace('{YEAR}', anno);
  576. //doJsonQuery(queryAnno).done(function(data) { handle_map2(data); });
  577. });
  578. $(document).on("click", ".date", function (ev) {
  579. var date = this.id;
  580. let eventDay = {};
  581. var zoom = 5;
  582. var j=0;
  583. map.setView([latitude, longitude], zoom);
  584. var data = parseInt(this.id);
  585. for (i in eventi) {
  586. if (eventi[i]['data'] == date) {
  587. eventDay[j] = eventi[i];
  588. j++;
  589. }
  590. }
  591. console.log(eventDay);
  592. document.getElementById('timeline').innerHTML = "";
  593. manageEvents(eventDay);
  594. cleanMap();
  595. handle_map(eventDay);
  596. //queryAnno = prefixes + (queryManager['queryTimeSpace']['queryTime2']).replace('{DATE}', date);
  597. //doJsonQuery(queryAnno).done(function(data) { handle_map3(data); });
  598. });
  599. //EVENT ON HOVER. ACTIVATE BY PASSING ON TITLE
  600. /*
  601. $(document).on("mouseover", ".event", function(){
  602. // parse lat and lng from the divs data attribute
  603. var latlng = $(this).data().point.split(', ');
  604. var lat = latlng[0];
  605. var lng = latlng[1];
  606. var zoom = 10;
  607. map.setView([lat, lng], zoom);
  608. });
  609. */
  610. $(document).on("click", ".event_title", function(){
  611. // parse lat and lng from the divs data attribute
  612. var latlng = $(this).data().point.split(', ');
  613. var lat = latlng[0];
  614. var lng = latlng[1];
  615. var zoom = 14;
  616. map.setView([lat, lng], zoom);
  617. });
  618. $(document).on("click", "#backToAnni", function (ev) {
  619. manageYears(anni);
  620. });
  621. $(document).on("click", "#backToDate", function (ev) {
  622. manageDates(time_span);
  623. });
  624. function show_list(){
  625. document.getElementById("res_container").style.display = "block";
  626. document.getElementById("evenTime").style.display = "none";
  627. }
  628. function show_map(){
  629. document.getElementById("res_container").style.display = "none";
  630. document.getElementById("evenTime").style.display = "block";
  631. }