PageSourceSearch

https://lcb.org/assets/js/search-V2IjzNj.js

js lcb.org collected 2026-10-02 04:10:37 UTC 5,138 bytes, 174 lines download raw bytes

1let window_w = $(window).width();
2let isMobile = window_w < 850;
3let pageSize = 16;
4let isLoadingSearchData = false;
5
6$(document).ready(function(){
7	$('#globalsearch-trigger').click(function() {
8		$('.global-search-wrapper').fadeIn('fast');
9		$('#globalSearchInput').focus();
10		if($('.global-search-wrapper-page').length == 0){
11			$('body').addClass('modal-open');
12		}
13	});
14	$('.global-search-wrapper .exit').click(function() {
15		$('.global-search-wrapper').fadeOut('fast');
16		$('body').removeClass('modal-open');
17	});
18
19	let searchTerm = null;
20	$('#globalSearchInput').donetyping(function(callback){
21		searchTerm = $(this).val();
22		if (searchTerm != undefined && searchTerm != null && searchTerm != '') {
23			globalSearch(searchTerm);
24		}
25	});
26
27	$('.main-menu .search').submit(function(event) {
28		event.preventDefault();
29		let searchTerm = $(this).find('input').val();
30		let searchType = $(this).data('search');
31		if (searchTerm != undefined && searchTerm != null && searchTerm != '') {
32			$('.global-search-wrapper').fadeIn('fast');
33			$('#globalSearchInput').val(searchTerm);
34			globalSearch(searchTerm, searchType);
35		}
36	});
37
38	var url = new URL(window.location.href);
39	if (url.pathname == '/search') {
40		searchTerm = url.searchParams.get('q');
41		if (searchTerm != undefined && searchTerm != null && searchTerm != '') {
42			$('#globalSearchInput').val(searchTerm)
43			globalSearch(searchTerm);
44		}
45	}
46
47	$(document).on('click', '.search-tabs-item', function() {
48		let tabKey = $(this).data('key');
49		partialKey = tabKey;
50		$('.search-tabs-item').removeClass('active');
51		$('.results-row').removeClass('active');
52		$('.search-tabs-item[data-key="'+tabKey+'"]').addClass('active');
53		$('.results-row[data-key="'+tabKey+'"]').addClass('active');
54		let tabTotal = $('.results-row[data-key="'+tabKey+'"]').find('.row').data('total');
55		if(tabTotal > 16) {
56            $('.search-scroll-more').addClass('active');
57        } else {
58            $('.search-scroll-more').removeClass('active');
59        }
60		loadOnScroll($('.results-row[data-key="'+tabKey+'"]'));
61	});
62});
63
64let key2class = {
65	'sites': 'sites',
66	'games': 'games',
67	'software': 'software',
68	'banking': 'banking',
69	'news': 'news',
70	'poker': 'poker',
71	'sports': 'sports',
72	'blog': 'blog',
73	'pages': 'pages',
74	'topics': 'topics'
75}
76
77let partialKey = '';
78let loadedPage = resetPageData();
79let totals = resetPageData();
80
81function resetPageData() {
82	return {
83		'sites': 0,
84		'games': 0,
85		'software': 0,
86		'banking': 0,
87		'news': 0,
88		'poker': 0,
89		'sports': 0,
90		'blog': 0,
91		'pages': 0,
92		'topics': 0
93	}
94}
95
96function loadOnScroll(row) {
97	row.each(function(){
98		$(this).scroll(function() {
99			if (partialKey && !isLoadingSearchData && (partialKey !== '')) {
100				if ($(this)[0].scrollHeight - $(this).height() - $(this).scrollTop() < 10) {
101					let query = $('#global-search-results').attr('data-search');
102					let page = loadedPage[partialKey];
103					if (page < Math.trunc((totals[partialKey] - 1) / pageSize) + 1) {
104						loadPartialSearch(query, partialKey, page + 1, $(this));
105					}
106				}
107			}
108		});
109	})
110}
111
112function loadPartialSearch(query, key, page, element) {
113	let callUrl = '/full-search?query=' + query + '&key=' + key + '&page=' + page;
114	let keyClass = key2class[key];
115	isLoadingSearchData = true;
116	$('.search-loader').addClass('active');
117	$.ajax({
118		type: 'get',
119		dataType: "html",
120		url: callUrl,
121		success: function (result, status, xhr) {
122			let className = '.' + key2class[key] + '-results';
123			$(className).data('page', page);
124			loadedPage[key] = page;
125			element.find('.row').append(result);
126			isLoadingSearchData = false;
127			$('.search-loader').removeClass('active');
128			if (loadedPage[partialKey] < Math.trunc((totals[partialKey] - 1) / pageSize) + 1) {
129                $('.search-scroll-more').addClass('active');
130            } else {
131                $('.search-scroll-more').removeClass('active');
132            }
133		}
134	});
135}
136
137function globalSearch(searchTerm, searchType) {
138	let callUrl = '/full-search';
139	if (searchTerm != null && searchTerm != '') {
140		callUrl += '?query=' + searchTerm;
141	}
142	loadedPage = resetPageData();
143	totals = resetPageData();
144	isLoadingSearchData = true;
145	$('.search-loader').addClass('active');
146	partialKey = '';
147	$.ajax({
148		type: 'get',
149		dataType: "html",
150		url: callUrl,
151		success: function (result, status, xhr) {
152			$('#global-search-results').attr("data-search", searchTerm);
153			$('#global-search-results').html(result);
154			$('.search-tabs-item').first().addClass('active');
155			$('.results-row').first().addClass('active');
156            if($('.results-row').first().find('.row').data('total') > 16) {
157                $('.search-scroll-more').addClass('active');
158            } else {
159                $('.search-scroll-more').removeClass('active');
160            }
161			for (let key in totals) {
162				totals[key] = parseInt($('.' + key + '-results').data('total'));
163				if (totals[key] > 0) {
164					loadedPage[key] = 1;
165				}
166			}
167			partialKey = $('.results-row').first().data('key');
168			loadedPage[searchType] = 1;
169			isLoadingSearchData = false;
170			$('.search-loader').removeClass('active');
171			loadOnScroll($('.results-row').first());
172		}
173	});
174}

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.