"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* eslint-disable no-undef */ function hrslBuildDom(target) { if (target.id) { return '@' + target.id; } if (target.tagName.toLowerCase() !== 'body') { return hrslBuildDom(target.parentNode) + ' > ' + target.tagName.toLowerCase() + '[' + hrslGetSiblingPosition(target, target.tagName) + ']'; } return 'body'; } function hrslGetSiblingPosition(target, nameToSearch) { var p = target.previousSibling; if (!p) { return 0; } else if (p.tagName === nameToSearch) { return 1 + hrslGetSiblingPosition(p, nameToSearch); } return hrslGetSiblingPosition(p, nameToSearch); } function hrslSendAction(json) { var xhr = new XMLHttpRequest(); xhr.withCredentials = true; var params = []; Object.keys(json).forEach(function (k) { var v = json[k]; params.push(k + '=' + encodeURIComponent(v)); }); xhr.open('POST', '//m.homerez.com/event'); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.send(params.join('&')); } function hrslSendScope(ownerId, propertyId, inquiryId, isInternal) { var xhr = new XMLHttpRequest(); xhr.withCredentials = true; var params = []; if (ownerId) { params.push('ownerId=' + ownerId); } if (propertyId) { params.push('propertyId=' + propertyId); } if (inquiryId) { params.push('inquiryId=' + inquiryId); } if (isInternal) { params.push('isInternal=' + true); } xhr.open('POST', '//m.homerez.com/whoiam?' + params.join('&')); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.send(params.join('&')); } function hrsl(mode, action, data, ownerId, propertyId, inquiryId) { var params = { action, data: data || null, ownerId: ownerId || null, propertyId: propertyId || null, inquiryId: inquiryId || null, }; if (mode === 'manual' || mode === 'all') { hrslSendAction(params); } if (mode === 'auto' || mode === 'pageview' || mode === 'singlepage_pageview' || mode === 'all') { params.action = 'page.view'; params.data = window.location.href; params.referer = document.referrer; hrslSendAction(params); var currentURL = window.location.href; if (mode === 'singlepage_pageview' || mode === 'auto') { setInterval(function () { if (window.location.href !== currentURL) { params.referer = currentURL; currentURL = window.location.href; params.action = 'page.view'; params.data = currentURL; hrslSendAction(params); } }, 1000); } } if (mode === 'auto' || mode === 'pageclick' || mode === 'all') { document.addEventListener('click', function (event) { params.action = 'document.click'; params.data = hrslBuildDom(event.target); hrslSendAction(params); }); } } hrsl('', '', '', '', '', '');