PageSourceSearch

https://www.visititaly.eu/js/js_viste/generic.js?v=15

js visititaly.eu collected 2026-09-24 18:12:43 UTC 18,825 bytes, 633 lines download raw bytes

1function GetArticoliRecentiMenu(c_visit, lingua) {
2
3  var sezione = $('#sezione').val();
4  var device = $('#device').val();
5
6  $.ajax({
7    type: "POST",
8    url: "https://admin.visititaly.eu/controller/articoli.controller.php?act=GetArticoliEvidenza",
9    data: { c_visit: c_visit, lingua: lingua },
10    cache: false,
11    dataType: "json",
12    success: function (obj) {
13
14      var articoliLimitati
15      if (device == "mobile") {
16        // Limita a massimo 3 articoli
17        articoliLimitati = obj.articoli.slice(0, 3);
18      } else {
19        articoliLimitati = obj.articoli;
20      }
21      var targetContainer2 = $("#artmenu_cont"), template2 = $("#cont_artmenu").html();
22      $(targetContainer2).html("");
23      $(targetContainer2).html(Mustache.to_html(template2, { "art": articoliLimitati }));
24
25      var targetContainer2 = $("#artmenulatest_cont"), template2 = $("#cont_artmenu").html();
26      $(targetContainer2).html("");
27      $(targetContainer2).html(Mustache.to_html(template2, { "art": obj.latest }));
28      articoli_evi_ricerca = obj.articoli;
29      var targetContainer2 = $("#ricerca_cont_header"), template2 = $("#cont_artmenu").html();
30      $(targetContainer2).html("");
31      $(targetContainer2).html(Mustache.to_html(template2, { "art": articoli_evi_ricerca }));
32
33      if (sezione == "404") {
34        var targetContainer2 = $("#artmenu404_cont"), template2 = $("#cont_artmenu404").html();
35        $(targetContainer2).html("");
36        $(targetContainer2).html(Mustache.to_html(template2, { "art": obj.articoli }));
37      }
38
39
40    }
41  });
42}
43function changeHero(id) { //id_tab
44
45  // Legge i valori dagli input hidden
46  const title = document.getElementById(`hero-title-${id}`)?.value;
47  const subtitle = document.getElementById(`hero-subtitle-${id}`)?.value;
48  const image = document.getElementById(`hero-image-${id}`)?.value;
49  const btnText = document.getElementById(`hero-btn-text-${id}`)?.value;
50  const btnUrl = document.getElementById(`hero-btn-url-${id}`)?.value;
51
52  // Se non trova l'ID, non fa nulla
53  if (!title || !image) return;
54
55  // Seleziona gli elementi del DOM
56  const heroTitle = document.querySelector(".page-header .hero a");
57  const heroSubtitle = document.querySelector(".page-header .subtitle");
58  const heroImage = document.querySelector(".page-header img.background-image");
59  const heroBtn = document.querySelector(".page-header .hero-btn");
60  heroImage.style.opacity = 0;
61  setTimeout(() => {
62    heroImage.src = image;
63    heroTitle.innerHTML = title;
64    heroTitle.href = btnUrl;
65    heroSubtitle.innerHTML = subtitle;
66    heroImage.style.opacity = 1;
67    if (heroBtn) {
68      heroBtn.innerHTML = btnText + " <i class=\"fa-solid fa-arrow-right\"></i>";
69      heroBtn.href = btnUrl || "#";
70    }
71  }, 50);
72
73}
74function RemoveHighlight(arg) {
75  var id = arg.getAttribute('id');
76  $("#" + id).removeClass("highlight");
77}
78
79function GetSocialProof(second) {
80  var lingua = $('#lingua').val();
81  var sezione = $('#sezione').val();
82
83  var id_regione
84
85  if (sezione == "regione") {
86    id_regione = $('#id_regione').val();
87  } else {
88    id_regione = "";
89  }
90
91  var c_visit = "visititaly";
92  $.ajax({
93    type: "POST",
94    url: "https://admin.visititaly.eu/controller/home.controller.php?act=proof_custom",
95    data: { c_visit: c_visit, lingua: lingua, id_regione: id_regione },
96    cache: false,
97    dataType: "json",
98    success: function (obj) {
99
100      if (obj.status == "success") {
101        $("#testo_proof").html(obj.text);
102        $("#link_proof").html(obj.cta_text);
103        $("#img_proof").attr("src", obj.image);
104        $("#link_proof").attr("href", obj.link);
105        $("#img_proof").attr("alt", obj.cta_text);
106
107        $("#pop_container").show();
108        $('#pop_proof').addClass('animated bounceInLeft');
109      } else {
110        $("#pop_container").hide();
111      }
112
113      setTimeout(() => {
114        ChiudiPopUp("pop1")
115      }, second);
116    }
117  });
118}
119
120function ChiudiPopUp(popup) {
121  $('#pop_proof').removeClass('animated bounceInLeft');
122  $("." + popup).fadeOut();
123}
124
125function CronProof() {
126
127  var counter = 0;
128
129  var i = setInterval(function () {
130    // do your thing
131    // console.log("qui");
132
133    if (counter === 1) {
134      //  console.log("vai pop");
135    }
136
137    counter++;
138
139    if (counter === 6) {
140      clearInterval(i);
141    }
142  }, 20000);
143
144}
145
146function FilterCategory() {
147  const tabs = document.querySelectorAll('.categorie-thingstodo .btn');
148  const tabs_filtri = document.querySelectorAll('.filtri-thingstodo .btn');
149  const sezione = $('#sezione').val();
150
151  tabs.forEach(tab => {
152    tab.addEventListener('click', function (e) {
153      e.preventDefault();
154
155      // Rimuove classe "active" da tutti
156      tabs.forEach(t => {
157        // t.classList.remove('active');
158        t.classList.remove('btn-dark');
159        t.classList.add('btn-light');
160      });
161
162      // this.classList.add('active');
163      this.classList.remove('btn-light');
164      this.classList.add('btn-dark');
165
166      // Trova l'input hidden associato a questo tab
167      const idCategoriaInput = this.closest('div').querySelector('input[name="id_categoria"]');
168      const id_categoria = idCategoriaInput ? idCategoriaInput.value : '';
169      const action = this.dataset.action;
170      selectedCategoria = id_categoria;
171
172      $('.skeleton_loader').show();
173
174      // Scegli la funzione da chiamare
175      if (action === 'experience') {
176        $(".loader").show();
177        $("#experience_cont").html("");
178        $("#page").val(1);
179        $("#page_size").val(18);
180        GetExperienceTiq(id_categoria, "#experience_cont");
181        // GetExperience("", "", id_categoria, "").then((success) => {
182        //   if (!success) console.warn("Nessuna esperienza trovata.");
183        // });
184      } else if (action === 'tickets') {
185
186        $("#ticket_cont").html("");
187        GetListaProdottiTiq("", "", "", id_categoria, "").then(success => {
188          if (!success) console.warn("Nessun ticket trovato.");
189        });
190      } else if (action === 'all') {
191
192        const nome_regione = $('#nome_regione').val();
193        const id_regione = $('#id_regione').val();
194
195        $("#ticket_cont").html("");
196        GetExpTiqets(nome_regione, id_regione, id_categoria, "");
197      } else if (action === 'guide') {
198        $(".loader").show();
199        const lingua = $('#lingua').val();
200        $("#guide_sotto_cat_cont").html("");
201
202        GetGuideFiltered(id_categoria, 1, lingua).then(success => {
203          if (!success) console.warn("Nessun risultato trovato.");
204        });
205
206      } else {
207        console.error("Azione non riconosciuta:", action);
208      }
209
210    });
211  });
212
213  tabs_filtri.forEach(tab => {
214    tab.addEventListener('click', function (e) {
215      e.preventDefault();
216
217      // Rimuove classe "active" da tutti
218      tabs_filtri.forEach(t => t.classList.remove('active'));
219      this.classList.add('active');
220
221      // Trova l'input hidden associato a questo tab
222      const id_categoria = selectedCategoria;
223      const action = this.dataset.action;
224      const id_tags = this.dataset.tags;
225
226
227      // Scegli la funzione da chiamare
228      if (action === 'tickets') {
229
230        $('.skeleton_loader').show();
231        $("#ticket_cont").html("");
232        GetListaProdottiTiq("", "", "", id_categoria, id_tags).then(success => {
233          if (!success) console.warn("Nessun ticket trovato.");
234        });
235      } else {
236        console.error("Azione non riconosciuta:", action);
237      }
238
239    });
240  });
241
242}
243
244function GetGuideFiltered(slug, paginazione, lingua) {
245  Promise.all([
246    $.ajax({
247      // url: "http://localhost:8888/visititaly/cms_visit/src/controller/home.controller.php?act=GetGuideSing&c_visit=visititaly&lingua=" + lingua,
248      url: "https://admin.visititaly.eu/controller/home.controller.php?act=GetGuideSing&c_visit=visititaly&lingua=" + lingua,
249      type: "POST",
250      dataType: "json",
251      data: {
252        c_visit: "visititaly",
253        lingua: lingua,
254        paginazione: paginazione,
255        id_categoria: slug
256      }
257    })
258  ]).then(function (results) {
259
260    const response = results[0];
261    data = response.data;
262
263    const nessunRisultatoTiq = !data || data.length === 0;
264
265    if (nessunRisultatoTiq) {
266      $('.skeleton_loader').hide();
267      return;
268    }
269
270    $(".loader").hide();
271    $("#guide_sotto_cat_cont").show();
272
273    var template = $("#schede_cont").html();
274    $("#guide_sotto_cat_cont").append(Mustache.to_html(template, { "schede_att": data }));
275    
276
277  }).catch(function (error) {
278    console.error("Errore AJAX:", error);
279    $('.loader').hide();
280  });
281
282}
283
284function truncateText(selector, maxLength) {
285  var element = document.querySelector(selector),
286    truncated = element.innerText;
287  // console.log(truncated)
288  if (truncated.length > maxLength) {
289    truncated = truncated.substr(0, maxLength) + '...';
290  }
291  return truncated;
292}
293
294function handleCityChangeType(type) {
295
296  const lingua = $('#lingua').val();
297  const selectElement = document.getElementById('citySelect' + type);
298  const id_regione = selectElement.value;
299  selectedRegione = id_regione;
300
301  if (lingua === "it") {
302    const titleElement = document.getElementById('popularTitle');
303    const citiesWithA = [34, 30, 27, 24, 29, 26, 25];
304    const preposition = citiesWithA.includes(parseInt(id_regione)) ? 'a' : 'in';
305    titleElement.textContent = titleElement.textContent.replace(/\b(in|a)/, preposition);
306  }
307
308
309  $('.skeleton_loader').show();
310
311  if (type == "generic") {
312    handleCityChange(id_regione)
313  } else if (type == "tickets") {
314    GetListaProdottiTiq("", "popularity%20desc", id_regione, selectedCategoria, "");
315  } else if (type == "experince") {
316    GetListaProdottiTiq("", "popularity%20desc", id_regione, selectedCategoria, "");
317  }
318}
319
320function handleCityChange(id_regione) {
321
322  var lingua = $('#lingua').val();
323  var c_visit = $('#c_visit').val();
324
325  // Costruisci i dati da inviare
326  const data = new URLSearchParams();
327  data.append('id_regione', id_regione);
328  data.append('c_visit', c_visit);
329  data.append('lingua', lingua);
330  data.append('act', "GetThingsToDoLight");
331  data.append('sezione', "home");
332
333  // Invia la richiesta (modifica l'URL secondo le tue necessità)
334  fetch('https://admin.visititaly.eu/controller/categorie.controller.php', {
335    method: 'POST',
336    headers: {
337      'Content-Type': 'application/x-www-form-urlencoded',
338    },
339    body: data.toString()
340  })
341    .then(response => response.text())
342    .then(result => {
343      console.log('Risposta dal server:', result);
344      // eventualmente aggiorna una parte della pagina con result
345    })
346    .catch(error => {
347      console.error('Errore nella richiesta:', error);
348    });
349}
350
351function GetProdottiTiq() {
352
353  var lingua = $('#lingua').val();
354  var c_visit = $('#c_visit').val();
355
356  $.ajax({
357    type: "POST",
358    url: "https://admin.visititaly.eu/controller/tickets.controller.php",
359    data: { c_visit: "visititaly", lingua: lingua, act: "get_tickets", sezione: "home" },
360    cache: false,
361    dataType: "json",
362    success: function (obj) {
363      if (obj.products.length > 0) {
364
365        var targetContainer2 = $("#ticket_cont"), template2 = $("#cont_ticket").html();
366        $(targetContainer2).html("");
367        $(targetContainer2).html(Mustache.to_html(template2, { "ticket": obj.products }));
368
369        var targetContainer2 = $("#citypass_cont"), template2 = $("#cont_ticket").html();
370        $(targetContainer2).html("");
371        $(targetContainer2).html(Mustache.to_html(template2, { "ticket": obj.city_pass }));
372
373        setTimeout(function () {
374          $(".loader-ticket").hide();
375          var $owl = $('.owl-ticket');
376          $owl.trigger('destroy.owl.carousel');
377          $owl.html($owl.find('.owl-stage-outer').html()).removeClass('owl-loaded');
378          $owl.owlCarousel({
379            loop: false,
380            nav: false,
381            dots: false,
382            items: 4,
383            lazyload: true,
384            animateIn: 'fadeIn'
385          });
386          $(".tickets_main_cont").show();
387        }, 100);
388
389
390      } else {
391        $(".tickets_main_cont").hide();
392      }
393
394
395    }
396  });
397
398
399}
400
401function validateEmail(email) {
402  var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
403  return re.test(String(email).toLowerCase());
404}
405
406function checkPassword(str) {
407  // at least one number, one lowercase and one uppercase letter
408  // at least six characters
409  var re = /(?=.*\d)(?=.*[a-z]).{6,}/;
410  return re.test(str);
411}
412
413function EmailVerificationNewsletter() {
414
415  var email = $("#email_nl").val();
416  var c_visit = $("#c_visit").val();
417  var nome = $("#nome_nl").val();
418  var sezione = $("#sezione").val();
419  var newsletter_form = $("#newsletter_form").serialize();
420
421  if ($('#privacy_nl').is(":checked")) {
422    var privacy = 1;
423  } else {
424    var privacy = 0;
425  }
426
427  if (email != "" && nome != "" && privacy == 1) {
428    if (validateEmail(email)) {
429      $.ajax({
430        url: "https://admin.visititaly.eu/controller/utenti.controller.php?c_visit=" + c_visit,
431        data: newsletter_form,
432        dataType: "json",
433        type: "POST",
434        cache: false,
435        success: function (obj) {
436
437          if (obj.status == "success") {
438
439            $(".cont_form_newsletter").hide();
440            $(".cont_success_newsletter").show();
441
442            toastr.success(messaggio_successo);
443
444          } else if (obj.status == "email") {
445
446            toastr.warning(messaggio_dati_mancanti, esito_password);
447
448          } else if (obj.status == "troppo_corto") {
449
450            toastr.warning(messaggio_warning, messaggio_troppo_corto);
451
452          } else if (obj.status == "esistente_richiesta") {
453
454            toastr.warning(lab_esistente_richiesta_nl);
455
456          } else if (obj.status == "esistente_utenti") {
457
458            toastr.success(lab_esistente_utenti_nl);
459
460          } else {
461
462            toastr.error(messaggio_errore_procedura);
463
464          }
465        }
466      });
467    } else {
468      toastr.error(label_mess_email_errata, label_titolo_email_errata);
469    }
470  } else {
471    toastr.error(messaggio_dati_mancanti, esito_password);
472  }
473
474}
475
476function EmailVerificationNewsletterFooter() {
477
478  var email = $("#email_nlf").val();
479  var c_visit = $("#c_visit").val();
480  var nome = $("#nome_nlf").val();
481  var sezione = $("#sezione").val();
482  var newsletter_form = $("#newsletterfooter_form").serialize();
483
484  if ($('#privacy_nlf').is(":checked")) {
485    var privacy = 1;
486  } else {
487    var privacy = 0;
488  }
489
490  if (email != "" && nome != "" && privacy == 1) {
491    if (validateEmail(email)) {
492      $.ajax({
493        url: "https://admin.visititaly.eu/controller/utenti.controller.php?c_visit=" + c_visit,
494        data: newsletter_form,
495        dataType: "json",
496        type: "POST",
497        cache: false,
498        success: function (obj) {
499
500          if (obj.status == "success") {
501
502            $(".cont_form_newsletter").hide();
503            $(".cont_success_newsletter").show();
504
505            toastr.success(messaggio_successo);
506
507          } else if (obj.status == "email") {
508
509            toastr.warning(messaggio_dati_mancanti, esito_password);
510
511          } else if (obj.status == "esistente_richiesta") {
512
513            toastr.warning(lab_esistente_richiesta_nl);
514
515          } else if (obj.status == "esistente_utenti") {
516
517            toastr.success(lab_esistente_utenti_nl);
518
519          } else {
520
521            toastr.error(messaggio_errore_procedura);
522
523          }
524        }
525      });
526    } else {
527      toastr.error(label_mess_email_errata, label_titolo_email_errata);
528    }
529  } else {
530    toastr.error(messaggio_dati_mancanti, esito_password);
531  }
532
533}
534
535let lastSearch = "";
536let debounceTimeout;
537let box_ricerca = "headerSearch3";
538let box_risultati = "ricerca_cont_header";
539
540function debounce(func, delay) {
541
542  //  console.log("debounce", func, delay);
543  let timer;
544  return function (...args) {
545    clearTimeout(timer);
546    timer = setTimeout(() => func.apply(this, args), delay);
547  };
548}
549
550function CloseSearch() {
551  document.getElementById(box_risultati).innerHTML = '';
552  document.getElementById(box_risultati).style.display = 'none';
553  $('#' + box_ricerca).val("");
554}
555
556function Search(serach_box) {
557
558  if (serach_box == "menu") {
559    box_ricerca = "headerSearch2";
560    box_risultati = "ricerca_cont";
561  } else {
562    box_ricerca = "headerSearch3";
563    box_risultati = "ricerca_cont_header";
564  }
565
566  const search_q = document.getElementById(box_ricerca).value;
567  const lingua = document.getElementById('lingua').value;
568  const c_visit = document.getElementById('c_visit').value;
569
570  if (search_q.length == 0) {
571    $('#' + box_risultati).html()
572    $('#' + box_risultati).hide()
573  }
574
575  if (search_q.length === 0) {
576    var targetContainer2 = $("#" + box_risultati), template2 = $("#cont_artmenu").html();
577    $(targetContainer2).html("");
578    $(targetContainer2).html(Mustache.to_html(template2, { "art": articoli_evi_ricerca }));
579    //document.getElementById(box_risultati).innerHTML = '';
580    document.getElementById(box_risultati).style.display = 'none';
581    return;
582  }
583
584  if (search_q.length > 3) {
585    $.ajax({
586      type: "POST",
587      url: "https://admin.visititaly.eu/controller/search.controller.php",
588      data: { c_visit, lingua, search_q, act: "ricercaV2" },
589      cache: false,
590      dataType: "json",
591    })
592      .done(function (obj) {
593        handleSearchResults(obj, search_q, lingua);
594      })
595      .fail(function (xhr, status, error) {
596        //console.error("Errore nella ricerca:", error);
597        document.getElementById("ricerca_null").style.display = 'block';
598        document.getElementById("all_result").style.display = 'none';
599      });
600  }
601
602}
603
604function handleSearchResults(obj, search_q, lingua) {
605  $("#" + box_risultati).show();
606  const targetContainer2 = $("#" + box_risultati);
607  const template2 = $("#cont_ricerca").html();
608
609  $(targetContainer2).html(Mustache.to_html(template2, { "ric": obj.ricerca }));
610  $("#url_risultati").attr("href", `https://visititaly.eu/index.php?sezione=risultati&lin=${lingua}&ricerca=${encodeURIComponent(search_q)}`);
611
612  if (obj.ricerca.length > 0) {
613    document.getElementById("ricerca_null").style.display = 'none';
614    // document.getElementById("all_result").style.display = 'block';
615  } else {
616    $("#" + box_risultati).hide();
617    document.getElementById("ricerca_null").style.display = 'block';
618    // document.getElementById("all_result").style.display = 'none';
619  }
620}
621
622// $('#headerSearch2').on('input', debounce(() => Search('menu'), 400));
623// $('#headerSearch3').on('input', debounce(() => Search('header'), 400));
624
625$(document).ready(function () {
626  $('#headerSearch2, #headerSearch3').each(function () {
627    $(this).on('input change', debounce(function () {
628      let id = $(this).attr('id');
629      let searchArea = id === 'headerSearch2' ? 'menu' : 'header';
630      Search(searchArea);
631    }, 400));
632  });
633});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.