(function () { const showFloating = document.querySelectorAll(".show-floating"); const floatingLicense = document.querySelectorAll(".floating-license"); const aboutLicense = document.querySelectorAll(".more-about-license"); const knowMore = document.querySelectorAll(".know-more"); const viewportWidth = window.innerWidth; const radios = document.querySelectorAll('input[type=radio][name="radio"]'); const price = document.querySelectorAll(".price"); const period = document.querySelectorAll(".period"); const buttons = document.querySelectorAll(".table-button"); const wrapper = document.querySelectorAll(".wrapper"); for (let i = 0; i < showFloating.length; i++) { showFloating[i].onclick = () => { if (floatingLicense[i].offsetHeight === 0) { floatingLicense[i].classList.add("partially-opened") } else { floatingLicense[i].classList.remove("partially-opened") floatingLicense[i].classList.remove("fully-opened") if (i === 0) { wrapper[1].classList.remove("is-open"); } else { wrapper[3].classList.remove("is-open"); } } } } function showHide(i) { if (i % 2 === 0) { if (window.getComputedStyle(aboutLicense[i]).height === "0px") { wrapper[i].classList.add("is-open"); } else { wrapper[i].classList.remove("is-open"); } } else { if (window.getComputedStyle(aboutLicense[i]).height === "0px") { wrapper[i].classList.add("is-open"); floatingLicense[(i - 1) / 2].classList.add("fully-opened"); } else { wrapper[i].classList.remove("is-open"); floatingLicense[(i - 1) / 2].classList.remove("fully-opened"); } } } knowMore.forEach((button, j) => { button.onclick = () => showHide(j); }); const prices = { 'one-year': ['234', '472', '472', '946'], 'lifetime': ['577', '1171', '1171', '2358'], 'three-month': ['87', '176', '221', '353'], }; const periods = { 'one-year': [' / 1 rok'], 'lifetime': [' na zawsze'], 'three-month': [' / trzy miesiÄ…ca'], }; const linkIds = { 'one-year': ['94989', '94994', '94990', '94995'], 'lifetime': ['94985', '94987', '94986', '94988'], 'three-month': ['94992', '94996', '94993', '94997'], }; function updatePricesAndLinks(radioId) { const priceValues = prices[radioId]; const periodValue = periods[radioId][0]; const linksValues = linkIds[radioId]; const length = Math.min(priceValues.length, linksValues.length); for (let i = 0; i < length; i++) { price[i].innerHTML = `${priceValues[i]}`; period[i].innerHTML = `${periodValue}`; buttons[i].setAttribute('href', 'https://store.payproglobal.com/checkout?products[1][id]=' + linksValues[i] + '&_gl=1'); } } radios.forEach((radio) => { const defaultValue = "one-year"; if (radio.checked && radio.id === defaultValue) { updatePricesAndLinks(defaultValue); } radio.addEventListener('change', () => { if (radio.checked) { const radioId = radio.id; updatePricesAndLinks(radioId); } }) }) }());