PageSourceSearch

https://amti.ru/js/layout.js?czv1g1

js amti.ru collected 2026-10-03 00:43:40 UTC 9,009 bytes, 352 lines download raw bytes

1/*! © kubstu.ru */
2
3class NavBar {
4	constructor() {
5		let overlay = false;
6		let storeScroll;
7		let scrollHome = 100;
8		let scrollRegular = 10;
9
10		const debounce = (fn) => {
11			let frame;
12			return (...params) => {
13				if (frame) cancelAnimationFrame(frame);
14				frame = requestAnimationFrame(() => fn(...params));
15			};
16		};
17
18		if (document.documentElement.dataset.home === 'true') {
19			document.documentElement.dataset.scroll = (window.scrollY < scrollHome) ? 0 : window.scrollY;
20			document.documentElement.dataset.overlay = overlay;
21			storeScroll = () => {
22				document.documentElement.dataset.scroll = (window.scrollY < scrollHome) ? 0 : window.scrollY;
23			};
24		} else {
25			document.documentElement.dataset.scroll = (window.scrollY < scrollRegular) ? 0 : window.scrollY;
26			document.documentElement.dataset.overlay = overlay;
27			storeScroll = () => {
28				document.documentElement.dataset.scroll = (window.scrollY < scrollRegular) ? 0 : window.scrollY;
29			};
30		}
31
32		document.addEventListener('scroll', debounce(storeScroll), {passive: true});
33
34		$('.header-navbar-olnav button').on('click', () => {
35			overlay = !overlay;
36			document.documentElement.dataset.overlay = overlay;
37
38			if (overlay) {
39				$('.header-navbar-olnav-icon').addClass('header-navbar-olnav-icon-open');
40				$('.olnav').show();
41			} else {
42				$('.header-navbar-olnav-icon').removeClass('header-navbar-olnav-icon-open');
43				$('.olnav').hide();
44			}
45		})
46	}
47}
48
49
50
51class OverlayNav {
52	constructor() {
53		$('.olnav-mobile-menu-item').on('click', 'span', (event) => {
54			const item = $(event.currentTarget).parent();
55			const menu = item.parent();
56			const list = item.next();
57			if (menu.hasClass('open')) {
58				list.css('height', '0px');
59				list.one('transitionend', () => menu.removeClass('open'));
60			} else {
61				menu.addClass('open');
62				list.css('height', 'auto');
63				let height = list.outerHeight();
64				list.css('height', '0px');
65				setTimeout(() => list.css('height', height+'px'), 1);
66			}
67		});
68	}
69}
70
71
72
73class HomeSlider {
74	constructor(duration) {
75		const slider = this;
76		let timeLeft = --duration;
77		slider.activeIndex = 0;
78
79		const slideCount =  $('.home-slider > .home-slider-item').length;
80		slider.setActiveIndex(0);
81	
82		const timer = setInterval(() => {
83			if (timeLeft > 0) {
84				timeLeft = timeLeft-1;
85				slider.setProgress(100-(timeLeft/duration)*100);
86			} else {
87				slider.setActiveIndex((prev) => prev == slideCount-1 ? 0 : prev+1);
88				timeLeft = duration;
89			}
90		}, 1000);
91	
92		$('.home-slider-pagination').on('click', '.home-slider-button', function() {
93			slider.setActiveIndex($(this).index());
94			timeLeft = duration;
95		});
96	
97		$('.home-slider-mobile-pagination').on('click', '.home-slider-mobile-button', function() {
98			slider.setActiveIndex($(this).index());
99			timeLeft = duration;
100		});
101	
102		let touches = {start: 0, end: 0};
103	
104		$('.home-slider').on('touchstart', (event) => {
105			touches.start = event.changedTouches[0].screenX;
106		}).on('touchend', (event) => {
107			touches.end = event.changedTouches[0].screenX;
108			if (touches.start-touches.end > 50) {
109				slider.setActiveIndex((prev) => prev == slideCount-1 ? 0 : prev+1);
110				timeLeft = duration;
111			}
112			if (touches.end-touches.start > 50) {
113				slider.setActiveIndex((prev) => prev == 0 ? slideCount-1 : prev-1);
114				timeLeft = duration;
115			}
116		});
117	}
118
119
120	setProgress(value) {
121		let dprog = $('.home-slider-pagination > div').eq(this.activeIndex).find('.home-slider-button-progress > div');
122		let mprog = $('.home-slider-mobile-progress > div');
123
124		if (value != null) {
125			if (value == 0) dprog.show();
126			dprog.css('width', `${value}%`);
127			mprog.css('width', `${value}%`);
128		} else {
129			dprog.hide();
130			dprog.css('width', '0%');
131			mprog.css('width', '0%');
132		}
133	}
134
135
136	setActiveIndex(index) {
137		this.setProgress(null);
138		$('.home-slider-mobile-button').eq(this.activeIndex).removeClass('active');
139
140		this.activeIndex = (typeof index == 'function') ? index(this.activeIndex) : index;
141
142		$('.home-slider > .home-slider-item').hide();
143		$('.home-slider > div').eq(this.activeIndex).css('display', 'flex');
144		$('.home-slider-mobile-button').eq(this.activeIndex).addClass('active');
145		this.setProgress(0);
146	}
147}
148
149
150
151class HomeTabs {
152	constructor() {
153		this.tabs = ['abit', 'stud', 'empl', 'grad'];
154		this.swiper = [false, false, false, false];
155		this.defaultIndex = 0;
156
157		this.setActiveTabIndex(this.defaultIndex);
158		
159		$('.home-tabs-pagination').on('click', 'a', (event) => {
160			this.setActiveTabIndex($(event.currentTarget).index());
161		});
162	}
163
164
165	setActiveTabIndex(index) {
166		const id = `#${this.tabs[index]}-content`;
167
168		if (typeof this.swiper[index] != 'object') {
169			this.swiper[index] = new Swiper(id, {
170				slidesPerView: 1,
171				spaceBetween: 30,
172				pagination: {
173					el: '.swiper-pagination',
174					clickable: true,
175				},
176				navigation: true,
177				enabled: true,
178				breakpoints: {
179					851: {
180						slidesPerView: 'auto',
181						initialSlide: 0,
182						enabled: false,
183					},
184				},
185			});
186		}
187
188		$('.home-tabs-pagination a').removeClass('active');
189		$('.home-tabs-pagination a').eq(index).addClass('active');
190		$('.home-tabs-content').hide();
191		$(`#${this.tabs[index]}-content`).show();
192	}
193}
194
195
196
197class HomeNewsSlider {
198	constructor() {
199		new Swiper('.news-slider', {
200			slidesPerView: 'auto',
201			spaceBetween: 30,
202			loop: true,
203			pagination: {
204				el: '.swiper-pagination',
205				clickable: true,
206			},
207			navigation: {
208				nextEl: '.swiper-button-next',
209				prevEl: '.swiper-button-prev',
210			},
211		});
212	}
213}
214
215
216
217class SideScroll {
218	prefix = '';
219	step = 300;
220	delay = 200;
221	offset = 0;
222	maxOffset = 0;
223	press = [false, false];
224	toId = 0;
225
226	constructor(opt) {
227		if (typeof opt.prefix != 'undefined') this.prefix = opt.prefix;
228		if (typeof opt.step != 'undefined') this.step = opt.step;
229		if (typeof opt.delay != 'undefined') this.delay = opt.delay;
230
231		this.maxOffset = $(this.prefix+'gallery > div').width() - Math.round($(this.prefix+'gallery').width());
232
233		if (this.maxOffset > 0) {
234			$(this.prefix+'prev,'+this.prefix+'next').css('display', 'block');
235		}
236
237		$(this.prefix+'prev').on('mousedown', (event) => {
238			this.press[0] = true;
239			if (!this.toId) this.move(0);
240		});
241
242		$(this.prefix+'next').on('mousedown', (event) => {
243			this.press[1] = true;
244			if (!this.toId) this.move(1);
245		});
246
247		$(this.prefix+'prev,'+this.prefix+'next').on('mouseup', (event) => {
248			this.press = [false, false];
249		});
250	}
251
252	move(index) {
253		this.toId = 0;
254		if (!this.press[index]) return;
255		document.querySelector(this.prefix+'gallery').scrollBy(((index ? 1 : -1) * this.step), 0);
256		this.toId = setTimeout(() => this.move(index), this.delay);
257	}
258}
259
260
261
262$(function() {
263	const mobile = document.documentElement.dataset.mobile === 'true';
264	if (mobile) $('body').addClass('mobile');
265
266	$('#search-show').on('click', (event) => {
267		$('.header-navsub-menu').removeClass('active');
268		$('.header-navsub-search').addClass('active');
269		return false;
270	});
271
272	$('#search-hide').on('click', (event) => {
273		$('.header-navsub-search').removeClass('active');
274		$('.header-navsub-menu').addClass('active');
275		return false;
276	});
277
278	$('article .lsx > li').each(function(index, el) {
279		if ($(this).children('ul').length) $(this).prepend('<span class="lsx-btn"></span>');
280	});
281
282	$('.lsx-btn').on('click', function(x) {
283		$(this).parent().toggleClass('open');
284	});
285
286	$('.nex').on('click', function(x) {
287		$(this).next().toggle();
288		return false;
289	});
290
291	$('.mdl-blink').on('click', function(x) {
292		if ($(this).next().length && $(this).data('rel')) {
293			$(this).next().toggle();
294		} else {
295			$(this).data('rel', 1);
296			$(this).after('<div class="mdl-block"><i>… Загрузка …</i></div>');
297			$(this).next().show();
298			fetch('?a=json/moodle&link='+$(this).attr('href')).then(res => res.json()).then(jx => {
299				$(this).next().html(jx.html);
300				$(this).next().find('.nex').on('click', function(x) {
301					$(this).next().toggle();
302					return false;
303				});
304			});
305		}
306		return false;
307	});
308
309	$('article table.sb').wrap('<div class="of-wrap" />');
310	$('.gallery').gallery();
311
312	$('.news-share-show').on('click', (event) => {
313		if (navigator.share && mobile) {
314			navigator.share({
315				title: $('title').html(),
316				url: location.href
317			});
318		} else {
319			$('.news-share').addClass('open');
320		}
321	});
322
323	$('.news-share-hide').on('click', (event) => {
324		$('.news-share').removeClass('open');
325	});
326
327	$('.news-share-copy').on('click', (event) => {
328		navigator.clipboard.writeText(location.href);
329		if (!$(event.currentTarget).hasClass('copied')) {
330			$(event.currentTarget).addClass('copied');
331			setTimeout(() => $(event.currentTarget).removeClass('copied'), 3000);
332		}
333	});
334
335	if ($('.news-item-gallery').length) {
336		new SideScroll({prefix: '.news-item-'});
337	}
338
339	$('#cknt button').on('click', (event) => {
340		localStorage.setItem('cookie_accept', '1');
341		$('#cknt').hide();
342	});
343
344	if (navigator.cookieEnabled && localStorage.getItem('cookie_accept') == null) $('#cknt').show();
345
346	new NavBar;
347	new OverlayNav;
348	new HomeSlider(12);
349	new HomeTabs;
350	new HomeNewsSlider;
351	new isvek.Bvi();
352});

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.