PageSourceSearch

https://www.worldclass.ru/local/templates/rd_worldclass_copy/js/geolocation.js?17544718622245

js worldclass.ru collected 2026-10-02 07:04:30 UTC 2,245 bytes, 63 lines download raw bytes

1/*
2* Скрипт геолокации через АПИ браузера \ яндекс
3*
4* Подставляет в шапку название города после отработки геоопределения
5*
6* В случае получение города не из основных (см www/local/php_interface/include/classes/Geolocation.php), ставиться Москва
7* */
8$(function () {
9	ymaps.ready(initGeolocation);
10
11	function initGeolocation() {
12		if (getCookie('geolocation_city_name')) {
13			console.log('geolocation_city_name');
14			console.log(getCookie('geolocation_city_name'));
15			// do nothing
16		} else if (getCookie('geolocation_change_city')) {
17			console.log('geolocation_change_city');
18			console.log(getCookie('geolocation_change_city'));
19			// do nothing
20		} else {
21			let Geolocation = ymaps.geolocation;
22
23			Geolocation.get({
24				provider: 'auto',
25				mapStateAutoApply: true
26			}).then(function (result) {
27				result.geoObjects.each(function(el) {
28					let areas = el.getAdministrativeAreas();
29console.log(areas);
30					setCity(areas[0] + ', ' + areas[1]);
31				});
32			});
33		}
34	}
35});
36
37function setCity(cityName) {
38	var year = 1000 * 60 * 60 * 24;
39	var expires = new Date((new Date()).valueOf() + year);
40	
41	console.log('Будет установлен город: ' + cityName);
42	document.cookie = 'geolocation_city_name=' + encodeURIComponent(cityName) + '; expires=' + expires.toUTCString() + '; path=/';
43	
44	if (!getCookie('region') && cityName.length > 0) {
45		$.ajax(location.protocol + '//' + location.hostname + '/local/api/geolocation.php?region=' + cityName)
46			.done(function () {
47				$.ajax(location.protocol + '//' + location.hostname + '/local/api/getLocatedCityData.php')
48					.done(function (result) {
49						result = JSON.parse(result);
50						console.log('Успешно установлен город: ' + result[0] + ', с номером: ' + result[1]);
51						$('.c-city-name').html(result[0]);
52						$('.c-city-phone').html(result[1]);
53					});
54			});
55	}
56}
57
58function getCookie(name) {
59	let matches = document.cookie.match(new RegExp(
60		"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
61	));
62	return matches ? decodeURIComponent(matches[1]) : undefined;
63}

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.