PageSourceSearch

https://www.krym4you.com/skewer/build/Page/CatalogViewer/js/catalog.js?v=1426576891

js krym4you.com collected 2026-10-02 21:20:51 UTC 3,943 bytes, 165 lines download raw bytes

1var skCatFilter = (function () {
2
3    return {
4
5        fields: {},
6
7        findGetParam: function () {
8
9            var search = window.location.search.substr(1);
10            var me = this;
11
12            search.split('&').forEach(function (item) {
13
14                if (item) {
15                    item = item.split('=');
16                    var cur_name = decodeURIComponent(item[0]);
17
18                    if (cur_name.indexOf('[]') > 0) {
19
20                        cur_name = cur_name.substr(0, cur_name.length - 2);
21
22                        if (me.fields[cur_name] === undefined)
23                            me.fields[cur_name] = [];
24
25                        me.fields[cur_name].push(decodeURIComponent(item[1]));
26
27                    } else {
28
29                        me.fields[cur_name] = decodeURIComponent(item[1]);
30                    }
31                }
32
33            });
34
35            return this.fields;
36        },
37
38        getParam: function (name) {
39
40            if (!Object.keys(this.fields).length)
41                this.findGetParam();
42
43            return this.fields[name];
44        },
45
46        addParam: function (name, value) {
47
48            if (!Object.keys(this.fields).length)
49                this.findGetParam();
50
51            this.fields[name] = value;
52
53        },
54
55        getParamStr: function () {
56
57            var str = [];
58
59            for (var key in this.fields) {
60
61                if (typeof this.fields[key] == 'object') {
62
63                    this.fields[key].forEach(function (item) {
64                        str.push(key + '[]=' + item);
65                    });
66
67                } else
68                    str.push(key + '=' + this.fields[key]);
69            }
70
71            return str.join('&');
72        },
73
74        getURL: function () {
75
76            return 'http://' + window.location.host + window.location.pathname + '?' + this.getParamStr();
77        },
78
79        go: function () {
80
81            document.location.href = this.getURL();
82        }
83
84    };
85
86}());
87
88//Выбираем выбранный элемент фильтра при загрузке страницы
89$(document).ready(function () {
90
91    var cityid = $_GET('cityid');
92    $("#city option[value='" + cityid + "']").prop('selected', true);
93});
94
95
96function $_GET(key) {
97
98    var s = window.location.search;
99
100    s = s.match(new RegExp(key + '=([^&=]+)'));
101
102    return s ? s[1] : false;
103
104}
105
106
107$(function () {
108
109
110    function delPrm(Url, Prm) {
111        var a = Url.split('?');
112        var re = new RegExp('(\\?|&)' + Prm + '=[^&]+', 'g');
113        Url = ('?' + a[1]).replace(re, '');
114        Url = Url.replace(/^&|\?/, '');
115        var dlm = (Url == '') ? '' : '';
116        return a[0] + dlm;
117    };
118
119//применяем выбранный фильтр
120    $('#city').on('change', function () {
121
122        var city = $(this).val();
123        var delparam = delPrm(window.location.pathname, 'cityid');
124
125        if ($(this).val() == '0') {
126
127
128            document.location.href = 'http://' + window.location.host + delparam;
129        } else {
130            if ($(this).val()) {
131
132                document.location.href = 'http://' + window.location.host + window.location.pathname + '?cityid=' + city;
133            }
134        }
135
136
137    })
138
139
140    $('.js_view_control').click(function () {
141
142        skCatFilter.addParam('view', $(this).attr('curval'));
143        skCatFilter.go();
144
145    });
146
147    $('.js_sort_control').click(function () {
148
149        var cur_sort_field = $(this).attr('curval');
150        var old_sort_field = $('input[name=sort]').val();
151        var old_sort_way = $('input[name=way]').val();
152
153        if (!cur_sort_field)
154            old_sort_way = 'down';
155
156        if (cur_sort_field == old_sort_field)
157            old_sort_way = old_sort_way == 'down' ? 'up' : 'down';
158        else
159            old_sort_way = 'up';
160
161        skCatFilter.addParam('sort', cur_sort_field);
162        skCatFilter.addParam('way', old_sort_way);
163        skCatFilter.go();
164    });
165});

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.