PageSourceSearch

https://www.loggly.com/wp-content/themes/loggly-2019/source/js/scroll.js?ver=1754550756

js loggly.com collected 2026-09-24 08:29:11 UTC 3,901 bytes, 142 lines download raw bytes

1( function( $, w ) {
2
3	var LogglyInfiniteScroller = function(dataLoaderSelector, dataContainerSelector) {
4
5		jQuery.extend(jQuery, {
6			imagesToLoad: 0,
7			loadedImages: [],
8			preloadImages: function(){
9				var settings = {
10					urls : [],
11					begin : function(){},
12					each : function(){},
13					complete : function(){},
14					scope: window
15				};
16				jQuery.extend(settings, arguments[0]);
17				var images = [];
18
19				jQuery.imagesToLoad = 0;
20				jQuery.loadedImages = [];
21				jQuery.imagesToLoad = settings.urls.length;
22
23				settings.begin.call(settings.scope, settings.urls);
24				for(var i = 0; i < settings.urls.length; i++){
25					images[i] = new Image();
26					images[i].onload = function(){
27						settings.each.call(settings.scope,this);
28						jQuery.loadedImages.push(this);
29						if(jQuery.loadedImages.length >= jQuery.imagesToLoad){
30							settings.complete.call(settings.scope,jQuery.loadedImages);
31						}
32					}
33					images[i].src= settings.urls[i];
34				}
35			}
36		});
37
38		var t = this;
39
40		t.dataLoaderSelector = dataLoaderSelector;
41		t.dataContainerSelector = dataContainerSelector;
42		t.dataLoader = null;
43		t.elementWatcher = null;
44
45		t.init = function() {
46			if ($(t.dataLoaderSelector).length > 0 && $(t.dataContainerSelector).length > 0) {
47				t.watch();
48			}
49		}
50
51		t.handle = function(self) {
52			var $element = $(self.watchItem);
53			var $anchor = $('a', $element);
54			var $container = $(dataContainerSelector);
55			if ( $anchor.length > 0 ) {
56				$element.text('Loading...');
57				$.ajax({
58					url: $anchor.attr('href'),
59					type: 'GET',
60					dataType: 'html',
61					success: function(response) {
62						// GET RESPONSE DATA
63						$response = $(response).find(dataContainerSelector)
64						$images = $response.find('img');
65						if ($images.length > 0) {
66							// THERE ARE IMAGES TO PRELOAD
67							urls = [];
68							// FIND IMAGES TO PRELOAD
69							$images.each(function(i, img){
70								if (urls.indexOf($(img).attr('src')) == -1) {
71									urls.push($(img).attr('src'));
72								}
73							})
74							// PRELOAD IMAGES
75							$.preloadImages({
76								urls: urls,
77								begin: function(urls){
78									// console.log("loading images %o", urls);
79								},
80								each: function(image){
81									// console.log("finished loading %s", image.src);
82								},
83								complete: function(images){
84									// IMAGE PRELOADING COMPLETED
85									// UPDATE "LOAD MORE" BUTTON/LINK
86									if ($(response).find(dataLoaderSelector).length > 0) {
87										t.dataLoader.html($(response).find(dataLoaderSelector).html());
88									} else {
89										t.dataLoader.html('');
90									}
91									// APPEND NEW CONTENT
92									$container.append($($response.html().trim()).hide().fadeIn(300, function(){
93										$(w).trigger('loggly:scroll:loaded');
94									}));
95									// WATCH FOR SCROLL
96									t.watch();
97								}
98							});
99						} else {
100							// THERE ARE NO IMAGES TO PRELOAD
101							// UPDATE "LOAD MORE" BUTTON/LINK
102							if ($(response).find(dataLoaderSelector).length > 0) {
103								t.dataLoader.html($(response).find(dataLoaderSelector).html());
104							} else {
105								t.dataLoader.html('');
106							}
107							// APPEND NEW CONTENT
108							$container.append($($response.html().trim()).hide().fadeIn(300, function(){
109								$(w).trigger('loggly:scroll:loaded');
110							}));
111							// WATCH FOR SCROLL
112							t.watch();
113						}
114					}
115				});
116			} else {
117				self.destroy();
118				$anchor.remove();
119			}
120		}
121
122		t.watch = function() {
123			if (t.elementWatcher != null) {
124				t.elementWatcher.destroy();
125			}
126			t.dataLoader = $(dataLoaderSelector);
127			t.elementWatcher = scrollMonitor.create(t.dataLoader);
128			t.elementWatcher.enterViewport(function() {
129				t.handle(this);
130			});
131		}
132
133	}
134
135	w.lggInfiniteScroller = new LogglyInfiniteScroller(
136		'[data-role="loggly-posts-loader"]',
137		'[data-role="loggly-posts-container"]'
138	);
139
140	w.lggInfiniteScroller.init();
141
142}( jQuery, window ) );

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.