if(location.pathname.split('/').slice(0,4).join('/') != '/pl/lite/widget') { gl_catg = location.pathname.split('/').slice(0,4).join('/'); gl_last_catg = location.pathname.split('/').slice(4,6).join('/'); send_gl_post = false; is_channels = true; var getloo_toggle = false; function no_channels() { $("body").append("
Нет активных каналов!
Проверьте подписку на сервис Getloo.ru
"); } function show_gl_frame(type,url) { if(!is_channels) { no_channels(); return false; } getloo_toggle = type; $('.getloo_frame').attr('src',url); $('#gl-widget-cont').fadeOut(800); $('.getloo_back').fadeIn(800); $('.getloo_close_icon').fadeIn(2000); $('.getloo_frame').show(); $('.talks-widget-button').hide(); } function hide_gl_frame() { $('#gl-widget-cont').show(); $('.getloo_back').fadeOut(500); $('.getloo_close_icon').fadeOut(200); $('.getloo_frame').hide(); $('.talks-widget-button').show(); if(getloo_toggle == 'all') { setTimeout(function() { $('.getloo_back').hide(); $('.getloo_close_icon').hide(); $('.getloo_frame').hide(); },1000); } getloo_toggle = false; } function init_GetlooWidget(type,wz_url,getlooArr) { if(type == 'user') { $('.gl_wz_container').hide(); $('.user-phone').append('
'); nbut = getlooArr[2].replace(/\D/g, ""); wa_link = 'https://wa.me/'+nbut; $('.gl_wa_link').attr('href', wa_link); } if(type == 'all') { show_gl_frame(type,wz_url['global']); } send_gl_post = false; } function data_GetlooWidget(type) { if(send_gl_post) { return false; } else { send_gl_post = true; } if(!getloo_toggle) { if(type == 'all') { var getlooArr = [window.accountUserId, false, false, false, false]; } else { var session = jQuery.parseJSON(localStorage.session); if($('div').hasClass('user-manager')) { var res = $('.user-manager').children('b').children('a').attr('href').split('/').pop(); } else { var res = false; } var phone = $('.user-phone').children('span.user-call-to-phone').text(); if(!phone) { phone = $('.user-phone').children('a').attr('href').substring($('.user-phone').children('a').last().attr('href').indexOf('[phone]=')+8); } var getlooArr = [window.accountUserId, $('.user-name').children('b').children('a').attr('href').split('/').pop(), phone, $('.user-name').children('b').children('a').html(), res]; } if(type == 'all' || getlooArr[2]) { console.log(getlooArr); $.post('https://getloo.ru/pixel/wazzup24/post/'+ gl_id+'/', {gc_id: window.accountId, gl_data: getlooArr}, function(wz_url){ if(!wz_url) { is_channels = false; } wz_url = JSON.parse(wz_url); init_GetlooWidget(type,wz_url,getlooArr); }); } } send_gl_post = false; } function check_user_info() { if($('div').hasClass('user-info')) data_GetlooWidget('user'); else setTimeout(function() { check_user_info(); },200); } if(gl_catg == '/user/control/user' || gl_catg == '/sales/control/deal' || (gl_catg == '/pl/tasks/task' && gl_last_catg != 'kanban') || gl_last_catg == 'task-view') { check_user_info(); } $(".gc-user-link, .resp-list, .kanban-card__title").on('click', function(event) { setTimeout(function() { check_user_info(); },100); }); var script = document.createElement('script'); script.src = 'https://cdn.socket.io/4.1.3/socket.io.min.js'; script.defer = true; document.body.appendChild(script); const apiKey = '60f525a8b68d46959c1b114527ac5075'; const userId = window.accountUserId; $('body').append('
'); if(gl_last_catg != 'task-view') { const connectOptions = { path: '/ws-counters/', transports: ['websocket', 'polling'] }; fetch(`https://integrations.wazzup24.com/counters/ws_host/api_v3/${apiKey}`) .then((response) => response.json()) .then((data) => { const { host } = data; const client = io('https://'+host+':443', connectOptions); client.on('connect', () => { client.emit('counterConnecting', { type: 'api_v3', apiKey, userId }); }); client.on('counterConnected', () => console.log('Connected to Wazzup notifications!')); $('#gl-widget-cont').show(); client.on('counterUpdate', (data) => { const { counter } = data; if(counter > 0) { $('#gl_cont_cont').css('visibility', 'visible'); document.getElementById('gl_counter').innerHTML = counter; } else { $('#gl_cont_cont').css('visibility', 'hidden'); document.getElementById('gl_counter').innerHTML = counter; } }); }) .catch((error) => { console.log('Connection error', error); }); if($('.gc-account-leftbar').width() != 70 && $(window).width() > 678) { $('#gl-widget-cont').width($('.gc-account-leftbar').width()); $('.gl-banner').css('left',$('.gc-account-leftbar').width()+15); } } } if(window.userInfo.canCms && new URL(window.location).search.indexOf("iframe=1") < 1) { $('body').append('
'); } if(window.userInfo.isAdmin || window.userInfo.isManager || window.userInfo.isTeacher) { $('body').append(''); if(window.userInfo.isAdmin) { $('body').append(''); } }