PageSourceSearch

https://cdn.sani-shop.ru/static/caec4/contact-yandex-map.js

js sani-shop.ru collected 2026-10-04 01:34:17 UTC 8,852 bytes, 346 lines download raw bytes

1(function (window, document) {
2	'use strict';
3
4	var fallbackRoutes = {
5		pedestrian: [
6			[55.636763, 37.655230],
7			[55.636761, 37.655226],
8			[55.636765, 37.655219],
9			[55.636766, 37.655208],
10			[55.636767, 37.655194],
11			[55.636763, 37.655173],
12			[55.636883, 37.655068],
13			[55.636942, 37.655017],
14			[55.637149, 37.654837],
15			[55.637177, 37.654810],
16			[55.637446, 37.654535],
17			[55.637451, 37.654484],
18			[55.637482, 37.654102],
19			[55.637518, 37.653588],
20			[55.637559, 37.653067],
21			[55.637626, 37.652272],
22			[55.637651, 37.651902],
23			[55.637663, 37.651745],
24			[55.637687, 37.651436],
25			[55.637719, 37.651032],
26			[55.637748, 37.650687],
27			[55.637792, 37.650143],
28			[55.637851, 37.650156],
29			[55.637923, 37.650171],
30			[55.638002, 37.650189],
31			[55.638022, 37.649867],
32			[55.638028, 37.649851],
33			[55.638042, 37.649841],
34			[55.638113, 37.649860],
35			[55.638124, 37.649761],
36			[55.638149, 37.649351],
37			[55.638181, 37.648674],
38			[55.638212, 37.648232],
39			[55.638233, 37.648036],
40			[55.638248, 37.647889],
41			[55.638277, 37.647607],
42			[55.638280, 37.647576],
43			[55.638307, 37.647447],
44			[55.638398, 37.647006],
45			[55.638485, 37.646513],
46			[55.638495, 37.646427],
47			[55.638532, 37.646039],
48			[55.638531, 37.646026],
49			[55.638527, 37.646016],
50			[55.638522, 37.646008],
51			[55.638502, 37.646004],
52			[55.638510, 37.645913],
53			[55.638513, 37.645871],
54			[55.638519, 37.645801],
55			[55.638525, 37.645802],
56			[55.638643, 37.645831],
57			[55.638752, 37.645858],
58			[55.638833, 37.645879],
59			[55.638834, 37.645861],
60			[55.638850, 37.645632],
61			[55.638852, 37.645606],
62			[55.638857, 37.645559],
63			[55.638999, 37.645595],
64			[55.639019, 37.645236],
65			[55.639192, 37.645267]
66		],
67		auto: [
68			[55.638186, 37.660799],
69			[55.638223, 37.660342],
70			[55.638429, 37.658572],
71			[55.638528, 37.657524],
72			[55.638569, 37.656840],
73			[55.638618, 37.655789],
74			[55.638622, 37.655071],
75			[55.638622, 37.654917],
76			[55.638616, 37.654573],
77			[55.638615, 37.654528],
78			[55.638613, 37.654367],
79			[55.638606, 37.653937],
80			[55.638542, 37.652056],
81			[55.638534, 37.651697],
82			[55.638540, 37.650719],
83			[55.638574, 37.648981],
84			[55.638578, 37.648754],
85			[55.638612, 37.647881],
86			[55.638630, 37.647625],
87			[55.638657, 37.647201],
88			[55.638715, 37.646404],
89			[55.638804, 37.646419],
90			[55.638867, 37.646436],
91			[55.638940, 37.646452],
92			[55.638961, 37.646248],
93			[55.638967, 37.646137],
94			[55.638999, 37.645595],
95			[55.639019, 37.645236]
96		]
97	};
98
99	function isValidPoint(point) {
100		return (
101			Array.isArray(point) &&
102			point.length === 2 &&
103			typeof point[0] === 'number' &&
104			typeof point[1] === 'number' &&
105			isFinite(point[0]) &&
106			isFinite(point[1]) &&
107			point[0] >= -90 &&
108			point[0] <= 90 &&
109			point[1] >= -180 &&
110			point[1] <= 180
111		);
112	}
113
114	function isValidRoutePoints(points) {
115		if (!Array.isArray(points) || points.length < 2) {
116			return false;
117		}
118
119		for (var i = 0; i < points.length; i++) {
120			if (!isValidPoint(points[i])) {
121				return false;
122			}
123		}
124
125		return true;
126	}
127
128	function readRouteData(elementId) {
129		var routeDataElement = document.getElementById(elementId || 'mapRouteData');
130
131		if (!routeDataElement) {
132			return {routes: {}};
133		}
134
135		try {
136			var routeData = JSON.parse(routeDataElement.textContent || routeDataElement.innerText || '{}');
137
138			return routeData && routeData.routes ? routeData : {routes: {}};
139		} catch (error) {
140			return {routes: {}};
141		}
142	}
143
144	function getRoutePoints(routeData, routeName) {
145		var route = routeData.routes[routeName];
146
147		if (
148			route &&
149			(route.source === 'api' || route.source === 'cache') &&
150			isValidRoutePoints(route.points)
151		) {
152			return route.points;
153		}
154
155		return fallbackRoutes[routeName];
156	}
157
158	function parsePair(value) {
159		var parts = value;
160
161		if (typeof value === 'string') {
162			parts = value.split(',');
163		}
164
165		if (!Array.isArray(parts) || parts.length !== 2) {
166			return null;
167		}
168
169		var first = Number(parts[0]);
170		var second = Number(parts[1]);
171
172		if (!isFinite(first) || !isFinite(second)) {
173			return null;
174		}
175
176		return [first, second];
177	}
178
179	function escapeHtml(value) {
180		return String(value)
181			.replace(/&/g, '&amp;')
182			.replace(/</g, '&lt;')
183			.replace(/>/g, '&gt;')
184			.replace(/"/g, '&quot;')
185			.replace(/'/g, '&#039;');
186	}
187
188	function fitMapToObjects(map, zoomMargin) {
189		var bounds = map.geoObjects.getBounds();
190
191		if (bounds) {
192			map.setBounds(bounds, {
193				checkZoomRange: true,
194				zoomMargin: zoomMargin
195			});
196		}
197	}
198
199	function addResizeHandler(container, map, zoomMargin) {
200		if (!window.addEventListener || container.__contactYandexMapResizeHandler) {
201			return;
202		}
203
204		var resizeTimer = null;
205		var resizeHandler = function () {
206			if (resizeTimer !== null) {
207				window.clearTimeout(resizeTimer);
208			}
209
210			resizeTimer = window.setTimeout(function () {
211				map.container.fitToViewport();
212				fitMapToObjects(map, zoomMargin);
213			}, 100);
214		};
215
216		container.__contactYandexMapResizeHandler = resizeHandler;
217		window.addEventListener('resize', resizeHandler);
218	}
219
220	function init(options) {
221		options = options || {};
222
223		var containerId = options.containerId || 'map';
224		var container = document.getElementById(containerId);
225
226		if (
227			!container ||
228			container.__contactYandexMapInstance ||
229			container.__contactYandexMapPending ||
230			!window.ymaps ||
231			typeof window.ymaps.ready !== 'function'
232		) {
233			return;
234		}
235
236		container.__contactYandexMapPending = true;
237
238		window.ymaps.ready(function () {
239			if (container.__contactYandexMapInstance) {
240				container.__contactYandexMapPending = false;
241				return;
242			}
243
244			try {
245				var shopCoordinates = [55.639192, 37.645267];
246				var markerCoordinates = isValidPoint(options.markerCoordinates)
247					? options.markerCoordinates
248					: shopCoordinates;
249				var mapCenter = isValidPoint(options.mapCenter) ? options.mapCenter : markerCoordinates;
250				var routeData = readRouteData(options.routeDataElementId);
251				var pedestrianPoints = getRoutePoints(routeData, 'pedestrian');
252				var autoPoints = getRoutePoints(routeData, 'auto');
253				var zoomMargin = typeof options.zoomMargin === 'number' ? options.zoomMargin : 50;
254				var map = new window.ymaps.Map(containerId, {
255					center: mapCenter,
256					zoom: typeof options.zoom === 'number' ? options.zoom : 15
257				}, {
258					searchControlProvider: 'yandex#search'
259				});
260				var placemarkOptions = {
261					iconLayout: 'default#image'
262				};
263				var iconImageSize = parsePair(options.iconImageSize);
264				var iconImageOffset = parsePair(options.iconImageOffset);
265
266				if (options.iconImageHref) {
267					placemarkOptions.iconImageHref = options.iconImageHref;
268				}
269
270				if (iconImageSize) {
271					placemarkOptions.iconImageSize = iconImageSize;
272				}
273
274				if (iconImageOffset) {
275					placemarkOptions.iconImageOffset = iconImageOffset;
276				}
277
278				var marker = new window.ymaps.Placemark(markerCoordinates, {
279					hintContent: options.markerHintContent || '',
280					balloonContent: options.markerBalloonContent || ''
281				}, placemarkOptions);
282				var autoRoute = new window.ymaps.Polyline(autoPoints, {}, {
283					strokeColor: '#1E98FF',
284					strokeWidth: 4,
285					strokeOpacity: 0.9
286				});
287				var pedestrianRoute = new window.ymaps.Polyline(pedestrianPoints, {}, {
288					strokeColor: '#EE5651',
289					strokeWidth: 4,
290					strokeOpacity: 0.9
291				});
292
293				map.geoObjects.add(autoRoute);
294				map.geoObjects.add(pedestrianRoute);
295				map.geoObjects.add(marker);
296				map.behaviors.disable(['scrollZoom']);
297
298				if (options.disableDrag) {
299					map.behaviors.disable('drag');
300				}
301
302				container.__contactYandexMapInstance = map;
303				fitMapToObjects(map, zoomMargin);
304				addResizeHandler(container, map, zoomMargin);
305			} finally {
306				container.__contactYandexMapPending = false;
307			}
308		});
309	}
310
311	function initFromData(containerId, dataElementId, extraOptions) {
312		var dataElement = document.getElementById(dataElementId || 'mapData');
313
314		if (!dataElement) {
315			return;
316		}
317
318		var title = dataElement.getAttribute('data-title') || '';
319		var address = dataElement.getAttribute('data-balloon-address') || '';
320		var options = {
321			containerId: containerId || 'map',
322			markerCoordinates: [55.639192, 37.645267],
323			mapCenter: [55.639192, 37.645267],
324			markerHintContent: escapeHtml(title),
325			markerBalloonContent: escapeHtml(title) + (address ? '<br>' + escapeHtml(address) : ''),
326			iconImageHref: dataElement.getAttribute('data-icon') || '',
327			iconImageSize: dataElement.getAttribute('data-icon-size') || '',
328			iconImageOffset: dataElement.getAttribute('data-icon-offset') || ''
329		};
330
331		extraOptions = extraOptions || {};
332
333		for (var optionName in extraOptions) {
334			if (Object.prototype.hasOwnProperty.call(extraOptions, optionName)) {
335				options[optionName] = extraOptions[optionName];
336			}
337		}
338
339		init(options);
340	}
341
342	window.ContactYandexMap = {
343		init: init,
344		initFromData: initFromData
345	};
346})(window, document);

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.