PageSourceSearch

https://arbatex.ru/bitrix/components/dresscode/sale.geo.positiion/templates/.default/script.js?17878614218824

js arbatex.ru collected 2026-10-02 12:56:42 UTC 8,824 bytes, 323 lines download raw bytes

1$(function () {
2	//global vars
3	var ajaxTimeOutId;
4
5	//jquery vars
6	$resContainer = $(".geo-location-window-search-values");
7
8	if ("getPositionIncludeApi" in window && getPositionIncludeApi === true) {
9		// fields
10		// jsonObject.isHighAccuracy,
11		// jsonObject.latitude,
12		// jsonObject.longitude,
13		// jsonObject.country,
14		// jsonObject.region,
15		// jsonObject.city,
16		// jsonObject.zoom
17
18		function yandex_init() {
19			var geolocation = ymaps.geolocation;
20
21			if (geolocation.city) {
22				$.getJSON(
23					geoPositionAjaxDir + "/ajax.php",
24					{
25						act: "userPosition",
26						latitude: geolocation.latitude,
27						longitude: geolocation.longitude,
28						city: geolocation.city,
29						country: geolocation.country,
30						isHighAccuracy: geolocation.isHighAccuracy,
31						region: geolocation.region,
32						zoom: geolocation.zoom
33					},
34					function (jsonObject) {
35						if (jsonObject["ERROR"] != "Y") {
36							//set values
37							$(
38								'.geo-location-window-list-item-link[data-id="' +
39									jsonObject.locationID +
40									'"]'
41							).trigger("click");
42							$(
43								".user-geo-position-value-link, .geo-location-window-city-value, .geo-location-ref-window-city-value"
44							).html(jsonObject.city);
45							$(".geo-location-window-search-input")
46								.val(jsonObject.city)
47								.data("id", jsonObject.locationID);
48							$(".geo-location-window-button").removeClass("disabled");
49							showLocationRefWindow();
50						} else {
51							showLocationWindow();
52						}
53					}
54				);
55			} else {
56				showLocationWindow();
57			}
58		}
59
60		function sypex_init() {
61			var sypexLink =
62				typeof geoPositionKey != "undefined" && geoPositionKey != ""
63					? "//api.sypexgeo.net/" + geoPositionKey + "/json/"
64					: "//api.sypexgeo.net/";
65			$.getJSON(sypexLink, function (json) {
66				if (typeof json["city"]["name_ru"] != "undefined") {
67					$.getJSON(
68						geoPositionAjaxDir + "/ajax.php",
69						{
70							act: "userPosition",
71							latitude: json["city"]["lat"],
72							longitude: json["city"]["lon"],
73							city: json["city"]["name_ru"],
74							country: json["country"]["name_ru"],
75							isHighAccuracy: false,
76							region: json["region"]["name_ru"],
77							zoom: false
78						},
79						function (jsonObject) {
80							if (jsonObject["ERROR"] != "Y") {
81								//set values
82								$(
83									'.geo-location-window-list-item-link[data-id="' +
84										jsonObject.locationID +
85										'"]'
86								).trigger("click");
87								$(
88									".user-geo-position-value-link, .geo-location-window-city-value, .geo-location-ref-window-city-value"
89								).html(jsonObject.city);
90								$(".geo-location-window-search-input")
91									.val(jsonObject.city)
92									.data("id", jsonObject.locationID);
93								$(".geo-location-window-button").removeClass("disabled");
94								showLocationRefWindow();
95							} else {
96								showLocationWindow();
97							}
98						}
99					);
100				} else {
101					showLocationWindow();
102				}
103			});
104		}
105
106		if (geoPositionEngine == "YANDEX") {
107			//load yandex map script
108			var yandexMapLoader = document.createElement("script");
109			yandexMapLoader.src = "//api-maps.yandex.ru/2.0/?load=package.standard&lang=ru-RU";
110
111			//check api key
112			if (typeof geoPositionYandexKey != "undefined" && geoPositionYandexKey != "") {
113				yandexMapLoader.src += "&apikey=" + geoPositionYandexKey;
114			}
115
116			yandexMapLoader.className = "yaMapLoaderScript";
117			document.body.appendChild(yandexMapLoader);
118			yandexMapLoader.onload = function () {
119				if (typeof ymaps == "object" && typeof ymaps.ready == "function") {
120					ymaps.ready(yandex_init);
121				}
122			};
123
124			//check 1 sec for load ya script
125			setTimeout(function () {
126				if (typeof ymaps != "object") {
127					$(".yaMapLoaderScript").remove();
128				}
129			}, 1000);
130		} else {
131			sypex_init();
132		}
133	}
134
135	var getSearchCity = function ($input, query) {
136		//loader
137		$input.addClass("loading");
138
139		//clear container
140		$resContainer.empty();
141
142		//get location list
143		$.getJSON(
144			geoPositionAjaxDir + "/ajax.php?act=locSearch&query=" + encodeURI(query),
145			function (jsonData) {
146				$input.removeClass("loading");
147				if (jsonData["ERROR"] != "Y") {
148					$.each(jsonData, function (i, arValues) {
149						$resContainer.append(
150							$("<div />", { class: "geo-location-list-item" }).append(
151								$("<a />", { class: "geo-location-list-item-link" })
152									.html(arValues["COUNTRY_NAME"] + ", " + arValues["CITY_NAME"])
153									.attr("href", "#")
154									.data("id", arValues["ID"])
155									.data("parse-value", arValues["CITY_NAME"])
156							)
157						);
158					});
159				}
160			}
161		);
162	};
163
164	var pressSearchField = function (event) {
165		var $this = $(this);
166		var thisValue = $this.val();
167
168		if (thisValue.length > 1 && !clearTimeout(ajaxTimeOutId)) {
169			ajaxTimeOutId = setTimeout(function () {
170				getSearchCity($this, thisValue);
171			}, 350);
172		}
173	};
174
175	var selectLocationFromFastView = function (event) {
176		var $this = $(this);
177		var thisID = $this.data("id");
178		var thisValue = $this.data("parse-value");
179
180		$(".geo-location-window-search-input").val(thisValue).data("id", thisID);
181		$(".geo-location-window-city-value").html(thisValue);
182
183		var $locationWindowList = $(".geo-location-window-list");
184		var $locationWindowListLinks = $locationWindowList
185			.find(".geo-location-window-list-item-link")
186			.removeClass("selected");
187
188		$locationWindowListLinks.each(function (index, el) {
189			var $nextElement = $(el);
190			if ($nextElement.data("id") == thisID) {
191				$nextElement.addClass("selected");
192				return false;
193			}
194		});
195
196		$(".geo-location-window-button").removeClass("disabled").addClass("modifed");
197
198		$resContainer.empty();
199
200		return event.preventDefault();
201	};
202
203	var setLocationFromServer = function (event) {
204		var $this = $(this).addClass("loading");
205
206		$.getJSON(
207			geoPositionAjaxDir + "/ajax.php",
208			{
209				act: "setLocation",
210				locationID: $(".geo-location-window-search-input").data("id")
211			},
212			function (jsonData) {
213				if (jsonData["SUCCESS"] == "Y") {
214					window.location.reload();
215				}
216			}
217		);
218
219		return event.preventDefault();
220	};
221
222	var showLocationWindow = function () {
223		if (getCookie("locationWindowClose") != "Y") {
224			$("#geo-location-window").removeClass("hidden").appendTo("body");
225		}
226	};
227
228	var openLocationWindow = function (event) {
229		$("#geo-location-window").removeClass("hidden").appendTo("body").show();
230		return event.preventDefault();
231	};
232
233	var closeLocationWindow = function (event) {
234		var currentDate = new Date(new Date().getTime() + 128000 * 1000);
235		document.cookie = "locationWindowClose=Y; path=/; expires=" + currentDate.toUTCString();
236		$("#geo-location-window").hide();
237		return event.preventDefault();
238	};
239
240	var showLocationRefWindow = function () {
241		//jquery vars
242		var $positionLink = $(".user-geo-position .user-geo-position-value-link");
243		var $positionWindow = $("#geo-location-ref-window");
244		var $window = $(window);
245
246		//disabled
247		if ($positionWindow.data("disabled") == "Y") {
248			return false;
249		}
250
251		//ref window
252		var refwidth = $positionWindow.width();
253		var windowWidth = $window.innerWidth();
254
255		//other
256		var coordinates = {
257			left: $positionLink.offset().left - refwidth / 2,
258			top: $positionLink.offset().top + 42
259		};
260
261		//move
262		$positionWindow.appendTo($("body"));
263
264		//display ref window
265		if (windowWidth <= 1024 || refwidth + $positionLink.offset().left > windowWidth) {
266			$positionWindow.addClass("visible centred");
267		}
268
269		//position
270		else {
271			$positionWindow.addClass("visible").css({
272				left: coordinates.left,
273				top: coordinates.top
274			});
275		}
276	};
277
278	var closeLocationRefWindow = function () {
279		//jquery vars
280		var $this = $(this).addClass("loading");
281
282		//reload page
283		window.location.reload();
284
285		//block actions
286		return event.preventDefault();
287	};
288
289	function getCookie(name) {
290		//vars
291		var cookie = " " + document.cookie;
292		var search = " " + name + "=";
293		var setStr = null;
294		var offset = 0;
295		var end = 0;
296
297		if (cookie.length > 0) {
298			offset = cookie.indexOf(search);
299			if (offset != -1) {
300				offset += search.length;
301				end = cookie.indexOf(";", offset);
302				if (end == -1) {
303					end = cookie.length;
304				}
305				setStr = unescape(cookie.substring(offset, end));
306			}
307		}
308
309		return setStr;
310	}
311
312	$(document).on("keyup", ".geo-location-window-search-input", pressSearchField);
313	$(document).on("click", ".geo-location-list-item-link", selectLocationFromFastView);
314	$(document).on("click", ".geo-location-window-list-item-link", selectLocationFromFastView);
315	$(document).on("click", ".geo-location-window-button", setLocationFromServer);
316	$(document).on("click", ".geo-location-window-exit", closeLocationWindow);
317	$(document).on("click", ".get-location-ref-window-confirm-button", closeLocationRefWindow);
318	$(document).on(
319		"click",
320		".user-geo-position-value-link, .get-location-ref-window-change-button",
321		openLocationWindow
322	);
323});

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.