1let defaultLocale = "de"; 2let locale; 3let translations = {}; 4 5const language = ["de", "fr", "it", "en"]; 6const userLang = navigator.language || navigator.userLanguage; 7async function loadHeader() { 8 await fetch("header.html") 9 .then((response) => response.text()) 10 .then((data) => { 11 document.getElementById("ssq-lp-header-placeholder").innerHTML = data; 12 }) 13 .catch((error) => console.error("Error loading header:", error)); 14} 15async function loadFooter() { 16 await fetch("footer.html") 17 .then((response) => response.text()) 18 .then((data) => { 19 document.querySelector("ssq-footer").innerHTML = data; 20 }) 21 .catch((error) => console.error("Error loading header:", error)); 22} 23function trackPageVisit(pagePath) { 24 // Check if the user has consented to cookies 25 if (getCookie("cookieConsent")) { 26 let visitedPages = JSON.parse(getCookie("visitedPages")) || []; 27 if (!visitedPages.includes(pagePath)) { 28 visitedPages.push(pagePath); 29 setCookie("visitedPages", JSON.stringify(visitedPages), 365); // Store visited pages in a cookie 30 } 31 } 32} 33function setCookie(name, value, days) { 34 if (getCookie("cookieConsent") === "true" || name === "cookieConsent") { 35 const d = new Date(); 36 d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000); 37 const expires = "expires=" + d.toUTCString(); 38 document.cookie = name + "=" + value + ";" + expires + ";path=/"; 39 } 40} 41 42function getCookie(name) { 43 const nameEQ = name + "="; 44 const ca = document.cookie.split(";"); 45 for (let i = 0; i < ca.length; i++) {
46 let c = ca[i]; 47 while (c.charAt(0) == " ") c = c.substring(1, c.length); 48 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 49 } 50 return null; 51} 52 53// Function to show cookie consent banner 54function showCookieConsentBanner() { 55 const cookieConsentBanner = document.getElementById("cookie-consent-banner"); 56 if (!getCookie("cookieConsent")) { 57 cookieConsentBanner.style.display = "flex"; 58 } 59} 60document.addEventListener("DOMContentLoaded", async function () { 61 await loadHeader(); 62 // await loadFooter(); 63 await setLocale(setLanguage()); 64 showCookieConsentBanner(); 65 const currentPagePath = window.location.pathname; 66 trackPageVisit(currentPagePath); 67 const sidebar = document.getElementById("sidebar"); 68 const openBtn = document.getElementById("sidebar-open-btn"); 69 const closeBtn = document.getElementById("sidebar-close-btn"); 70 const searchModal = document.getElementById("ssqLpSearchModal"); 71 const searchBtn = document.getElementById("ssqLpSearchOpenModalButton"); 72 const searchBtnSideBar = document.getElementById( 73 "ssqLpSearchOpenModalButtonSideBar" 74 ); 75 const searchClose = document.getElementById("ssqLpSearchcloseModalButton"); 76 77 function openSearchModal() { 78 // Close the sidebar 79 sidebar.classList.remove("active"); 80 // Open the search modal 81 searchModal.style.display = "flex"; 82 document.getElementById("searchKeyInput").focus(); // Focus the input field 83 } 84 85 openBtn?.addEventListener("click", function () { 86 sidebar.classList.add("active"); 87 }); 88 89 closeBtn.addEventListener("click", function () { 90 sidebar.classList.remove("active"); 91 }); 92 93 searchBtn.onclick = openSearchModal; 94 searchBtnSideBar.onclick = openSearchModal; 95 96 searchClose.onclick = function () { 97 searchModal.style.display = "none"; 98 }; 99 100 document 101 .getElementById("accept-cookies") 102 .addEventListener("click", function () { 103 setCookie("cookieConsent", "true", 365); 104 setCookie("lang", locale, 365); // Only set the language cookie if cookies are accepted 105 document.getElementById("cookie-consent-banner").style.display = "none"; 106 }); 107 // Event listener for declining cookies 108 // document 109 // .getElementById("decline-cookies") 110 // .addEventListener("click", function () { 111 // setCookie("cookieConsent", "false", 365); 112 // document.getElementById("cookie-consent-banner").style.display = "none"; 113 // }); 114 115 document.addEventListener("keydown", function (event) { 116 if (event.key === "Escape") { 117 searchModal.style.display = "none"; 118 searchBtn.blur(); 119 searchBtnSideBar.blur(); 120 } 121 }); 122 // document.getElementById("ssqLpHeaderLogo").addEventListener("click", () => { 123 // window.location.href = "index.html"; 124 // }); 125 126 var coll = document.getElementsByClassName("ssq-lp-ftr-collapsible"); 127 var i; 128 129 for (i = 0; i < coll.length; i++) { 130 coll[i].addEventListener("click", function () { 131 for (var j = 0; j < coll.length; j++) { 132 if (coll[j] !== this) { 133 coll[j].classList.remove("collpase-active"); 134 coll[j].nextElementSibling.style.maxHeight = null; 135 } 136 } 137 this.classList.toggle("collpase-active"); 138 var content = this.nextElementSibling; 139 if (content.style.maxHeight) { 140 content.style.maxHeight = null; 141 } else { 142 content.style.maxHeight = content.scrollHeight + "px"; 143 } 144 }); 145 } 146 // }); 147 // // tech wrapper animation 148 // document.addEventListener("DOMContentLoaded", async function () { 149 const wrapperInner = document.querySelector(".ssq-lp-ftr-tech-wrapper-inner"); 150 const items = Array.from( 151 document.querySelectorAll(".ssq-lp-ftr-tech-wrapper-item") 152 ); 153 const itemWidth = items[0].offsetWidth; 154 let currentIndex = 0; 155 156 function moveItems() { 157 const totalItems = items.length; 158 const newIndex = (currentIndex + 1) % totalItems; 159 160 // Move the entire container towards the left 161 wrapperInner.style.transition = 162 "transform 1s cubic-bezier(0.42, 0, 0.58, 1)"; 163 wrapperInner.style.transform = `translateX(-${itemWidth}px)`; 164 165 // Move the current item to the end of the container 166 setTimeout(() => { 167 wrapperInner.appendChild(items[currentIndex]); 168 wrapperInner.style.transition = "none";
168 // Remove transition after moving 169 wrapperInner.style.transform = "none"; // Reset container's transform 170 currentIndex = newIndex; 171 }, 1000); // Adjust the timing as needed 172 } 173 174 setInterval(moveItems, 3000); // const container = document.querySelector(".ssq-lp-insight-item-wrpr"); 175 176 // 177 function initModal() { 178 var cookieModal = document.getElementById("cookieModal"); 179 180 if (!cookieModal) { 181 return; // Exit if modal does not exist 182 } 183 184 // Get the buttons that open the modal 185 var cookieBannerBtn = document.getElementById("openCookieModalBtn"); 186 var cookieFooterBtn = document.getElementById("openCookieModalFtrBtn"); 187 // Get the <span> element that closes the modal 188 var span = document.getElementById("closeCookieModalBtn"); 189 190 // Function to open the modal 191 function openModal() { 192 cookieModal.style.display = "block"; 193 } 194 195 // Function to close the modal 196 function closeModal() { 197 cookieModal.style.display = "none"; 198 } 199 200 // Add event listeners if elements exist 201 if (cookieBannerBtn) { 202 cookieBannerBtn.onclick = openModal; 203 } 204 205 if (cookieFooterBtn) { 206 cookieFooterBtn.onclick = openModal; 207 } 208 209 if (span) { 210 span.onclick = closeModal; 211 } 212 213 // When the user clicks anywhere outside of the modal, close it 214 // window.onclick = function (event) { 215 // if (event.target === cookieModal) { 216 // closeModal(); 217 // } 218 // }; 219 } 220 221 initModal(); 222}); 223 224function loadBlog() { 225 window.location.href = "blog.html"; 226} 227function loadCompany() { 228 window.location.href = "about-us.html"; 229} 230function loadContactUs() { 231 window.location.href = "contact-us.html"; 232} 233function loadOurTeam() { 234 window.location.href = "our-team.html"; 235} 236function loadGallery() { 237 window.location.href = "gallery.html"; 238} 239function loadInsights() { 240 window.location.href = "insights.html"; 241} 242function opensideBarAboutMenu() { 243 // document.getElementById("ssq-lp-sidebar-main-menu").classList.add("hidden"); 244 document.getElementById("ssq-lp-sidebar-main-menu").style.display = "none"; 245 document.getElementById("ssq-lp-about-sidebar").style.transform = 246 "translateX(-100%)"; 247} 248function closesideBarAboutMenu() { 249 document.getElementById("ssq-lp-sidebar-main-menu").style.display = "block"; 250 document.getElementById("ssq-lp-about-sidebar").style.transform = 251 "translateX(0)"; 252} 253function opensideBarServicesMenu() { 254 // document.getElementById("ssq-lp-sidebar-main-menu").classList.add("hidden"); 255 document.getElementById("ssq-lp-sidebar-main-menu").style.display = "none"; 256 document.getElementById("ssq-lp-services-sidebar").style.transform = 257 "translateX(-100%)"; 258} 259function closesideBarServicesMenu() { 260 document.getElementById("ssq-lp-sidebar-main-menu").style.display = "block"; 261 document.getElementById("ssq-lp-services-sidebar").style.transform = 262 "translateX(0)"; 263} 264function opensideBarIndustriesMenu() { 265 // document.getElementById("ssq-lp-sidebar-main-menu").classList.add("hidden"); 266 document.getElementById("ssq-lp-sidebar-main-menu").style.display = "none"; 267 document.getElementById("ssq-lp-industries-sidebar").style.transform = 268 "translateX(-100%)"; 269} 270function closesideBarIndustriesMenu() { 271 document.getElementById("ssq-lp-sidebar-main-menu").style.display = "block"; 272 document.getElementById("ssq-lp-industries-sidebar").style.transform = 273 "translateX(0)"; 274} 275function closeModal() { 276 // Hide the modal 277 var iframeModal = document.getElementById("iframe-modal"); 278 var iframeContent = document.getElementById("iframe-content"); 279 280 iframeModal.style.display = "none"; 281 iframeContent.src = ""; 282} 283 284window.addEventListener("message", async function (event) { 285 if (event.data === "closeModal") { 286 closeModal(); 287 } 288}); 289 290async function fetchHtmlPage(url) { 291 const response = await fetch(url); 292 const html = await response.text(); 293 return html; 294} 295 296function translateHTMLDocument(doc, translations) { 297 doc.querySelectorAll("[data-i18n-key]").forEach((element) => { 298 const key = element.getAttribute("data-i18n-key"); 299 const translation = translations[key]; 300 if (translation) { 301 element.textContent = translation; 302 } 303 }); 304} 305 306function setLanguage() { 307 // const currentLng = localStorage.getItem("lang"); 308 const currentLng = getCookie("lang") || localStorage.getItem("lang"); 309 const userLanguage = userLang.split("-")[0]; 310 // Check if the user's language is in the supported languages list 311 if (language.includes(userLanguage)) { 312 defaultLocale = userLanguage; 313 } 314 if (!currentLng || currentLng === "null") { 315 localStorage.setItem("lang", defaultLocale); 316 if (document.getElementById("dropdownBtnLang")) { 317 document.getElementById( 318 "dropdownBtnLang" 319 ).innerHTML = `<i class="fa-solid fa-globe"></i>${defaultLocale.toUpperCase()}<i class="fa-solid fa-angle-down"></i>`; 320 } 321 if (document.getElementById("sideBarLangSelBtn")) { 322 document.getElementById( 323 "sideBarLangSelBtn" 324 ).innerHTML = `${defaultLocale.toUpperCase()}<i class="fa-solid fa-angle-down"></i>`; 325 } 326 } 327 if (language.includes(currentLng)) { 328 if (document.getElementById("dropdownBtnLang")) { 329 document.getElementById( 330 "dropdownBtnLang" 331 ).innerHTML = `<i class="fa-solid fa-globe"></i>${currentLng.toUpperCase()}<i class="fa-solid fa-angle-down"></i>`; 332 } 333 if (document.getElementById("sideBarLangSelBtn")) { 334 document.getElementById( 335 "sideBarLangSelBtn" 336 ).innerHTML = `${currentLng.toUpperCase()}<i class="fa-solid fa-angle-down"></i>`; 337 } 338 return currentLng; 339 } else { 340 return defaultLocale; 341 } 342} 343 344async function setLocale(newLocale) { 345 if (newLocale === locale) return; 346 const newTranslations = await fetchTranslationsFor(newLocale); 347 locale = newLocale; 348 translations = newTranslations; 349 translatePage(); 350 if (getCookie("cookieConsent")) {
351 setCookie("lang", newLocale, 365); 352 } 353 localStorage.setItem("lang", newLocale); 354} 355 356async function fetchTranslationsFor(newLocale) { 357 const response = await fetch(`assets/lang/${newLocale}.json?ver=19`); 358 return await response.json(); 359} 360 361function translatePage() { 362 document.querySelectorAll("[data-i18n-key]").forEach(translateElement); 363 document 364 .querySelectorAll("[data-translate-placeholder]") 365 .forEach((element) => { 366 const key = element.getAttribute("data-translate-placeholder"); 367 if (translations[key]) { 368 element.setAttribute("placeholder", translations[key]); 369 } 370 }); 371} 372 373function translateElement(element) { 374 const key = element.getAttribute("data-i18n-key"); 375 const translation = translations[key]; 376 element.innerText = translation; 377} 378 379// dropdowns 380function toggleDropdown(elementId, buttonId, showClass) { 381 const element = document.getElementById(elementId); 382 const button = document.getElementById(buttonId); 383 384 // Hide other dropdowns 385 document.querySelectorAll(".dropdown-content").forEach((dropdown) => { 386 if (dropdown !== element) { 387 dropdown.classList.remove(showClass); 388 } 389 }); 390 391 document.querySelectorAll(".dropdown-btn-border").forEach((btn) => { 392 if (btn !== button) { 393 btn.classList.remove("dropdown-btn-border"); 394 } 395 }); 396 397 // Toggle the clicked dropdown 398 element.classList.toggle(showClass); 399 button.classList.toggle("dropdown-btn-border"); 400} 401 402function toggleDropdownService() { 403 toggleDropdown("dropdown-service", "dropdownBtnService", "show-service"); 404} 405 406function toggleDropdownLang() { 407 toggleDropdown("dropdown-lang", "dropdownBtnLang", "show-lang"); 408} 409function toggleDropdownLangSide() { 410 toggleDropdown("dropdown-lang-side", "dropdownBtnLangSideBar", "show-lang"); 411} 412function toggleDropdownAbout() { 413 toggleDropdown("dropdown-about", "dropdownBtnAbout", "show-about"); 414} 415// Select language function 416// let isReloading = false; 417// function reloadPagesForBlogs() { 418// const currentPage = window.location.pathname.split("/").pop(); 419// const pagesToReload = [ 420// "", 421// "index.html", 422// "insights.html", 423// "blog.html", 424// "blogdetails.html", 425// "insights-detail.html", 426// ]; 427// if (pagesToReload.includes(currentPage)) { 428// isReloading = true; // Set the reloading flag 429// window.location.reload(); 430// } 431// } 432 433function selectLanguage(language, languageCode) { 434 // if (isReloading) return; // Prevent multiple reloads 435 436 const currentLang = localStorage.getItem("lang"); 437 if (currentLang === languageCode) return; // No need to reload if the language hasn't changed 438 439 document.getElementById( 440 "dropdownBtnLang" 441 ).innerHTML = `<i class="fa-solid fa-globe"></i>${language}<i class="fa-solid fa-angle-up"></i>`; 442 toggleDropdownLang(); // Hide the dropdown after selecting a language 443 444 // Call the setLocale function from custom.js?ver=0.0.4 445 setLocale(languageCode); 446 if (getCookie("cookieConsent")) { 447 setCookie("lang", languageCode, 365); 448 } 449 450 localStorage.setItem("lang", languageCode); 451 452 // Reload the page if the language has changed 453 // reloadPagesForBlogs(); 454} 455 456function selectLanguageSideBar(language, languageCode) { 457 document.getElementById( 458 "sideBarLangSelBtn" 459 ).innerHTML = `</i>${language}<i class="fa-solid fa-angle-up"></i>`; 460 toggleDropdownLangSide(); // Hide the dropdown after selecting a language 461 462 // Call the setLocale function from custom.js?ver=0.0.4 463 setLocale(languageCode); 464 if (getCookie("cookieConsent")) { 465 setCookie("lang", languageCode, 365); 466 } 467 localStorage.setItem("lang", languageCode); 468 // reloadPagesForBlogs(); 469} 470// async function translateText(text, targetLang) { 471// const AZURE_API_KEY = "609268e9d91c43a789574b839c024e5d"; 472// const AZURE_ENDPOINT = "https://api.cognitive.microsofttranslator.com"; 473// const AZURE_LOCATION = "switzerlandnorth"; 474 475// const url = `${AZURE_ENDPOINT}/translate?api-version=3.0&to=${targetLang}`; 476 477// const response = await fetch(url, { 478// method: "POST", 479// headers: { 480// "Ocp-Apim-Subscription-Key": AZURE_API_KEY, 481// "Ocp-Apim-Subscription-Region": AZURE_LOCATION, 482// "Content-Type": "application/json", 483// }, 484// body: JSON.stringify([{ text: text }]), 485// }); 486 487// const data = await response.json(); 488// return data[0].translations[0].text; 489// } 490// Function to close all dropdowns 491function closeAllDropdowns() { 492 document.querySelectorAll(".dropdown-content").forEach((dropdown) => { 493 dropdown.classList.remove("show-service", "show-lang", "show-about"); 494 }); 495 document.querySelectorAll(".dropdown-btn-border").forEach((btn) => { 496 btn.classList.remove("dropdown-btn-border"); 497 }); 498} 499 500// Consolidated click event handler 501window.onclick = function (event) { 502 const dropdowns = [ 503 { 504 dropdown: "dropdown-service", 505 button: "dropdownBtnService", 506 showClass: "show-service", 507 }, 508 509 { 510 dropdown: "dropdown-lang", 511 button: "dropdownBtnLang", 512 showClass: "show-lang", 513 }, 514 { 515 dropdown: "dropdown-lang-side", 516 button: "dropdownBtnLangSideBar", 517 showClass: "show-lang", 518 }, 519 { 520 dropdown: "dropdown-about", 521 button: "dropdownBtnAbout", 522 showClass: "show-about", 523 }, 524 ]; 525 526 dropdowns.forEach(({ dropdown, button, showClass }) => { 527 const dropdownElement = document.getElementById(dropdown); 528 const buttonElement = document.getElementById(button); 529 530 if (!buttonElement.contains(event.target)) { 531 dropdownElement.classList.remove(showClass); 532 buttonElement.classList.remove("dropdown-btn-border"); 533 } 534 }); 535 536 // Close modal when clicking outside the modal 537 var popupModal = document.getElementById("pop-up-form-modal"); 538 if (popupModal && event.target == popupModal) { 539 popupModal.style.display = "none"; 540 } 541}; 542// for intermediate search modal submission 543// search form submission 544function handleSearchSubmit(event) { 545 event.preventDefault(); // Prevent the default form submission 546 const searchInput = document.getElementById("searchKeyInput").value; 547 //for local 548 // const searchUrl = `/webpage/src/search-results.html?query=${encodeURIComponent( 549 //for server 550 const searchUrl = `/search-results.html?query=${encodeURIComponent( 551 searchInput 552 )}`; 553 window.location.href = searchUrl; // Redirect to the search results page with the query 554 return false; // Prevent further form submission 555} 556 557// get a quote load 558$(document).ready(async function () { 559 await loadFooter(); 560 function closeAllDropdowns() { 561 $(".dropdown-content").removeClass("show"); 562 } 563 564 // Handle dropdowns
565 $(".dropdown-toggle").click(function (event) { 566 event.stopPropagation(); 567 closeAllDropdowns(); // Close all other dropdowns 568 $(this).next(".dropdown-content").toggleClass("show"); // Toggle current dropdown 569 }); 570 571 // Close all dropdowns if clicked outside 572 $(document).click(function () { 573 closeAllDropdowns(); 574 }); 575 576 function handleGetQuoteButtonClick(event) { 577 event.stopPropagation(); // Stop event propagation 578 579 // Close all dropdowns before opening the quote modal 580 closeAllDropdowns(); 581 582 // Show the iframe modal and load the form 583 var iframeModal = document.getElementById("iframe-modal"); 584 var iframeContent = document.getElementById("iframe-content"); 585 586 iframeContent.src = "pop-up-form.html"; 587 iframeContent.onload = () => { 588 const iframeDoc = 589 iframeContent.contentDocument || iframeContent.contentWindow.document; 590 translateHTMLDocument(iframeDoc, translations); 591 }; 592 593 iframeModal.style.display = "block"; 594 595 var iframeModalCloseBtn = 596 document.getElementsByClassName("iframe-modal-close")[0]; 597 598 // Close modal when the close button is clicked 599 iframeModalCloseBtn.onclick = function () { 600 iframeModal.style.display = "none"; 601 iframeContent.src = ""; // Clear the iframe src to stop the loading process 602 }; 603 translatePage(); 604 605 // Close modal when clicking outside of it 606 window.onclick = function (event) { 607 if (event.target == iframeModal) { 608 iframeModal.style.display = "none"; 609 iframeContent.src = ""; // Clear the iframe src to stop the loading process 610 } 611 }; 612 } 613 document.getElementById("ssq-lp-get-a-quote-button").onclick = 614 handleGetQuoteButtonClick; 615 document.getElementById("ftrEnquireOpenBtn").onclick = 616 handleGetQuoteButtonClick; 617 document.getElementById("ftrCareerOpenBtn").onclick = () => { 618 window.location.href = "careers.html"; 619 }; 620 if (document.getElementById("ssqMlEnquireBtn")) { 621 document.getElementById("ssqMlEnquireBtn").onclick = 622 handleGetQuoteButtonClick; 623 } 624 //for opening the enquire modal on clicking the medical application page-enquire btn 625 if (document.getElementById("medReqDemoBtn")) { 626 document.getElementById("medReqDemoBtn").onclick = 627 handleGetQuoteButtonClick; 628 } 629 if (document.getElementById("ssqQTEnquireBtn")) { 630 document.getElementById("ssqQTEnquireBtn").onclick = 631 handleGetQuoteButtonClick; 632 } 633}); 634if ("serviceWorker" in navigator) { 635 window.addEventListener("load", function () { 636 navigator.serviceWorker 637 .register("./service-worker.js") 638 .then(function (registration) {}) 639 .catch(function (error) {}); 640 }); 641}
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.