!function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((u=d(d(t,n),d(e,u)))<>>32-o,r)}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function c(n,t){var r,e,o,u;n[t>>5]|=128<>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h>5]>>>e%32&255);return t}function a(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e>5]|=(255&n.charCodeAt(e/8))<>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return i(c(a(n=r(n)),8*n.length))}function u(n,t){return function(n,t){var r,e=a(n),o=[],u=[];for(o[15]=u[15]=void 0,16 { const value = params.get(param); if (value) { utmParams[param] = value; } }); return utmParams; }catch(err){ console.log(err) } } function saveUTMParams() { try{ const utmParams = getUTMParams(); if (Object.keys(utmParams).length > 0) { sessionStorage.setItem('utmParams', JSON.stringify(utmParams)); } }catch(err){ console.log(err) } } function appendUTMToAddressBar() { try{ const storedUTMParams = sessionStorage.getItem('utmParams'); if (storedUTMParams) { const utmParams = JSON.parse(storedUTMParams); const url = new URL(window.location.href); const searchParams = url.searchParams; let hasNewParams = false; Object.keys(utmParams).forEach(param => { if (!searchParams.has(param) && utmParams[param]) { searchParams.set(param, utmParams[param]); hasNewParams = true; } }); if (hasNewParams) { window.history.replaceState({}, '', url.toString()); } } }catch(err){ console.log(err) } } function getClientIdByScript(){ try{ let clientId let result const headScripts = document.head.getElementsByTagName('script'); let clientIDFound = false; for (let i = 0; i < headScripts.length; i++) { const script = headScripts[i]; const scriptContent = script.textContent || script.innerText; if (scriptContent.includes('ym(')) { const match = scriptContent.match(/ym\(([^,]+)/); if (match && match[1]) { clientId = match[1].trim(); clientIDFound = true; break; } } } if (!clientIDFound) { const bodyScripts = document.body.getElementsByTagName('script'); for (let i = 0; i < bodyScripts.length; i++) { const script = bodyScripts[i]; const scriptContent = script.textContent || script.innerText; if (scriptContent.includes('ym(')) { const match = scriptContent.match(/ym\(([^,]+)/); if (match && match[1]) { clientId = match[1].trim(); console.log(clientId); break; } } } } ym(clientId, 'getClientID', function(clientID) { result = clientID }); return result }catch(err){ console.log(err) return false } } function sendStartTrigger (th) { const data = { scanId: th.scanId, schoolId: th.school_id, accountId: th.account_id, hit: th.hit, type: "start", } fetch(reqUrl, { method: "POST", body: JSON.stringify(data) }) } function sendEndTrigger (th) { const data = { scanId: th.scanId, schoolId: th.school_id, accountId: th.account_id, hit: th.hit, type: "end", } fetch(reqUrl, { method: "POST", body: JSON.stringify(data) }) } (function(conf) { if (window.location.pathname.includes('/pl/help/launcher')) { return } if(window.location.pathname === '/sales/control/userProduct/my'){ const rows = document.querySelectorAll(".table tbody tr"); rows.forEach(row => { const cell = row.querySelector(".text-right"); if (cell && cell.innerHTML.trim() === "0 руб.") { row.remove(); } }); } let Webvisor = function Webvisor(conf) { const ISSTR = 'string'; const ISINT = 'number'; const ISOBJ = 'object'; const ISFUNC = 'function'; const POSITIVE = 'abovezero'; const NOTEMPTY = 'notempty'; const NOTUNDEF = undefined; const NOTNULL = null; const NOTSYMBOL = '/'; const HANDLER = '__'; this.isActivePage = true this.account_id = conf.account_id; this.user_id = conf.user_id || false; this.school_id = conf.school_id || false; this.version = conf.version || false; this.components = {monitor: true, chat: true, forms: true, clicks: true, payment: true, monitor_all: true}; this.params = {"domains":{}}; this.eventId = window.requestSimpleSign + '_' + window.requestTime; this.pageUrl = window.location.href; this.pageTitle = document.title; this.referrer = document.referrer || null; this.duration = false; this.domen = 'https://api.analitika.school/'; this.order_id = false; this.userComment = false; this.userEmail = false; this.userName = false; this.userPhone = false; this.elementType = false; this.method = false; this.GETParams = false; this.POSTParams = false; this.element = false; this.eventHandler = false; this.ready = false; this.fbc = false; this.fbp = false; this.scanId = undefined; this.scanIdMap = []; this.hit = undefined; this.ip = '77.111.244.6'; this.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0'; this.browserLang = 'ru'; this.screenSize = window.screen.width + '/' + window.screen.height; this.domains = []; this.hitJson = null; this.hash = undefined; this.countClicks = 0; this.scrollHeight = 0; this.pageYOffset = 0; this.isFramed = false; this.ClientID = false; this.tab = 1; this.UserInfo = []; this.timeZone = undefined; this.emailValidationEnabled = 1; this.redirectUtmEnabled = 2; this.load_duration = undefined; function getTimezoneString() { const timezoneOffsetMinutes = -new Date().getTimezoneOffset(); const timezoneOffsetHours = Math.abs(timezoneOffsetMinutes) / 60; const timezoneSign = timezoneOffsetMinutes >= 0 ? '+' : '-'; return 'UTC' + " " + timezoneSign + timezoneOffsetHours; } function startEmailValidationScript() { const script = ` ` const elem = document.getElementsByName("formParams[email]")[0] const textElem = document.createElement("div") textElem.id = "email-err-text" if (!document.getElementById("email-err-text")) { elem.parentNode.appendChild(textElem) } let dropdown = document.createElement("div") dropdown.id = "email_dropdown" dropdown.style = "position: absolute; top: 60px; left: 0; display: none;" elem.parentNode.appendChild(dropdown) elem.addEventListener("blur", (e) => setTimeout(() => validation(e, elem), 100)) elem.addEventListener("input", (e) => validation2(e, elem)) let scriptContainer = document.createElement("div") scriptContainer.innerHTML = script document.body.appendChild(scriptContainer) } function startFocusObserver (th) { setInterval(function () { if (document.hidden) { if (th.isActivePage === true) { th.isActivePage = false sendEndTrigger() } } else { if (th.isActivePage === false) { th.isActivePage = true sendStartTrigger() } } }, 1000) } this.eventHandlers = { chatBtnMouseDown: function(data, event) { this.ready = true; this.element = document.querySelector('#comment_form .new-comment-input'); this.valid(NOTNULL, this.element); this.userComment = this.ready ? this.element.value : false; this.valid(ISSTR, this.userComment); this.valid(NOTEMPTY, this.userComment); this.setGETParams('account_id', 'school_id', 'url', 'comment', 'hit'); this.sendRequest('chat'); }, chatBtnKeyPress: function(data, event) { if(event.keyCode === 13) { this.ready = true; this.eventHandler = this.getEventHandler('chatBtnMouseDown'); this.valid(ISFUNC, this.eventHandler); this.ready ? this.eventHandler.call(this) : undefined; } }, formSubmitBtnClick: function(data, event) { document.querySelectorAll('form').forEach(form => { if (event.currentTarget == form.querySelector('button[type=submit]')) { this.ready = true; this.valid(NOTNULL, form.id.match(/^ltForm+\d+$/ig)); this.valid(NOTNULL, event.currentTarget.id.match(/^button+\d+$/ig)); this.element = document.querySelector('#' + form.id + ' input[name="formParams[email]"]'); this.valid(NOTNULL, this.element); this.userEmail = this.ready ? this.element.value : false; this.valid(ISSTR, this.userEmail); this.valid(NOTEMPTY, this.userEmail); if (document.querySelector('#' + form.id + ' input[name="formParams[first_name]"]')) { this.element = document.querySelector('#' + form.id + ' input[name="formParams[first_name]"]'); this.userName = this.element.value; } else { this.userName = ''; } if (document.querySelector('#' + form.id + ' input[name="formParams[phone]"]')) { this.element = document.querySelector('#' + form.id + ' input[name="formParams[phone]"]'); this.userPhone = this.element.value; } else { this.userPhone = ''; } this.fbp = this.cookie('_fbp'); this.fbc = this.cookie('_fbc'); if (decodeURIComponent(window.location.href).includes("&loc=")) { this.pageUrl = decodeURIComponent(window.location.href.split("&loc=")[1]); } else { this.pageUrl = window.location.href; } this.setPOSTParams('email', 'name', 'phone', 'school_id', 'url_short', 'params', 'title', 'fbp', 'fbc', 'event_id', 'url', 'hit', 'scan_id', 'hash'); this.sendPostRequest('forms'); } }); }, allFormsButtonsImagesClick: function(data, event) { this.ready = true; this.setElementTypeByEventTarget(event.target); this.valid(ISINT, this.elementType); this.setGETParams('account_id', 'school_id', 'url', 'type', 'hit'); this.sendRequest('clicks'); }, payFormSubmitBtnMouseDown: function(data, event) { this.ready = true; this.elementType = 'button'; this.valid(NOTNULL, this.order_id); this.setGETParams('account_id', 'school_id', 'order_id', 'type', 'hit'); this.sendRequest('payment'); } }; this.setElementTypeByEventTarget = function(element, deep) { deep = deep || 4; this.elementType = false; this.elementType = (element.id && element.id.match(/^button+\d+$/ig) && element.parentElement.id && element.parentElement.id.match(/^ltForm+\d+$/ig)) ? 3 : this.elementType; this.elementType = (!this.elementType && element.id && element.id.match(/^button+\d+$/ig)) ? 2 : this.elementType; this.elementType = (!this.elementType && element.id && element.id.match(/^image+\d+$/ig)) ? 1 : this.elementType; return ((deep > 1) && !this.elementType && element.parentElement) ? this.setElementTypeByEventTarget(element.parentElement, deep - 1) : undefined; }; this.setRequestMethod = function(component) { switch (component) { case 'monitor': this.method = 'monitoring'; break; case 'chat': this.method = 'chat_comment'; break; case 'forms': this.method = 'users_school_second'; break; case 'clicks': this.method = 'click'; break; case 'payment': this.method = 'payment'; break; case 'monitor_all': this.method = 'monitor_all'; break; case 'set_scan_id': this.method = 'set_scan_id'; break; default: this.ready = false; } }; this.controller = function(component) { switch (component) { case 'monitor': this.startMonitor(); break; case 'chat': this.startChat(); break; case 'forms': this.startFroms(); break; case 'clicks': this.startClicks(); break; case 'payment': this.startPayment(); break; case 'monitor_all': this.startMonitorAll(); break; default: } }; this.startMonitor = function() { if (document.hidden) { this.tab = 2; this.ready = true; this.valid(ISINT, this.account_id); this.valid(POSITIVE, this.account_id); this.valid(ISINT, this.user_id); this.valid(ISINT, this.school_id); this.valid(ISSTR, this.pageUrl); this.valid(ISSTR, this.pageTitle); this.strContain(this.pageUrl, '/webinar/show'); this.timeZone = getTimezoneString(); this.setPOSTParams('account_id', 'school_id', 'url', 'title', 'hit', 'tab', 'current_user', 'timeZone'); this.sendPostRequest('monitor'); } setTimeout(this.startMonitor.bind(this),10000); }; this.startChat = function() { this.ready = true; this.valid(ISINT, this.account_id); this.valid(POSITIVE, this.account_id); this.valid(ISINT, this.user_id); this.valid(ISINT, this.school_id); this.valid(ISSTR, this.pageUrl); this.strContain(this.pageUrl, '/webinar/show'); this.element = document.querySelector('#comment_form .webinar-btn-send'); this.eventHandler = this.getEventHandler('chatBtnMouseDown'); this.valid(NOTNULL, this.element); this.valid(ISFUNC, this.eventHandler); this.attachListener(this.element, 'mousedown', 'chatBtnMouseDown'); this.element = document.querySelector('#comment_form .new-comment-input'); this.eventHandler = this.getEventHandler('chatBtnKeyPress'); this.valid(NOTNULL, this.element); this.valid(ISFUNC, this.eventHandler); this.attachListener(this.element, 'keydown', 'chatBtnKeyPress'); }; this.startFroms = function() { this.ready = true; this.valid(ISINT, this.user_id); this.valid(ISINT, this.school_id); this.valid(ISSTR, this.pageTitle); document.querySelectorAll('form').forEach(form => { this.element = form.querySelector('button[type=submit]'); this.element ? this.attachListener(this.element, 'click', 'formSubmitBtnClick') : undefined; }); }; this.startClicks = function() { this.ready = true; this.valid(ISINT, this.account_id); this.valid(POSITIVE, this.account_id); this.valid(ISINT, this.user_id); this.valid(ISINT, this.school_id); this.valid(ISSTR, this.pageTitle); this.strContain(this.pageUrl, '/webinar/show'); document.querySelectorAll('div[id^=image], button[type=button], button[type=submit]').forEach(element => { this.attachListener(element, 'click', 'allFormsButtonsImagesClick'); }); }; this.startPayment = function() { this.ready = true; this.valid(ISINT, this.user_id); this.valid(ISINT, this.school_id); this.valid(ISSTR, this.pageTitle); this.strContain(this.pageUrl, '/sales/shop/dealPay'); this.order_id = this.pageTitle.match(/\d{5}/ig); this.valid(NOTNULL, this.order_id); document.querySelectorAll('button[type=submit], button.tinkoffcredit-submit, button.btn-success, button.pay-button').forEach(element => { this.attachListener(element, 'mousedown', 'payFormSubmitBtnMouseDown'); }); this.ready ? this.paymentMonitor('visit') : undefined; }; addEventListener("click", countClick); addEventListener("contextmenu", countClick); var countCl = 0; var countClickSecond = 0; var countClickHour = 0; function countClick() { countCl = countCl + 1; countClickSecond = countClickSecond + 1; countClickHour = countClickHour + 1 } window.onscroll = function() { countClickHour = countClickHour + 1 } this.startAllObserver = function () { if (this.isFramed) return; if (this.pageUrl.indexOf('/pl/lite/widget/widget') > -1) return this.fbp = this.cookie('_fbp') this.fbc = this.cookie('_fbc') const th = { scanId: this.scanId, school_id: this.school_id, account_id: this.account_id, hit: this.hit, } sendStartTrigger(th) startFocusObserver(th) window.addEventListener('beforeunload', function (e) { sendEndTrigger(th) }) } // Метод подстановки хита в url страницы this.setHitToUrl = function () { let handle = true if (handle) { let value = this.hit let key = "scan" const url = new URL(window.location.href) url.searchParams.set(key, value) url.searchParams.set("scan_id", this.scanId) if(!window.location.href.includes('/pl/lite/widget/widget')){ const getUrlWithParams = (url) => { url.searchParams.set("scan_id",this.scanId) return url } try{ const iframes = document.querySelectorAll('iframe'); iframes.forEach((iframe) => { try{ const src = iframe.getAttribute('src'); if(src.includes("widget")){ let url = new URL(src); const scan = url.searchParams.get('scan'); const scan_id = url.searchParams.get('scan_id'); const loc = url.searchParams.get('loc'); if (!scan || !scan_id) { url = getUrlWithParams(url) } if (loc) { url.searchParams.set('loc', getUrlWithParams(url)); } iframe.setAttribute('src', url.toString()); } }catch(err){ console.log(err) } }); }catch(err){ console.log(err) } } window.history.replaceState(null, null, url) } } this.removeHitFromUrl = function () { // const url = new URL(window.location.href) // url.searchParams.delete("scan") } this.startMonitorAll = function () { if (this.isFramed) return; if (this.pageUrl.indexOf('/pl/lite/widget/widget') > -1) return; try{ this.scanId = this.scanId.substring(0,36).toLowerCase() }catch(err){ console.log(err) } this.fbp = this.cookie('_fbp'); this.fbc = this.cookie('_fbc'); let firstPaintTime; const perfEntries = performance.getEntriesByType("navigation"); if (perfEntries.length > 0) { const navigationEntry = perfEntries[0]; firstPaintTime = (navigationEntry.domContentLoadedEventStart - navigationEntry.startTime) / 1000; } this.load_duration = typeof firstPaintTime === "number" ? firstPaintTime.toFixed(3) : 0 function monitorSend(hitJson) { if (!document.hidden) { this.tab = 1; this.countClicks = countCl; countCl = 0; if (this.duration === false) { this.duration = 0; } else { this.duration = this.duration + 10; } this.ready = true; this.valid(ISINT, this.school_id); this.valid(ISSTR, this.pageUrl); this.valid(ISSTR, this.pageTitle); this.valid(NOTUNDEF, this.hash); this.hitJson = hitJson; this.screenSize = window.screen.width + '/' + window.screen.height; this.pageYOffset = window.pageYOffset; this.scrollHeight = Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight ); if(!!document.querySelector('.sub-icon')){ return } else { this.timeZone = getTimezoneString(); this.setPOSTParams('account_id', 'school_id', 'url_short', 'params', 'title', 'fbp', 'fbc', 'event_id', 'url', 'referrer', 'hit', 'hash', 'screen_size', 'count_clicks', 'scrollHeight', 'pageYOffset', 'duration', 'scan_id', 'hit_json', 'tab', 'client_id', 'current_user', 'timeZone', 'load_duration'); this.sendPostRequest('monitor_all'); } } } let foo = monitorSend.bind(this); var i = 0; var arr = []; var num = 0; const second = setInterval(function() { if(i == 10) { i = 0; foo(JSON.stringify(arr), new Date()); arr = []; } if (!document.hidden) { var maxHeight = Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight ); arr[i] = { 'second': num+=1, 'page_y_offset': Math.ceil(window.pageYOffset) + window.innerHeight, 'scroll_height': maxHeight, 'count_licks': countClickSecond, 'window_size': window.innerWidth + '/' + window.innerHeight, 'screen_size': window.screen.width + '/' + window.screen.height, }; i+=1; countClickSecond = 0; } }, 1000); var hour = setInterval(function(){ if (countClickHour == 0) { clearInterval(second); clearInterval(minute); clearInterval(hour); } countClickHour = 0; }, 7200000); foo(); }; this.sessionStart = function () { this.ready = true; this.domains = this.params.domains; this.hit = this.generateUserId(); this.hash = md5(this.userAgent + (window.screen.width + window.screen.height) + this.browserLang + this.ip); var scanId = this.scanIdMap.find(el => el.hash == this.hash); if (this.params.domains.length > 1) { if (!this.isItemExist('_scanId')) { if (this.referrer !== null) { if (this.checkDomains(this.domains)) { if (typeof scanId !== 'undefined') { this.scanId = scanId.scan_id; localStorage.setItem('_scanId', this.scanId); } else { this.scanId = this.generateUserId(); localStorage.setItem('_scanId', this.scanId); } } else { this.scanId = this.generateUserId(); localStorage.setItem('_scanId', this.scanId); } } else { if (typeof scanId !== 'undefined') { this.scanId = scanId.scan_id; localStorage.setItem('_scanId', this.scanId); } else { this.scanId = this.generateUserId(); localStorage.setItem('_scanId', this.scanId); } } } else this.scanId = localStorage.getItem('_scanId'); } else { if (!this.isItemExist('_scanId')) { this.scanId = this.generateUserId(); localStorage.setItem('_scanId', this.scanId); } else this.scanId = localStorage.getItem('_scanId'); } if(window.location.href.includes('/pl/lite/widget/widget')){ let url = new URL(window.location.href) const scan_id = url.searchParams.get("scan_id") this.scanId = scan_id } try{ const scanIdFromReferrer = new URL(decodeURIComponent(document.referrer)).searchParams.get("scan_id") if(scanIdFromReferrer) { localStorage.setItem('_scanId',scanIdFromReferrer); this.scanId = scanIdFromReferrer } }catch(err){ console.log(err) } try{ const currentUrl = new URL(window.location.href); if(currentUrl.searchParams.has("rel_scan")){ if(currentUrl.searchParams.get("rel_scan") && currentUrl.searchParams.get("rel_scan").length > 0 && typeof currentUrl.searchParams.get("rel_scan") === "string"){ this.scanId = currentUrl.searchParams.get("rel_scan")?.substring(0,36) localStorage.setItem('_scanId',this.scanId) currentUrl.searchParams.delete("rel_scan") } } history.replaceState({}, document.title, currentUrl.toString()) } catch(err){ console.log(err) } try{ const links = document.querySelectorAll("a"); const scanIdValue = this.scanId links.forEach(link => { try{ if(link.getAttribute("href") === "#"){ return }else { const currentUrl = new URL(link.href); currentUrl.searchParams.set("rel_scan", scanIdValue); link.href = currentUrl.toString(); } }catch(err){ console.log(err) } }); }catch(err){ console.log(err) } if (this.params.domains.length > 1) { this.setGETParams('school_id', 'screen_size', 'scan_id'); this.setClientId('set_scan_id'); } }; this.paymentMonitor = function(elementType) { this.ready = true; this.elementType = elementType || 'monitor'; this.valid(NOTNULL, this.order_id); this.strContain(this.pageUrl, '/sales/shop/dealPay'); this.setGETParams('account_id', 'school_id', 'order_id', 'type'); this.sendRequest('payment'); setTimeout(this.paymentMonitor.bind(this),10000); }; this.createGETParam = function(param) { switch (param) { case 'account_id': param += '=' + this.account_id; break; case 'user_id': param += '=' + this.user_id; break; case 'school_id': param += '=' + this.school_id; break; case 'duration': param += '=' + this.duration; break; case 'order_id': param += '=' + this.order_id; break; case 'email': param += '=' + this.userEmail; break; case 'name': param += '=' + this.userName; break; case 'phone': param += '=' + this.userPhone; break; case 'type': param += '=' + this.elementType; break; case 'url': param += '=' + encodeURIComponent(this.pageUrl); break; case 'referrer': param += '=' + encodeURIComponent(this.referrer); break; case 'title': param += '=' + encodeURIComponent(this.pageTitle); break; case 'comment': param += '=' + encodeURIComponent(this.userComment); break; case 'params': param += '=' + encodeURIComponent(this.pageUrl.slice(this.pageUrl.indexOf('?') + 1)); break; case 'url_short': param += '=' + encodeURIComponent(this.pageUrl.split('?')[0]); break; case 'fbp': param += '=' + this.fbp; break; case 'fbc': param += '=' + this.fbc; break; case 'event_id': param += '=' + this.eventId; break; case 'hit': param += '=' + this.hit; break; case 'hit_json': param += '=' + this.hitJson; break; case 'hash': param += '=' + this.hash; break; case 'screen_size': param += '=' + this.screenSize; break; case 'count_clicks': param += '=' + this.countClicks; break; case 'scrollHeight': param += '=' + this.scrollHeight; break; case 'pageYOffset': param += '=' + this.pageYOffset; break; case 'scan_id': param += '=' + this.scanId; break; case 'tab': param += '=' + this.tab; break; default: param = null; } return param; }; this.createPOSTParam = function(param) { switch (param) { case 'account_id': param = this.account_id; break; case 'user_id': param = this.user_id; break; case 'school_id': param = this.school_id; break; case 'duration': param = this.duration; break; case 'order_id': param = this.order_id; break; case 'email': param = this.userEmail; break; case 'name': param = this.userName; break; case 'phone': param = this.userPhone; break; case 'type': param = this.elementType; break; case 'url': param = encodeURIComponent(this.pageUrl); break; case 'referrer': param = encodeURIComponent(this.referrer); break; case 'title': param = encodeURIComponent(this.pageTitle); break; case 'comment': param = encodeURIComponent(this.userComment); break; case 'params': param = encodeURIComponent(this.pageUrl.slice(this.pageUrl.indexOf('?') + 1)); break; case 'url_short': param = encodeURIComponent(this.pageUrl.split('?')[0]); break; case 'fbp': param = this.fbp; break; case 'fbc': param = this.fbc; break; case 'event_id': param = this.eventId; break; case 'hit': param = this.hit; break; case 'hit_json': param = this.hitJson; break; case 'hash': param = this.hash; break; case 'screen_size': param = this.screenSize; break; case 'count_clicks': param = this.countClicks; break; case 'scrollHeight': param = this.scrollHeight; break; case 'pageYOffset': param = this.pageYOffset; break; case 'scan_id': param = this.scanId; break; case 'tab': param = this.tab; break; case 'client_id': param = this.ClientID; break; case 'current_user': param = this.UserInfo; break; case 'timeZone': param = this.timeZone; break; case 'load_duration': param = this.load_duration; break; default: param = null; } return param; }; this.setGETParams = function() { this.GETParams = Array.prototype.slice.call(arguments); this.GETParams.forEach((param, index) => { this.GETParams[index] = this.valid(NOTNULL, this.createGETParam(param)); }); this.GETParams = this.GETParams.join('&', this.GETParams); }; this.setPOSTParams = function() { let params = Array.prototype.slice.call(arguments); this.POSTParams = {}; params.forEach((param) => { this.POSTParams[param] = this.valid(NOTNULL, this.createPOSTParam(param)); }); }; this.valid = function(type, value) { switch (type) { case ISSTR: this.ready && (this.ready = (typeof(value) === ISSTR)); break; case ISINT: this.ready && (this.ready = (parseInt(value) === parseInt(value))); break; case ISFUNC: this.ready && (this.ready = (typeof(value) === ISFUNC)); break; case ISOBJ: this.ready && (this.ready = (typeof(value) === ISOBJ)); break; case NOTUNDEF: this.ready && (this.ready = (value !== NOTUNDEF)); break; case NOTNULL: this.ready && (this.ready = (value !== NOTNULL)); break; case NOTEMPTY: this.ready && (this.ready = (value.trim() !== '')); break; case POSITIVE: this.ready && (this.ready = (value > 0)); break; case NOTSYMBOL: this.ready && (this.ready = (value.trim() !== '/')); break; default: this.ready = false; } return value; }; this.strContain = function(str, searchText) { this.valid(POSITIVE, str.indexOf(searchText)); }; this.sendRequest = function(component) { this.setRequestMethod(component); this.valid(ISSTR, this.domen); this.valid(ISSTR, this.method); this.valid(ISSTR, this.GETParams); this.ready ? fetch(this.domen + this.method + '?' + this.GETParams) : undefined; }; this.sendPostRequest = function(component) { this.setRequestMethod(component); this.valid(ISSTR, this.domen); this.valid(ISSTR, this.method); this.valid(ISOBJ, this.POSTParams); this.ready ? fetch(this.domen + this.method, { method: "POST", body: JSON.stringify(this.POSTParams) }) : undefined; }; this.setClientId = function() { this.ready = true; this.setRequestMethod('set_scan_id'); this.valid(NOTUNDEF, this.scanId); this.valid(NOTSYMBOL, this.screenSize); this.valid(ISINT, this.school_id); this.valid(ISSTR, this.domen); this.valid(ISSTR, this.method); this.valid(ISSTR, this.GETParams); this.ready ? fetch(this.domen + this.method + '?' + this.GETParams): false; }; this.getEventHandler = function(handlerName) { return this.eventHandlers[HANDLER + handlerName] || this.eventHandlers[handlerName]; }; this.attachListener = function(element, event, handlerName, eventData) { this.ready ? element.addEventListener(event, this.registrListener(handlerName, eventData)) : undefined; }; this.registrListener = function(handlerName, eventData) { this.eventHandlers[HANDLER + handlerName] = this.eventHandlers[HANDLER + handlerName] || this.eventHandlers[handlerName].bind(this, eventData); return this.eventHandlers[HANDLER + handlerName]; }; this.cookie = function(name) { let matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; }; this.isItemExist = function(name) { return (name in localStorage) } this.checkDomains = function (domains) { for (var domain in domains) { if (this.referrer.indexOf(domain) > -1 && domains[domain] === true) { return true; } } return false; } this.generateUserId = function() { var d = new Date().getTime(); if (typeof performance !== 'undefined' && typeof performance.now === 'function'){ d += performance.now(); } return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); } this.start = function(components) { try { this.isFramed = window != window.top || document != top.document || self.location != top.location; } catch (e) { this.isFramed = true; } this.sessionStart() if (typeof currentUser !== 'undefined' && Object.keys(currentUser).length !== 0) { this.UserInfo = { 'name': currentUser['first_name'] + ' ' + currentUser['last_name'], 'email': currentUser['email'], 'phone': currentUser['phone_standart'], 'created_at': currentUser['created_at'] }; } var match = document.cookie.match('(?:^|;)\\s*_ym_uid=([^;]*)'); // this.ClientID = (match) ? decodeURIComponent(match[1]) : false; this.ClientID = getClientIdByScript() ? getClientIdByScript() : match ? decodeURIComponent(match[1]) : false if (!this.isFramed) { this.setHitToUrl() setTimeout(() => this.removeHitFromUrl(), 2000) } // this.startAllObserver() components = components || this.components; Object.keys(components).forEach(component => { (components[component] === true) ? !this.params.launch_delay ? this.controller(component) : setTimeout(this.controller.bind(this, component), 1000) : undefined; }); if (this.emailValidationEnabled === 1) { try { startEmailValidationScript() } catch (e) { console.warn("Email validation disabled...") } } if(this.redirectUtmEnabled === 1) { try{ saveUTMParams(); appendUTMToAddressBar(); } catch(e){ console.log(e + "Redirect UTM failed") } } }; }; const domains = [ "mail.com", "gmail.com", "yandex.ru", "bk.ru", "ukr.net", "list.ru", "rambler.ru", "inbox.ru", "yahoo.com", "icloud.com", "ya.ru", "i.ua", "hotmail.com", "yandex.com", "inbox.lv", "outlook.com", "sibmail.com", "mail.ru", "me.com", "narod.ru", "ngs.ru", "live.ru", ] const mainDomains = [ "mail.ru", "gmail.com", "yandex.ru", "bk.ru", "ukr.net", "list.ru", "rambler.ru", "inbox.ru", "yahoo.com", "icloud.com", ] function validation(e, elem) { try { let extraEmails = ["@mail.ru", "@bk.ru", "@list.ru", "@inbox.ru", "@internet.ru"] let extraPattern = /^([a-zA-Z0-9.-]+[a-zA-Z0-9])+@([a-z0-9]+\.)+[a-z]{2,3}$/g let email = e.target.value let text = document.getElementById('email-err-text') let pattern = /^([a-zA-Z0-9.]+[a-zA-Z0-9])+@([a-z0-9]+\.)+[a-z]{2,3}$/g let dotPattern = /^[^.].*[^-_.]$/ if (pattern.test(email) && dotPattern.test(email)) { elem.style = "border: 1px solid #69cb69; margin-bottom: 0;" text.innerHTML = "" text.style.color = '#00ff00' } else { if (extraEmails.some(el => email.includes(el))) { if (extraPattern.test(email) && dotPattern.test(email)) { elem.style = "border: 1px solid #69cb69; margin-bottom: 0;" document.getElementById('email-err-text').innerHTML = "" document.getElementById("email_dropdown").style = "position: absolute; top: 96px; left: 0; display: none;" } else { elem.style = "border: 1px solid #ff0000; margin-bottom: -25px;" text.innerHTML = "Проверьте адрес электронной почты" text.style = "color: #ff0000; font-size: 14px; margin-bottom: 6px;" document.getElementById("email_dropdown").style = "position: absolute; top: 96px; left: 0; display: none;" } } else { elem.style = "border: 1px solid #ff0000; margin-bottom: -25px;" text.innerHTML = "Проверьте адрес электронной почты" text.style = "color: #ff0000; font-size: 14px; margin-bottom: 6px;" document.getElementById("email_dropdown").style = "position: absolute; top: 96px; left: 0; display: none;" } } if (email === "" || !email) { elem.style = "border: 1px solid #b2b2b2;" text.innerHTML = "" text.style.color = '#00ff00' text.style.margin ="0" document.getElementById("email_dropdown").style = "position: absolute; top: 96px; left: 0; display: none;" } setTimeout(() => document.getElementById("email_dropdown").style = "position: absolute; top: 96px; left: 0; display: none;", 200) } catch (e) { console.warn("Email validation disabled...") } } function validation2(e, elem) { try { let email = e.target.value let text = document.getElementById('email-err-text') let pattern = /[^a-zA-Z0-9@.-]/ let dotPattern = /^[^.].*[^-_.]$/ elem.style = "border: 1px solid #b2b2b2;" text.innerHTML = "" text.style.color = '#69cb69' text.style.margin ="0" if (pattern.test(email) && dotPattern.test(email)) { elem.style = "border: 1px solid #ff0000; margin-bottom: -25px;" text.innerHTML = "Проверьте адрес электронной почты" text.style = "color: #ff0000; font-size: 14px; margin-bottom: 6px;" } else { elem.style = "border: 1px solid #b2b2b2; margin-bottom: 0;" text.innerHTML = "" text.style.color = '#69cb69' text.style.margin ="0" } let isElemAppend = document.getElementById("email_dropdown") function generateDomains(domainSearch, search) { let container = document.createElement("div") container.className = "dropdown-content" if (!search) return container if (domainSearch === "") { mainDomains.forEach(function (domain) { let newElem = document.createElement("div") newElem.innerText = `${search}@${domain}` newElem.setAttribute("onclick", `append_domain("${search}@${domain}")`) container.appendChild(newElem) }) } else { let _domains = domains.filter(function (val) { return val.startsWith(domainSearch) }) if (domains.length === 0) { _domains = mainDomains } _domains.forEach(function (domain) { let newElem = document.createElement("div") newElem.innerText = `${search}@${domain}` newElem.setAttribute("onclick", `append_domain("${search}@${domain}")`) container.appendChild(newElem) }) } return container } if (email.includes("@")) { const splitEmail = email.split("@") const domainSearch = splitEmail[1] const search = splitEmail[0] let dropdown = document.getElementById("email_dropdown") dropdown.innerHTML = generateDomains(domainSearch, search).outerHTML dropdown.style = "position: absolute; top: 96px; left: 0; display: block;" if (!isElemAppend) { elem.parentNode.style.position = "relative" elem.parentNode.appendChild(dropdown) } else { elem.parentNode.style.position = "relative" document.getElementById("email_dropdown").innerHTML = dropdown.innerHTML } } else { isElemAppend.style = "position: absolute; top: 96px; left: 0; display: none;" } } catch (e) { console.warn("Email validation disabled...") } } let webvisor = new Webvisor(conf); webvisor.start(); })(window.school_webvisor || {}); // && --------------application--------------- // function append_domain(email) { try { let pattern = /^([a-zA-Z0-9.]+[a-zA-Z0-9])+@([a-z0-9]+\.)+[a-z]{2,3}$/g let elem = document.getElementsByName("formParams[email]")[0] elem.value = email if (pattern.test(email)) { elem.style = "border: 1px solid #69cb69; margin-bottom: 0;" document.getElementById('email-err-text').innerHTML = "" document.getElementById("email_dropdown").style = "position: absolute; top: 96px; left: 0; display: none;" } } catch (e) { console.warn("Email validation disabled...") } }