--- --- console.log(document.querySelectorAll('*').length); if ("{{ site.safeui }}"==="true") { document.addEventListener("DOMContentLoaded", function () { var safuiAlert = document.querySelector("#safeui-alert"); if (safuiAlert) { setTimeout(function () { safuiAlert.style.transition = "1s"; safuiAlert.style.height = "0"; safuiAlert.style.paddingTop = "0"; safuiAlert.style.paddingBottom = "0"; safuiAlert.style.marginTop = "0"; safuiAlert.style.marginBottom = "0"; setTimeout(function () { safuiAlert.parentNode.removeChild(safuiAlert); }, 1000); }, 7000); } }); } const hamburger = document.querySelector("#hamburger"); const closeNavHam = document.querySelector("#close-nav-ham"); const appscmsToolbar = document.querySelector(".appscms-toolbar"); const appscmsToolbarListItems = document.querySelectorAll( ".appscms-toolbar-list-item-span" ); closeNavHam.addEventListener("click", () => { if (hamburger.dataset.open === "1") { hamburger.dataset.open = "0"; appscmsToolbar.style.right = "-272px"; appscmsToolbar.style.display = "none"; hamburger.innerHTML = ` `; } }) hamburger.addEventListener("click", () => { if (hamburger.dataset.open === "1") { hamburger.dataset.open = "0"; appscmsToolbar.style.right = "-272px"; appscmsToolbar.style.display = "none"; hamburger.innerHTML = ` `; } else { hamburger.dataset.open = "1"; appscmsToolbar.style.right = "0px"; appscmsToolbar.style.display = "block"; hamburger.innerHTML = ``; } }); Array.from(appscmsToolbarListItems).map((item) => { item.addEventListener("click", (e) => { e.preventDefault(); var style = window.getComputedStyle(item.nextElementSibling); var maxHeight = style.getPropertyValue("max-height"); console.log(maxHeight) if (maxHeight && maxHeight !== "0px") { // If the item is expanded, collapse it item.nextElementSibling.style.maxHeight = "0"; item.nextElementSibling.style.opacity = "0"; item.nextElementSibling.style.height = "0"; } else { // If the item is collapsed, expand it item.nextElementSibling.style.maxHeight = item.nextElementSibling.scrollHeight + "px"; item.nextElementSibling.style.opacity = "1"; item.nextElementSibling.style.height = "auto"; } }); }); if ("{{ site.removeBootstrapJs }}" === "true") { const languagesModal = document.querySelector("#staticBackdrop"); const intModalBtn = document.querySelector("#int-modal-btn"); const closeBtn = document.querySelector("#close-modal"); if (intModalBtn) { intModalBtn.addEventListener("click", () => { languagesModal.style.display = "block"; languagesModal.classList.add("show"); let modal = document.createElement("div"); modal.classList.add("modal-backdrop", "show"); document.body.appendChild(modal); }); closeBtn.addEventListener("click", () => { languagesModal.style.display = "none"; languagesModal.classList.remove("show"); let modal = document.querySelector(".modal-backdrop"); document.body.removeChild(modal); }); } } document.addEventListener("DOMContentLoaded", function() { const downloadButton = document.getElementById("download-button"); if (downloadButton) { const loader = document.querySelector(".button-loader"); const downloadSvg = downloadButton.querySelector("#download-svg"); const savingData = document.getElementById("saving-data"); downloadButton.addEventListener("click", function() { loader.style.display = "block"; downloadSvg.style.visibility = "hidden"; // Show saving data message savingData.style.display = "flex"; // Your additional code can go here // Add your code logic here to execute when the button is clicked }); } }); // Check if the button exists const processingBtn = document.getElementById('processing-btn'); const buttonLoader = document.querySelector('.button-loader'); if (processingBtn && buttonLoader) { // Use passive event listener processingBtn.addEventListener('click', () => { // Use requestAnimationFrame for visual changes requestAnimationFrame(() => { buttonLoader.style.display = 'block'; }); // Use setTimeout to defer non-critical operations setTimeout(() => { history.back(); }, 0); }, { passive: true }); } if ("{{ site.navigationSearch }}" === "true" ) { // Fetch data from data.json const worker = new Worker('/search-worker.js'); worker.onmessage = function(event) { if (event.data.error) { console.error('Error fetching data:', event.data.error); } else { window.fetchedData = event.data; } }; worker.onerror = function(error) { console.error('Worker error:', error.message); }; // Send a message to the worker to start fetching the data worker.postMessage('fetchData'); // Filter data based on search query function filterData(data, query) { return data.filter(item => item.name.toLowerCase().includes(query.toLowerCase())); } // Display filtered results function displayResults(results) { const resultsContainer = document.getElementById('results'); resultsContainer.style.display = results.length ? 'block' : 'none'; resultsContainer.innerHTML = results.length ? results.map(result => `
`).join('') : 'No results found
'; } function mobileDisplayResults(results) { const mobileResultsContainer = document.querySelector('.mobile-searchbarResults'); mobileResultsContainer.style.display = results.length ? 'block' : 'none'; mobileResultsContainer.innerHTML = results.length ? results.map(result => ``).join('') : 'No results found
'; } // Handle search input const searchInput = document.querySelector('.search-input'); ; searchInput.addEventListener('input', (event) => { const query = event.target.value; const data = window.fetchedData || []; const filteredResults = filterData(data, query); displayResults(filteredResults); gtag('event', 'search', { 'event_category': 'engagement', 'event_label': 'Search Box', 'value': query }); }); const mobileSearchInput = document.querySelector('.mobile-search-input') mobileSearchInput.addEventListener('input', (event) => { const query = event.target.value; const data = window.fetchedData || []; const filteredResults = filterData(data, query); mobileDisplayResults(filteredResults); gtag('event', 'search', { 'event_category': 'engagement', 'event_label': 'Search Box', 'value': query }); }); // Hide results when clicking outside search input and results container document.addEventListener('click', (event) => { const resultsContainer = document.getElementById('results'); if (!searchInput.contains(event.target) && !resultsContainer.contains(event.target)) { resultsContainer.style.display = 'none'; } if ("{{ page.lang }}" === "en") { const mobileResultsContainer = document.querySelector('.mobile-searchbarResults'); if (!mobileSearchInput.contains(event.target) && !mobileResultsContainer.contains(event.target)) { mobileResultsContainer.style.display = 'none'; } } }); } document.addEventListener("DOMContentLoaded", function () { const scrollContainer = document.querySelector(".appscms-toolbar-list"); const scrollLeft = document.querySelector(".scroll-left"); const scrollRight = document.querySelector(".scroll-right"); function updateScrollButtons() { scrollLeft.style.display = scrollContainer.scrollLeft > 0 ? "block" : "none"; scrollRight.style.display = scrollContainer.scrollWidth > scrollContainer.clientWidth + scrollContainer.scrollLeft ? "block" : "none"; } scrollLeft.addEventListener("click", function () { scrollContainer.scrollLeft -= 120; // Adjust this value as needed updateScrollButtons(); }); scrollRight.addEventListener("click", function () { scrollContainer.scrollLeft += 120; // Adjust this value as needed updateScrollButtons(); }); scrollContainer.addEventListener("scroll", updateScrollButtons); // Initial check to hide buttons if necessary updateScrollButtons(); });