PageSourceSearch

https://sm-motors.ru/local/templates/aspro_max/js/custom.js?17856803065610

js sm-motors.ru collected 2026-09-29 20:03:20 UTC 5,610 bytes, 221 lines download raw bytes

1/*
2You can use this file with your scripts.
3It will not be overwritten when you upgrade solution.
4*/
5
6//window.onerror = function (msg, url, line, col, exception) { BX.ajax.get('/ajax/error_log_logic.php', { data: { msg: msg, exception: exception, url: url, line: line, col: col } }); }
7
8function getCookie(name) {
9	let matches = document.cookie.match(new RegExp(
10		"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
11	));
12	return matches ? decodeURIComponent(matches[1]) : undefined;
13}
14
15function setCookie(name, value, options = {}) {
16	options = {
17		path: '/',
18		...options
19	};
20	
21	if (options.expires instanceof Date) {
22		options.expires = options.expires.toUTCString();
23	}
24	
25	let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);
26	
27	for (let optionKey in options) {
28		updatedCookie += "; " + optionKey;
29		let optionValue = options[optionKey];
30		if (optionValue !== true) {
31			updatedCookie += "=" + optionValue;
32		}
33	}
34	
35	document.cookie = updatedCookie;
36}
37
38$(document).ready(function () {
39	$(document).on('click', '.mobile_regions .city_item', function (e) {
40		e.preventDefault();
41		var _this = $(this);
42		$.removeCookie('current_region');
43		$.cookie('current_region', _this.data('id'), { path: '/', domain: 'next.aspro-partner.ru' });
44	});
45	
46	$(document).on('click', '.region_wrapper .more_item:not(.current) span', function (e) {
47		$.removeCookie('current_region');
48		$.cookie('current_region', $(this).data('region_id'), { path: '/', domain: 'next.aspro-partner.ru' });
49	});
50	
51	$(document).on('click', '.confirm_region .aprove', function (e) {
52		var _this = $(this);
53		$.removeCookie('current_region');
54		$.cookie('current_region', _this.data('id'), { path: '/', domain: 'next.aspro-partner.ru' });
55	});
56	
57	$(document).on('click', '.cities .item a', function (e) {
58		e.preventDefault();
59		var _this = $(this);
60		$.removeCookie('current_region');
61		$.cookie('current_region', _this.data('id'), { path: '/', domain: 'next.aspro-partner.ru' });
62	});
63	
64	$(document).on('click', '.popup_regions .ui-menu a', function (e) {
65		e.preventDefault();
66		var _this = $(this);
67		var href = _this.attr('href')
68		if (typeof arRegions !== 'undefined' && arRegions.length) {
69			$.removeCookie('current_region');
70			for (i in arRegions) {
71				var region = arRegions[i];
72				if (region.HREF == href) {
73					$.cookie('current_region', region.ID, { path: '/', domain: 'next.aspro-partner.ru' });
74				}
75			}
76		}
77		location.href = href;
78	});
79	
80	document.querySelectorAll('.left_menu a').forEach(link => {
81		let href = link.getAttribute('href');
82		
83		if (href.includes('#')) {
84			link.addEventListener('click', function (e) {
85				e.preventDefault();
86				
87				let hrefSplited = href.split('#');
88				const scrollTarget = document.getElementById(hrefSplited[1]);
89				const elementPosition = scrollTarget.getBoundingClientRect().top;
90				const offsetPosition = elementPosition - 70;
91				
92				window.scrollBy({
93					top: offsetPosition,
94					behavior: 'smooth'
95				});
96			});
97		}
98	});
99});
100
101window.addEventListener('DOMContentLoaded', function () {
102	if (getCookie('COOKIE_AGREEMENT') !== 'Y' && getCookie('COOKIE_AGREEMENT') !== 'N') {
103		const popupCookie = document.getElementById('popup-cookie-agreement');
104		const popupCookieAccept = document.querySelector('.js-cookie-agreement-accept');
105		const popupCookieCancel = document.querySelector('.js-cookie-agreement-cancel');
106		
107		setTimeout(function () {
108			popupCookie.classList.add('_active');
109		}, 3000);
110		
111		popupCookieAccept.addEventListener('click', function() {
112			popupCookie.remove();
113			setCookie('COOKIE_AGREEMENT', 'Y', {secure: true, 'max-age': 2419200});
114			if (gtag) {
115				gtag('consent', 'update', {
116					'ad_storage': 'granted',
117					'ad_user_data': 'granted',
118					'ad_personalization': 'granted',
119					'analytics_storage': 'granted'
120				});
121			}
122		});
123		popupCookieCancel.addEventListener('click', function() {
124			popupCookie.remove();
125			setCookie('COOKIE_AGREEMENT', 'N', {secure: true, 'max-age': 2419200});
126			if (gtag) {
127				gtag('consent', 'update', {
128					'ad_storage': 'denied',
129					'ad_user_data': 'denied',
130					'ad_personalization': 'denied',
131					'analytics_storage': 'denied'
132				});
133			}
134		});
135	}
136	
137	Dadata.createSuggestions(document.querySelector('form[name=DEALER_FORM_NEWSM] input[name=form_text_65]'), {
138		token: '46d979457c7cc414fee3461dfb337991e22c0284',
139		type: 'address',
140		params: {
141			division: 'municipal',
142		},
143		beforeFormat: beforeFormatSuggestions,
144		formatSelected: formatSelectedSuggestions
145	});
146});
147
148function formatSelectedSuggestions(suggestion) {
149	let result = dotify(suggestion.value);
150	
151	if (suggestion.data.federal_district) {
152		result = 'ф.о. ' + suggestion.data.federal_district + ', ' + result;
153	}
154	
155	return result;
156}
157
158function beforeFormatSuggestions(suggestion) {
159	suggestion.value = dotify(suggestion.value);
160	return suggestion;
161}
162
163const SHORT_TYPES = new Set([
164	'аобл',
165	'респ',
166	'вл',
167	'г',
168	'д',
169	'двлд',
170	'днп',
171	'дор',
172	'дп',
173	'жт',
174	'им',
175	'к',
176	'кв',
177	'км',
178	'комн',
179	'кп',
180	'лпх',
181	'м',
182	'мкр',
183	'наб',
184	'нп',
185	'обл',
186	'оф',
187	'п',
188	'пгт',
189	'пер',
190	'пл',
191	'платф',
192	'рзд',
193	'рп',
194	'с',
195	'сл',
196	'снт',
197	'ст',
198	'стр',
199	'тер',
200	'туп',
201	'ул',
202	'х',
203	'ш'
204]);
205
206function dotify(address) {
207	const parts = address.split(',').map(function (part) {
208		const words = part.split(' ').map(addDot);
209		return words.join(' ');
210	});
211	
212	return parts.join(',');
213}
214
215function addDot(word) {
216	if (SHORT_TYPES.has(word.toLowerCase())) {
217		return word + '.';
218	} else {
219		return word;
220	}
221}

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.