PageSourceSearch

https://smolensk-i.ru/wp-content/themes/amlan_smolenski/js/main.js?ver=0.3.7

js smolensk-i.ru collected 2026-10-01 08:43:45 UTC 8,191 bytes, 253 lines download raw bytes

1jQuery(function($){
2	$('#true_loadmore').click(function(){
3		$(this).text('Загружаю...'); // изменяем текст кнопки, вы также можете добавить прелоадер
4		$(this).addClass('loading'); 
5		var data = {
6			'action': 'loadmore',
7			'page' : current_page,
8			'query': true_posts,
9			'offset' : offset,
10		};
11		$.ajax({
12			url:ajax_url.url, // обработчик
13			data:data, // данные
14			type:'POST', // тип запроса
15			success:function(data){
16				if( data ) { 
17					$('#true_loadmore').text('Показать ещё');
18					$('#true_loadmore').removeClass('loading');
19					$('#uploadAjaxPost').before(data); // вставляем новые посты
20					current_page++; // увеличиваем номер страницы на единицу
21					if (current_page == max_pages) $("#true_loadmore").remove(); // если последняя страница, удаляем кнопку
22				} else {
23					$('#true_loadmore').remove(); // если мы дошли до последней страницы постов, скроем кнопку
24				}
25			}
26		});
27	});		
28});
29
30jQuery(function($){
31	$('#true_loadmore_best').click(function(){
32		$(this).text('Загружаю...'); // изменяем текст кнопки, вы также можете добавить прелоадер
33		$(this).addClass('loading'); 
34		var data = {
35			'action': 'loadmore_best',
36			'page' : current_page,
37			'query': true_posts,
38			'offset' : offset,
39		};
40		$.ajax({
41			url:ajax_url.url, // обработчик
42			data:data, // данные
43			type:'POST', // тип запроса
44			success:function(data){
45				if( data ) { 
46					$('#true_loadmore_best').text('Показать ещё');
47					$('#true_loadmore_best').removeClass('loading');
48					$('#uploadAjaxPost').before(data); // вставляем новые посты
49					current_page++; // увеличиваем номер страницы на единицу
50					if (current_page == max_pages) $("#true_loadmore_best").remove(); // если последняя страница, удаляем кнопку
51				} else {
52					$('#true_loadmore_best').remove(); // если мы дошли до последней страницы постов, скроем кнопку
53				}
54			}
55		});
56	});		
57});
58
59
60jQuery(document).ready(function($){
61	
62	function uploaddAJAXimg(elem)  {
63		let arr = new Array();
64		$(elem).each(function( index ) {
65			el = $( this );
66			let arr2 = new Array();
67			arr2.push($( el ).attr("thumbnail"));
68			arr2.push($( el ).attr("id_thumbnail"));
69			arr.push(arr2);
70		});		
71		
72		var data = {
73			'action': 'loadimg',
74			'arr': arr,
75			'width' : screen.width,
76		};
77				
78		$.ajax({
79			url: ajax_url.url, // обработчик
80			data: data, // данные
81			type: 'POST', // тип запроса
82			success:function(data){
83				if( data ) { 
84					data.data.forEach(function(item, index) {
85						$('.imgsrc[id_thumbnail = '+item[1]+']').attr("src", item[2]).on("load", function() {  
86						  $(this).removeClass('preload-img');
87						  $(this).removeClass('on-load-img');
88						  $(this).removeClass('imgsrc');
89						});  
90					});
91				}
92			}
93		});
94	}
95	function uploaddAJAXarchive(elem)  {
96		$(elem).removeClass('on-load-archive');	
97		let arr = new Array();
98		$(elem).each(function( index ) {
99			if ((screen.width < 1024)) {
100				if ($( this ).hasClass("onload_m") == false) {
101					return; 
102				}
103			}
104				el = $( this );
105				let arr2 = new Array();
106				arr2.push($( el ).attr("archive"));
107				arr.push(arr2);
108		});		
109		if (arr.length == 0) {return;}
110		var data = {
111			'action': 'loadarchive',
112			'arr': arr,
113			'width' : screen.width,
114		};		
115		$.ajax({
116			url: ajax_url.url, // обработчик
117			data: data, // данные
118			type: 'POST', // тип запроса
119			success:function(data){
120				if( data ) { 
121					data.data.forEach(function(item, index) {
122						$('.opload-ajax-archive[archive = '+item[0]+']').html(item[1]);
123						$('.opload-ajax-archive[archive = '+item[0]+']').removeClass('preload-load');
124					});
125				}
126			}
127		});
128				
129	}
130	
131	let target = $('.content-wrapper')[0];
132	let target_single = $('.front-col-single')[0];
133	 
134	// создаем новый экземпляр наблюдателя
135	let observer = new MutationObserver(function(mutations) {
136	  mutations.forEach(function(mutation) {
137		if (mutation.type === 'childList') {
138			mutation.addedNodes.forEach((element) => {
139				if ( $(element).hasClass('front-ajax-conteiner') ) {
140					uploaddAJAXimg($('.imgsrc'));
141				}
142			});
143		} 
144	  });    
145	});
146	 
147	// создаем конфигурации для наблюдателя
148	let config = { attributes: true, childList: true, characterData: true };
149	 
150	// запускаем механизм наблюдения
151	observer.observe(target,  config);
152	// observer.observe(target_single,  config);
153	 
154	//observer.disconnect();
155	
156		
157	if ($('.imgsrc.on-load-img')) {
158		uploaddAJAXimg($('.imgsrc'));		
159	}
160			
161	if ($('.opload-ajax-archive').length > 0) {		
162		uploaddAJAXarchive($('.opload-ajax-archive'));		
163	}
164	
165	const myBody = document.getElementsByTagName('body')[0];
166
167    window.addEventListener('scroll', function() {
168        if (window.scrollY >= 300) {
169            myBody.classList.add('fixed-menu');
170        } else {
171            myBody.classList.remove('fixed-menu');
172        }
173    });
174	
175	//const showMoreBtns = document.querySelectorAll('.archive-show-more-btn');
176
177	// Добавляем обработчик события на каждую кнопку
178	//showMoreBtns.forEach(function(btn) {
179		
180	document.addEventListener('click', function(event) {
181    // Проверяем, что клик произошел на кнопке с нужным классом
182		if (event.target && event.target.classList.contains('archive-show-more-btn')) {
183			const btn = event.target;
184			//btn.addEventListener('click', function() {
185			// Получаем категорию, связанную с кнопкой
186			btn_add = $(btn);
187			const cat = btn.dataset.cat;
188			const offset = parseInt(btn_add.attr('data-offset'));
189			let get_news = false;
190
191
192			// let hiddenItems = $('.wrapper-archive-' + cat).children('.hidden');
193			let hiddenItems = $('.wrapper-archive-' + cat + ' .hidden');
194			
195			
196			if (screen.width > 900) {
197				// Используем jQuery для выбора элементов, которые относятся к текущей категории
198				hiddenItems.removeClass('hidden'); // jQuery метод .eq() для работы с элементами
199				hiddenItems = $('.wrapper-archive-' + cat).children('.hidden');
200			}
201			
202			console.log(hiddenItems); 
203			
204			// Показываем следующие 5 скрытых элемента
205			if (hiddenItems.length > 0) {
206				for (let i = 0; i < Math.min(5, hiddenItems.length); i++) {
207					hiddenItems.eq(i).removeClass('hidden'); // jQuery метод .eq() для работы с элементами
208				}
209			} else {
210				//Загружаем с сервера
211				
212				$.ajax({
213					url: ajax_url.url,
214					type: 'POST',
215					data: {
216						action: 'load_more_news_archive',
217						cat: cat,
218						offset: offset,
219					},
220					beforeSend: function () {
221						btn_add.text('Загружается...'); // Меняем текст на кнопке
222					},
223					success: function (response) {
224						if (response) {
225							$('.wrapper-archive-' + cat + ' .upload').append(response); // Добавляем новости в конец
226							btn_add.attr('data-offset', offset + 5); // Увеличиваем смещение
227							btn_add.text('Показать еще');
228						} else {
229							//btn.text('Больше новостей нет').prop('disabled', true); // Отключаем кнопку
230							get_news = true;
231						}
232					},
233					error: function () {
234						btn.text('Ошибка загрузки');
235					}
236				});
237			}
238			// Проверяем, есть ли еще скрытые элементы
239			// hiddenItems = $('.wrapper-archive-' + cat).children('.hidden');
240			if (get_news) {
241				btn.style.display = 'none'; // Скрываем кнопку, если все элементы показаны
242			}
243		};
244	});
245	
246});
247
248
249
250
251
252
253

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.