window.onload = () => { const thisYear = new Date().getFullYear(); const yearNode = document.getElementById('footer-year'); const scrollTopElement = document.getElementById('scroll-top'); const scrollTopAction = document.getElementById('scroll-top-action'); const storeLinks = document.getElementsByClassName('js-store-link'); function changeScrollTopVisibility() { if (scrollTopElement) { if (window.innerHeight < window.scrollY) { scrollTopElement.classList.add('scroll-top--visible'); } else { scrollTopElement.classList.remove('scroll-top--visible'); } } } if (yearNode) { yearNode.innerHTML = `${thisYear}`; } changeScrollTopVisibility(); window.addEventListener('scroll', (e) => { changeScrollTopVisibility(); }); if(scrollTopAction) { scrollTopAction.addEventListener('click', (e) => { e.preventDefault(); window.scrollTo(0, 0); }); } // Метрика function sendMetrika(type, data) { if (!data) { data = {}; } window.postMessage( { host: 'premier.one', //window.document.location.host, - чтобы работало на тестовом, сейчас передаем боевой домен type: `analytics::${type}`, data, }, '*', ); } function storeButtonClick(store, source = 'site') { sendMetrika('users_leave_appmarket', { store, source }); } if (storeLinks.length) { for (const link of storeLinks) { link.addEventListener('click', (e) => { var store = e.currentTarget.getAttribute('data-store'); storeButtonClick(store); }); } } };