PageSourceSearch

https://www.framo.ch/_assets/53f770bb05cab5e4d9eb75c2e791b1c4/Scripts/jquery.main.js?1787742155

js framo.ch collected 2026-10-08 13:28:43 UTC 4,920 bytes, 138 lines download raw bytes

1jQuery(document).ready(function () {
2
3    var allFilterSelector = '[name=canton], [name=producttype]';
4    var inputSelector = '#zip';
5    var selectedFilters = {};
6    var tableRowFilter = '.userncdealer-content .row';
7    var visibleTableRowFilter = '.userncdealer-content .row:visible';
8    var noEntriesSelector = '.noentries';
9    var formSelector = '#dealerFilter';
10
11    var __constructor = function () {
12        initEvents();
13    };
14
15    /**
16     * Initialise all event listeners
17     */
18    var initEvents = function () {
19
20        $(allFilterSelector).on('change', function () {
21            changeFilter($(this)[0].name, $(this));
22            updateResult();
23        });
24
25        $(inputSelector).on('change', function () {
26            changeFilter($(this)[0].id, $(this));
27            updateResult();
28        });
29
30        $(formSelector).on("submit", function (e) {
31            e.preventDefault();
32        });
33
34        $(noEntriesSelector).hide();
35    };
36
37    /**
38     * Save selected filter into an object
39     * @param {*} name
40     * @param {*} event
41     */
42    var changeFilter = function (name, event) {
43        selectedFilters[name] = event.val();
44    };
45
46    /**
47     * Filter the store table and map markers based on the selected filters.
48     */
49    var updateResult = function () {
50        resetMap();
51        $(noEntriesSelector).hide();
52        var bounds = new google.maps.LatLngBounds();
53        $(tableRowFilter).show();
54        $(tableRowFilter).each(function () {
55            var row = $(this);
56            var storeAttributes = $(this).data();
57            markers[row.data("id")].setMap(map);
58            var hideRow = false; //for AND Logic
59            $.each(storeAttributes, function (attribute, attributeValues) {
60                if (attributeValues.toString() != "") {
61                    attributeValues = attributeValues.toString().split(" ");
62                    //if more than 1 item in array, success is when array contains filter attr (OR).
63                    if (attributeValues.length > 1) {
64                        if (attributeValues.includes(selectedFilters[attribute]) || selectedFilters[attribute] == 'default') {
65                            bounds.extend(markers[row.data("id")].getPosition());
66                            row.show();
67                        } else {
68                            // Hide store row and map marker if doesnt contain.
69                            row.hide();
70                            markers[row.data("id")].setMap(null);
71                            hideRow = true;
72                        }
73                    } else {
74                        // Check if attribute matches selected filters (AND).
75                        if (selectedFilters[attribute]) {
76                            if (selectedFilters[attribute] != attributeValues[0] && selectedFilters[attribute] != 'default') {
77                                // Hide store row and map marker if no match.
78                                row.hide();
79                                markers[row.data("id")].setMap(null);
80                                hideRow = true;
81                            } else if (!hideRow) {
82                                // Set google maps bounds for stores that do match. AND Logic. if anything doesnt match, row is hidden.
83                                bounds.extend(markers[row.data("id")].getPosition());
84                                row.show();
85                            }
86                        }
87                    }
88                } else {
89                    //no attribute set => match everything (show row)
90                    bounds.extend(markers[row.data("id")].getPosition());
91                }
92
93            });
94        });
95
96        if ($(visibleTableRowFilter).length === 0) {
97            $(noEntriesSelector).show();
98        }
99        refreshColors();
100        map.fitBounds(bounds);
101    };
102
103    var refreshColors = function () {
104        $(visibleTableRowFilter).removeClass('odd even');
105        $(visibleTableRowFilter).filter(':odd').addClass('odd');
106        $(visibleTableRowFilter).filter(':even').addClass('even');
107    };
108
109    /**
110     * Reset all selected filters, map markers and inputs.
111     */
112    var resetMap = function () {
113        for (marker in markers) {
114            markers[marker].setMap(map);
115        }
116        var center = new google.maps.LatLng(46.8131873, 8.22421);
117        map.setCenter(center);
118        map.setZoom(8);
119    };
120
121    $("#zip").numeric(false, function () {
122        alert("Integers only");
123        this.value = "";
124        this.focus();
125    });
126    $('#selectCanton').change(function () {
127        $('#frmFilter').submit();
128        $.each($('#dealerFilter .selectpicker'), function () {
129            filterStr += "[data-" + $(this).data('for') + " ~= " + this.value + "]";
130        });
131    });
132    $('#zip').blur(function () {
133        $('#frmFilter').submit();
134    });
135
136    __constructor();
137});
138

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.