PageSourceSearch

https://inhabitat.com/wp-content/plugins/ib-infinite-scroll/js/single-infinite-scroll.js?ver=260806-145309

js inhabitat.com collected 2026-09-24 08:25:57 UTC 7,442 bytes, 208 lines download raw bytes

1;(function($){
2	if(typeof(Ib_Scroll_Config) == "object") {
3		delete Ib_Scroll_Config.script;
4		delete Ib_Scroll_Config.loadingImg;
5		Ib_Scroll_Config.opage = parseInt(Ib_Scroll_Config.opage);
6		Ib_Scroll_Config.paged = -1;
7		Ib_Scroll_Config.posts_per_page = parseInt(Ib_Scroll_Config.posts_per_page);
8
9		var container, hasMorePosts = true, isRequesting = false;
10		var abTesting = window.location.search.indexOf("newgallery=true") >= 0 ? "?newgallery=true" : "";
11		var currentUrl = $('section.single.post').first().data('permalink')+abTesting;
12		//var currentUrl = $('section.single.post').first().data('permalink');
13
14		function injectAds(element){
15			$(element).ibinject({
16				charactersOffset: 900,
17				maxNumberOfAds: 2,
18				applicableTags: "p",
19				tagCode: "generated-" + (new Date()).getTime(),           // REQUIRED. - String
20				adUnits: "2922/InhabitatMobile/article",           		  // REQUIRED. - String
21				adWidth: 300,           // REQUIRED. - Number
22				adHeight: 250,          // REQUIRED. - Number
23				noAdsAbove: 768,          // Number, (pixel width of browser)
24				endOfContentAd: false,
25				adSingleTargets: "kw=content,in-content",
26				callback: function() {
27
28				}
29			});
30		}
31
32		function tabletIbInjectAds(element){
33			$(element).ibinject({
34				charactersOffset: 1150,
35				maxNumberOfAds: 2,
36				applicableTags: "p",
37				tagCode: "generated-" + (new Date()).getTime(),           // REQUIRED. - String
38				adUnits: "2922/Inhabitat/article",           		  // REQUIRED. - String
39				adWidth: 300,           // REQUIRED. - Number
40				adHeight: 250,          // REQUIRED. - Number
41				noAdsAbove: null,          // Null for desktop
42				endOfContentAd: false,
43				adSingleTargets: "kw=content,in-content",
44				callback: function() {
45
46				}
47			});
48		}
49
50		function deskInjectAds(element){
51			$(element).ibinject({
52				charactersOffset: 1150,
53				maxNumberOfAds: 2,
54				applicableTags: "p",
55				tagCode: "generated-" + (new Date()).getTime(),           // REQUIRED. - String
56				adUnits: "2922/Inhabitat/article",           		  // REQUIRED. - String
57				adWidth: 300,           // REQUIRED. - Number
58				adHeight: 250,          // REQUIRED. - Number
59				noAdsAbove: null,          // Null for desktop
60				endOfContentAd: false,
61				adSingleTargets: "kw=content,in-content",
62				callback: function() {
63
64				}
65			});
66		}
67
68		function pushPage(url,article){
69			url = url.replace("https:",window.location.protocol);
70			window.history.replaceState({},"",url);
71
72			//Google analytics
73			ga_url = url.replace(window.location.protocol+ "//" + window.location.host,"");
74
75			//Content Groups on inf scroll
76			let args = {
77				'page_location': ga_url,
78				'content_group1': article.data('contentgroup1'),
79				'content_group2': '/'+article.data('contentgroup2')+'/'
80			};
81			gtag('event','page_view',args);
82
83			//Chartbeat
84			if('object' == typeof pSUPERFLY){
85				_sf_async_config.sections="";
86				_sf_async_config.authors="";
87				pSUPERFLY.virtualPage(ga_url, "");
88			}
89
90		}
91
92		function updateSocialLogin(url){
93			if($(".wp-social-login-provider-facebook").length ){
94
95				$(".login-row:last-of-type .wp-social-login-provider-facebook, .login-row:last-of-type .wp-social-login-provider-google, .login-row:last-of-type .wp-social-login-provider-twitter").each(function(index, value){
96					var urlReplace = url;
97					var lastURL = $(this).attr("href").substring(0, $(this).attr("href").indexOf('redirect_to'));
98					var urlReplace = encodeURIComponent([urlReplace+"#comments"].join(' '));
99
100					$(this).attr("href", lastURL+"redirect_to="+urlReplace);
101				});
102			}
103		}
104
105		container = $(".container");
106		$(document).ready(function(){
107			assetsUrl = "https://inhabitat.com/wp-content/plugins/ib-infinite-scroll/images/mosaic-loading.gif";
108			$("body").append("<div id='infscr-loading' style='display: none;'><img alt='Loading...' src='"+assetsUrl+"' width='32' height='32'><div><em>Loading...</em></div></div>");
109		});
110		$(window).on('scroll',function() {
111			var scrollTop = $(window).scrollTop();
112			var posts = $('.maincontent.single');
113
114			if(!isRequesting && hasMorePosts && (($(".single.post .if-page-toggle").last().offset().top - 150 <= $(window).scrollTop()) || (($(window).scrollTop() + $(window).height()) - $(document).height()) >= -300)) {
115				isRequesting = true;
116				Ib_Scroll_Config.paged += 1;
117				requestUrl = window.location.origin + "/wp-json/infinite-scroll/article/" + Ib_Scroll_Config.p + "?offset=" + Ib_Scroll_Config.paged + "&blog_id=" + Ib_Scroll_Config.blog_id;
118				
119				$.ajax({
120					url: requestUrl,
121					dataType: "JSON",
122					type: "GET"
123				})
124				.done(function(json) {
125					if(json.html && json.html.length > 0 ) {
126						container.append(json.html);
127						isRequesting = false;
128						
129						if(json.post_id) {
130							Ib_Scroll_Config.p = json.post_id;
131						}
132
133						if($("#infscr-loading")) {
134							$("#infscr-loading").hide();
135						}
136
137						//Tabs
138						$(".tab_container:last").find('.ihmp_hideonload').css("display","block");
139						$(".tab_container:last").find('.ihmp_panel_hide').hide();
140						$(".tab_container:last").find('.tab_content').data('currentPage',1);
141						$(".tab_container:last").find('.tab_content').hide(); //Hide all content
142						$("ul.tabs").find("li:first").last().addClass("active").show(); //Activate first tab
143						$(".tab_container").find(".tab_content:first").last().show(); //Show first tab content
144
145						//Newsletter
146						$('.newsletter-container').last().newsletterInhabitat();
147
148						//FB LIKE
149						if(typeof FB == "object") {
150							FB.XFBML.parse();
151						}
152
153						//ibinject
154						console.log($('section.single.post').last(),$('section.single.post').last().hasClass("sponsored"));
155						if(Ib_Scroll_Config.isMobile && !Ib_Scroll_Config.isTablet && !$('section.single.post').last().hasClass("sponsored")){
156							injectAds($('.post-content').last());
157						}
158						if(typeof initLightbox == "function") initLightbox();
159						$(document).trigger("infiniteScroll:newPage");
160					} else {
161						hasMorePosts = false;
162						isRequesting = false;
163
164						if($("#infscr-loading")) {
165							$("#infscr-loading").hide();
166						}
167					}
168				});
169
170			} else if(isRequesting && hasMorePosts && ($(document).height()) <= ($(window).scrollTop() + $(window).height() + 50)) {
171				if($("#infscr-loading")) {
172					$("#infscr-loading").show();
173				}
174			} else if(!hasMorePosts && $("#infscr-loading")) {
175				if($("#infscr-loading")) {
176					$("#infscr-loading").remove();
177				}
178			}
179
180			for(var i = posts.length - 1; i >= 0; i--){
181				var top = $(posts[i]).position().top;
182				if(top < scrollTop){
183					//var newUrl = $(posts[i]).find("section.single.post").data('permalink')+abTesting;
184					var newUrl = $(posts[i]).find("section.single.post").data('permalink');
185					if(newUrl != currentUrl){
186						currentUrl = newUrl;
187						var newTitle = $(posts[i]).find("h1").html();
188						var newImage = $(posts[i]).find("img.single-lead-image").attr('src');
189						var article = $(posts[i]).find("section.single.post");
190						pushPage(newUrl,article);
191						//injectExelateTag(newUrl,$(posts[i]));
192						updateSocialLogin(newUrl);
193						$(window).trigger("infiniteScroll:nextPage");
194						isSponsored($(posts[i]),function() {
195							refreshSidebarSlots();
196						});
197						var sharebar = jQuery('#sharebar');
198						if(typeof jQuery().sharebar != "undefined"){
199							jQuery().sharebar('update',{url:newUrl,title:newTitle,image:newImage})
200						}
201					}
202
203					break;
204				}
205			}
206		});
207	}
208}(jQuery));

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.