4301);4302const firstFocusableElement = focusableElements[0];4303const lastFocusableElement = focusableElements[focusableElements.length - 1];43044305document.addEventListener('keydown', function (event) {4306if (!document.body.classList.contains('t-body_popupshowed')) return;43074308const isTab = event.key === 'Tab' || event.keyCode === 9;4309const isTabPressed = isTab || (isTab && event.shiftKey);4310if (!isTabPressed) {4311return;4312
} if (event.shiftKey && document.activeElement.classList.contains('t-popup_show')) { lastFocusableElement.focus(); } if (event.key === 'Tab' && !event.shiftKey && document.activeElement === lastFocusableElement) { event.preventDefault(); firstFocusableElement.focus(); } // if tab+shift and we moving back if (event.key === 'Tab' && event.shiftKey && document.activeElement === firstFocusableElement) { event.preventDefault(); lastFocusableElement.focus(); } });}/** * Проверяет открыта ли страница на кеширующем сервисе * @returns {boolean} Возвращает true, если страница открыта на кеширующем сервисе, иначе false. */function t_forms__isCachedPage() { try { const url = new URL(window.location.href); const hostname = url.hostname; const href = url.href; // Список кеширующих сервисов и их доменов/шаблонов URL const cacheServices = [ { domains: ['webcache.googleusercontent.com'], urlPattern: /(^|&|\?)q=cache:/, }, { domains: ['www.google.com'], urlPattern: /\/amp\/s\//, }, { domains: ['t.me'], urlPattern: /\/web\//, }, { domains: ['dzen.ru'], urlPattern: /\/away\?/, }, { domains: [ 'yandex.ru', 'yandexwebcache.net', 'archive.today', 'archive.ph', 'archive.is', 'web.archive.org', 'ghostarchive.org', 'cachedview.com', ], }, ]; for (const service of cacheServices) { const isDomainMatch = service.domains.some(domain => hostname === domain); const isUrlPatternMatch = service.urlPattern ? service.urlPattern.test(href) : true; if (isDomainMatch && isUrlPatternMatch) { return true; } } return false; } catch (error) { return false; }}/** * Получает каноническую ссылку страницы, если она задана. * @returns {string} Каноническая ссылка страницы, если она есть, иначе пустая строка. */function t_forms__getCanonicalUrl() { const canonicalLink = document.querySelector('link[rel="canonical"]'); return canonicalLink ? canonicalLink.getAttribute('href') : '';}/** * Рендерит сообщение о том, что форма открыта не на том url * @param {string} canonicalUrl */