PageSourceSearch

https://www.angelsense.com/wp-content/themes/angelsense/js/script.js?v=146.7&ver=146.7

js angelsense.com collected 2026-09-24 10:08:59 UTC 20,305 bytes, 708 lines download raw bytes

1var lateScriptsLoaded = false;
2
3jQuery(document).ready(function(){
4	if (!sessionStorage.getItem('landingPageViewed')) {
5		sessionStorage.setItem('landingPageViewed', 'true');
6		window.dataLayer = window.dataLayer || [];
7		window.dataLayer.push({
8			event: 'first_landing_page'
9		});
10		console.log("First Landing Page Data Layer Fired");
11	}
12	const stickyOffer = document.getElementById('sticky-offer');
13
14	jQuery('section.header div.action.holiday').on('click', function() {
15		window.location = '/pricing/';
16	});
17
18	if(!isMobile.any() && stickyOffer) {
19        if(!sessionStorage.getItem('sticky-offer')) {
20            jQuery('#sticky-offer').addClass('show');
21        } else {
22			jQuery('body').removeClass('strip');
23		}
24		window.addEventListener('scroll', () => {
25			if (window.scrollY < 100) {
26				stickyOffer.classList.remove('sticky-scrolled');
27			} else {
28				stickyOffer.classList.add('sticky-scrolled');
29			}
30		});
31	}
32
33	/*AAM Free Device Note Event Handler*/
34	if(isMobile.any()) {
35		if(sessionStorage.getItem('sticky-offer')) {
36			jQuery('#sticky-offer').removeClass('show');
37			jQuery('body').removeClass('strip');
38		} else {
39			setTimeout(function() {
40                jQuery('#sticky-offer').addClass('show');
41            }, 1000);
42		}
43	}
44
45	jQuery('#sticky-offer a.remove-offer').on('click', function() {
46		eventTracking && eventTracking.TrackEventLog('Sticky Free Device Banner Removed');
47		sessionStorage.setItem('sticky-offer', true);
48		jQuery('#sticky-offer').removeClass('show');
49		jQuery('body').removeClass('strip');
50	})
51
52	/*Control Header Pricing page to redirect to watch pricing page*/
53	jQuery('.menu-order-now').on('click', function(e) {
54		if( jQuery('body').hasClass('gps-tracker-watch') ||
55			jQuery('body').hasClass('elderly-watch') ||
56			jQuery('body').hasClass('teens-and-adults') ||
57			(jQuery('body').hasClass('gps-tracker-for-elderly')))
58		{
59			e.preventDefault();
60			window.location.href = '/pricing/?device=watch';
61		}
62	});
63
64	if(jQuery("body").hasClass("es")) {
65		jQuery("header a[href='/pricing/']").on("click", function(e) {
66			e.preventDefault();
67			window.location.href = '/es/pricing/';
68		});
69	}
70
71	jQuery('#sticky-offer a.text').on('click', function() {
72		eventTracking.TrackEventLog('Sticky Free Device Banner Clicked');
73	});
74
75	window.addEventListener("klaviyoForms", function(e) {
76		if (e.detail.type == 'submit') {
77			jQuery.ajax({
78				url: '/wp-admin/admin-ajax.php',
79				type:   'post',
80				data: {
81					"action": "subscribe_lead_automation",
82					"email": e.detail.metaData.$email,
83					"tag": e.detail.metaData.$source,
84                    "promo": "on"
85				},
86				async: true
87			}).done (function (response) {
88				console.log(response)
89				if(window.dataLayer) {
90					dataLayer.push({
91						'event': 'popupConversion',
92						'popupConversionName': e.detail.metaData.$source
93					});
94				}
95			});
96		}
97	});
98
99	window.addEventListener("klaviyoForms", function(e) {
100		if (e.detail.type == 'open') {
101			if(isMobile.any()) {
102				jQuery("header.mobile div.top").css("z-index", 1);
103				jQuery("#sticky-offer").hide();
104			} else {
105				jQuery("#sticky-offer").hide();
106				jQuery("body").removeClass("strip");
107			}
108		}
109	});
110
111	window.addEventListener("klaviyoForms", function(e) {
112		if (e.detail.type == 'close') {
113			if(isMobile.any()) {
114				jQuery("header.mobile div.top").css("z-index", 1000000);
115				jQuery("#sticky-offer").show();
116			} else {
117				jQuery("#sticky-offer").show();
118				jQuery("body").addClass("strip");
119			}
120		}
121	});
122
123	function getUrlVars()
124	{
125		var vars = [], hash;
126		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
127		for(var i = 0; i < hashes.length; i++)
128		{
129			hash = hashes[i].split('=');
130			vars.push(hash[0]);
131			vars[hash[0]] = hash[1];
132		}
133		return vars;
134	}
135
136	/*Add Coupon Cookie if long checkout coupon*/
137	if(getUrlVars().source == 'coupon-signup-long' || getUrlVars().source == 'coupon-signup-long-elderly') {
138		angelsense_setCookie('angelsense_twenty_coupon', true, 10);
139	}
140
141	if(getUrlVars().upgrade && window.location.href.indexOf("checkout") > 0) {
142		jQuery('body').addClass('upgrade');
143	}
144
145	// Important! Set Amplitude Session ID in cookie
146	amplitude.getInstance().onInit(function(){
147		setTimeout(function(){
148			var sessionId = amplitude.getInstance()._sessionId;
149			angelsense_setCookie('angelsense_mpdi', sessionId, 365);
150		}, 1000);
151	});
152
153
154	function experimentVersionLoaded () {
155		if(angelsense_getCookie('angelsense_testing_version') !== '') {
156			eventTracking.TrackEventLog('Experiment Version Loaded', {
157				'testVersion': angelsense_getCookie('angelsense_testing_version')
158			})
159		}
160	}
161
162    if (window.location.href.indexOf("checkout") < 0){
163    	new LazyLoad();
164    }
165
166    jQuery('section.model #cta a.info').on('click', function() {
167    	jQuery(this).toggleClass('show');
168	});
169
170	jQuery(document).mouseup(function(e)
171	{
172		var container = jQuery("section.model #cta a.info");
173
174		// if the target of the click isn't the container nor a descendant of the container
175		if (!container.is(e.target) && container.has(e.target).length === 0)
176		{
177			container.removeClass('show');
178		}
179	});
180
181	jQuery(document).mouseup(function(e) {
182		var container = jQuery("div#blog_popup div.content");
183
184		// if the target of the click isn't the container nor a descendant of the container
185		if (!container.is(e.target) && container.has(e.target).length === 0)
186		{
187			container.parent().removeClass('open');
188		}
189	});
190
191	jQuery(document).mouseup(function(e) {
192		var container = jQuery("div#popup div.content");
193
194		// if the target of the click isn't the container nor a descendant of the container
195		if (!container.is(e.target) && container.has(e.target).length === 0)
196		{
197			container.parent().removeClass('open');
198		}
199	});
200
201	jQuery(document).mouseup(function(e) {
202		var container = jQuery("#elderly-popup div.content");
203
204		// if the target of the click isn't the container nor a descendant of the container
205		if (!container.is(e.target) && container.has(e.target).length === 0)
206		{
207			container.parent().removeClass('open');
208		}
209	});
210
211	jQuery(document).mouseup(function(e) {
212		var container = jQuery("#teens-popup div.content");
213
214		// if the target of the click isn't the container nor a descendant of the container
215		if (!container.is(e.target) && container.has(e.target).length === 0)
216		{
217			container.parent().removeClass('open');
218		}
219	});
220
221	jQuery(document).mouseup(function(e) {
222		var container = jQuery("div#gps-popup div.content");
223
224		// if the target of the click isn't the container nor a descendant of the container
225		if (!container.is(e.target) && container.has(e.target).length === 0)
226		{
227			container.parent().removeClass('open');
228		}
229	});
230
231
232	jQuery(document).mouseup(function(e) {
233		var container = jQuery("#pricing-dialer");
234
235		// if the target of the click isn't the container nor a descendant of the container
236		if (!container.is(e.target) && container.has(e.target).length === 0)
237		{
238
239			if(jQuery('body').hasClass('working-hours') && jQuery("#pricing-dialer").hasClass('open')) {
240				container.removeClass('open');
241				eventTracking.TrackEventLog('Dialer Popup Closed');
242				jQuery('#sticky-dialer-minimized').addClass('open');
243			}
244		}
245	});
246
247	if(
248		(window.location.href.indexOf("checkout") < 1)
249		&& (window.location.pathname != "/pricing/")
250		&& (window.location.href.indexOf("success") < 1)
251		&& (!sessionStorage.getItem('strip'))) {
252		jQuery('div#strip').addClass('show');
253	} else {
254		jQuery('div#strip').removeClass('show');
255		jQuery('body').removeClass('strip');
256	}
257
258	jQuery('div#strip a.guarantee').on('click', function() {
259		jQuery(this).toggleClass('show');
260	});
261
262	jQuery('div#strip a.remove').on('click', function() {
263		jQuery('div#strip').removeClass('show');
264		jQuery('body').removeClass('strip');
265	});
266
267	jQuery('div#strip a.action').on('click', function() {
268		eventTracking.TrackEventLog('Strip Cta Clicked');
269	});
270
271	jQuery('div#strip a.remove').on('click', function() {
272		eventTracking.TrackEventLog('Strip Cta Removed');
273	});
274
275	jQuery('#safety-cta').on('click', function() {
276		eventTracking.TrackEventLog('HP School Safety Cta Clicked');
277	});
278
279
280    /* Press */
281    jQuery('.media-coverage-item').each(function(){
282        var target_url = jQuery(this).find('a').attr('href');
283        jQuery(this).attr('data-link', target_url);
284    });
285
286    jQuery( ".media-coverage-item" ).click( function () {
287        var url = "";
288        url = jQuery( this ).attr( "data-link" );
289        if ( url !== '' ) {
290            window.open( url );
291            return false;
292        }
293    } );
294
295	/*signup form generic */
296	jQuery("#promo").on("change", function() {
297		let submitButton = jQuery(this).closest("#footer-signup").find('input[type="submit"]');
298		if (jQuery(this).is(":checked")) {
299			submitButton.attr("disabled", false);
300		} else {
301			submitButton.attr("disabled", true);
302		}
303	});
304
305});
306
307function angelsenseCreateLead(formfields) {
308	console.log('Create Lead',formfields+'&action=' + 'send_lead');
309	jQuery.ajax({
310		type: "POST",
311		url: '/wp-admin/admin-ajax.php',
312		data: formfields+'&action=' + 'send_lead',
313		async: false,
314		success: function(response) {
315			console.log(response);
316		},
317		error: function(error) {
318			console.log('err',error)
319		}
320	});
321}
322
323function active_campaign_create_lead(formfields, callback) {
324	console.log(formfields+'&action=' + 'subscribe_lead_automation');
325	jQuery.ajax({
326		type: "POST",
327		url: '/wp-admin/admin-ajax.php',
328		data: formfields+'&action=' + 'subscribe_lead_automation',
329		async: true,
330		success: function(response) {
331			console.log(response);
332			if (typeof callback === 'function') {
333				callback();
334			}
335		},
336		error: function(error) {
337			console.log('err',error);
338		}
339	});
340}
341
342
343
344/* Getting Querystring Value */
345function angelsense_qs(key) {
346    key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
347    var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
348    return match && decodeURIComponent(match[1].replace(/\+/g, " "));
349}
350
351function angelsense_dynamic_param_replace(param, el_selector){
352    var param_value = angelsense_qs(param);
353    if  (param_value !== null){
354        var button_anchor = jQuery(el_selector);
355        var button_anchor_href = button_anchor.attr('href');
356        button_anchor.attr('href',  button_anchor_href + '?'+param+'='+param_value );
357    }
358}
359
360function angelsense_quick_dynamic_param_replace(param, el_selector, param_value){
361    var button_anchor = jQuery(el_selector);
362    var button_anchor_href = button_anchor.attr('href');
363    button_anchor.attr('href',  button_anchor_href + '?'+param+'='+param_value );
364}
365
366
367function angelsense_iaf_quick_coupon_replace(el_selector, param_value){
368    var coupon_el = jQuery(el_selector);
369    coupon_el.text( param_value );
370}
371
372// LP Comparison
373jQuery(document).ready(function (){
374	// active for mobiles (for retina bgs) & zoom out desktop
375	if ( (jQuery(window).width() < 768 || (jQuery(window).width() > 768 && window.devicePixelRatio < 1))
376		&& jQuery('body').hasClass('page-template-template-lpcomparsion')) {
377
378		console.log('LP comparison backgrounds size adjust activated');
379		var list = [
380			'.nav-section-wrapper',
381			'.timeline-section',
382			'.location-first-row-quote',
383			'.location-second-row',
384			'.listenin-section',
385			'.missing-section',
386			'.missing-quote-row',
387			'.late-section',
388			'.cellular-section',
389			'.support-section',
390			'.location-last-quote-row', //mobile
391			'.cellular-img', //mobile
392		];
393
394		function refreshBGsize() {
395			jQuery.each(list, function (index, value) {
396				var bg = jQuery(value).css('background');
397				var url = /url\(\s*(['"]?)(.*?)\1\s*\)/g.exec(bg);
398				if (!url) return;
399				url = url[2];
400
401				jQuery('<img/>').attr('src', url).load(function() {
402
403					var newheight = (this.height / this.width) * jQuery(window).width();
404
405					if (value == '.location-section' && jQuery(window).width() < 768) {
406						newheight = newheight + (newheight * 0.4);
407					}
408					if (value == '.cellular-section' && jQuery(window).width() < 768) {
409						jQuery(value).css('height', newheight);
410					}
411
412					jQuery(value).css('min-height', newheight);
413
414					jQuery(this).remove(); // prevent memory leaks
415
416				});
417			});
418
419			if(jQuery(window).width() > 768 && window.devicePixelRatio < 1) {
420				var missingratio = 0.2636789;
421				var missingratio2 = 0.1515625;
422				var missingheight = (missingratio * jQuery(window).width()) + (missingratio2 * jQuery(window).width());
423				jQuery('.missing-section').css('min-height', missingheight);
424
425			}
426
427		}
428
429		refreshBGsize();
430		jQuery(window).resize(function() {
431			refreshBGsize();
432		});
433
434	}
435
436	if ( jQuery(window).width() < 768 && jQuery('body').hasClass('page-template-template-lpcomparsion') ) {
437
438		function sticky_comparison() {
439			var window_top = jQuery(window).scrollTop();
440			var comparison_title = jQuery('#m-comparison .comparison-first-row');
441			var comparison_title_height = jQuery('#m-comparison .comparison-first-row').outerHeight();
442			var comparison_title_anchor = jQuery('#m-comparison .comparison-sticky-anchor');
443			var comparison_late_row = jQuery('#m-comparison .comparison-late').parent();
444
445			if (window_top >= (comparison_title_anchor.offset().top - 72) ) {
446				comparison_title.addClass('sticky');
447				comparison_title_anchor.height(comparison_title_height);
448
449				if ( window_top >= ( comparison_late_row.offset().top - 72 ) ) {
450					comparison_title.addClass('freeze');
451					comparison_title.css("top", jQuery('#m-comparison .comparison-late').parent().position().top);
452				} else {
453					comparison_title.removeClass('freeze');
454					comparison_title.css("top", '');
455				}
456
457			} else {
458				comparison_title.removeClass('sticky');
459				comparison_title_anchor.height(0);
460			}
461		}
462
463		jQuery(window).scroll(function() {
464			sticky_comparison();
465		});
466		sticky_comparison();
467
468	}
469
470	// fix menu link for tablets
471	if ( jQuery(window).width() >= 768 && jQuery('body').hasClass('page-template-template-lpcomparsion') ) {
472		jQuery('ul#menu-lp-comparison-mobile li a[href="#m-comparison"]').attr('href', '#comparison');
473	}
474
475});
476
477// Comparison mobile menu links click event
478
479jQuery('#menu-lp-comparison-mobile ul.sub-menu a').on('click', function() {
480	jQuery('nav.menu').toggleClass('open');
481	jQuery('div.overlay').toggleClass('open');
482});
483
484
485// Detecting mobile devices
486var isMobile = {
487    Android: function() {
488        return navigator.userAgent.match(/Android/i);
489    },
490    BlackBerry: function() {
491        return navigator.userAgent.match(/BlackBerry/i);
492    },
493    iOS: function() {
494        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
495    },
496    Opera: function() {
497        return navigator.userAgent.match(/Opera Mini/i);
498    },
499    Windows: function() {
500        return navigator.userAgent.match(/IEMobile/i);
501    },
502    any: function() {
503        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
504    }
505};
506
507
508// Signup footer form
509jQuery('#footer-signup').on('submit', function(event) {
510	event.preventDefault();
511	var form = jQuery(this);
512	var submitButton = jQuery(this).find('input[type="submit"]');
513	var responseElement = jQuery(this).find('div.response');
514	var loader = jQuery(this).find('.lds-css.form');
515	submitButton.attr('disabled', 'disabled');
516	loader.addClass('show');
517
518	var ajax_form_data = jQuery(this).serialize();
519
520	ajax_form_data = ajax_form_data + '&' + tag + '=' + 'on';
521	console.log(ajax_form_data);
522	jQuery.ajax({
523		url: '/wp-admin/admin-ajax.php',
524		type: 'post',
525		data: ajax_form_data,
526		async: true,
527	}).done(function (response) {
528		var responseObject = JSON.parse(response);
529		console.log(responseObject.result);
530		loader.removeClass('show');
531		if (responseObject.result == 1) {
532			responseElement.html("Thank you.You're on the newsletter list!");
533			form.addClass('success');
534			eventTracking.TrackEventLog('Newsletter Signed', {
535				'email': jQuery('#email-signup').val(),
536			});
537			/*Testing Custom Event Tracking Datalayer GA4*/
538			dataLayer.push({
539				'event': 'form_submission',
540				'source': 'footer_newsletter_signup'
541			});
542		} else {
543			submitButton.removeAttr('disabled');
544			form.addClass('error');
545			responseElement.html("Please enter a valid e-mail address!");
546		}
547	});
548});
549
550// Clear mailchimp response on email field focus event
551jQuery('#footer-signup #email').on('focus', function() {
552	jQuery('div.response').text(' ');
553});
554
555// function for displaying sticky mobile on user scroll
556var is_bottom = false;
557jQuery(window).ready(function() {
558
559	jQuery('div.sticky_expand.open a.close ').on('click', function(event) {
560		jQuery('div.sticky_expand').hide();
561		setTimeout(function() {
562			jQuery('footer.delay_show a.sticky_banner').addClass('open');
563		}, 1000);
564	});
565});
566
567// Function for showing mobile menu
568jQuery(document).ready(function() {
569	var start_scroll = null;
570	var end_scroll = null;
571	var event_start;
572	var event_end;
573	var duration;
574	var currentUrl = window.location.pathname;
575	if(jQuery('header.mobile a.menu') && currentUrl != '/pricing/' && currentUrl != '/checkout/') {
576		jQuery('header.mobile a.menu').on('click', function(event) {
577			event.preventDefault();
578			jQuery(this).toggleClass('open');
579			jQuery('nav.menu').toggleClass('open');
580			jQuery('div.overlay').toggleClass('open');
581		});
582
583		jQuery('li.menu-item-has-children').on('click', function() {
584			jQuery(this).toggleClass('show');
585		});
586	}
587});
588
589document.addEventListener('DOMContentLoaded', function () {
590	if (isMobile.any()) {
591		var swipeElement = document.querySelector('nav.menu');
592
593		// Check if Hammer is defined
594		if (typeof Hammer !== 'undefined') {
595			var hammer = new Hammer(swipeElement);
596
597			hammer.on('swiperight', function () {
598				jQuery("header.mobile a.menu").removeClass("open");
599				jQuery("nav.menu").removeClass("open");
600				jQuery("div.overlay").removeClass("open");
601			});
602		} else {
603			console.error("Hammer.js is not defined. Please ensure it is loaded correctly.");
604		}
605	}
606});
607
608
609jQuery('header.mobile div.overlay').on('click', function() {
610	jQuery('nav.menu').removeClass('open');
611	jQuery('header.mobile a.menu').removeClass('open');
612	jQuery('div.overlay').removeClass('open');
613});
614
615jQuery('body').on('click', 'a.chat', function(e){
616	jQuery('#chatRequest').removeClass('hide');
617	jQuery('#chat_popup').removeClass('show');
618});
619
620function current_page_is(slug){
621    return window.location.href.indexOf(slug) > -1;
622}
623
624function angelsense_getCookie(cname) {
625	var name = cname + "=";
626	var ca = document.cookie.split(';');
627	for(var i=0; i<ca.length; i++) {
628		var c = ca[i];
629		while (c.charAt(0)==' ') c = c.substring(1);
630		if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
631	}
632	return "";
633}
634
635
636function angelsense_setCookie(cname, cvalue, exdays) {
637	var d = new Date();
638	d.setTime(d.getTime() + (exdays*24*60*60*1000));
639	var expires = "expires="+ d.toUTCString();
640	document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
641	//console.log(cname+' cookie set');
642}
643
644function angelsense_deleteCookie(cname){
645	document.cookie = cname+'=; Max-Age=0; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT; domain=' + location.host;
646	//document.cookie = cname + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
647}
648
649
650if (angelsense_qs('supporthelp')){
651	angelsense_setCookie('angelsense_support_help', true, 365);
652}
653
654function getUrlParameter(sParam) {
655	var sPageURL = window.location.search.substring(1),
656		sURLVariables = sPageURL.split('&'),
657		sParameterName,
658		i;
659
660	for (i = 0; i < sURLVariables.length; i++) {
661		sParameterName = sURLVariables[i].split('=');
662
663		if (sParameterName[0] === sParam) {
664			return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
665		}
666	}
667}
668
669function inIframe () {
670	try {
671		return window.self !== window.top;
672	} catch (e) {
673		return true;
674	}
675}
676
677jQuery(document).ready(function(){
678
679	if (angelsense_getCookie('angelsense_in_app_signup') !== ""){
680		if (!inIframe()) {
681			jQuery.ajax({
682				url: '/wp-admin/admin-ajax.php',
683				type: 'post',
684				data: {action: 'delete_in_app_cookie'},
685				async: true,
686			}).done(function (response) {
687				if (response === 'ok') {
688					document.location.reload();
689				}
690			});
691		}
692	}
693});
694
695function emptyString(str) {
696	return !str;
697}
698
699function getCurrencySymbol(currencyCode) {
700	const currencySymbols = {
701		"USD": "$",
702		"CAD": "$",
703		"GBP": "£",
704		"EUR": "€"
705	};
706
707	return currencySymbols[currencyCode] || currencyCode; // Default to currency code if symbol not found
708}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.