if (typeof $$ == 'undefined') { var $a = [], $$ = a => a && $a.push(a) ; $$.init = () => { while ($a.length) ($a.shift())() }; } /** * подгрузка скриптов для которых необходимо jquery */ function add_one_script_append_jquery() { let head_nodes = document.getElementsByTagName('head')[0].childNodes; let link_is = false; for (let prop in head_nodes) { if(prop == 'link', head_nodes[prop].id == 'link-digital-dolina') { link_is = true; } } if(! link_is) { // добавляем только один раз let add_js = []; forIn(add_js, s => { s1[s] = document.createElement('script'); s1[s].src = 'https://lk.x10academy.ru/js/' + s; // s1[s].setAttribute('async', 'async'); document.getElementsByTagName('head')[0].appendChild(s1[s]); }); } } var send_data_var_blocking = false; (() => { let isEmpty = obj => { for (let key in obj) { return false; } return true; }, empty = var_data => { return typeof var_data === 'undefined' || var_data === undefined || var_data === "" || var_data === 0 || var_data === "0" || var_data === null || var_data === false || (Array.isArray(var_data) && var_data.length === 0) || isEmpty(var_data) ? true : false; }, foreach = (iters, func) => { if(! empty(iters)) { for(let key in iters) { func(iters[key], key); } } }, forIn = foreach, get = (url, data = false) => { return new Promise((success, reject) => { $.ajax({ url, type: 'GET', data, dataType: 'JSON', cache: false, success, error: (jqXHR, textStatus, errorThrown) => { let error_obj = { jqXHR, textStatus, errorThrown, }; reject(error_obj); } }); }) }, post = (url, data_send = null) => { return new Promise((resolve, reject) => { $.ajax({ url, data: { _method: 'post', ...data_send }, // crossDomain: true, type: 'POST', dataType: 'JSON', cache: false, success: function(responseData, textStatus, jqXHR) { resolve(responseData); }, error: (jqXHR, textStatus, errorThrown) => { let error_obj = { jqXHR, textStatus, errorThrown, }; reject(error_obj); } }); }) } ; let head_nodes = document.getElementsByTagName('head')[0].childNodes; let link_is = false; for (let prop in head_nodes) { if(prop == 'link', head_nodes[prop].id == 'link-digital-dolina') { link_is = true; } } let promises = []; if(! link_is) { // добавляем только один раз let link_choices = document.createElement('link'); link_choices.href = 'https://lk.x10academy.ru/css/choices.min.css'; link_choices.rel = 'stylesheet'; document.getElementsByTagName('head')[0].appendChild(link_choices); let link_intlTelInput = document.createElement('link'); link_intlTelInput.href = 'https://lk.x10academy.ru/css/intlTelInput.css'; link_intlTelInput.rel = 'stylesheet'; document.getElementsByTagName('head')[0].appendChild(link_intlTelInput); let link = document.createElement('link'); link.href = 'https://lk.x10academy.ru/css/popup_sub_domain.css'; link.rel = 'stylesheet'; link.id = 'link-digital-dolina'; document.getElementsByTagName('head')[0].appendChild(link); let s1 = {}; // подгрузка скриптов на ранней стадии не требующих jquery let add_js = [ 'popper.min.js', 'choices.min.js', 'intlTelInput.js', 'utils.js', 'inputmask/inputmask.min.js' ]; forIn(add_js, s => { promises.push(new Promise(function(resolve, reject) { s1[s] = document.createElement('script'); s1[s].src = 'https://lk.x10academy.ru/js/' + s; s1[s].setAttribute('async', 'async'); s1[s].onload = resolve; s1[s].onerror = reject; document.getElementsByTagName('head')[0].appendChild(s1[s]); })); }); let add_other_js = [ 'https://widget.cloudpayments.ru/bundles/cloudpayments.js' ]; forIn(add_other_js, s => { promises.push(new Promise(function(resolve, reject) { s1[s] = document.createElement('script'); s1[s].src = s; s1[s].setAttribute('async', 'async'); s1[s].onload = resolve; s1[s].onerror = reject; document.getElementsByTagName('head')[0].appendChild(s1[s]); })); }); //style let css = document.createElement('style'); css.setAttribute('type', 'text/css'); let cssText = ` .iti__flag {background-image: url("` + `https://lk.x10academy.ru` + `/img/flags.png");} .iti--container { z-index: 100600; width: 100%; left: auto !important; right: auto !important; display: flex; justify-content: center; } .iti-mobile .iti__country-list { max-width: 500px; } @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { .iti__flag {background-image: url("` + `https://lk.x10academy.ru` + `/img/flags@2x.png");} } `; if(css.styleSheet) { // IE does it this way css.styleSheet.cssText = cssText; } else { // everyone else does it this way css.appendChild(document.createTextNode(cssText)); } document.getElementsByTagName("head")[0].appendChild(css); } // создаем форму (html) let html = document.createElement('div'); html.className = 'digital-dolina-popup'; html.setAttribute('style', 'display: none'); html.setAttribute('id', 'script-academy-container-b9cd31b4a032f648dfe18705e4e0107f364e'); let popup = document.createElement('div'); popup.className = 'digital-dolina-popup__content'; popup.id = 'digital-dolina-popup__content-b9cd31b4a032f648dfe18705e4e0107f364e'; html.appendChild(popup); // размещаем форму после загрузки страницы var add_popup_to_body_b9cd31b4a032f648dfe18705e4e0107f364e = () => { document.body.appendChild(html); let popup_ = document.getElementById('digital-dolina-popup__content-b9cd31b4a032f648dfe18705e4e0107f364e'); // вставляем контент формы в контейнер попапа popup_.style['max-width'] = '500px'; popup_.innerHTML = `

Регистрация на курс «Стратегия продаж»

Стратегия продаж
45 000 ₽
Цена
45 000 ₽
Я принимаю условия оферты и даю согласие на обработку данных
`; } // ищем вставку текущего скрипта как dom элемент let _stript = document.querySelector('[id=script-academy-b9cd31b4a032f648dfe18705e4e0107f364e]'); //_stript.after(html); // вставляем форму сразу после текущего скрипта // функция открытия формы var _open_form_b9cd31b4a032f648dfe18705e4e0107f364e = () => { document.getElementById('script-academy-container-b9cd31b4a032f648dfe18705e4e0107f364e') .style.display = 'flex'; /* let elems = document.querySelectorAll('.digital-dolina-popup'); for (let index = 0; index < elems.length; index++) { elems[index].style.zIndex = ''; } document.getElementById('script-academy-b9cd31b4a032f648dfe18705e4e0107f364e') .style.zIndex = '100600'; */ }; // определеяем кнопку над скрптом let action_button = _stript && _stript.previousElementSibling; // вешаем событие на кнопку открытия формы action_button && action_button.addEventListener('click', function() { console.log('opening'); _open_form_b9cd31b4a032f648dfe18705e4e0107f364e(); }); /* add */ $$(() => { add_popup_to_body_b9cd31b4a032f648dfe18705e4e0107f364e(); $(document).on('click', '[href="#b9cd31b4a032f648dfe18705e4e0107f364e"]', function (e) { e.preventDefault(); _open_form_b9cd31b4a032f648dfe18705e4e0107f364e(); }) if (document.querySelector("#script-academy-container-b9cd31b4a032f648dfe18705e4e0107f364e").querySelector("input[name='phone']") != null) { let phone = document.querySelector("#script-academy-container-b9cd31b4a032f648dfe18705e4e0107f364e").querySelector("input[name='phone']"); window.intlTelInput(phone, { initialCountry: "ru", placeholderNumberType: "FIXED_LINE", autoPlaceholder: 'aggressive', utilsScript: "https://lk.x10academy.ru/js/utils.js", nationalMode: false }); set_mask(phone); phone.addEventListener("countrychange", function (e) { e.target.value = ""; e.target.setAttribute("value", ""); set_mask(e.target); }); function set_mask(element) { let activePlaceholder = element.getAttribute('placeholder'); let code = activePlaceholder.match(/\+\d*/g)[0]; let codes = { '+82': '99-9999-9999', '+355': '(999) 999-999', '+213': '99-999-9999', '+54': '(999) 9999-9999', '+61': '99-9999-9999', '+43': '(999) 999-99999', '+880': '9999-999999', '+32': '(999) 999-999', '+975': '9-999-9999', '+267': '99-999-999', '+55': '(99) 99999-9999', '+359': '(999) 999-999', '+86': '(999) 9999-9999', '+57': '(999) 999-9999', '+243': '(999) 999-999', '+385': '99-999-9999', '+593': '99-999-9999', '+20': '(999) 999-9999', '+372': '9999-9999', '+251': '99-999-9999', '+358': '999-9999999', '+33': '(999) 999-999', '+241': '(999) 999-9999', '+49': '(999) 999-99999', '+224': '999-99-99-99', '+245': '9-999999', '+36': '(999) 999-999', '+62': '(999) 999-99-999', '+964': '(999) 999-9999', '+353': '(999) 999-999', '+972': '999-999-9999', '+81': '99-9999-9999', '+962': '9-9999-9999', '+961': '99-999-999', '+218': '99-999-999', '+261': '99-99-99999', '+265': '9-9999-9999', '+60': '99-999-9999', '+230': '999-9999', '+52': '(999) 999-9999', '+95': '99-999-999', '+264': '99-999-9999', '+64': '(999) 999-999', '+234': '999-999-9999', '+507': '9999-9999', '+92': '(999) 999-9999', '+970': '99 999 9999', '+675': '(999) 99-999', '+51': '(999) 999-999', '+63': '(999) 999-9999', '+685': '99-9999', '+378': '9999-999999', '+381': '99-999-9999', '+677': '999-9999', '+252': '99-999-999', '+597': '999-9999', '+46': '99-999-9999', '+886': '9999-9999', '+66': '99-999-9999', '+90': '(999) 999-99999', '+688': '999999', '+971': '99-999-9999', '+44': '99-9999-99999', '+678': '99-99999', '+39': '(999) 9999-999', '+58': '(999) 999-9999', '+84': '99-9999-999' }; if (! empty(codes[code])) { activePlaceholder = codes[code]; } else { activePlaceholder = activePlaceholder.replaceAll(/\+\d*/g, ""); activePlaceholder = activePlaceholder.replaceAll(/[0-8]/g, "9"); } let new_placeholder = code + " " + activePlaceholder.trim(); code = code.replaceAll("9", "\\9"); let newMask = code + " " + activePlaceholder.trim(); element.setAttribute('placeholder', new_placeholder); var im = new Inputmask(newMask); im.mask(element); } } let url = new URL(window.location.href); let utm = {}; url.search.slice(1).split('&').forEach(s => { let el = s.split('='); utm[el[0]] = el[1]; }); let json_utm = 'null'; if (json_utm.length) { if (typeof utm != 'undefined') { utm = { ...utm, ...JSON.parse(json_utm) }; } else { utm = json_utm; } } let this_popup = $("#script-academy-container-b9cd31b4a032f648dfe18705e4e0107f364e"); // закрываем форму $(this_popup).on('mousedown', '.digital-dolina-popup__close', function () { let elem = $(this).closest('.digital-dolina-popup'); $(elem).hide(); $(elem).parent().css("z-index", ""); }); $(this_popup).on('mousedown', function (e) { if ($(e.target).is('.digital-dolina-popup')) { $(this).hide(); $(this).parent().css("z-index", ""); } }); let agre = $('[name="agre"]', this_popup); let email = $('[name="email"]', this_popup); let phone = $('[name="phone"]', this_popup); let promo = $('[name="promo"]', this_popup); let name = $('[name="name"]', this_popup); let surname = $('[name="surname"]', this_popup); let personal_chars_id = $('[name="personal_chars_id"]', this_popup); let business_ids = $('[name^="business_ids"]', this_popup); forIn([phone, promo, name, surname, email, personal_chars_id], input => { input.length && input.on('input', () => { if (input.val() != '') { input.parent().addClass('digital-dolina-active'); } else { input.parent().removeClass('digital-dolina-active'); } }); }); let sum = parseInt(45000); let result_sum = sum; let interval_promo = false promo.length && promo.on('input', function () { if (interval_promo) { clearTimeout(interval_promo); } interval_promo = setTimeout(() => { if ($(this).val() != '') { post('https://lk.x10academy.ru/purchase_doc_system/get_price', { pricing_politics_id: '378', promo: $(this).val() }) .then(data => { $(".digital-dolina-field__msg", this_popup).remove(); // $("#success_promo").remove(); if (data.errors) { promo.closest(".digital-dolina-field") .append(`
`); data.errors.forEach(error => { $(".digital-dolina-field__msg_error").append( $('
').text(error) ); }); result_sum = parseInt(sum); let result_sum_text = result_sum.toString();//.replaceAll(/(\d)(?=(\d{3})+([^\d]|$))/g, s => s + ' '); $(".digital-dolina-js-sum").html(result_sum_text + ' ₽'); $(".digital-dolina-discount").remove(); } else if (data.data) { let text_discount = ''; promo.closest(".digital-dolina-field") .append(`
`); if (data.data.type == 'percent') { result_sum = sum - (sum / 100 * parseInt(data.data.value)); text_discount = data.data.value + '%'; $(".digital-dolina-field__msg_sucess").text('Скидка ' + parseInt(data.data.value) + '%'); } else { result_sum = sum - parseInt(data.data.value); if (result_sum <= 0) { result_sum = 0; } text_discount = data.data.value + '₽'; $(".digital-dolina-field__msg_sucess").text('Скидка ' + data.data.value + '₽') } result_sum = parseInt(result_sum) + ' '; let result_sum_text = result_sum.toString();//.replaceAll(/(\d)(?=(\d{3})+([^\d]|$))/g, s => s + ' '); $(".digital-dolina-js-sum", this_popup).html(result_sum_text + ' ₽'); $(".digital-dolina-discount", this_popup).remove(); $(".digital-dolina-pay__item_total", this_popup).before( $(".digital-dolina-pay__item_total", this_popup).clone() ) $($(".digital-dolina-pay__item_total", this_popup).get(0)).addClass('digital-dolina-discount'); $(".digital-dolina-discount .digital-dolina-pay__title", this_popup).html('Скидка'); $(".digital-dolina-discount .digital-dolina-pay__amount", this_popup).html(text_discount); } }) .catch(error => { console.log(error); }); } else { // убираем сообщение $(".digital-dolina-field__msg", this_popup).remove(); result_sum = parseInt(sum); let result_sum_text = result_sum.toString();//.replaceAll(/(\d)(?=(\d{3})+([^\d]|$))/g, s => s + ' '); $(".digital-dolina-js-sum").html(result_sum_text + ' ₽'); } }, 500); }); // let interval_to_Sent_form = false; $('.digital-dolina-form', this_popup).on('submit', function (e) { e.preventDefault(); if (send_data_var_blocking) { return false; } let fields = {}; forIn($(this).serializeArray(), iter => { fields[iter.name] = iter.value; }); fields.json_utm = JSON.stringify(utm); fields.str_cookie = document.cookie; let sub = true; let errors = []; // условия оферты обязательны if (!agre.prop("checked")) { agre.on('change.my_event', function (e) { $(this).closest('.digital-dolina-checkbox').removeClass('digital-dolina-checkbox_error').off('.my_event'); $(".digital-dolina-js-field_error").remove(); }).closest('.digital-dolina-checkbox').addClass('digital-dolina-checkbox_error'); sub = false; errors.push('Примите соглашение о политике конфиденциальности'); } else { agre.closest('.digital-dolina-checkbox').removeClass('digital-dolina-checkbox_error'); $(".digital-dolina-js-field_error").remove(); } // email - обезателен для ввода if (email.val() == '' || !/^[^@\.]([^@]{0,}[^@\.])?@[^@\.]([^@]{0,}[^@\.])?\.[^@\.]{2,}$/i.test(email.val())) { sub = false; if (email.val() == '') { errors.push('Поле Email обязательно'); } else { errors.push('Неверный формат Email'); } email.on('input.my_event', function (e) { $(this).closest('.digital-dolina-input').removeClass('digital-dolina-input_error').off('.my_event'); $(".digital-dolina-js-field_error").remove(); }).closest('.digital-dolina-input').addClass('digital-dolina-input_error'); } else { email.closest('.digital-dolina-input').removeClass('digital-dolina-input_error'); $(".digital-dolina-js-field_error").remove(); } //phone if (phone.length) { let phone_sub = true; if (!phone.val().length) { if (phone.data('required') == true) { phone.on('input.my_event', function (e) { $(this).closest('.digital-dolina-input').removeClass('digital-dolina-input_error').off('.my_event'); $(".digital-dolina-js-field_error").remove(); }).closest('.digital-dolina-input').addClass('digital-dolina-input_error'); sub = false; phone_sub = false; errors.push('Поле Телефон обязательно'); } } else { if (phone.attr("placeholder").replaceAll(/\s/g, '').length != phone.val().replaceAll(/\s/g, '').replaceAll('_', '').length) { phone.on('input.my_event', function (e) { $(this).closest('.digital-dolina-input').removeClass('digital-dolina-input_error').off('.my_event'); $(".digital-dolina-js-field_error").remove(); }).closest('.digital-dolina-input').addClass('digital-dolina-input_error'); sub = false; phone_sub = false; errors.push('Неверный формат номера телефона'); } } if (phone_sub) { phone.closest('.digital-dolina-input').removeClass('digital-dolina-input_error'); $(".digital-dolina-js-field_error").remove(); } } forIn([name, surname, promo, personal_chars_id], field => { if (field.data('required') == true) { if (field.val() == '') { field.on('input.my_event', function (e) { $(this).closest('.digital-dolina-input').removeClass('digital-dolina-input_error').off('.my_event'); $(".digital-dolina-js-field_error").remove(); }).closest('.digital-dolina-input').addClass('digital-dolina-input_error'); sub = false; let label = $(this).closest('.digital-dolina-input').find('label'); if (label.length) { errors.push('Поле ' + $(label).text() + ' обязательно'); } } else { field.closest('.digital-dolina-input').removeClass('digital-dolina-input_error'); $(".digital-dolina-js-field_error").remove(); } } }); if (!sub) { /* if (!errors.length) { $(this_popup).find(".digital-dolina-form__content").prepend(`
Ошибка заполнения полей
`) } else { forIn(errors, e => { $(this_popup).find(".digital-dolina-form__content").prepend(`
${e}
`) }) } */ } else { send_data_var_blocking = true; window.dataLayer = window.dataLayer || []; window.dataLayer.push({'event': 'submit_form378'}); post('https://lk.x10academy.ru/purchase_doc_system/choosing_payment_systems/378', fields) .then(data => { if (data.status == 'error') { $(".digital-dolina-form__content").prepend(`
${data.message}
`) } if (data.url_to) { location.href = data.url_to; } if (data.html) { // если есть промежуточная страница if ($('#script-academy-b9cd31b4a032f648dfe18705e4e0107f364e-no_pay').length) { $('#script-academy-b9cd31b4a032f648dfe18705e4e0107f364e-no_pay').remove(); } let html = document.createElement('div'); html.className = 'digital-dolina-popup'; html.setAttribute('style', 'display: none'); html.setAttribute('id', 'script-academy-b9cd31b4a032f648dfe18705e4e0107f364e-no_pay'); let popup = document.createElement('div'); popup.className = 'digital-dolina-popup__content'; popup.id = 'digital-dolina-popup__content-b9cd31b4a032f648dfe18705e4e0107f364e-no_pay'; html.appendChild(popup); this_popup.after(html); // закрываем форму $('#script-academy-b9cd31b4a032f648dfe18705e4e0107f364e-no_pay').on('click', '.digital-dolina-popup__close', function () { let elem = $(this).closest('.digital-dolina-popup'); $(elem).hide(); $(elem).parent().css("z-index", ""); }); let new_popup_ = $('#script-academy-b9cd31b4a032f648dfe18705e4e0107f364e-no_pay'); $('#digital-dolina-popup__content-b9cd31b4a032f648dfe18705e4e0107f364e-no_pay', new_popup_) .css({ maxWidth: 600 }) .html(data.html); this_popup.hide(); $(this_popup).parent().css("z-index", ""); new_popup_.css({display: 'flex'}); $$.init(); } }) .catch(error => { console.log(error); }) .finally(() => { send_data_var_blocking = false; }); } }); }); // проверка наличия jquery и загрузка jquery let get_exist_function_jqyert = () => { if (!window.jQuery) { window.onload = () => { let link_is = false; for (let prop in head_nodes) { if (prop == 'link', head_nodes[prop].id == 'jquery-form-academy') { link_is = true; } } if (! link_is) { // добавляем только один раз script_jquery = document.createElement('script'); script_jquery.src = 'https://lk.x10academy.ru/js/jquery-3.5.1.min.js'; script_jquery.setAttribute('async', 'async'); script_jquery.addEventListener('load', () => { console.log(`jQuery has been loaded successfully!`); add_one_script_append_jquery(); Promise.all(promises) .then(() => { $$.init(); }); }); script_jquery.id = 'jquery-form-academy'; document.getElementsByTagName('head')[0].appendChild(script_jquery); } else { $$.init(); } } } else { window.onload = () => { let link_is = false; if ($('#link-form-academy').length) { link_is = true; } if (!link_is) { // добавляем только один раз add_one_script_append_jquery(); Promise.all(promises) .then(() => { $$.init(); }); } else { $$.init(); } } } } get_exist_function_jqyert(); // let check_page_load = () => { // if(window.jQuery){ // get_exist_function_jqyert(); // // $$.init(); // } else { // setTimeout(check_page_load, 1000); // } // } // check_page_load(); })();