PageSourceSearch

https://amenzing.com/wp-content/themes/jawn/js/alp.js?ver=7.1.2

js amenzing.com collected 2026-10-02 10:52:37 UTC 4,070 bytes, 158 lines download raw bytes

1//jQuery(document).ready(function($) {
2jQuery(window).on('load', function() {
3	var $ = jQuery;
4	var nextPostFlag = false;
5
6	if(!$('body').hasClass('single-post'))
7		return;
8
9	if($('article').eq(0).length)
10		$('article').eq(0).addClass('first');
11
12	createStickyWidgetArea();
13
14	var $nextPost = $('.alp-related-post').eq(1);
15	if($nextPost.length)
16		$nextPost.addClass('load-next');
17
18	createLastArticleWaypoint();
19
20	$(window).on('scroll', findCurrentArticle);
21	$(window).on('resize', findCurrentArticle);
22	$(window).trigger('resize');
23
24	function loadRelatedPosts()
25	{
26		if(nextPostFlag)
27			return;
28
29		$nextPost = $('.alp-related-posts .alp-related-post.load-next');
30		if(!$nextPost.length)
31			return;
32
33		//get next article
34		nextPostFlag = true;
35		$.get($nextPost.find('.post-title').attr('href'), {}, function(data) {
36			var postTitle=$(data).filter('title').text();
37			$nextPost.attr('data-document-title', postTitle);
38			var $newArticle = $(data).find('article');
39			if(!$newArticle.length)
40				return;
41
42			if($('article#' + $newArticle.attr('id')).length)
43				return;
44
45			$('article:last-of-type').after($newArticle);
46
47			Waypoint.destroyAll();
48			$('.alp-related-post').removeClass('load-next');
49
50			if($nextPost.next().length)
51				$nextPost.next().addClass('load-next');
52
53			$('article img').load(function() {
54				createLastArticleWaypoint();
55				$(window).trigger('resize');
56				nextPostFlag = false;
57			});
58		}, 'html');
59	}
60
61	function createStickyWidgetArea()
62	{
63		if(!$('.widget_alp-related-posts').length)
64			return;
65		$('.widget_alp-related-posts').stick_in_parent({
66			offset_top: 100,
67			recalc_every: 1,
68			bottoming: true
69		});
70	}
71
72	function findCurrentArticle()
73	{
74		var windowTop = $(window).scrollTop();
75		var windowHeight = $(window).height();
76		var windowBottom = windowTop+windowHeight;
77		var post_title_selector = '.mvp-post-title';
78
79		var $article,
80			articleTop,
81			articleHeight,
82			articleBottom,
83			articleTitle,
84			$widgetPost,
85			advertHtml,
86			offset = 300;
87
88		$('article').each(function() {
89			$article = $(this);
90			articleTop = $article.offset().top;
91			articleHeight = $article.height();
92			articleBottom = articleTop+articleHeight;
93			articleTitle = $article.find( post_title_selector ).text();
94
95			if(articleTop-offset<windowTop && articleBottom-offset>windowTop &&
96				('post-'+$('.alp-related-post.current').attr('data-id'))!=$article.attr('id'))
97			{
98				$('.alp-related-post').removeClass('current');
99				$widgetPost = $('.alp-related-post.' + $article.attr('id'));
100				$widgetPost.addClass('current');
101
102				advertHtml = $('.alp-related-posts .alp-advert')[0].outerHTML;
103				$('.alp-related-posts .alp-advert').remove();
104				$widgetPost.after(advertHtml);
105				
106				window.document.title = articleTitle;
107
108				history.pushState(null, $widgetPost.attr('data-document-title'), $widgetPost.find('.post-title').attr('href'));
109				if($article.attr('pageview')!='1' &&
110					!$article.hasClass('first'))
111				{
112					var pageViewData={
113						hitType: 'pageview',
114						title: document.title,
115						page: location.pathname
116					};
117					window['GoogleAnalyticsObject'] = 'ga';
118  						window['ga'] = window['ga'] || function() {
119    					(window['ga'].q = window['ga'].q || []).push(arguments)
120  					};
121					//console.log('pageview');
122					//console.log(pageViewData);
123					ga('send', pageViewData);
124					$article.attr('pageview', 1)
125				}
126
127				//$('.alp-related-post.' + $article.attr('id')).addClass('current');
128
129				$('.alp-related-post').show();
130				$('.alp-related-post').each(function() {
131					if($(this).hasClass('current'))
132						return false;
133					$(this).hide();
134				});
135				return false;
136			}
137		});
138	}
139
140	function createLastArticleWaypoint()
141	{
142		var $lastArticle = $('article:last-of-type')[0];
143		var waypoint = new Waypoint({
144			element: $lastArticle,
145			handler: function(direction) {
146				loadRelatedPosts();
147			},
148			//offset: 'bottom-in-view'
149			offset: function() {
150				//taken from waypoit.js 'bottom-in-view' function
151				return this.context.innerHeight() - this.adapter.outerHeight()+1500;
152			}
153			//offset: '80%'
154		})
155	}
156
157});
158

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.