PageSourceSearch

https://www.mirkrasok.ru/local/templates/mirkrasok_2026v2/componen…/.defaultn/script.js?178756976321981

js mirkrasok.ru collected 2026-10-03 20:59:59 UTC 21,981 bytes, 585 lines download raw bytes

1$.expr[':'].attrCaseInsensitive1 = function (node, stackIndex, properties) {
2
3
4    var args = properties[3].split(',').map(function (arg) {
5        return arg.replace(/^\s*["']|["']\s*$/g, '');
6    });
7
8    if (typeof ($(node).attr(args[0])) == "undefined") {
9        return false
10    }
11    var temp = $(node).attr(args[0]).toLowerCase();
12
13    var regex = new RegExp(args[1].toLowerCase());
14
15    var count = (temp.match(regex) || []).length;
16
17
18    return count > 0;
19};
20var obShopVisiblePage = {
21    SearchVal: "",
22    searchKeyup: function () {
23
24        var $self = $(this);
25
26        if ($self.hasClass("loading")) {
27            $self.oneTime("300ms", function () {
28                obShopVisiblePage.searchKeyup(self);
29            });
30            return;
31        }
32        obShopVisiblePage.searchShop();
33
34        obShopVisiblePage.hideEmptinessSecion();
35        obShopMapPage.reSearch();
36        obShopMapPage.zoomMap();
37
38    },
39
40    hideEmptinessSecion: function () {
41        $(".shops-list-section-box").addClass("hidden")
42        $(this).parents('.shops-list-section-box').removeClass("active")
43        $(".shop-element-box").each(function (index, element) {
44
45
46            if (!$(this).hasClass("hidden")) {
47
48                $(this).parents('.shops-list-section-box').removeClass("hidden")
49
50
51                if (obShopVisiblePage.SearchVal != "") {
52                    $(this).parents('.shops-list-section-box').addClass("active")
53                }
54
55            }
56        })
57    },
58    // sValue — искать по этому значению, не трогая поле поиска: так работает выбор
59    // города из выпадающего списка. Без него запрос берётся из самого поля.
60    searchShop: function (sValue) {
61
62        var $self = $("[data-search-shop-input]");
63        var sQuery = typeof sValue === "string" ? sValue : $self.val();
64        obShopVisiblePage.SearchVal = sQuery;
65        $self.addClass("loading");
66
67        var eSelf = sQuery.replace(/е/g, "ё");
68
69        var $parentList = $("[data-shop-list-box]");
70
71        $parentList.find("[data-shop]").addClass("hidden");
72        $parentList.find('[data-shop]:attrCaseInsensitive1("data-item-name", "' + sQuery + '")').removeClass("hidden");
73        $parentList.find('[data-shop]:attrCaseInsensitive1("data-item-name", "' + eSelf + '")').removeClass("hidden");
74        $self.removeClass("loading");
75
76
77    },
78    // Приводит название населённого пункта к виду, в котором его можно сравнивать:
79    // в свойстве CITY они записаны по-разному — «г. Владимир», «с.Тарасовка»,
80    // «п. Шевляково.», а в выпадающем списке лежит одно голое название.
81    normalizeCity: function (sCity) {
82
83        var sName = String(sCity || "").toLowerCase().replace(/ё/g, "е");
84
85        // «г. Одинцово, р.п. Заречье» — город стоит до первой запятой.
86        sName = sName.split(",")[0];
87        sName = sName.replace(/\s+/g, " ").trim();
88        // Приставки вида «г.», «д.», «р. п.», «село»: отбрасываем, пока они есть.
89        sName = sName.replace(/^(?:(?:г|д|п|с|р|ст|рп|гп|пгт|сп|пос|дер|село|город|поселок)(?:\.\s*|\s+))+/, "");
90        sName = sName.replace(/[.\s]+$/, "");
91
92        return sName;
93    },
94    // Отбирает магазины по свойству «Город» (CITY инфоблока «Где купить»), а не по
95    // тексту карточки: так работает выбор города из выпадающего списка.
96    searchCity: function (sCity) {
97
98        var sNeedle = obShopVisiblePage.normalizeCity(sCity);
99        var $parentList = $("[data-shop-list-box]");
100        var iFound = 0;
101
102        obShopVisiblePage.SearchVal = sCity;
103
104        $parentList.find("[data-shop]").addClass("hidden");
105        $parentList.find("[data-shop][data-city]").each(function () {
106            if (obShopVisiblePage.normalizeCity($(this).attr("data-city")) === sNeedle) {
107                $(this).removeClass("hidden");
108                iFound++;
109            }
110        });
111
112        // Город в карточке заполнен неверно — не оставляем страницу пустой,
113        // а ищем по тексту, как было раньше.
114        if (iFound === 0) {
115            obShopVisiblePage.searchShop(sCity);
116        }
117    },
118    // Показывает магазины выбранных регионов целиком, минуя поиск по Ð
118½Ð°Ð·Ð²Ð°Ð½Ð¸ÑŽ:
119    // так работает пункт «Москва и Московская область».
120    showRegions: function (sLabel, arSelectors) {
121
122        obShopVisiblePage.SearchVal = sLabel;
123
124        var $parentList = $("[data-shop-list-box]");
125        $parentList.find("[data-shop]").addClass("hidden");
126        $(arSelectors.join(",")).find("[data-shop]").removeClass("hidden");
127    },
128    changeTypeVisible: function () {
129
130        let type = $(this).data("type-btn");
131        $('[data-type-visible]').css({"display": "none"})
132        $('[data-type-btn]').removeClass("active")
133        $(this).addClass("active")
134        $('[data-type-visible="' + type + '"]').css({"display": "block"})
135    }
136    ,
137    changeShopListBox: function () {
138        $(this).parent().toggleClass("active")
139    },
140    bind: function () {
141
142        $('.shop-type-list').on("click", '[data-type-btn]', obShopVisiblePage.changeTypeVisible)
143        $('.shops-list-box').on("click", '.shops-list-section-title-block', obShopVisiblePage.changeShopListBox)
144        $(".shop-search-box").on("keyup", '[data-search-shop-input]', obShopVisiblePage.searchKeyup)
145        $("#header").on("keyup", '.tx_search.required', obShopVisiblePage.searchKeyup)
146    },
147    init: (function () {
148        $(function () {
149
150            obShopVisiblePage.bind()
151        });
152    })()
153}
154
155var obShopMapPage = {
156    minMaxCords: {
157        minW: "",
158        maxW: "",
159        minH: "",
160        maxH: "",
161        centerW: "",
162        centerH: "",
163        deltaW: "",
164        deltaH: "",
165    },
166
167    idNearest: "",
168    toggleNearest: false,
169    hash: false,
170    nearestCount: 10,
171    map: false,
172    json: false,
173    params:[],
174    points: [],
175    mapObject: false,
176    arIcon: {
177        '7': '/i/icons/map/mk_spot.svg',
178        '7_FM': '/i/icons/map/mk_spot.svg',
179        'TD': '/i/icons/map/td_spot.svg',
180        'TD_opacity': '/i/icons/map/td_spot_opacity.svg',
181        '8': '/i/icons/map/t_spot.svg',
182        '8_opacity': '/i/icons/map/t_spot_opacity.svg',
183        '9': '/i/icons/map/mk_spot.svg',
184        '7_8': '/i/icons/map/t_spot.svg',
185        '8_9': '/i/icons/map/t_spot.svg',
186        '7_9': '/i/icons/map/d_spot.svg',
187        '7_8_9': '/i/icons/map/t_spot.svg',
188        '7_10': '/i/icons/map/mk_spot.svg',
189        '7_10_opacity': '/i/icons/map/mk_spot_opacity.svg',
190        '7_opacity': '/i/icons/map/mk_spot_opacity.svg',
191        '10': '/i/icons/map/mk_spot.svg',
192        'd_e_l_u_x': '/i/icons/map/pin2.svg',
193        'd_e_l_u_x_opacity': '/i/icons/map/pin2_opacity.svg',
194        'd_e_l_u_x_f_': '/i/icons/map/pin2.svg',
195    },
196    arIconCKT: {
197        '7': '/i/icons/map/ckt_spot.svg',
198        '7_FM': '/i/icons/map/ckt_spot.svg',
199        'TD': '/i/icons/map/td_spot.svg',
200        'TD_opacity': '/i/icons/map/td_spot_opacity.svg',
201        '8': '/i/icons/map/t_spot.svg',
202        '8_opacity': '/i/icons/map/ckt_spot.svg',
203        '9': '/i/icons/map/ckt_spot.svg',
204        '7_8': '/i/icons/map/t_spot.svg',
205        '8_9': '/i/icons/map/t_spot.svg',
206        '7_9': '/i/icons/map/ckt_spot.svg',
207        '7_8_9': '/i/icons/map/t_spot.svg',
208        '7_10': '/i/icons/map/ckt_spot.svg',
209        '7_10_opacity': '/i/icons/map/ckt_spot.svg',
210        '7_opacity': '/i/icons/map/ckt_spot.svg',
211        '10': '/i/icons/map/ckt_spot.svg',
212        'd_e_l_u_x': '/i/icons/map/ckt_spot.svg',
213        'd_e_l_u_x_opacity': '/i/icons/map/ckt_spot.svg',
214        'd_e_l_u_x_f_': '/i/icons/map/ckt_spot.svg',
215    },
216    setMinMaxCord: function (w, h) {
217
218        if (!obShopMapPage.minMaxCords.minW) {
219            obShopMapPage.minMaxCords.minW = w
220        }
221        if (!obShopMapPage.minMaxCords.minH) {
222            obShopMapPage.minMaxCords.minH = h
223        }
224        obShopMapPage.minMaxCords.minW = Math.min(w, obShopMapPage.minMaxCords.minW);
225        obShopMapPage.minMaxCords.maxW = Math.max(w, obShopMapPage.minMaxCords.maxW);
226        obShopMapPage.minMaxCords.minH = Math.min(h, obShopMapPage.minMaxCords.minH);
227        obShopMapPage.minMaxCords.maxH = Math.max(h, obShopMapPage.minMaxCords.maxH);
228
229        obShopMapPage.minMaxCords.centerW = (obShopMapPage.minMaxCords.maxW - obShopMapPage.minMaxCords.minW) / 2 + obShopMapPage.minMaxCords.minW;
230        obShopMapPage.minMaxCords.centerH = (obShopMapPage.minMaxCords.maxH - obShopMapPage.minMaxCords.minH) / 2 + obShopMapPage.minMaxCords.minH;
231
232        obShopMapPage.minMaxCords.deltaW = (obShopMapPage.minMaxCords.maxW - obShopMapPage.minMaxCords.minW) / 2;
233        obShopMapPage.minMaxCords.deltaH = (obShopMapPage.minMaxCords.maxH - obShopMapPage.minMaxCords.minH) / 2;
234    },
235
236    zoomMap: function () {
237        obShopMapPage.map.setCenter([obShopMapPage.minMaxCords.centerW, obShopMapPage.minMaxCords.centerH], 7, {
238            checkZoomRange: true
239        });
240        obShopMapPage.map.setBounds(obShopMapPage.map.geoObjects.getBounds())
241    },
242
243    zoomVisibleObject: function (e) {
244        // console.log( obShopMapPage.map.getBounds())
245        arCordMap = obShopMapPage.map.getBounds()
246        $(".box-left-section .shop-element-box").removeClass("map-hidden")
247        for (point in obShopMapPage.points) {
248            if (
249                obShopMapPage.map.getBounds()[0][0] > obShopMapPage.points[point].geometry.getCoordinates()[0]
250                || obShopMapPage.map.getBounds()[0][1] > obShopMapPage.points[point].geometry.getCoordinates()[1]
251                || obShopMapPage.map.getBounds()[1][0] < obShopMapPage.points[point].geometry.getCoordinates()[0]
252                || obShopMapPage.map.getBounds()[1][1] < obShopMapPage.points[point].geometry.getCoordinates()[1]
253            ) {
254                $('[data-tk-id="' + point + '"]').addClass("map-hidden")
255            }
256        }
257    },
258
259    isVisiblePoinsts: function (id) {
260        if ($("[data-tk-id='" + id + "']").hasClass("hidden")) {
261            return 0;
262        } else {
263            return 1;
264        }
265    },
266
267    successGeoPoint: function (self) {
268        var point = {lat: self.coords.latitude, lon: self.coords.longitude};
269        var pointCoords = [self.coords.latitude, self.coords.longitude];
270        obShopMapPage.setGeoPoint(point);
271        var arNearest = [];
272
273        for (ID in obShopMapPage.points) {
274            var obPoint = obShopMapPage.points[ID];
275            var coords = obPoint.geometry.getCoordinates();
276            var iCurrentDistance = ymaps.coordSystem.geo.getDistance(pointCoords, coords);
277            /*if((iDistance<0) || (iDistance>iCurrentDistance))
278             {
279             iDistance=iCurrentDistance;
280             iNearestID=ID;
281             }*/
282            arNearest.push({distance: iCurrentDistance, id: ID});
283        }
284
285
286        arNearest.sort(function (a, b) {
287            return FloatVal(a.distance) - FloatVal(b.distance);
288        });
289
290        obShopMapPage.idNearest = arNearest[0]["id"];
291        obShopMapPage.showNearest()
292    },
293
294    setGeoPoint: function (point) {
295        obShopMapPage.geoPoint = point;
296        var sPoint = $.toJSON(point);
297        ExtSetCookie("geo_point", sPoint);
298    },
299
300    getNearest: function () {
301        obShopMapPage.processGeoPoint();
302    },
303
304    showNearest: function () {
305        var $parentList = $("[data-shop-list-box]");
306
307        if (obShopMapPage.toggleNearest) {
308            obShopMapPage.toggleNearest = false;
309            $parentList.find("[data-shop]").removeClass("hidden");
310            obShopVisiblePage.hideEmptinessSecion();
311            obShopMapPage.reSearch();
312            $("[data-shownearest]").removeClass("active");
313        } else {
314            obShopMapPage.toggleNearest = true;
315            $parentList.find("[data-shop]").addClass("hidden");
316            $parentList.find("[data-tk-id='" + obShopMapPage.idNearest + "']").removeClass("hidden");
317            $("[data-shownearest]").addClass("active");
318            obShopVisiblePage.hideEmptinessSecion();
319            obShopMapPage.reSearch();
320        }
321    },
322
323    processGeoPoint: function () {
324
325        if (navigator.geolocation) {
326            var options = {
327                noCentering: true,
328                // Не ставить метку.
329                noPlacemark: false,
330                // Не показывать точность определения местоположения.
331                noAccuracy: false,
332                // Режим получения наиболее точных данных.
333                enableHighAccuracy: true,
334                // Максимальное время ожидания ответа (в миллисекундах).
335                timeout: 10000,
336                // Максимальное время жизни полученных данных (в миллисекундах).
337                maximumAge: 1000
338            };
339
340            navigator.geolocation.getCurrentPosition(
341                obShopMapPage.successGeoPoint,
342                obShopMapPage.errorGeoPoint,
343                options
344            );
345        } else alert("1 - Ошибка определения местоположения");
346    },
347
348    errorGeoPoint: function (self) {},
349
350    addPont: function (shop) {
351        console.log(shop.ID);
352        var arPoint = shop.UF_POINT.split(",");
353        var zIndex = 99999999999999 - shop.SORT;
354        var LINK = shop.VISIBLE_FOR_LIST.LINK;
355        var ID = shop.ID;
356        var point = [arPoint[1], arPoint[0]];
357
358        var balloon = new ymaps.Balloon(this.map, null, {
359            maxWidth: "1000px",
360            minWidth: "1000px"
361        });
362        var strType = Object.values(shop.UF_NET_TYPE).join('_');
363
364        idTT = Object.keys(shop.ELEMENTS)[0];
365        console.log(shop.ELEMENTS[idTT].PROP.STATUS_COVID)
366        STATUS_COVID = shop.ELEMENTS[idTT].PROP.STATUS_COVID;
367
368        if (shop.UF_DAY_1 == "" || STATUS_COVID == "Закрыто") {
369            strType = strType + "_opacity"
370        }
371
372        if(shop.ID == 15817||shop.ID == 15822||shop.ID == 15820||shop.ID == 15821
373            //||shop.ID ==15821
374            // ||shop.ID == 15820
375            // )
376        )
377        {
378            if(window.location.pathname!="/company/shops/sct.php")
379            {
380                strType="TD";
381            }
382            else{
383                strType="7_8_9";
384            }
385        }
386        /*console.log('debug start')
387        console.log(shop.VISIBLE_FOR_LIST.NAME.includes('Центр Красок Тikkurila'))
388        console.log(shop.VISIBLE_FOR_LIST.NAME)
389        console.log('debug end')*/
390        if (shop.VISIBLE_FOR_LIST.NAME.includes('Центр Красок Тikkurila')) {
391            strType="7";
392        }
393
394        let icon = obShopMapPage.arIcon;
395
396        if (obShopMapPage.params.ICON === "SCT") {
397            icon = obShopMapPage.arIconCKT;
398        }
399
400        var options = {
401            iconLayout: 'default#image',
402            hideIconOnBalloonOpen: false,
403            iconImageHref: (shop.ID == 2683 || shop.ID == 2684) ? icon[strType] : icon[strType],
404            iconImageSize: (shop.ID == 2683 || shop.ID == 2684 || shop.ID == 2547) ? [36, 45] : [24, 30],
405            link: LINK,
406            element_id: ID,
407            cord: point,
408            zIndex: IntVal(shop.UF_MAIN) ? zIndex : 1000 - shop.SORT,
409        };
410
411        if (shop.ID == 2547 || shop.ID == 2581 || shop.ID == 2563 || shop.ID == 2810) {
412            options.iconImageOffset = [0, -38];
413        }
414
415        if (shop.ID == 2578) {
416            options.iconImageOffset = [-30, -38];
417        }
418
419        if ($(window).width() > 600) {
420            obShopMapPage.points[shop.ID] = new ymaps.Placemark(point, {
421                balloonContent: " ",
422                balloon: balloon
423            }, options);
424        } else {
425            obShopMapPage.points[shop.ID] = new ymaps.Placemark(point, {
426            }, options);
427        }
428
429        obShopMapPage.setMinMaxCord(arPoint[1], arPoint[0])
430        if ($(window).width() > 600) {
431            obShopMapPage.points[shop.ID].events.add("balloonopen", function (a) {
432                obShopMapPage.temp = a;
433                var props = a.originalEvent.currentTarget.properties;
434                var html = "<div class='bcont'>" + props.get("balloonContent") + "</div>";
435                var $html = $(html);
436
437                var id = obShopMapPage.points[shop.ID].options._options.element_id
438                cloneElement = $("[data-tk-id='" + id + "']").clone()
439                cloneElement.removeClass("flagman")
440                $html.html(cloneElement[0]);
441
442                props.set("balloonContent", $html.html());
443
444            });
445        }
446        obShopMapPage.points[shop.ID].events.add('click', function (a) {
447            if ($(window).width() > 600) {
448            } else {
449                location.href = obShopMapPage.points[shop.ID].options._options.link
450            }
451
452        });
453        if(shop.ID==15898 || shop.ID==2559){
454            console.log(shop.NAME);
455            console.log(strType);
456            console.log(this.points[shop.ID]);
457
458        }
459        this.map.geoObjects.add(this.points[shop.ID]);
460    },
461
462    reSearch: function () {
463        this.map.geoObjects.removeAll();
464        this.addPonts();
465    },
466
467    addPonts: function (array) {
468        let arrayResult = array ? array : this.json;
469
470        obShopMapPage.minMaxCords = {
471            minW: "",
472            maxW: "",
473            minH: "",
474            maxH: "",
475        }
476
477        for (keyRegion in arrayResult) {
478            obRegion = arrayResult[keyRegion].SHOP_SECTION;
479
480            for (indexShop in obRegion) {
481                shop = obRegion[indexShop];
482
483                if (obShopMapPage.isVisiblePoinsts(shop.ID)) {
484                    obShopMapPage.addPont(shop)
485                }
486            }
487        }
488        return false;
489    },
490
491    createMap: function () {
492        obShopMapPage.mapObject = $("[data-map]");
493        let minZoom=10
494        let parameterName="search";
495        let result="";
496        window.location.search.substr(1).split("&").forEach(function (item) {
497            tmp = item.split("=");
498            if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
499        });
500        if(result)
501        {
502            minZoom=10;
503        }
504        obShopMapPage.map = new ymaps.Map(obShopMapPage.mapObject[0], {
505            center: obShopMapPage.params.COORDINATE,
506            zoom: minZoom,
507            //controls: [geolocationControl],
508            controls: ['smallMapDefaultSet']
509        }, {maxZoom: 17, minZoom: 7});
510        if (window.innerWidth < 768) {
511            obShopMapPage.map.behaviors.disable('scrollZoom');
512        }
513
514        obShopMapPage.map.controls.remove('trafficControl');
515        obShopMapPage.map.controls.remove('typeSelector');
516
517        //       obShops.addPolygons();
518        obShopMapPage.addPonts();
519
520        obShopMapPage.map.events.add('boundschange', this.zoomVisibleObject)
521        //obShops.processGeoPoint();
522    },
523    changeSort: function () {
524
525
526    },
527    bind: function () {
528        obShopMapPage.createMap();
529        $('.section-n.shops-map-box').on("click", '[data-showNearest]', obShopMapPage.getNearest)
530        setTimeout(this.changeSort, 1000);
531        // this.changeSort();
532    },
533
534    init: (function () {
535        $(function () {
536            ymaps.ready(obShopMapPage.bind);
537            console.log(ymaps)
538            console.log(1255555555553);
539            $('[sort-laste="1"]').each(function (index) {
540                //let parent=$(this).parent()
541                //parent.append($(this))
542            });
543        });
544        //
545    })()
546
547}
548$('.shop-type-list-bnt-box.active').click();
549
550/**
551 * Город из выпадающего списка отбираем по свойству «Город» магазина: обработчик
552 * виджета оставляем работать (куки, телефоны, центр карты), а поверх фильтруем список.
553 */
554var citySearchFromSelect = function () {
555    $(document).on('change', '#citi-select', function () {
556        var $selected = $(this).find('option:selected');
557
558        if (typeof obShopVisiblePage === 'undefined') {
559            return;
560        }
561
562        if ($selected.index() <= 0) {
563            // Первый пункт объединяет Москву с областью: такого названия нет ни у
564            // одного магазина, поэтому показываем оба региона целиком. Блок Москвы
565            // помечен data-main, у области — номер региона из самого пункта.
566            obShopVisiblePage.showRegions(
567                $.trim($selected.text()),
568                ['[data-main="Y"]', '[data-section-id="' + $selected.data('region') + '"]']
569            );
570        } else {
571            // Поле поиска не заполняем: отбираем по свойству «Город» карточки.
572            obShopVisiblePage.searchCity($.trim($selected.text()));
573        }
574        obShopVisiblePage.hideEmptinessSecion();
575
576        if (typeof obShopMapPage !== 'undefined' && obShopMapPage.map) {
577            obShopMapPage.reSearch();
578            obShopMapPage.zoomMap();
579        }
580    });
581};
582
583$(function () {
584    citySearchFromSelect();
585});

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.