function jc_setfrmfld() { var obj = document.documentElement; while (obj.lastChild) obj = obj.lastChild; obj = obj.parentNode; var a = obj.parentNode; var inp = a.getElementsByTagName('input'); var td = inp.item(inp.length-1).parentNode; } /** * @param {object} form * @param {boolean} isUserNameShow * @param {boolean} isUserNameRequired * @param {boolean} isMiddleNameShow * @param {boolean} isMiddleNameRequired * @param {boolean} isLastNameShow * @param {boolean} isLastNameRequired * @param {boolean} isEmailShow * @param {boolean} isEmailRequired * @param {boolean} isPhoneShow * @param {boolean} isPhoneRequired * @param {boolean} isCityShow * @param {boolean} isCityRequired * @return {boolean} */ function jc_chkscrfrm(form, isUserNameShow, isUserNameRequired, isMiddleNameShow, isMiddleNameRequired, isLastNameShow, isLastNameRequired, isEmailShow, isEmailRequired, isPhoneShow, isPhoneRequired, isCityShow, isCityRequired) { var formData = new FormData(form); if (typeof form.elements.hash === 'undefined') { var hashParameters = { uname: isUserNameShow && isUserNameRequired, middlename: isMiddleNameShow && isMiddleNameRequired, lastname: isLastNameShow && isLastNameRequired, email: isEmailShow && isEmailRequired, phone: isPhoneShow && isPhoneRequired, city: isCityShow && isCityRequired }; var hashParametersSerialized = Object.keys(hashParameters).map(function(key) { return encodeURIComponent(key) + '=' + encodeURIComponent(hashParameters[key]); }).join('&') formData.append('hash', btoa(hashParametersSerialized)); } var xhr = new XMLHttpRequest(); var action = form.action.replace(/^(http:|https:)/, ''); xhr.open(form.method, action + '&isJsValidation=1'); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.withCredentials = true; xhr.send(formData); xhr.onreadystatechange = function() { if (this.readyState !== 4) { return; } if (this.status === 200) { var response = JSON.parse(this.responseText); if (response.success === false) { var firstError = response.errors[0]; form.elements[firstError.attribute].focus(); alert(firstError.message); } else { window.location.href = response.location; } } } return false; } function getCookie(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return (setStr); } if (getCookie('sitePreview') != '1') { var real_location = location.hostname; if (real_location.indexOf("justclick.ru") + 1) { // мы на домене JC, заменим юзерскую оферту офертой JC var oferta_link = '/media/oferta.php'; $('[id ^= "subscr-form-"]').find('tr[rel="oferta"]').remove(); var oferta_element = '' + '' + '' + 'Прочитал и согласен с договором оферты' + '\n\t\t' + ''; $('[id ^= "subscr-form-"]').find('tr:last').before(oferta_element); } else { $('tr[rel="oferta"] a.oferta').each(function (index, offerLink) { if ($(offerLink).attr('href').indexOf("justclick.ru") !== -1) { $(offerLink).closest('tr[rel="oferta"]').remove(); } }); } }