if (typeof $ === 'undefined') { window.$ = function(selector) { console.log(selector); var match = document.querySelectorAll(selector); console.log(match); return { val: function() { console.log('inner', match); return null; return match ? match[0].value : null; } } } } _NextpedrionApp = function() { var HOST = 'www.expedrion.neustar'; var lastSearch = ''; var siteKey = 0; function ownItWorkaround(siteKey, pageRef, tagUrl, availability) { setTimeout(function() { kwd = document.querySelector('#domain').value; var url = tagUrl('search/?'+utmParams()+'&s='+siteKey+'&t='+encodeURIComponent(kwd)+'&pageRef='+pageRef + '&availability='+availability); var img = new Image(); img.src = url; lastSearch = kwd; }, 1000); } function utmParams() { if(!window.location.search) return ''; return window.location.search.substring(1); } function requestMethod() { return document.location.protocol; } function tagUrl(suffix) { var url = requestMethod()+'//'+HOST; return url + '/tag/' + suffix; } var publicInterface = {}; publicInterface.setSite = function ss(newSiteKey) { siteKey = newSiteKey; } publicInterface.trackSearch = function ts(kwd,pageRef, availability) { if (siteKey == 0) throw 'trackSearch() requires a site key be set'; ownItWorkaround(siteKey, pageRef, tagUrl, availability); return; var url = tagUrl('search/?'+utmParams()+'&s='+siteKey+'&t='+encodeURIComponent(kwd)); var img = new Image(); img.src = url; lastSearch = kwd; } publicInterface.bindEvents = function be(sel) { if (siteKey == 0) throw 'trackSearch() requires a site key be set'; setTimeout(function() { var i, el, elems = document.querySelectorAll(sel); for (i = 0; i < elems.length; i++) { el = elems[i]; // avoid double tagging the same link if (!el.href.match(/tag\/click/)) { var ls = encodeURIComponent(lastSearch); var u = encodeURIComponent(el.href); el.setAttribute('href', tagUrl('click/?'+utmParams()+'&s='+siteKey+'&t='+ls+'&u='+u)); } } }, 1000); } return publicInterface; } window._Nextpedrion = window._Nextpedrion || _NextpedrionApp();