1401isFormChanged = false;1402setTimeout(function () {1403tmst_profile__updateSaveButtonState('default');1404}, 1000);1405}, 1000);14061407var profileName = 'tilda_members_profile' + objProfile.projectid;1408localStorage.setItem(profileName, JSON.stringify(objProfile));1409localStorage.setItem(profileName + '_timestamp', Math.floor(Date.now() / 1000).toString());14101411if (options.needReload) {1412
setTimeout(function () { window.location.reload(); }, 1000); } else { tma__userbar__updateDataProfile(); } if (options && typeof options.onSuccess === 'function') { options.onSuccess(); }}/** * Обрабатывает ошибочный ответ * @param {Object} response * @param {HTMLFormElement} form */function tmst_profile__handleErrorResponse(response, form) { var errorCode = response.code || response.data; if (errorCode === 'need_captcha') { tmst__profile__showRecaptcha(form); } else { tma__showErrorRequest(form, errorCode, 'userbar_dict', 'edit_profile'); tmst_profile__updateSaveButtonState('default'); }}/** * Отображает капчу для редактирования профиля * @param {HTMLFormElement} formChangeProfile - форма редактирования профиля */function tmst__profile__showRecaptcha(formChangeProfile) { var captchaCallback = function (captchaEvent) { var isRecaptchaSucceed = tmst__profile__handleRecaptcha(captchaEvent, formChangeProfile); if (isRecaptchaSucceed) { window.removeEventListener('message', captchaCallback); } }; tmst__profile__drawCaptcha(function () { window.removeEventListener('message', captchaCallback); }); window.addEventListener('message', captchaCallback);}/** * Добавляет капчу на страницу * @param {Function} [onClose] - функция, вызываемая при закрытии капчи */function tmst__profile__drawCaptcha(onClose) { var allRecords = document.getElementById('allrecords'); if (!allRecords) return; allRecords.insertAdjacentHTML('beforeend', tmst__profile__getRecaptchaHtml()); /** @type {HTMLDivElement} */ var recaptcha = document.querySelector('.tlk-recaptcha'); if (!recaptcha) return; var closeRecaptcha = recaptcha.querySelector('.tlk-recaptcha__close'); closeRecaptcha.addEventListener('click', function () { tmst__profile__closeRecaptcha(recaptcha); if (typeof onClose === 'function') { onClose(); } });}/** * Удаляет капчу с экрана * @param {HTMLElement} recaptcha - элемент капчи */function tmst__profile__closeRecaptcha(recaptcha) { if (recaptcha) { recaptcha.remove(); }}/** * Обрабатывает событие капчи * @param {MessageEvent} captchaEvent - событие капчи * @param {HTMLFormElement} formChangeProfile - форма редактирования профиля * @returns {boolean} - true, если капча успешно обработана, иначе false */function tmst__profile__handleRecaptcha(captchaEvent, formChangeProfile) { if (captchaEvent.origin.indexOf(window.tildaMembers.endpoint) === -1) return false; /** @type {HTMLDivElement} */ var recaptcha = document.querySelector('.tlk-recaptcha');