101document.addEventListener('msvisibilitychange', function () {102(document.msHidden ? unfocused : focused)();103});104}105// IE 9 and lower:106if ('onfocusin' in document) {107document.onfocusin = focused;108document.onfocusout = unfocused;109}110// All others:111window.onpageshow = window.onfocus = focused;112window.onpagehide = window.onblur = unfocused;
// } } function t_stat__trackScrollEvent() { var topPosition = window.pageYOffset; var windowHeight = window.innerHeight; var documentHeight = Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight ); var headerHeight = 0; var footerHeight = 0; isWindowActive = true; var headerBlock = document.getElementById('t-header'); var footerBlock = document.getElementById('t-footer'); var tildaCopy = document.getElementById('tildacopy'); if (headerBlock) { headerHeight = headerBlock.offsetHeight; } if (footerBlock) { footerHeight = footerBlock.offsetHeight; } if (tildaCopy) { footerHeight += tildaCopy.offsetHeight; } var userScreenPositon = Math.floor( ((topPosition - headerHeight + windowHeight) * 100) / (documentHeight - headerHeight - footerHeight) ); if (userScreenPositon < 10) return; var breakpoints = [10, 25, 50, 75, 90]; for (var i = 0; i < breakpoints.length; i++) { var currentPoint = breakpoints[i]; var lastPointIndex = breakpoints.length - 1; if (i === 0 && userScreenPositon >= currentPoint && !isSendScrollEvent['p' + currentPoint]) { statParams.page = '/tilda/scroll/' + currentPoint + '/'; window.tildastat('pageview'); isSendScrollEvent['p' + currentPoint] = true; } else if (userScreenPositon >= currentPoint - 1) { if (isSendScrollEvent['p' + currentPoint] === 0) { statParams.page = '/tilda/scroll/' + currentPoint + '/'; window.tildastat('pageview'); isSendScrollEvent['p' + currentPoint] = setTimeout(function () { clearTimeout(isSendScrollEvent['p' + currentPoint]); isSendScrollEvent['p' + currentPoint] = -1; }, 5000); break; } else if ( ((i !== lastPointIndex && userScreenPositon < breakpoints[i + 1]) || i === lastPointIndex) && isSendScrollEvent['p' + currentPoint] === -1 ) { isSendScrollEvent['p' + currentPoint] = 0; break; } } } } function t_stat__getPageURL() { var hostName = window.location.hostname.indexOf('www.') === 0 ? window.location.hostname.slice(4) : window.location.hostname; if (hostName.lastIndexOf('.') === hostName.length - 1) { hostName = hostName.slice(0, -1); } return hostName + window.location.pathname; } function t_stat__makeHash(str) { var range = Array(str.length); for (var i = 0; i < str.length; i++) { range[i] = i; } return Array.prototype.map .call(range, function (i) { return str.charCodeAt(i).toString(16); }) .join('');