1 2var sgart = sgart || {}; 3/* 4* Sgart.it - chiamata ajax in POST 5* url: url del servizio da chiamare 6* jsonObject: oggetto javascript 7* fnCallbackOk: funzione richiamata in caso di successo 8* fnCallbackError: funzione richiamata in caso di errore 9*/ 10sgart.jsonPost = function (url, jsonObject, fnCallbackOk, fnCallbackError) { 11 var xHttp = new XMLHttpRequest(); 12 xHttp.onreadystatechange = function () { 13 if (this.readyState === 4) { 14 if (this.status === 200) { 15 if (typeof fnCallbackOk === "function") { 16 fnCallbackOk(JSON.parse(this.responseText)); 17 } else { 18 //console.log("warning: reponse ok but no calback function", url); 19 } 20 } else { 21 /* console.log("Error", url, this.status, this.responseText);*/ 22 if (typeof fnCallbackError === "function") { 23 fnCallbackError(this.status, this.responseText); 24 } 25 } 26 } 27 }; 28 // imposto la chiamata in POST asincrona 29 xHttp.open("POST", url, true); 30 xHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); 31 32 xHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 33 // header necessario per le chiamate alla API di SharePoint 34 xHttp.setRequestHeader("Accept", "*/*"); 35 36 var query = []; 37 for (var key in jsonObject) { 38 query.push(encodeURIComponent(key) + '=' + encodeURIComponent(jsonObject[key])); 39 } 40 // serializzo l'oggetto json in stringa 41 /* var data = JSON.stringify(jsonObject);*/ 42 // invio la chiamata in post con la stringa che rappresenta il json 43 xHttp.send(query.join('&')); 44}; 45 46 47 48var sgart = sgart || {}; 49/* 50 * Sgart.it - chiamata ajax in GET 51 * url: url del servizio da chiamare con eventuali parametri in query string 52 * fnCallbackOk: funzione richiamata in caso di successo 53 * fnCallbackError: funzione richiamata in caso di errore 54 */ 55sgart.jsonGet = function (url, fnCallbackOk, fnCallbackError) { 56 // creo l'oggetto per la chiamata 57 var xHttp = new XMLHttpRequest(); 58 // gestisco la callback di risposta 59 xHttp.onreadystatechange = function () { 60 if (this.readyState === 4) { 61 if (this.status === 200) { 62 if (typeof fnCallbackOk === "function") { 63 // se ho un 200 tutto ok, 64 // chiamo la funzione passata di callback passandogli l'oggetto json 65 fnCallbackOk(JSON.parse(this.responseText)); 66 } else { 67 // se non ho passato una funzione stampo un warning in console; 68 //console.log("warning: reponse ok but no calback function", url); 69 } 70 } else { 71 // se sono qui c'è stato un errore, lo scrivo sempre in console 72 //console.log("Error", url, this.status, this.responseText); 73 if (typeof fnCallbackError === "function") { 74 // se esiste chiamo la callback di errore 75 fnCallbackError(this.status, this.responseText); 76 } 77 } 78 } 79 }; 80 // inposto la chiamata in GET asincrona (true) 81 xHttp.open("GET", url, true); 82 // imposto il content type per le chiamate json 83 xHttp.setRequestHeader("Content-type", "application/json"); 84 xHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 85 // header necessario per le chiamate alla API di SharePoint 86 xHttp.setRequestHeader("Accept", "application/json; odata=verbose"); 87 // eseguo la chiamata 88 xHttp.send(); 89}; 90 91 92sgart.jsonPostjosonencode = function (url, jsonObject, fnCallbackOk, fnCallbackError) { 93 var xHttp = new XMLHttpRequest(); 94 xHttp.onreadystatechange = function () { 95 if (this.readyState === 4) { 96 if (this.status === 200) { 97 if (typeof fnCallbackOk === "function") { 98 fnCallbackOk(JSON.parse(xHttp.responseText)); 99 } else { 100 //console.log("warning: reponse ok but no calback function", url); 101 } 102 } else { 103 /* console.log("Error", url, this.status, this.responseText);*/ 104 if (typeof fnCallbackError === "function") { 105 fnCallbackError(this.status, this.responseText); 106 } 107 } 108 } 109 }; 110 // imposto la chiamata in POST asincrona 111 xHttp.open("POST", url, true); 112 xHttp.setRequestHeader("Content-type", "application/json"); 113 114 xHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 115 // header necessario per le chiamate alla API di SharePoint 116 xHttp.setRequestHeader("Accept", "*/*");
117 xHttp.setRequestHeader("Access-Control-Allow-Methods", "POST"); 118 119 120 xHttp.setRequestHeader("Access-Control-Allow-Origin", "*"); 121 //xHttp.onreadystatechange = function () { 122 // if (xHttp.readyState === 4 && xHttp.status === 200) { 123 // var json = JSON.parse(xHttp.responseText); 124 125 // } 126 //}; 127 128 xHttp.send(JSON.stringify(jsonObject)); 129 130 131}; 132 133 134var globalTimeout = null; 135function autocomplete(componentid, post,clerfunction) { 136 137 138 var container = document.getElementById(componentid); 139 var txtinput = container.querySelector("input[name='search']"); 140 var btn = container.querySelector("button[name='applayserach']"); 141 var form = document.getElementById(componentid + '_form'); 142 document.querySelector("form." + componentid + "_form input[name='page']").value = 0; 143 144 //var paging = document.querySelector("form." + componentid + "_form input[name='page']"); 145 //if (paging != null && paging.length > 0) { 146 // paging[0].value = 0; 147 148 //} 149 var currentFocus = -1; 150 151 152 153 window.addEventListener('click', function (e) { 154 //e.preventDefault(); 155 156 if (!container.contains(e.target)) { 157 158 if (document.getElementById(componentid + "_autocomplete-list")) { 159 document.getElementById(componentid + "_autocomplete-list").style.display = "none"; 160 } 161 } else { 162 if (document.getElementById(componentid + "_autocomplete-list")) { 163 document.getElementById(componentid + "_autocomplete-list").style.display = "block"; 164 } 165 } 166 167 /* return false;*/ 168 }); 169 170 txtinput.addEventListener("keyup", function (e) { 171 e.preventDefault(); 172 var inputElements = document.getElementsByClassName('autocompliteinput'); 173 for (var i = 0; inputElements[i]; ++i) { 174 if (inputElements[i] != txtinput) { 175 inputElements[i].value = txtinput.value; 176 } 177 } 178 var inputpages = document.getElementsByClassName('page'); 179 for (var i = 0; inputpages[i]; ++i) { 180 181 inputpages[i].value =0; 182 183 } 184 185 changequerystring(componentid + '_form'); 186 187 var x = document.getElementById(componentid + "_autocomplete-list"); 188 if (x) x = x.getElementsByTagName("li"); 189 190 if (e.keyCode == 40) { 191 192 /*If the arrow DOWN key is pressed, 193 increase the currentFocus variable:*/ 194 if (currentFocus < x.length - 1) 195 currentFocus++; 196 /*and and make the current item more visible:*/ 197 addActive(x); 198 199 } 200 else if (e.keyCode == 38) { //up 201 /*If the arrow UP key is pressed, 202 decrease the currentFocus variable:*/ 203 if (currentFocus > 0) 204 currentFocus--; 205 /*and and make the current item more visible:*/ 206 addActive(x); 207 208 } 209 else if (e.keyCode == 13) { 210 211 //if (globalTimeout != null) clearTimeout(globalTimeout); 212 213 if (currentFocus > -1) { 214 /*and simulate a click on the "active" item:*/ 215 216 if (x[currentFocus]) { 217 a = x[currentFocus].getElementsByTagName("a"); 218 if (a && a.length > 0 && a[0]) { 219 220 window.location.href = a[0].getAttribute('data-url') 221 } 222 } 223 } 224 else { 225 226 if (post != null) { 227 post(); 228 } 229 230 } 231 232 233 } 234 else { 235 if (globalTimeout != null) clearTimeout(globalTimeout); 236 globalTimeout = setTimeout(function () { SearchFunc(txtinput) }, 500); 237 238 } 239 }); 240 241 txtinput.addEventListener("search", function (e) { 242 e.preventDefault(); 243 244 if (e.currentTarget != null && e.currentTarget.value == '') { 245 246 247 txtinput.value = ''; 248 249 var inputElements = document.getElementsByClassName('autocompliteinput'); 250 for (var i = 0; inputElements[i]; ++i) { 251 if (inputElements[i] != txtinput) { 252 inputElements[i].value = ''; 253 } 254 } 255 var inputpages = document.getElementsByClassName('page'); 256 for (var i = 0; inputpages[i]; ++i) { 257 258 inputpages[i].value = 0; 259 260 } 261 changequerystring(componentid + '_form'); 262 263 closeAllLists(txtinput.parentNode); 264 265 if (clerfunction) { 266 clerfunction(); 267 } 268 269 } 270 271 272 273 });
274 275 //btn.addEventListener('click', function (e) { 276 // e.preventDefault(); 277 // if (post) { 278 // post(); 279 // } 280 //}); 281 282 function addActive(x) { 283 /*a function to classify an item as "active":*/ 284 if (!x) return false; 285 286 removeActive(x); 287 /* if (currentFocus >= x.length) currentFocus = 0;*/ 288 /* if (currentFocus < 0) currentFocus = (x.length - 1);*/ 289 /*add class "autocomplete-active":*/ 290 x[currentFocus].classList.add("autocomplete-active"); 291 292 scrollToElm(document.getElementById(componentid + "_autocomplete-list"), x[currentFocus], 0.1); 293 294 } 295 function removeActive(x) { 296 /*a function to remove the "active" class from all autocomplete items:*/ 297 for (var i = 0; i < x.length; i++) { 298 x[i].classList.remove("autocomplete-active"); 299 } 300 } 301 302 303 function closeAllLists(parent) { 304 305 if (document.getElementById(parent.id + "_autocomplete-list")) { 306 parent.removeChild(document.getElementById(parent.id + "_autocomplete-list")); 307 308 } 309 } 310 311 function SearchFunc(txtinput) { 312 313 currentFocus = -1; 314 globalTimeout = null; 315 316 317 318 if (txtinput.value != '' && txtinput.value.length > 2) { 319 sgart.jsonGet('/ricerca/autocomplete?languageId=' + languageId + '&' + getquerystringfromform(componentid + '_form'), function (res) { 320 321 if (res.success) { 322 closeAllLists(txtinput.parentNode); 323 324 a = document.createElement("ul"); 325 a.setAttribute("id", txtinput.parentNode.id + "_autocomplete-list"); 326 a.setAttribute("class", "autocomplete-items"); 327 txtinput.parentNode.appendChild(a); 328 for (var i = 0; i < res.items.items.length; i++) { 329 var obj = res.items.items[i]; 330 b = document.createElement("li"); 331 var linkhtml = "<a href='" + obj.content['url'] + "' data-url='" + obj.content['url'] + "' >" + obj.content['name']; 332 if (obj.mainTassonomi != null) { 333 linkhtml += "<span class='category'>" + obj.mainTassonomi['name'] + "</span>"; 334 } 335 336 linkhtml += "</a>"; 337 b.innerHTML += linkhtml 338 a.appendChild(b); 339 } 340 341 342 343 } 344 else { 345 } 346 }, 347 function () { 348 349 } 350 351 ); 352 } 353 354 355 356 } 357 358 359 360 function scrollToElm(container, elm, duration) { 361 var pos = getRelativePos(elm); 362 scrollTo(container, pos.top, 0.1); // duration in seconds 363 } 364 365 function getRelativePos(elm) { 366 var pPos = elm.parentNode.getBoundingClientRect(), // parent pos 367 cPos = elm.getBoundingClientRect(), // target pos 368 pos = {}; 369 370 pos.top = cPos.top - pPos.top + elm.parentNode.scrollTop, 371 pos.right = cPos.right - pPos.right, 372 pos.bottom = cPos.bottom - pPos.bottom, 373 pos.left = cPos.left - pPos.left; 374 375 return pos; 376 } 377 378 function scrollTo(element, to, duration, onDone) { 379 var start = element.scrollTop, 380 change = to - start, 381 startTime = performance.now(), 382 val, now, elapsed, t; 383 384 function animateScroll() { 385 now = performance.now(); 386 elapsed = (now - startTime) / 1000; 387 t = (elapsed / duration); 388 389 element.scrollTop = start + change * easeInOutQuad(t); 390 391 if (t < 1) 392 window.requestAnimationFrame(animateScroll); 393 else 394 onDone && onDone(); 395 }; 396 397 animateScroll(); 398 } 399 function easeInOutQuad(t) { return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t }; 400 401 402 403 404} 405 406function inlinesearch(autocomplte,componentid, selector, sliderselector, clerfunction,searchfuntion) { 407 408 409 410 var container = document.getElementById(componentid); 411 var txtinput = container.querySelector("input[name='search']"); 412 var btn = container.querySelector("div > input[name='applayserach']"); 413 var form = document.getElementById(componentid + '_form'); 414 document.querySelector("form." + componentid + "_form input[name='page']").value = 0; 415 416 417 418 var direction = document.getElementById('direction'); 419 420 if (direction) { 421 direction.addEventListener("change", function (e) { 422 e.preventDefault(); 423 424 425 changequerystring(componentid + '_form'); 426 427 requestajax(selector, document.getElementById(componentid + '_form').action + '?languageId=' + languageId + '&' + getquerystringfromform(componentid + '_form'), false, sliderselector) 428 429 430 }); 431 } 432 if (autocomplte == true) { 433 txtinput.addEventListener("keyup", function (e) { 434 e.preventDefault(); 435 var inputElements = document.getElementsByClassName('autocompliteinput'); 436 for (var i = 0; inputElements[i]; ++i) { 437 if (inputElements[i] != txtinput) { 438 inputElements[i].value = txtinput.value; 439 } 440 } 441 var inputpages = document.getElementsByClassName('page'); 442 for (var i = 0; inputpages[i]; ++i) { 443 444 inputpages[i].value = 0; 445 446 } 447 448 changequerystring(componentid + '_form'); 449 450 451 452 if (globalTimeout != null) clearTimeout(globalTimeout); 453 globalTimeout = setTimeout(function () { SearchFunc(txtinput) }, 500); 454 }); 455 } 456 457 458 txtinput.addEventListener("search", function (e) { 459 e.preventDefault(); 460 461 if (e.currentTarget != null && e.currentTarget.value == '') { 462 463 464 txtinput.value = ''; 465 466 var inputElements = document.getElementsByClassName('autocompliteinput'); 467 for (var i = 0; inputElements[i]; ++i) { 468 if (inputElements[i] != txtinput) { 469 inputElements[i].value = ''; 470 } 471 } 472 var inputpages = document.getElementsByClassName('page'); 473 for (var i = 0; inputpages[i]; ++i) { 474 475 inputpages[i].value = 0; 476 477 } 478 changequerystring(componentid + '_form'); 479 480 481 482 if (clerfunction) { 483 clerfunction(); 484 } 485 486 } 487 488 489 490 });
491 if (btn) { 492 btn.addEventListener("click", function (e) { 493 e.preventDefault(); 494 495 var inputpages = document.getElementsByClassName('page'); 496 for (var i = 0; inputpages[i]; ++i) { 497 498 inputpages[i].value = 0; 499 500 } 501 if (searchfuntion) { 502 searchfuntion(); 503 } 504 else { 505 changequerystring(componentid + '_form'); 506 requestajax('lista', document.getElementById('inline_form').action + '?languageId=' + languageId + '&' + getquerystringfromform('inline_form'),'') 507 } 508 509 }); 510 } 511 512 function SearchFunc(txtinput) { 513 514 515 globalTimeout = null; 516 517 518 519 if (txtinput.value != '' ) { 520 sgart.jsonGet(document.getElementById('inline_form').action + '?languageId=' + languageId +'&' + getquerystringfromform(componentid + '_form'), function (res) { 521 522 if (res.success) { 523 524 document.getElementById(selector).innerHTML = res.modalPartial.result; 525 if (sliderselector != '') { 526 /*document.getElementById(sliderselector).innerHTML = res.modalsliderPartial.result;*/ 527 var inputElements = document.getElementsByClassName(sliderselector); 528 for (var i = 0; inputElements[i]; ++i) { 529 if (inputElements[i]) { 530 inputElements[i].innerHTML = res.modalsliderPartial.result; 531 } 532 } 533 } 534 535 } 536 else { 537 } 538 }, 539 function () { 540 541 } 542 543 ); 544 } 545 546 547 548 } 549 550 551 552} 553requestajax = function (selector, action, append, sliderselector) { 554 document.getElementById('mainloading').style.display = "block"; 555 556 sgart.jsonGet(action, function (res) { 557 if (res.success) { 558 559 if (append) { 560 561 document.getElementById(selector).innerHTML += res.modalPartial.result; 562 if (sliderselector != '') { 563 var inputElements = document.getElementsByClassName(sliderselector); 564 for (var i = 0; inputElements[i]; ++i) { 565 if (inputElements[i]) { 566 inputElements[i].innerHTML += res.modalsliderPartial.result;; 567 } 568 } 569 /*document.getElementById(sliderselector).innerHTML += res.modalsliderPartial.result;*/ 570 } 571 } 572 else { 573 document.getElementById(selector).innerHTML = res.modalPartial.result; 574 if (sliderselector != '') { 575 /*document.getElementById(sliderselector).innerHTML = res.modalsliderPartial.result;*/ 576 var inputElements = document.getElementsByClassName(sliderselector); 577 for (var i = 0; inputElements[i]; ++i) { 578 if (inputElements[i]) { 579 inputElements[i].innerHTML = res.modalsliderPartial.result; 580 } 581 } 582 } 583 } 584 585 document.getElementById('mainloading').style.display = "none"; 586 587 588 } 589 else { 590 document.getElementById('mainloading').style.display = "none"; 591 592 } 593 594 }, 595 function () { 596 597 document.getElementById('mainloading').style.display = "none"; 598 } 599 600 ); 601 return false; 602} 603 604handleOnClick = function (e, input, pageindex, componentid, selector, sliderselector) { 605 e.preventDefault(); 606 607 var paging = document.getElementsByClassName('paging'); 608 if (paging != null && paging.length > 0) { 609 paging[0].remove(); 610 611 } 612 else { 613 input.remove(); 614 615 } 616 617 document.querySelector("form." + componentid + "_form input[name='page']").value = pageindex; 618 changequerystring(componentid + '_form',true); 619 requestajax(selector, document.getElementById(componentid + '_form').action + '?languageId=' + languageId +'&' + getquerystringfromform(componentid + '_form'), true, sliderselector); 620 621 622 return false; 623}; 624 625 626gotopage = function (e, input, pageindex, componentid, selector, sliderselector) { 627 e.preventDefault(); 628 629 var paging = document.getElementsByClassName('paging'); 630 if (paging != null && paging.length > 0) { 631 paging[0].remove(); 632 633 } 634 else { 635 input.remove(); 636 637 } 638 639 document.querySelector("form." + componentid + "_form input[name='page']").value = pageindex; 640 changequerystring(componentid + '_form',false); 641 requestajax(selector, document.getElementById(componentid + '_form').action + '?languageId=' + languageId +'&' + getquerystringfromform(componentid + '_form'), false, sliderselector); 642 643 644 return false; 645}; 646 647 648function searchresult(componentid) { 649 650 651 var container = document.getElementById(componentid); 652 var txtinput = document.getElementById('search'); 653 var form = document.getElementById(componentid + '_form'); 654 document.querySelector("form." + componentid + "_form input[name='page']").value = 0; 655 656 657 txtinput.addEventListener("keyup", function (e) { 658 e.preventDefault(); 659 660 661 if (e.keyCode == 13) { 662 SearchinlieFunc(txtinput) 663 } 664 665 //if (globalTimeout != null) clearTimeout(globalTimeout); 666 //globalTimeout = setTimeout(function () { SearchinlieFunc(txtinput) }, 500); 667 668 669 });
670 671 txtinput.addEventListener("search", function (e) { 672 e.preventDefault(); 673 674 if (e.currentTarget != null && e.currentTarget.value == '') { 675 document.getElementById('search').value = ''; 676 document.getElementById('page').value = 0; 677 changequerystring(componentid + '_form', true); 678 LoadSearchItemsAjax(); 679 } 680 681 682 683 }); 684 685 686 function SearchinlieFunc(txtinput) { 687 688 689 globalTimeout = null; 690 691 692 693 694 document.getElementById('page').value = 0; 695 changequerystring(componentid + '_form', true); 696 LoadSearchItemsAjax(); 697 698 } 699 700 701} 702removealertfilter = function (e, type) { 703 e.preventDefault(); 704 var value = document.getElementById('tassonomycheck').value; 705 706 value = value.replace(type+';','') 707 708 document.getElementById('tassonomycheck').value = value; 709 710 711 712 document.getElementById('page').value = 0; 713 changequerystring('main_form', true); 714 715 LoadSearchItemsAjax(); 716 717 return false; 718}; 719 720removealerttopicfilter = function (e, type) { 721 e.preventDefault(); 722 var value = document.getElementById('topiccheck').value; 723 724 value = value.replace(type + ';', '') 725 726 document.getElementById('topiccheck').value = value; 727 728 729 730 document.getElementById('page').value = 0; 731 changequerystring('main_form', true); 732 733 LoadSearchItemsAjax(); 734 735 return false; 736 }; 737 738updatechekfilter = function (e, type) { 739 e.preventDefault(); 740 741 var inputElements = document.getElementsByClassName(type); 742 document.getElementById(type).value = ''; 743 for (var i = 0; inputElements[i]; ++i) { 744 if (inputElements[i].checked) { 745 document.getElementById(type).value += inputElements[i].value + ';'; 746 } 747 } 748 749 750 document.getElementById('page').value = 0; 751 changequerystring('main_form', true); 752 753 LoadSearchItemsAjax(); 754 755 return false; 756}; 757 758updatechekfiltermobile = function (e, type) { 759 e.preventDefault(); 760 761 var inputElements = document.getElementsByClassName(type); 762 document.getElementById(type).value = ''; 763 for (var i = 0; inputElements[i]; ++i) { 764 if (inputElements[i].checked) { 765 document.getElementById(type).value += inputElements[i].value + ';'; 766 } 767 } 768 769 770 document.getElementById('page').value = 0; 771 772 773 return false; 774}; 775 776applyinlinesearch = function (e) { 777 e.preventDefault(); 778 779 780 781 changequerystring('main_form', true); 782 783 LoadSearchItemsAjax(); 784 785 return false; 786}; 787 788applyinlinesearchmobile = function (e) { 789 e.preventDefault(); 790 791 792 document.getElementById('tassonomycheck').value = document.getElementById('tassonomycheckmobile').value;; 793 document.getElementById('topiccheck').value = document.getElementById('topiccheckmobile').value;; 794 changequerystring('main_form', true); 795 796 LoadSearchItemsAjax(); 797 798 return false; 799}; 800 801 802 803clearfilter = function (e) { 804 e.preventDefault(); 805 806 807 808 document.getElementById('page').value = 0; 809 document.getElementById('search').value = ''; 810 811 document.getElementById('tassonomycheck').value = ''; 812 document.getElementById('topiccheck').value = ''; 813 var inputElements = document.getElementsByClassName('tassonomycheckmobile'); 814 815 for (var i = 0; inputElements[i]; ++i) { 816 if (inputElements[i].checked) { 817 inputElements[i].checked = false; 818 } 819 } 820 var inputElements = document.getElementsByClassName('topiccheckmobile'); 821 822 for (var i = 0; inputElements[i]; ++i) { 823 if (inputElements[i].checked) { 824 inputElements[i].checked = false; 825 } 826 } 827 828 changequerystring('main_form', true); 829 830 LoadSearchItemsAjax(); 831 832 return false; 833}; 834 835//clearfiltermobile = function (e) { 836// e.preventDefault(); 837 838 839 840// document.getElementById('page').value = 0; 841// document.getElementById('search').value = ''; 842 843// document.getElementById('tassonomycheck').value = ''; 844// document.getElementById('topiccheck').value = ''; 845// changequerystring('main_form', true); 846 847// LoadSearchItemsAjax(); 848 849// return false; 850//}; 851 852LoadSearchItemsAjax = function () { 853 854 855 requestajax('finderesult', document.getElementById('main_form').action + '?languageId=' + languageId + '&' + getquerystringfromform('main_form'), false,''); 856 857 858 859 860 861} 862 863window.__append_script = function (src, callback) { 864 865 if (!isMyScriptLoaded(src)) { 866 var scriptElement = document.createElement('script'); 867 scriptElement.type = 'text/javascript'; 868 scriptElement.src = src; 869 if (callback) 870 scriptElement.onload = callback; 871 document.body.appendChild(scriptElement); 872 873 } 874} 875 876mainchangeLine = function (e, input, form) { 877 e.preventDefault(); 878 var idroute = input.value 879 880 881 if (idroute != '') { 882 document.getElementById('searchlineHomecta').innerHTML = '' 883 document.getElementById('mainloading').style.display = "block"; 884 var htmldirection = '<option value="">' + __com_ecommerce_resources["Seleziona direzione"] + '</option>'; 885 sgart.jsonGet('/ricerca/mainchangelineafermate' + '?languageId=' + languageId + '&idroute=' + idroute, function (res) { 886 if (res.success) { 887 888 889 890 891 892 res.diresctions.forEach(function (e, index, arr) { 893 894 if (index == 0) { 895 htmldirection += '<option value="1"> ' + e + '</option>' 896 } 897 else if (index == 1) { 898 htmldirection += '<option value="0"> ' + e + '</option>' 899 } 900 }); 901 document.getElementById('direction').innerHTML = htmldirection; 902 903 904 /* document.getElementById('searchlineHomecta').innerHTML = res.modalPartial;*/ 905 906 907 document.getElementById('mainloading').style.display = "none"; 908 document.getElementById('direction').disabled = false; 909 910 document.querySelector("label[for=direction]").classList.remove("disabled"); 911 912 changequerystring('prossimefermateformhome', true); 913 } 914 else { 915 document.getElementById('mainloading').style.display = "none"; 916 917 } 918 919 }, 920 function () { 921 922 document.getElementById('mainloading').style.display = "none"; 923 } 924 925 ); 926 927 } 928 else { 929 document.getElementById('searchlineHomecta').innerHTML ='' 930 document.getElementById('direction').innerHTML = '<option value="">' + __com_ecommerce_resources["Seleziona direzione"] + '</option>'; 931 document.getElementById('direction').disabled = true;; 932 document.querySelector("label[for=direction]").classList.add("disabled"); 933 } 934 935 936 937 938 return false; 939}; 940 941 942mainchangedirection = function (e, input, form) { 943 e.preventDefault(); 944 var idroute = document.getElementById('idroute').value; 945 var direction = input.value 946 947 948 949 950 if (direction != '' && idroute != '') { 951 document.getElementById('mainloading').style.display = "block"; 952 sgart.jsonGet('/ricerca/mainchangelineafermate' + '?languageId=' + languageId + '&idroute=' + idroute + '&direction=' + direction, function (res) { 953 954 if (res.success) { 955 956 957 958 959 document.getElementById('searchlineHomecta').innerHTML = res.modalPartial; 960 961 document.getElementById('mainloading').style.display = "none"; 962 963 964 } 965 else { 966 document.getElementById('mainloading').style.display = "none"; 967 968 } 969 970 }, 971 function () { 972 973 document.getElementById('mainloading').style.display = "none"; 974 } 975 976 ); 977 } 978 else { 979 document.getElementById('searchlineHomecta').innerHTML = ''; 980 } 981 982 changequerystring('prossimefermateformhome', true); 983 984 985 986 return false; 987}; 988 989changeLine = function (e, input,form) { 990 e.preventDefault(); 991 var idroute = input.value 992 993 document.getElementById('result').innerHTML = ''; 994 if (idroute != '') { 995 document.getElementById('mainloading').style.display = "block"; 996 sgart.jsonGet('/ricerca/lineafermate' + '?languageId=' + languageId + '&idroute=' + idroute, function (res) { 997 if (res.success) { 998 999 1000 if (document.getElementById('result')) { 1001 document.getElementById('result').innerHTML = ''; 1002 } 1003 1004 var htmldirection = '<option value="">' + __com_ecommerce_resources["Seleziona direzione"] + '</option>'; 1005 res.diresctions.forEach(function (e, index, arr) { 1006 1007 if (index == 0) { 1008 htmldirection += '<option value="1"> ' + e + '</option>' 1009 } 1010 else if (index == 1) { 1011 htmldirection += '<option value="0"> ' + e + '</option>' 1012 } 1013 }); 1014 document.getElementById('direction').innerHTML = htmldirection; 1015 document.getElementById('direction').disabled = false; 1016 document.querySelector("label[for=direction]").classList.remove("disabled"); 1017 1018 1019 document.getElementById('idstop').innerHTML = '<option value="">' + __com_ecommerce_resources["Seleziona fermata"] + '</option>'; 1020 document.getElementById('idstop').disabled = true;; 1021 document.querySelector("label[for=idstop]").classList.add("disabled"); 1022 1023 document.getElementById('mainloading').style.display = "none"; 1024 document.getElementById("getcorsebtn").classList.add("disabled"); 1025 changequerystring('prossimefermateform', true); 1026 1027 } 1028 else { 1029 document.getElementById('mainloading').style.display = "none"; 1030 1031 } 1032 1033 }, 1034 function () { 1035 1036 document.getElementById('mainloading').style.display = "none"; 1037 } 1038 1039 ); 1040 } 1041 else { 1042 document.getElementById('direction').innerHTML = '<option value="">' + __com_ecommerce_resources["Seleziona direzione"] + '</option>'; 1043 document.getElementById('direction').disabled = true;; 1044 document.querySelector("label[for=direction]").classList.add("disabled"); 1045 1046 document.getElementById('idstop').innerHTML = '<option value="">' + __com_ecommerce_resources["Seleziona fermata"] + '</option>'; 1047 document.getElementById('idstop').disabled = true;; 1048 document.querySelector("label[for=idstop]").classList.add("disabled"); 1049 document.getElementById("getcorsebtn").classList.add("disabled"); 1050 } 1051 1052 changequerystring('prossimefermateform', true); 1053 return false; 1054}; 1055 1056 1057 1058 1059 1060changedirection = function (e, input, form, selectorlinee, selectdfermate, selectcta) { 1061 e.preventDefault(); 1062 var idroute = document.getElementById('idroute').value; 1063 var direction = input.value 1064 1065 document.getElementById('result').innerHTML = ''; 1066 if (direction != '' && idroute != '') { 1067 document.getElementById('mainloading').style.display = "block"; 1068 1069 sgart.jsonGet('/ricerca/lineafermate?languageId=' + languageId + '&idroute=' + idroute + '&direction=' + direction, function (res) { 1070 if (res.success) { 1071 1072 1073 var htmlfermate = '<option value=""> ' + __com_ecommerce_resources["Seleziona fermata"] + '</option>'; 1074 res.fermate.forEach(function (e, index, arr) { 1075 1076 1077 htmlfermate += '<option value="' + e.id + '"> ' + e.name + '</option>' 1078 }); 1079 document.getElementById('idstop').innerHTML = htmlfermate; 1080 1081 1082 document.getElementById('idstop').disabled = false;; 1083 document.querySelector("label[for=idstop]").classList.remove("disabled"); 1084 1085 if (document.getElementById('result')) { 1086 document.getElementById('result').innerHTML = ''; 1087 } 1088 1089 document.getElementById('mainloading').style.display = "none"; 1090 document.getElementById("getcorsebtn").classList.add("disabled"); 1091 changequerystring('prossimefermateform', true); 1092 } 1093 else { 1094 document.getElementById('mainloading').style.display = "none"; 1095 1096 } 1097 1098 }, 1099 function () { 1100 1101 document.getElementById('mainloading').style.display = "none"; 1102 } 1103 1104 ); 1105 } 1106 else { 1107 document.getElementById('idstop').disabled = true;; 1108 document.querySelector("label[for=idstop]").classList.add("disabled"); 1109 document.getElementById('idstop').innerHTML = '<option value="">' + __com_ecommerce_resources["Seleziona fermata"] + '</option>'; 1110 changequerystring('prossimefermateform', true); 1111 document.getElementById("getcorsebtn").classList.add("disabled"); 1112 } 1113 1114 1115 1116 1117 return false; 1118}; 1119 1120 1121changefermata = function (e, input, form) { 1122 e.preventDefault(); 1123 var idstop = document.getElementById('idstop').value; 1124 if ( idstop != '') { 1125 document.getElementById("getcorsebtn").classList.remove("disabled"); 1126 } 1127 else { 1128 document.getElementById("getcorsebtn").classList.add("disabled"); 1129 } 1130 changequerystring('prossimefermateform', true); 1131 document.getElementById('result').innerHTML = ''; 1132 return false; 1133}; 1134 1135 1136getcorse = function (e, selectdfermate,selectdirection, selectidroute) { 1137 if (e != null) { 1138 1139 e.preventDefault(); 1140 } 1141 1142 var idstop = document.getElementById(selectdfermate).value; 1143 var idroute = document.getElementById(selectidroute).value; 1144 var direction = document.getElementById(selectdirection).value; 1145 //changequerystring('mappa_form', true); 1146 if (idstop != '') { 1147 if (e != null) { 1148 document.getElementById('mainloading').style.display = "block"; 1149 } 1150 sgart.jsonGet('/ricerca/prossimecorse' + '?languageId=' + languageId + '&idstop=' + idstop + '&direction=' + direction+ '&idroute=' + idroute, function (res) { 1151 if (res.success) { 1152 1153 1154 1155 1156 document.getElementById('result').innerHTML = res.model.modalPartial; 1157 1158 1159 setTimeout(refreshgetcorse, 30000); 1160 1161 document.getElementById('mainloading').style.display = "none"; 1162 1163 1164 } 1165 else { 1166 document.getElementById('mainloading').style.display = "none"; 1167 alert(res) 1168 } 1169 1170 }, 1171 function () { 1172 1173 document.getElementById('mainloading').style.display = "none"; 1174 } 1175 1176 ); 1177 } 1178 1179 1180 1181 1182 1183 1184 return false; 1185}; 1186 1187refreshgetcorse = function () { 1188 1189 var idstop = document.getElementById('idstop').value; 1190 var idroute = document.getElementById('idroute').value; 1191 if (idstop != '') { 1192 getcorse(null, 'idstop', 'idroute'); 1193 } 1194} 1195 1196function autocompleteFermate(componentid,name,hiddenname) { 1197 1198 1199 var container = document.getElementById(componentid); 1200 var txtinput = container.querySelector("input[name='" +name+"']"); 1201 var hiddeninput = container.querySelector("input[name='" + hiddenname + "']"); 1202 var form = document.getElementById(componentid + '_form'); 1203 1204 var currentFocus = -1; 1205 1206 1207 1208 window.addEventListener('click', function (e) { 1209 //e.preventDefault(); 1210 1211 if (!container.contains(e.target)) { 1212 1213 if (document.getElementById(componentid + "_autocomplete-list")) { 1214 document.getElementById(componentid + "_autocomplete-list").style.display = "none"; 1215 } 1216 } else { 1217 if (!e.srcElement.classList.contains("stopelement")) 1218 { 1219 if (document.getElementById(componentid + "_autocomplete-list")) { 1220 document.getElementByI
1220d(componentid + "_autocomplete-list").style.display = "block"; 1221 } 1222 } 1223 1224 } 1225 1226 /* return false;*/ 1227 }); 1228 1229 txtinput.addEventListener("keyup", function (e) { 1230 e.preventDefault(); 1231 var inputElements = document.getElementsByClassName('autocompliteinput'); 1232 for (var i = 0; inputElements[i]; ++i) { 1233 if (inputElements[i] != txtinput) { 1234 inputElements[i].value = txtinput.value; 1235 } 1236 } 1237 var inputpages = document.getElementsByClassName('page'); 1238 for (var i = 0; inputpages[i]; ++i) { 1239 1240 inputpages[i].value = 0; 1241 1242 } 1243 1244 changequerystring(componentid + '_form'); 1245 1246 var x = document.getElementById(componentid + "_autocomplete-list"); 1247 if (x) x = x.getElementsByTagName("li"); 1248 1249 if (e.keyCode == 40) { 1250 1251 /*If the arrow DOWN key is pressed, 1252 increase the currentFocus variable:*/ 1253 if (currentFocus < x.length - 1) 1254 currentFocus++; 1255 /*and and make the current item more visible:*/ 1256 addActive(x); 1257 1258 } 1259 else if (e.keyCode == 38) { //up 1260 /*If the arrow UP key is pressed, 1261 decrease the currentFocus variable:*/ 1262 if (currentFocus > 0) 1263 currentFocus--; 1264 /*and and make the current item more visible:*/ 1265 addActive(x); 1266 1267 } 1268 else if (e.keyCode == 13) { 1269 1270 //if (globalTimeout != null) clearTimeout(globalTimeout); 1271 1272 if (currentFocus > -1) { 1273 /*and simulate a click on the "active" item:*/ 1274 1275 if (x[currentFocus]) { 1276 a = x[currentFocus].getElementsByTagName("a"); 1277 if (a && a.length > 0 && a[0]) { 1278 1279 window.location.href = a[0].getAttribute('data-url') 1280 } 1281 } 1282 } 1283 //else { 1284 1285 // if (post != null) { 1286 // post(); 1287 // } 1288 1289 //} 1290 1291 1292 } 1293 else { 1294 if (globalTimeout != null) clearTimeout(globalTimeout); 1295 globalTimeout = setTimeout(function () { SearchFunc(txtinput) }, 500); 1296 1297 } 1298 }); 1299 1300 1301 1302 1303 1304 function addActive(x) { 1305 /*a function to classify an item as "active":*/ 1306 if (!x) return false; 1307 1308 removeActive(x); 1309 /* if (currentFocus >= x.length) currentFocus = 0;*/ 1310 /* if (currentFocus < 0) currentFocus = (x.length - 1);*/ 1311 /*add class "autocomplete-active":*/ 1312 x[currentFocus].classList.add("autocomplete-active"); 1313 1314 scrollToElm(document.getElementById(componentid + "_autocomplete-list"), x[currentFocus], 0.1); 1315 1316 } 1317 function removeActive(x) { 1318 /*a function to remove the "active" class from all autocomplete items:*/ 1319 for (var i = 0; i < x.length; i++) { 1320 x[i].classList.remove("autocomplete-active"); 1321 } 1322 } 1323 1324 1325 function closeAllLists(parent) { 1326 1327 if (document.getElementById(parent.id + "_autocomplete-list")) { 1328 parent.removeChild(document.getElementById(parent.id + "_autocomplete-list")); 1329 1330 } 1331 } 1332 1333 function SearchFunc(txtinput) { 1334 1335 currentFocus = -1; 1336 globalTimeout = null; 1337 1338 1339 document.getElementById('searchfermataHomecta').innerHTML = ''; 1340 if (txtinput.value != '') { 1341 sgart.jsonGet('/ricerca/autocompletefermate?languageId=' + languageId + '&term=' + txtinput.value, function (res) { 1342 1343 if (res.success) { 1344 closeAllLists(txtinput.parentNode); 1345 1346 a = document.createElement("ul"); 1347 a.setAttribute("id", txtinput.parentNode.id + "_autocomplete-list"); 1348 a.setAttribute("class", "autocomplete-items"); 1349 txtinput.parentNode.appendChild(a); 1350 for (var i = 0; i < res.fermateLista.length; i++) { 1351 var obj = res.fermateLista[i]; 1352 b = document.createElement("li"); 1353 var linkhtml = "<a href='#' onclick='return selectstop(event,this)' class='stopelement' data-idstop='" + obj.id + "' >" + obj.id + " " + obj.name; 1354 1355 linkhtml += "</a>"; 1356 1357 b.innerHTML += linkhtml 1358 1359 a.appendChild(b); 1360 1361 } 1362 1363 1364 1365 } 1366 else { 1367 } 1368 }, 1369 function () { 1370 1371 } 1372 1373 ); 1374 } 1375 else 1376 closeAllLists(txtinput.parentNode); 1377 1378 1379 } 1380 1381 1382 1383 function scrollToElm(container, elm, duration) { 1384 var pos = getRelativePos(elm); 1385 scrollTo(container, pos.top, 0.1); // duration in seconds 1386 } 1387 1388 function getRelativePos(elm) { 1389 var pPos = elm.parentNode.getBoundingClientRect(), // parent pos 1390 cPos = elm.getBoundingClientRect(), // target pos 1391 pos = {}; 1392 1393 pos.top = cPos.top - pPos.top + elm.parentNode.scrollTop, 1394 pos.right = cPos.right - pPos.right, 1395 pos.bottom = cPos.bottom - pPos.bottom, 1396 pos.left = cPos.left - pPos.left; 1397 1398 return pos; 1399 } 1400 1401 function scrollTo(element, to, duration, onDone) { 1402 var start = element.scrollTop, 1403 change = to - start, 1404 startTime = performance.now(), 1405 val, now, elapsed, t; 1406 1407 function animateScroll() { 1408 now = performance.now();
1409 elapsed = (now - startTime) / 1000; 1410 t = (elapsed / duration); 1411 1412 element.scrollTop = start + change * easeInOutQuad(t); 1413 1414 if (t < 1) 1415 window.requestAnimationFrame(animateScroll); 1416 else 1417 onDone && onDone(); 1418 }; 1419 1420 animateScroll(); 1421 } 1422 function easeInOutQuad(t) { return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t }; 1423 1424 1425 selectstop = function (e, obj) { 1426 e.preventDefault(); 1427 1428 txtinput.value = obj.textContent; 1429 hiddeninput.value = obj.dataset.idstop; 1430 document.getElementById(componentid + "_autocomplete-list").style.display = "none"; 1431 1432 changequerystring(componentid + '_form'); 1433 sgart.jsonGet('/ricerca/fermata?languageId=' + languageId + '&idstop=' + obj.dataset.idstop + '&searchStop=' + document.getElementById('searchstop').value, function (res) { 1434 1435 if (res.success) { 1436 1437 1438 1439 document.getElementById('searchfermataHomecta').innerHTML = res.modalPartial; 1440 1441 1442 } 1443 else { 1444 } 1445 }, 1446 function () { 1447 1448 } 1449 1450 ); 1451 return false; 1452 }; 1453 1454} 1455 1456 1457 1458function isMyScriptLoaded(url) { 1459 if (!url) url = ""; 1460 var scripts = document.getElementsByTagName('script'); 1461 for (var i = scripts.length; i--;) { 1462 1463 if (scripts[i].src == url) return true; 1464 } 1465 return false; 1466} 1467 1468function isMyScriptLoadedStartWith(url) { 1469 if (!url) url = ""; 1470 var scripts = document.getElementsByTagName('script'); 1471 for (var i = scripts.length; i--;) { 1472 1473 if (scripts[i].src.startsWith(url)) return true; 1474 } 1475 return false; 1476} 1477showModal = function (element) { 1478 var myModal = new bootstrap.Modal(document.getElementById(element), {}) 1479 myModal.show(); 1480 1481 1482 1483} 1484 1485 1486openmappa = function (e, idroute, direction, idstop, searchstop, tab, departure, arrival, dplaceid, aplaceid, data, ora, when, cpoitab, categoriespoi, transitmode, showresult) { 1487 if (e != undefined && e != null) { 1488 e.preventDefault(); 1489 } 1490 document.getElementById('mainloading').style.display = "block"; 1491 var url = '/mappa/open?languageId=' + languageId; 1492 if (idroute != '' && idroute != undefined) { 1493 url += '&idroute=' + idroute; 1494 } 1495 if (direction != '' && direction != undefined) { 1496 url += '&direction=' + direction; 1497 } 1498 if (idstop != '' && idstop != undefined) { 1499 url += '&idstop=' + idstop; 1500 } 1501 if (searchstop != '' && searchstop != undefined) { 1502 url += '&searchstop=' + searchstop; 1503 } 1504 if (tab != '' && tab != undefined) { 1505 url += '&tab=' + tab; 1506 } 1507 if (departure != '' && departure != undefined) { 1508 url += '&departure=' + departure; 1509 } 1510 if (arrival != '' && arrival != undefined) { 1511 url += '&arrival=' + arrival; 1512 } 1513 if (dplaceid != '' && dplaceid != undefined) { 1514 url += '&dplaceid=' + dplaceid; 1515 } 1516 if (aplaceid != '' && aplaceid != undefined) { 1517 url += '&aplaceid=' + aplaceid; 1518 } 1519 1520 if (data != '' && data != undefined) { 1521 url += '&data=' + data; 1522 } 1523 if (ora != '' && ora != undefined) { 1524 url += '&ora=' + ora; 1525 } 1526 if (when != '' && when != undefined) { 1527 url += '&when=' + when; 1528 } 1529 if (cpoitab != '' && cpoitab != undefined) { 1530 url += '&cpoitab=' + cpoitab; 1531 } 1532 if (categoriespoi != '' && categoriespoi != undefined) { 1533 url += '&categoriespoi=' + categoriespoi; 1534 } 1535 if (transitmode != '' && transitmode != undefined) { 1536 url += '&transitmode=' + transitmode; 1537 } 1538 if (showresult != '' && showresult != undefined) { 1539 url += '&showresult=' + showresult; 1540 } 1541 document.getElementById('closemenumoblie').click(); 1542 1543 sgart.jsonGet(url, function (res) { 1544 if (res.success) { 1545 1546 1547 document.getElementById('modal-mappa').innerHTML = res.modalPartial.result; 1548 1549 1550 showModal('modal-mappa'); 1551 1552 if (isMyScriptLoadedStartWith('https://maps.googleapis.com/ma
1552ps/api/js?key=')) 1553 { 1554 if (isMyScriptLoaded('/assets/js/map.js?v=5')) 1555 { 1556 document.getElementById('mainloading').style.display = "none"; 1557 1558 googleMap.initMap(); 1559 } 1560 else { 1561 window.__append_script('/assets/js/map.js?v=5', function () { 1562 document.getElementById('mainloading').style.display = "none"; 1563 1564 googleMap.initMap(); 1565 }); 1566 } 1567 } 1568 else 1569 { 1570 window.__append_script('/assets/js/map.js?v=5', function () { 1571 window.__append_script('https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js', function () { 1572 window.__append_script('https://maps.googleapis.com/maps/api/js?key=' + cnf.googleapi + '&libraries=places,geometry,marker&fields=geometry&callback=googleMap.initMap&v=weekly', function () { 1573 1574 /*initMap();*/ 1575 1576 1577 document.getElementById('mainloading').style.display = "none"; 1578 /*showModal('modal-mappa');*/ 1579 1580 }); 1581 }); 1582 }); 1583 } 1584 1585 1586 1587 } 1588 else { 1589 document.getElementById('mainloading').style.display = "none"; 1590 1591 } 1592 1593 }, 1594 function () { 1595 1596 document.getElementById('mainloading').style.display = "none"; 1597 } 1598 1599 ); 1600 return false; 1601} 1602 1603closeMap = function () { 1604 clearquerystring(); 1605 return false; 1606} 1607 1608clearquerystring = function (e) { 1609 1610 var url = window.location.href.split('?')[0]; 1611 var searchUrl = url; 1612 1613 window.history.replaceState({ isSearch: true, path: searchUrl }, document.title, searchUrl); 1614} 1615getquerystring = function () { 1616 var query = '' 1617 if (window.location.href.split('?').length > 0) { 1618 query = window.location.href.split('?')[1]; 1619 } 1620 return query; 1621} 1622changequerystring = function (idform, witoutpage) { 1623 1624 var url = window.location.href.split('?')[0]; 1625 var searchUrl = ''; 1626 if (witoutpage) { 1627 searchUrl = url + '?' + getquerystringfromformtourl(idform); 1628 } 1629 1630 else { 1631 searchUrl = url + '?' + getquerystringfromform(idform); 1632 } 1633 window.history.replaceState({ isSearch: true, path: searchUrl }, document.title, searchUrl); 1634} 1635 1636 1637 1638getquerystringfromform = function (idform) { 1639 var form = document.getElementById(idform); 1640 const formData = new FormData(form); 1641 const params = new URLSearchParams(formData); 1642 1643 1644 1645 let keysForDel = []; 1646 params.forEach((value, key) => { 1647 if (value == '' ) { 1648 keysForDel.push(key); 1649 } 1650 }); 1651 1652 keysForDel.forEach(key => { 1653 params.delete(key); 1654 }); 1655 1656 return params.toString(); 1657} 1658getquerystringfromformtourl = function (idform) { 1659 var form = document.getElementById(idform); 1660 const formData = new FormData(form); 1661 const params = new URLSearchParams(formData); 1662 1663 1664 1665 let keysForDel = []; 1666 params.forEach((value, key) => { 1667 if (value == '' || key == 'page') { 1668 keysForDel.push(key); 1669 } 1670 }); 1671 1672 keysForDel.forEach(key => { 1673 params.delete(key); 1674 }); 1675 1676 return params.toString(); 1677} 1678getaction = function (idform) { 1679 1680 return document.getElementById(idform).action; 1681} 1682 1683window.onpopstate = function (event) { 1684 1685 if (event.state && event.state.isSearch && event.state.path) { 1686 doSearch(event.state.path); 1687 } 1688}; 1689 1690function getPath() { 1691 return window.location.pathname + window.location.search + window.location.hash; 1692} 1693 1694var path = getPath(); 1695 1696window.history.replaceState({ isSearch: true, path: path }, document.title, document.location.href); 1697 1698 1699 1700function condividiSocial(type, url, title) { 1701 if (url == "") { 1702 url = document.location.href; 1703 } 1704 if (title == "") { 1705 title = document.title; 1706 } 1707 var socialType = new Array('facebook', 'twitter', 'googleplus', 'linkedin', 'whatsapp', 'telegram'); 1708 var socialLink = new Array( 1709 'https://www.facebook.com/sharer.php?u=' + escape(url) + '&t=' + escape(title), 1710 'https://twitter.com/share?url=' + escape(url) + '&text=' + title, 1711 'https://plus.google.com/share?url=' + escape(url), 1712 'https://www.linkedin.com/shareArticle?mini=true&url=' + escape(url) + '&title=' + escape(title) + '&ro=false&summary=&source=',
1713 'https://api.whatsapp.com/send?text=' + escape(url), 1714 'https://t.me/share/url?url=' + escape(url) + '&text=' + escape(title) 1715 ); 1716 for (i in socialType) 1717 if (type == socialType[i]) window.open(socialLink[i]); 1718} 1719 1720 1721function initgoogleautocompletehome() { 1722 1723 1724 if (isMyScriptLoadedStartWith('https://maps.googleapis.com/maps/api/js?key=')) { 1725 1726 googleautocompletehome(); 1727 } 1728 else { 1729 window.__append_script('https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js', function () { 1730 window.__append_script('https://maps.googleapis.com/maps/api/js?key=' + cnf.googleapi + '&libraries=places,geometry,marker&fields=geometry&callback=googleautocompletehome&v=weekly', function () { 1731 1732 }); 1733 }); 1734 1735 } 1736 1737 1738 1739 1740} 1741 1742 1743var googleHome = { 1744 1745 1746 1747 departure: { 1748 autocompleteInputId: "departurehome", 1749 placeidInputId: "dplaceidhome", 1750 1751 autocomplete: null, 1752 1753 }, 1754 arrival: { 1755 autocompleteInputId: "arrivalhome", 1756 placeidInputId: "aplaceidhome", 1757 1758 autocomplete: null, 1759 1760 }, 1761 1762 selectLocation: function (obj) { 1763 var place = obj.autocomplete.getPlace(); 1764 if (typeof place !== 'undefined' && place.name != "" && typeof place.place_id !== 'undefined') { 1765 1766 var place_id = place.place_id; 1767 1768 if (place_id == 'EixWaWEgQWVyb3BvcnRvLCAyNDA1MCBPcmlvIGFsIFNlcmlvIEJHLCBJdGFseSIuKiwKFAoSCTP3InBrUIFHERjpV9zB_nFxEhQKEglV1Ps2QlCBRxGABWcuAngGBA') { 1769 place_id = 'ChIJDYMynm9QgUcRggAD8frHdwE'; 1770 } 1771 else if (place_id == 'ChIJvVkIHUFQgUcRzTAlWh1Xhq0') { 1772 place_id = 'ChIJDYMynm9QgUcRggAD8frHdwE'; 1773 }
1774 else if (place_id == 'ChIJJcfg9kVQgUcRQCuHYWRN4-M') { 1775 place_id = 'ChIJDYMynm9QgUcRggAD8frHdwE'; 1776 } 1777 else if (place_id == 'ChIJ27jbNs9RgUcRR87uWzYRbFY') { 1778 place_id = 'ChIJDYMynm9QgUcRggAD8frHdwE'; 1779 } 1780 else if (place_id == 'ChIJ_3xfSaxRgUcRy-bwbDDB9Mo') { 1781 place_id = 'ChIJDYMynm9QgUcRggAD8frHdwE'; 1782 } 1783 //città alta 1784 else if (place_id == 'ChIJcw4m5z9RgUcRbGd7EXUId4Q') { 1785 place_id = 'EipMLmdvIENvbGxlIEFwZXJ0bywgMjQxMjkgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgkrGSiWQVGBRxG2EaX_2BBafRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1786 } 1787 else if (place_id == 'ChIJ0w1RdRVRgUcRHAN4XB7Dpfc') { 1788 place_id = 'EipMLmdvIENvbGxlIEFwZXJ0bywgMjQxMjkgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgkrGSiWQVGBRxG2EaX_2BBafRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1789 } 1790 else if (place_id == 'ChIJPS75kEFRgUcRCry0jxEz5Bk') { 1791 place_id = 'EipMLmdvIENvbGxlIEFwZXJ0bywgMjQxMjkgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgkrGSiWQVGBRxG2EaX_2BBafRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1792 } 1793 else if (place_id == 'ChIJGY7G8AVRgUcRSFqa_xaomFI') { 1794 place_id = 'EipMLmdvIENvbGxlIEFwZXJ0bywgMjQxMjkgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgkrGSiWQVGBRxG2EaX_2BBafRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1795 } 1796 //Fiera 1797 else if (place_id == 'ChIJQxpnCwBRgUcRPoH9Rfn95eo') { 1798 place_id = 'ChIJ_7p72vVQgUcRLTuO0evuxp0'; 1799 } 1800 else if (place_id == 'ChIJy0dy3_RQgUcRpSlYowDso3w') { 1801 place_id = 'ChIJ_7p72vVQgUcRLTuO0evuxp0'; 1802 } 1803 //funicolare 1804 else if (place_id == 'EjNGdW5pY29sYXJlIEJlcmdhbW8gLSBDaXR0w6AgQWx0YSwgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgkvVhitFVGBRxEPaFNVJ5w6LxIUChIJc65ivBFRgUcR0aTlC4_LL9M') { 1805 place_id = 'ChIJy6CLs_xRgUcRev6B2nkFqqY'; 1806 } 1807 //Funicolare San Vigilio inferiore 1808 else if (place_id == 'Ei5GdW5pY29sYXJlIFMuIFZpZ2lsaW8sIDI0MTI5IEJlcmdhbW8gQkcsIEl0YWx5Ii4qLAoUChIJyx4YEkNRgUcRm3s0-tb_Cn8SFAoSCXOuYrwRUYFHEdGk5QuPyy_T') { 1809 place_id = 'ChIJy0-BiUFRgUcRc5Yd5yl-krs'; 1810 } 1811 else if (place_id == 'ChIJy0-BiUFRgUcRc5Yd5yl-krs') { 1812 place_id = 'ChIJy0-BiUFRgUcRc5Yd5yl-krs'; 1813 } 1814 else if (place_id == 'ChIJFbLuJohRgUcRLvMtKFfW0HU') { 1815 place_id = 'ChIJy0-BiUFRgUcRc5Yd5yl-krs'; 1816 } 1817 else if (place_id == 'ChIJY6OZiUFRgUcR3rkl6jbOhPU') { 1818 place_id = 'ChIJy0-BiUFRgUcRc5Yd5yl-krs'; 1819 } 1820 else if (place_id == 'ChIJFbLuJohRgUcRLvMtKFfW0HU') { 1821 place_id = 'ChIJy0-BiUFRgUcRc5Yd5yl-krs'; 1822 } 1823 else if (place_id == 'EjxGdW5pY29sYXJlIENpdHTDoCBBbHRhIC0gUy4gVmlnaWxpbywgMjQxMjkgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEglPK2sdQ1GBRxGWyq1FslIsMRIUChIJc65ivBFRgUcR0aTlC4_LL9M') { 1824 place_id = 'ChIJy0-BiUFRgUcRc5Yd5yl-krs'; 1825 } 1826 //Funicolare San Vigilio superiore 1827 else if (place_id == 'ChIJKfpkvAVRgUcRm2rN25ACGjI') { 1828 place_id = 'ChIJQ61Q3VxRgUcReQdMgl5sdmE'; 1829 } 1830 else if (place_id == 'EidWaWEgUy4gVmlnaWxpbywgMjQxMjkgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgl1T1CdXFGBRxFvEV_MLiwcORIUChIJc65ivBFRgUcR0aTlC4_LL9M') { 1831 place_id = 'ChIJQ61Q3VxRgUcReQdMgl5sdmE'; 1832 } 1833 else if (place_id == 'ChIJB5rKlVxRgUcRySn60vX7mr4') { 1834 place_id = 'ChIJQ61Q3VxRgUcReQdMgl5sdmE'; 1835 } 1836 //Ospedale Papa 1837 else if (place_id == 'ChIJR-J-HYJRgUcRgJ9X8JbBmJo') { 1838 place_id = 'ChIJS6ZEXH9RgUcRx1UzbUjyqtg'; 1839 } 1840 else if (place_id == 'ChIJZa0SH4JRgUcRbxJ1iI-BOZQ') { 1841 place_id = 'ChIJS6ZEXH9RgUcRx1UzbUjyqtg'; 1842 } 1843 else if (place_id == 'ChIJL80QQWpRgUcRk404fw9SaiA') { 1844 place_id = 'ChIJS6ZEXH9RgUcRx1UzbUjyqtg'; 1845 } 1846 //Della Fara - San Lorenzo 1847 else if (place_id == 'Ei9WaWEgYWxsYSBQb3J0YSBkaSBTLiBMb3JlbnpvLCBCZXJnYW1vIEJHLCBJdGFseSIuKiwKFAoSCWM4GYQ_UYFHEV_yxxagP_bjEhQKEglzrmK8EVGBRxHRpOULj8sv0w') {
1848 place_id = 'ChIJ71cDpz9RgUcRYpiBE5mwqwc'; 1849 } 1850 else if (place_id == 'ChIJlXnogD9RgUcRI2gE5H_wG7Y') { 1851 place_id = 'ChIJ71cDpz9RgUcRYpiBE5mwqwc'; 1852 } 1853 else if (place_id == 'ChIJJ5uDUCxRgUcRKCEYW0OFf_0') { 1854 place_id = 'ChIJ71cDpz9RgUcRYpiBE5mwqwc'; 1855 } 1856 //Dello Statuto 43 1857 else if (place_id == 'ChIJe-aE7mhRgUcRbX7PN7UDOew') { 1858 place_id = 'ChIJu938VWhRgUcRCMAA7uMPdOo'; 1859 } 1860 //Largo Porta Nuova, Bergamo, BG, Italia 1861 else if (place_id == 'ChIJh_2OAxBRgUcREarr_Ol-fpQ') { 1862 place_id = 'EiRMYXJnbyBQb3J0YSBOdW92YSwgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgmD_Ur8D1GBRxFcZDDa7WrVGRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1863 } 1864 else if (place_id == 'ChIJW2SQVg5RgUcRmDkVDl_HIWI') { 1865 place_id = 'EiRMYXJnbyBQb3J0YSBOdW92YSwgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgmD_Ur8D1GBRxFcZDDa7WrVGRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1866 } 1867 else if (place_id == 'ChIJGw424w9RgUcRwBRUPt-dSTw') { 1868 place_id = 'EiRMYXJnbyBQb3J0YSBOdW92YSwgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgmD_Ur8D1GBRxFcZDDa7WrVGRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1869 } 1870 //Vittorio Emanuele - S.Agostino, 24121 Bergamo BG 1871 else if (place_id == 'ChIJ4_8AundRgUcR3NWph5It7dU') { 1872 place_id = 'ChIJDxLAxBdRgUcR473T9hUDz6g'; 1873 } 1874 else if (place_id == 'Ei1QaWF6emFsZSBTLiBBZ29zdGlubywgMjQxMjkgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgmVEgGZPVGBRxGglMVCXSzZtxIUChIJc65ivBFRgUcR0aTlC4_LL9M') { 1875 place_id = 'ChIJDxLAxBdRgUcR473T9hUDz6g'; 1876 } 1877 else if (place_id == 'ChIJocPvW6lRgUcRkIEYVe9FY3o') { 1878 place_id = 'ChIJDxLAxBdRgUcR473T9hUDz6g'; 1879 } 1880 else if (place_id == 'ChIJ7VWAu3dRgUcRV-JQxutYTr0') { 1881 place_id = 'ChIJDxLAxBdRgUcR473T9hUDz6g'; 1882 } 1883 //stazione 1884 else if (place_id == 'ChIJ4zPTUQNRgUcROWCE7FAJzAI') { 1885 place_id = 'Ei1QaWF6emFsZSBHdWdsaWVsbW8gTWFyY29uaSwgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgmtRoVoBFGBRxEsL9BDO26uwRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1886 } 1887 else if (place_id == 'ChIJszhDfgRRgUcRNc3SyoDXXqU') { 1888 place_id = 'Ei1QaWF6emFsZSBHdWdsaWVsbW8gTWFyY29uaSwgQmVyZ2FtbyBCRywgSXRhbHkiLiosChQKEgmtRoVoBFGBRxEsL9BDO26uwRIUChIJc65ivBFRgUcR0aTlC4_LL9M'; 1889 } 1890 1891 document.getElementById(obj.placeidInputId).value = place_id; 1892 /*document.getElementById(obj.autocompleteInputId).value = place.name;*/ 1893 1894 1895 1896 changequerystring('calcolapercorsoformhome', true); 1897 checkDisabledirectionRoutesSearch(); 1898 1899 } 1900 1901 1902 }, 1903} 1904function googleautocompletehome() { 1905 var north = parseFloat(45.74275); 1906 var south = parseFloat(45.61658); 1907 var east = parseFloat(9.8517903); 1908 var west = parseFloat(9.5414265); 1909 var NE = new google.maps.LatLng(north, east); 1910 var SW = new google.maps.LatLng(south, west); 1911 var defaultBounds = new google.maps.LatLngBounds(SW, NE); 1912 1913 var opts = { 1914 bounds: defaultBounds, 1915 1916 componentRestrictions: { country: 'IT' }, 1917 strictBounds: true 1918 }; 1919 1920 googleHome.departure.autocomplete = new google.maps.places.Autocomplete(document.getElementById(googleHome.departure.autocompleteInputId), opts); 1921 /*googleHome.departure.autocomplete.setTypes(["airport"]);*/ 1922 1923 1924 googleHome.arrival.autocomplete = new google.maps.places.Autocomplete(document.getElementById(googleHome.arrival.autocompleteInputId), opts); 1925 /* googleHome.arrival.autocomplete.setTypes(["address"]);*/ 1926 1927 document.getElementById(googleHome.arrival.autocompleteInputId).addEventListener("change", function (e) { 1928 e.preventDefault(); 1929 checkDisabledirectionRoutesSearch(); 1930 }); 1931 1932 1933 1934 document.getElementById(googleHome.departure.autocompleteInputId).addEventListener("change", function (e) { 1935 e.preventDefault(); 1936 1937 checkDisabledirectionRoutesSearch(); 1938 });
1939 1940 ////add place_changed departure listener 1941 google.maps.event.addListener(googleHome.departure.autocomplete, 'place_changed', function () { googleHome.selectLocation(googleHome.departure); }); 1942 //add place_changed arrival listener 1943 google.maps.event.addListener(googleHome.arrival.autocomplete, 'place_changed', function () { googleHome.selectLocation(googleHome.arrival); }); 1944} 1945 1946 1947function invertsearch(e) { 1948 e.preventDefault(); 1949 1950 var dplaceid = document.getElementById(googleHome.departure.placeidInputId).value; 1951 var dep = document.getElementById(googleHome.departure.autocompleteInputId).value; 1952 1953 1954 var aplaceid = document.getElementById(googleHome.arrival.placeidInputId).value; 1955 var arr = document.getElementById(googleHome.arrival.autocompleteInputId).value; 1956 1957 document.getElementById(googleHome.departure.placeidInputId).value = aplaceid; 1958 document.getElementById(googleHome.departure.autocompleteInputId).value = arr; 1959 1960 document.getElementById(googleHome.arrival.placeidInputId).value = dplaceid; 1961 document.getElementById(googleHome.arrival.autocompleteInputId).value = dep; 1962 1963 1964 1965 changequerystring('calcolapercorsoformhome', true); 1966} 1967 1968 1969function opencalcolapercorsomappa(e) { 1970 e.preventDefault(); 1971 openmappa(e, '', '', '', '', 'searchpercorso', document.getElementById(googleHome.departure.autocompleteInputId).value, document.getElementById(googleHome.arrival.autocompleteInputId).value, document.getElementById(googleHome.departure.placeidInputId).value, document.getElementById(googleHome.arrival.placeidInputId).value, '', '', '') 1972} 1973 1974function checkDisabledirectionRoutesSearch() { 1975 1976 if (document.getElementById(googleHome.departure.autocompleteInputId).value != "" && 1977 document.getElementById(googleHome.arrival.autocompleteInputId).value != "" && 1978 document.getElementById(googleHome.departure.placeidInputId).value != '' && 1979 document.getElementById(googleHome.arrival.placeidInputId).value != '') { 1980 document.getElementById('homestartdirectionbtn').classList.remove("disabled"); 1981 } 1982 else { 1983 document.getElementById('homestartdirectionbtn').classList.add("disabled"); 1984 } 1985} 1986 1987 1988 1989 1990function detectMainMob() { 1991 return ((window.innerWidth <= 800)); 1992} 1993function settab(e,left) { 1994 e.preventDefault(); 1995 if (detectMainMob()) { 1996 document.getElementById("tab-hero").scrollLeft = left; 1997 } 1998 1999}
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.