/* window.onbeforeunload = function() { delete_cookie ('added'); delete_cookie ('visits'); delete_cookie ('added_db'); }; function delete_cookie ( cookie_name ) { var cookie_date = new Date ( ); // Текущая дата и время onbeforeunload cookie_date.setTime ( cookie_date.getTime() - 1 ); document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString(); } function getCookie(byname) // возвращает по имени значение, здесь не используется {byname=byname+"="; nlen = byname.length; fromN = document.cookie.indexOf(byname)+0; if((fromN) != -1) {fromN +=nlen toN=document.cookie.indexOf(";",fromN)+0; if(toN == -1) {toN=document.cookie.length;} return unescape(document.cookie.substring(fromN,toN)); } return null; } function parseCookie() // Разделение cookie { var cookieList = document.cookie.split("; "); // Массив для каждого cookie в cookieList var cookieArray = new Array(); for (var i = 0; i < cookieList.length; i++) { // Разделение пар имя-значение. var name = cookieList[i].split("="); // Декодирование и добавление в cookie-массив. cookieArray[unescape(name[0])] = unescape(name[1]); } return cookieArray; } function setCookie(visits) { console.log('referer='+document.referrer); console.log('location='+window.location.href); var ref = document.referrer.split('/'); var href = window.location.href.split('/'); console.log(getCookie('added')); console.log(((!(href[0] == ref[0] && href[2] == ref[2])) || document.referrer !== '') && getCookie('added') != 1); if (((!(href[0] == ref[0] && href[2] == ref[2])) || document.referrer !== '') && getCookie('added') != 1) { console.log('not same'); document.referrer = window.location.href; // Счетчик числа посещений с указанием даты последнего посещения // и определением срока хранения в 1 год. var expireDate = new Date(); var today = new Date(); // Установка даты истечения срока хранения. expireDate.setDate(365 + expireDate.getDate()); // Сохранение числа посещений. document.cookie = "visits=" + visits + "; expires=" + expireDate.toGMTString() + ";"; document.cookie = "added=" + 1 + "; expires=" + expireDate.toGMTString() + ";"; } } if ("" == document.cookie) { // Инициализация cookie. setCookie(1); } else { var cookies = parseCookie(); setCookie(isNaN(cookies.visits)?1:cookies.visits); } (function() { var XHR = ("onload" in new XMLHttpRequest()) ? XMLHttpRequest : XDomainRequest; var xhr = new XHR(); xhr.open('GET', 'https://chimemail.com/standalone-chat/check-location?id=535&url=' + document.URL.replace(window.location.protocol + "//", ""), true); xhr.onload = function () { if (this.responseText == 'OK') { console.log('chimemail OK'); var text1 = 'Ask Questions Anonymously'; var text2 = 'Resume Your Conversation'; var d = document.createElement('div'); var i = document.createElement('iframe'); i.setAttribute('style', 'z-index: 1000001 !important;border: 0 !important; position: fixed !important;bottom: 50px !important; right: 20px !important; width: 100% !important; max-width:325px !important;min-width: 300px !important;display:block !important;background-color: transparent !important;max-height: 50px !important;margin-bottom: 0px!important;'); i.setAttribute('src', 'https://chimemail.com/standalone-chat/get-btn?id=535&url='+document.URL.replace(window.location.protocol + "//", "")+'&count='+getCookie('visits')+'&added='+getCookie('added')); d.appendChild(i); document.body.appendChild(d); } else if (this.responseText == 'EXEPT-URL') { console.log('chimemail EXEPT-URL'); } }; xhr.onerror = function () { console.log('chimemail error check origin'); }; xhr.send(); }()); */ (function() { if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { console.log('chimemail disabled on mobile devices'); // какой-то код ... } else{ var XHR = ("onload" in new XMLHttpRequest()) ? XMLHttpRequest : XDomainRequest; var xhr = new XHR(); xhr.open('GET', 'https://chimemail.com/standalone-chat/check-location?id=535&url=' + document.URL.replace(window.location.protocol + "//", ""), true); xhr.onload = function () { if (this.responseText == 'OK') { console.log('chimemail OK'); var text1 = 'Ask Questions Anonymously'; var text2 = 'Resume Your Conversation'; var d = document.createElement('div'); var i = document.createElement('iframe'); i.setAttribute('style', 'z-index: 1000001 !important;border: 0 !important; position: fixed !important;bottom: 50px !important; right: 20px !important; width: 100% !important; max-width:325px !important;min-width: 300px !important;display:block !important;background-color: transparent !important;max-height: 50px !important;'); i.setAttribute('src', 'https://chimemail.com/standalone-chat/get-btn?id=535&url='+document.URL.replace(window.location.protocol + "//", "")); d.appendChild(i); document.body.appendChild(d); } else if (this.responseText == 'EXEPT-URL') { console.log('chimemail EXEPT-URL'); } }; xhr.onerror = function () { console.log('chimemail error check origin'); }; xhr.send(); } } ());