PageSourceSearch

https://www.breketshop.ru/js/site/city-routines.js

js breketshop.ru collected 2026-10-04 16:16:22 UTC 2,268 bytes, 91 lines download raw bytes

1var
2    $token = "136ab3e6c1628b181bbf236c3c9a64e35a5cd27d",
3    $type  = "ADDRESS",
4    $city   = $("#city-input"),
5    $addr   = $("#address-input");
6
7function join(arr /*, separator */) {
8    var separator = arguments.length > 1 ? arguments[1] : ", ";
9    return arr.filter(function(n){return n}).join(separator);
10}
11
12function setConstraints(sgt, kladr_id) {
13    var restrict_value = false;
14    var locations = null;
15    if (kladr_id) {
16        locations = { kladr_id: kladr_id };
17        restrict_value = true;
18    }
19    sgt.setOptions({
20        constraints: {
21            locations: locations
22        },
23        restrict_value: restrict_value
24    });
25}
26
27function enforceCity(suggestion) {
28/*
29    var sgt = $addr.suggestions();
30    console.log(sgt);
31    console.log(suggestion);
32    if (sgt) {
33        sgt.clear();
34        if (suggestion) {
35            setConstraints(sgt, suggestion.data.kladr_id);
36        } else {
37            setConstraints(sgt, null);
38        }
39    }else{
40        $city.val('');
41    }
42*/
43    $city.val('');
44}
45
46function cityToString(address) {
47    return join([
48        join([address.city_type, address.city], " "),
49        join([address.settlement_type, address.settlement], " ")
50    ]);
51}
52
53$(document).ready(function() {
54    $addr.suggestions({
55        token: $token,
56        type: $type,
57        constraints: $city,
58        bounds: "street-house"
59    });
60
61    // Ограничиваем область поиска от города до населенного пункта
62    $city.suggestions({
63        token: $token,
64        type: $type,
65        hint: false,
66        bounds: "region-city-settlement",
67        //onSelect: enforceCity,
68        onSelectNothing: enforceCity
69    });
70
71    // Определяем город по IP-адресу
72    if ($city.data('geo') == true) {
73/*
74        $city.suggestions().getGeoLocation()
75            .done(function (locationData) {
76                var sgt = {
77                    value: null,
78                    date: locationData
79                };
80                //console.log(locationData);
81                $city.suggestions().setSuggestion(sgt);
82                $city.val(cityToString(locationData));
83            });
84*/
85    }
86
87    //console.log($city);
88    $city.suggestions().fixData();
89
90});
91

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.