*/window.tildaForm.addTildaCaptcha = function (formNode, formKey) { const form = t_forms__getElement(formNode); const formCaptchaBox = document.getElementById('tildaformcaptchabox'); const tildaCaptcha = document.getElementById('js-tildaspec-captcha'); if (formCaptchaBox) t_removeEl(formCaptchaBox); if (tildaCaptcha) t_removeEl(tildaCaptcha); form.insertAdjacentHTML( 'beforeend', '<input type="hidden" name="tildaspec-tildacaptcha" id="js-tildaspec-captcha">' ); let randomKey; try { randomKey = '' + new Date().getTime() + '=' + parseInt(Math.random() * 8, 10); } catch (e) { randomKey = 'rnd=' + parseInt(Math.random() * 8, 10); } const captchaBox = document.createElement('div'); captchaBox.id = 'tildaformcaptchabox'; captchaBox.tabIndex = -1; captchaBox.style.cssText = 'z-index: 99999999999; position: fixed; text-align: center; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.97);'; const iframe = document.createElement('iframe'); iframe.id = 'captchaIframeBox'; iframe.setAttribute('frameborder', '0'); iframe.style.cssText = 'display: block; border: 0; width: 100%; height: 100%;'; // В Chrome на iOS iframe с высотой 100% перезагружается, когда адресная строка меняет высоту экрана. if (/CriOS/.test(navigator.userAgent)) { const frameWidth = window.innerWidth + 'px'; const frameHeight = window.innerHeight + 'px'; captchaBox.style.right = 'auto'; captchaBox.style.bottom = 'auto'; captchaBox.style.width = frameWidth; captchaBox.style.height = frameHeight; captchaBox.style.overflow = 'hidden'; iframe.style.width = frameWidth; iframe.style.height = frameHeight; } captchaBox.appendChild(iframe); document.body.appendChild(captchaBox); iframe.src = `//${window.tildaForm.endpoint}/procces/captcha/?tildaspec-formid=${form.id}&tildaspec-formskey=${formKey}&${randomKey}`; window.removeEventListener('message', checkVerifyTildaCaptcha); window.addEventListener('message', checkVerifyTildaCaptcha); captchaBox.focus();};/** * Add information on members * @param {Node} formNode - block form * @returns {boolean} - return true/false */window.tildaForm.addMembersInfoToForm = function (formNode) { const form = t_forms__getElement(formNode); if (!form) return; try { var mauserInfo = form.querySelector('.js-tilda-mauserinfo'); if (mauserInfo) t_removeEl(mauserInfo); if (!window.mauser) return; window.tildaForm.tildamember = {}; if (window.mauser.name) { window.tildaForm.tildamember['name'] = window.mauser.name; } // code и email должны быть заполнены вместе if (window.mauser.code && window.mauser.email) { window.tildaForm.tildamember['email'] = window.mauser.email; window.tildaForm.tildamember['code'] = window.mauser.code; } // phonecode и phone должны быть заполнены вместе if (window.mauser.phonecode && window.mauser.phone) { window.tildaForm.tildamember['phone'] = window.mauser.phone; window.tildaForm.tildamember['phonecode'] = window.mauser.phonecode; }