console.log("Test") function getUrlParameter(name) { const urlParams = new URLSearchParams(window.location.search); return urlParams.get(name) || ''; } // Заполняем поле при загрузке страницы document.addEventListener('DOMContentLoaded', function() { const searchValue = getUrlParameter('p__search_text2'); if (searchValue) { document.getElementById('searchInput').value = decodeURIComponent(searchValue); } }); const button = document.createElement('button'); button.innerHTML = '↑'; button.setAttribute('aria-label', 'Наверх'); // Стилизуем кнопку button.style.cssText = ` position: fixed; bottom: 120px; right: 58px; width: 50px; height: 50px; border-radius: 50%; background-color: #9e0502; color: white; border: none; font-size: 24px; font-weight: bold; cursor: pointer; opacity: 0; visibility: hidden; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,0.3); transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.2s ease; z-index: 9999; `; // Добавляем эффект наведения button.addEventListener('mouseenter', () => { button.style.transform = 'scale(1.05)'; }); button.addEventListener('mouseleave', () => { button.style.transform = 'scale(1)'; }); // Функция плавного показа/скрытия кнопки function toggleButtonVisibility() { if (window.scrollY > 300) { button.style.opacity = '1'; button.style.visibility = 'visible'; } else { button.style.opacity = '0'; button.style.visibility = 'hidden'; } } // Функция плавного скролла наверх function scrollToTop() { window.scrollTo({ top: 0, behavior: 'smooth' }); } // Навешиваем обработчики button.addEventListener('click', scrollToTop); window.addEventListener('scroll', toggleButtonVisibility); // Добавляем кнопку на страницу document.body.appendChild(button); // Запускаем проверку при загрузке toggleButtonVisibility();