var validNavigation = false; var survey_showed = false; var disabledConfirm_exit = false; function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var ca = document.cookie.split(';'); var nameEQ = name + "="; for(var i=0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } var isActive = '0'; var isPopup = 0;//readCookie('conversiepopup125'); var count_visited = 0;//readCookie('conversie125_counter'); if( count_visited == 0 || count_visited == null) { if( isPopup != '1' && isActive == '1') { var url = 'https://conversietools.be//js/jquery.js'; var head = document.getElementsByTagName('head')[0]; if(!window.jQuery) { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = url; //script.onreadystatechange = callback; script.onload = callback; head.appendChild(script); } else { callback(); } var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'https://conversietools.be//css/style_embed_hellobar.css'; link.media = 'all'; head.appendChild(link); } } function embedValidNavigation() { // Attach the event keypress to exclude the F5 refresh jQuery('document').bind('keypress', function(e) { if (e.keyCode == 116){ validNavigation = true; } }); // Attach the event click for all links in the page jQuery("a").bind("click", function() { validNavigation = true; }); // Attach the event submit for all forms in the page jQuery("form").bind("submit", function() { validNavigation = true; }); // Attach the event click for all inputs in the page jQuery("input[type=submit]").bind("click", function() { validNavigation = true; }); } function callback() { embedValidNavigation(); var timeframe = 30 * 24 * 60 * 60 * 1000; var count_visited = readCookie('conversie125_counter'); if( count_visited == 'null' || count_visited == null) { count_visited = 1; } window.onbeforeunload = function(e) { if( validNavigation == false) { count_visited++; } createCookie('conversie125_counter', count_visited ,365); } var conversie_lasttime = readCookie('conversie125_lasttime'); var visitor_type = 'new'; var visitor_from = 'all'; var when_appear = 'timer'; var where_appear = 'all'; var current_page = window.location.href.toLowerCase(); var time_fromlast = 0; switch(where_appear) { case 'home': var location = window.location.href; if( location.lastIndexOf('/') < 10) { opensurvey_lightbox(); return; } break; case 'specific': if( where_appear.toLowerCase().indexOf(current_page) > 0) { opensurvey_lightbox(); return; } break; case 'all': opensurvey_lightbox(); return; break; } if( conversie_lasttime == 'null' || conversie_lasttime == null || count_visited < 2) { createCookie('conversie125_lasttime', new Date().getTime() ,365); createCookie('conversie125_counter', 1 ,365); if( visitor_type == 'return') return; } time_fromlast = new Date().getTime() - conversie_lasttime; var current_visitor_type = 'new'; if( time_fromlast < timeframe) current_visitor_type = 'return'; createCookie('conversie125_lasttime', new Date().getTime() ,365); current_visitor_type = visitor_type; if( current_visitor_type != visitor_type) { return; } var referer = document.referrer; var current_visitor_from = referer; if( referer.indexOf('facebook') > -1) current_visitor_from = 'facebook'; if( referer.indexOf('twitter') > -1) current_visitor_from = 'twitter'; if( referer.indexOf('utm') > -1) current_visitor_from = 'google_organic'; if( referer.indexOf('adword') > -1) current_visitor_from = 'adword'; visitor_from = ''; var passport = 0; if(sessionStorage.visitor_from) passport = 1; if( window.location.href == visitor_from) passport = 1; if( current_visitor_from != visitor_from && passport == 0) return; else if( passport == 0) { sessionStorage.visitor_from = visitor_from; passport = 1; } if( passport == 0) return; switch(when_appear) { case 'enter': opensurvey_lightbox(); break; case 'leave': var isLeave = 0; if( isLeave == 1) { window.onbeforeunload = function(e) { if (e.keyCode == 116) disabledConfirm_exit = true; if(disabledConfirm_exit) return; if(!e) e = window.event; disabledConfirm_exit = true; e.cancelBubble = true; e.returnValue = 'Would you like fill the survey before leave. Click "Stay on Page" or "Don\'t reload" to enter survey information'; if (e.stopPropagation) { e.stopPropagation(); e.preventDefault(); } window.setTimeout(function() { opensurvey_lightbox(); }, 3000); return 'Please fill the survey before leave. Click "Stay on Page" or "Don\'t reload" to enter survey information'; } } break; case 'timer': var timeout = 5; timeout *= 1000; window.setTimeout(opensurvey_lightbox, timeout); break; case 'pages': var totalPageVisited = readCookie('conversiepopup125_totalvisited'); if( totalPageVisited == null) totalPageVisited = 0; totalPageVisited++; createCookie('conversiepopup125_totalvisited', totalPageVisited ,365); var countPages = 0; if( totalPageVisited == countPages) { opensurvey_lightbox(); } break; default: opensurvey_lightbox(); break; } }; function opensurvey_lightbox() { if( !survey_showed) { var lightbox_url = 'https://conversietools.be//popup/jsHeaderSliderContent/125&callback=?'; jQuery.ajax({ url: lightbox_url, dataType: 'jsonp', crossDomain: true, success: function(data) { jQuery('.conversieToolInfo').html(data[0]); jQuery.getScript('https://conversietools.be//js/embed_headerslider.js'); } }); survey_showed = true; } }