glob = new Array(); glob["ai_show"] = 0; function setupAnalytics() { let searchParams = new URLSearchParams(window.location.search); var utm_s_elements = document.getElementsByName('utm_source'); var utm_m_elements = document.getElementsByName('utm_medium'); var utm_c_elements = document.getElementsByName('utm_campaign'); for(var i = 0; i < utm_s_elements.length; i++) { utm_s_elements[i].value = searchParams.get('utm_source'); utm_m_elements[i].value = searchParams.get('utm_medium'); utm_c_elements[i].value = searchParams.get('utm_campaign'); } } setupAnalytics(); function change_lang(newLangCode) { const currentUrl = window.location.href; const newUrl = currentUrl.replace(/\/[a-z]{2}\//i, `/${newLangCode}/`); window.location.href = newUrl; } $('#applicationForm').submit(function(event){ event.preventDefault(); var cardData = $('.details__btn.clicked'); var title = cardData.data('title'); var subtitle = cardData.data('subtitle'); var text = cardData.data('text'); var price = cardData.data('price'); if (cardData.data('title') != undefined) { var formData = $(this).serialize() + "\nTitle: " + title + "\nSubtitle: " + subtitle + "\nDescription: " + text + "\nPrice: " + price; } else var formData = $(this).serialize(); var submitButton = $(this).find('.popup__form-submit'); $.ajax({ type: 'POST', url: '/tg_bot_b2b.php', data: formData, success: function(response){ closePopup(5); $('#applicationForm')[0].reset(); openPopup(200, event); }, error: function(xhr, status, error){ console.error(xhr.responseText); closePopup(5); $('#applicationForm')[0].reset(); openPopup(400, event); } }); }); $('.details__btn').click(function() { $('.details__btn').removeClass('clicked'); $(this).addClass('clicked'); }); $('.contact__block-btn').click(function() { $('.details__btn').removeClass('clicked'); $(this).addClass('clicked'); }); $('#applicationFormCareer').submit(function(event){ event.preventDefault(); var vacancyName = $('.vacancy__main-title').text(); var telegram = $('input[name="career_telegram"]').val(); var email = $('input[name="career_email"]').val(); var resume = $('#resume')[0].files[0]; var correctAnswers = $('input[name="correct_answers"]').val(); var formData = new FormData(); formData.append('career_telegram', telegram); formData.append('career_email', email); formData.append('career_resume', resume); formData.append('vacancy_name', vacancyName); formData.append('correct_answers', correctAnswers); $.ajax({ type: 'POST', url: '/tg_ah_bot_careers.php', data: formData, contentType: false, processData: false, success: function(response){ closePopup(11); $('#applicationFormCareer')[0].reset(); $('#resume').val(''); setUploadName(); openPopup(200, event); }, error: function(xhr, status, error){ console.error(xhr.responseText); closePopup(11); $('#applicationFormCareer')[0].reset(); $('#resume').val(''); setUploadName(); openPopup(400, event); } }); }); function ajax_post_data(requestURL,params,func) { const xhr = new XMLHttpRequest(); xhr.open('POST', requestURL); xhr.onload = () => { if (xhr.status !== 200) { return; }; eval(func); }; xhr.send(params); } function ga_dataLayer_push(evnt = "deposit",name,amount=0,comments="",hash="") { window.dataLayer = window.dataLayer || []; var m = new Object(); m.event = evnt; m.name = name; m.qty = amount; m.value = amount; m.comments = comments; m.hash = hash; console.log(m); window.dataLayer.push(m); log("GA push sended"); }